How to create a full OOP application?

Posted on 2004-10-24
Medium Priority
Last Modified: 2010-05-18
I am creating a content management system using PHP. I am trying to use oop classes.

My problem is:

I have created so many classes. One for database, file manipulation, data validation and so on. Now, database class needs to call some functions in the validation. file manipulation needs to call database and validation also.

I cannot use :: to execute a function in another class. I have to create an object of each and every class. because class function needs each others.

Finally, I found that I have to create extended classes ALWAYS, to have access of all functions. I am really scared about using this as the application grows.

Any advise would be highly appreciated.

Question by:HamidHossain

Author Comment

ID: 12396499
Note that the 3 classes mentioned above are examples to clear the idea. real live application might more than three connected classes.
LVL 48

Accepted Solution

hernst42 earned 500 total points
ID: 12397647
Why don't you use a db-object in the file-maninpulation class instead of extending the file-manipulation class from the db-class

Have a look at this design pattern of OOP:

Also read this thread to better unsteadn the way OOP works.

If you get stuck, Could you post you clas -definitions here (what you have so far) without the function-code like this:
class A {
  function b() {

class B extends A  {

LVL 49

Assisted Solution

Roonaan earned 500 total points
ID: 12398137
As the "design patterns" phrase has already be mentioned; take a look at www.phppatterns.com

They offer a clean description and implementation of patterns.

For a CMS system, you could read into the singleton, registry and possibly observer/observable and decorator pattern.


Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Suggested Courses

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question