Re: DB_DataObject - problem with inheritance

From: Date: Mon, 29 Dec 2003 12:38:02 +0000
Subject: Re: DB_DataObject - problem with inheritance
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-9867@lists.php.net to get a copy of this message
I think this is a case where delegation/composition is better than inheritance. With composition, you can design your Person with the behaviour it needs, and delegate permanent storage to a service class (DataObjects_Person in this case). With inheritance, you are writing in stone that your Person class is a DataObject stored class. It hurts modularity and introduces a hard dependency on an external library. A better presentation than I could write, of composition vs inheritance is here: http://brighton.ncsa.uiuc.edu/~prajlich/T/node14.html Cheers, Sérgio Torsten Roehr wrote:
Hi, I just read the DB_DataObject documentation and wondered about the following. If I create a DataObject class for all my tables and use those as my application objects (e.g. DataObjects_Person is my Person class), I've got no possibility to inherit from other classes (for example extend a Base class with basic functionality for all classes) because of PHP4's inheritance limitation. How do you guys get around this? Big thanks in advance, Torsten Roehr


« previous php.pear.general (#9867) next »