Is this bad Object Oriented PHP?

The issue with the approach you've given is that you're not following any sort of "separation of powers" principles. Your Display object has a database in it, along with the logic as to how to connect to it; that's probably not the best approach ("the God object"). It may be a better idea to follow MVC (model-view-controller) principles, where you have one class that knows something about your model (database), another that knows how to transform the model into objects that will be presented (controller), and the third that actually shows the data with all of its CSS goodness (view, frequently just a PHP template file) I'd recommend you take a look at an existing MVC framework - I use QCubed ( qcu.be ), there are others - Symfony, Zend, CakePHP.

They all offer you a great way to separate your code cleanly, which ultimately results in maintainability.

The issue with the approach you've given is that you're not following any sort of "separation of powers" principles. Your Display object has a database in it, along with the logic as to how to connect to it; that's probably not the best approach ("the God object"). It may be a better idea to follow MVC (model-view-controller) principles, where you have one class that knows something about your model (database), another that knows how to transform the model into objects that will be presented (controller), and the third that actually shows the data with all of its CSS goodness (view, frequently just a PHP template file).

I'd recommend you take a look at an existing MVC framework - I use QCubed (qcu.be), there are others - Symfony, Zend, CakePHP. They all offer you a great way to separate your code cleanly, which ultimately results in maintainability.

I don't think it's that bad. He just needs to pass the dependencies in from outside. – troelskn Jul 29 '09 at 20:16 1 It's unmaintainable.It would work OK for a small toy project, but I wouldn't ship code like this for a production system.

– Alex Jul 29 '09 at 20:17 Thanks for taking the time to comment. I'm new to OOPHP, so the guidance really helps. – timborden Jul 29 '09 at 20:38 Whether it's maintainable really depends on how much of an application he piles on top of it.

It isn't wise to choose a design without considering the context. Using Symfony for a 5 page portfolio site and a contact form, is a bad call in my opinion. – troelskn Jul 29 '09 at 22:55.

You pass it in the constructor: class User { protected $name; public function __construct($mysql) { $this->id = $mysql->something(); } }.

Right....I think I'll try and flatten things a bit....I guess nesting and objects don't mix well. Thanks – timborden Jul 29 '09 at 21:09.

If you override functions in child classes (for example your IndexPHP class overrides body()) you should make them protected instead of private. Also, it's good practice to only do simple things, like assign values, in the constructor. Your Display constructor does all the work in the class it might be better to move the construction work to displayPage: public function __construct(MySQL $mysql) { $this->mysql = $mysql; } public function displayPage($rebuild=false) { if(empty($this->framework) || $rebuild) { $this->framework = $this->header(); $this->framework .

= $this->body(); $this->framework . = $this->sidebar(); $this->framework . = $this->footer(); } print $this->framework; }.

FYI - I found this discussion helpful: stackoverflow.com/questions/1148068/how-....

Your Display object has a database in it, along with the logic as to how to connect to it; that's probably not the best approach ("the God object"). It may be a better idea to follow MVC (model-view-controller) principles, where you have one class that knows something about your model (database), another that knows how to transform the model into objects that will be presented (controller), and the third that actually shows the data with all of its CSS goodness (view, frequently just a PHP template file). I'd recommend you take a look at an existing MVC framework - I use QCubed (http://qcu.be), there are others - Symfony, Zend, CakePHP.

They all offer you a great way to separate your code cleanly, which ultimately results in maintainability.

Some liver functions are to produce substances that break down fats, convert glucose to glycogen, produce urea (for urine), make certain amino acides, filter harmful substances from the blood (like alcohol) , store vitamins and minerals and produces about 80% of cholesterol in your body.

These functions are: Production of bile (or gall) ... Secreted by the liver, bile either drains directly into the duodenum, or it travels to the gallbladder where it is stored and concentrated until it is required. Bile salts increase the absorption of fats, and help the body absorb vitamins A, D, E and K. Bile also helps the body remove damaged red blood cells.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions