Chris wrote:
Hi,

I've got a collection of Element classes (about 8 different ones). They are all subclasses of a single parent element. I'm trying to extend their functionality (both the individual classes, and the parent class they inherit).

I can extend each Element subclass with it's new specific functionality, but I would also like to add specific functionality to all of the subclasses. Extending the parent element with the new functionality would *seem* to be the way to go, but I can't make it work None of the Subclasses inherit from the extended superclass. Any thoughts? I'd appreciate any ideas.


BaseElement
|- SubElement1
|  \- ExtendedSubElement
|- SubElement2
|- SubElement3
|- SubElement4
|- SubElement5
|- SubElement6
|- SubElement7
|- SubElement8
\- ExtendedBaseElement

ExtendedSubElement will never be able to inherit from ExtendedBaseElement.
there is no multiple inheritance in php.

So either change your 'tree':

BaseElement
\- ExtendedBaseElement
   |- SubElement1
   |  \- ExtendedSubElement
   |- SubElement2
   |- SubElement3
   |- SubElement4
   |- SubElement5
   |- SubElement6
   |- SubElement7
   |- SubElement8

... stick the functionality of ExtendedBaseElement into BaseElement
and get rid of the ExtendedBaseElement

... or figure out a neat way to use the 'Decorator Pattern'
(http://www.google.com/search?q=Decorator+Pattern) in order to
conditionally make extended functionality available in specific
descendant classes?

otherwise post some code (cutdown :-) for people to look at.



Thanks,
Chris


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

Reply via email to