?
Solved

How to create a full OOP application?

Posted on 2004-10-24
5
Medium Priority
?
195 Views
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.

Regards,
Hamid
0
Comment
Question by:HamidHossain
3 Comments
 

Author Comment

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

Accepted Solution

by:
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:
http://www.zend.com/zend/trick/tricks-app-patt-php.php

Also read this thread to better unsteadn the way OOP works.
http://www.sitepoint.com/forums/showthread.php?s=&threadid=89421

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  {
...
}

0
 
LVL 49

Assisted Solution

by:Roonaan
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.

-r-
0

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