PHP OO
September 2, 2008 – 09:55INHERITANCE APPROACH
- Advantage
- easy to inherit an implementation
- Disadvantage
- may be difficult to adapt to changing roles
INTERFACE APPROACH
- Advantages
- can be clearer what methods must be implemented.
- A class in another inheritance hierarchy can provide the services of an interface.
- Disadvantage
- may end up with lots of helper classes.
Things to Remember
You can design with an emphasis on either inheritance or interfaces:
- Interfaces show commonality of behavior.
- Inheritance shows commonality of behavior along with commonality of implementation.
- Interfaces are more fluid than inheritance, but you need to use delegation to share common code.
- Inheritance couples the derived classes to the base class, but it allows them to easily share the common code of the base class.




















Sorry, comments for this entry are closed at this time.