Stut wrote:
This is a question of design, not a question of whether to use OOP. For example, in several of the sites I maintain I have classes that inherit from a base class called Table. The base class provides a lot of the basic methods for working on a table (think ActiveRecord). It also has static methods for doing things like updates and deletes based on a where clause. The derived classes can override filter methods (AfterLoad and BeforeSave) to massage the data after it's loaded and before it's saved. They also add any methods needed for acting on that particular entity.

I'm the first to admit that OOP is not always the best methadology to use - the 'best methadology for all situations' does not exist. However, the general feeling people will get towards OOP from this list seems to be 'OOP bad, anything else better'. OOP is great as long as you follow OOD principles and have a fair amount of common sense. It should not be used just because it's there, but it should also not be dismissed.

In fact, in writing that I've just realised that OOP is not the key... OOD is. OOD can be applied (with no syntax or compiler assistance) in a functional system which will have great benefits, all of which I think most people are aware of but, for whatever reason, fail to adequately apply - which is where OOP can be useful since it enforces the structure and protection through the syntax (PHP4 sucked for this, PHP5 is better).

When you actually think about it, OOP is not a methadology - it's a syntax. OOD is the methadology. Ramble... ramble... ramble... over!

I know this is a fairly old thread, but I thought people might be interested in reading a write-up I've recently finished regarding my Table class and it's usage. I had been intending to write it for a while, but a request from Ed Lazor kicked me into actually doing it. Don't expect the quality to be too high - I'm more used to writing requirement/functional specs and user documentation than this type of thing.

   http://stut.net/articles/php_models.html

All comments are welcome, both on the article and on the code itself. However, please keep on-list replies to the code!

-Stut

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to