"Joel Kitching" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Mon, 28 Jun 2004 13:41:19 -0500, Jay Blanchard > <[EMAIL PROTECTED]> wrote: > > If you are going to duplicate code why not just create a generic class > > with the code that would be duplicated and then extend the class as > > required? > > > > What generic class name would be appropriate in this case? I just > can't see how I would link the two together. Also, they would have to > use fairly generic variables names if I were to do this. Like using > the variable $items for the array of classes of either albums or > photos. > > Or maybe this is exactly what OOP is about and I'm just starting to get it.
Hi Joel, from what you wrote it seems that only the type of display is similar in both classes. I don't think this is enough to extend them from the same base class because the class properties and update/insert/load methods will be different in each. You have more of a 'is part of' relationship here. So I'd suggest something like this (simplified): class Portfolio { var $portfolioID; var $albums = array(); } class Album { var $albumID; var $portfolioID; var $photos = array(); } class Photo { var $photoID; var $albumID; var $name; } Just my 2c. Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php