Composition over inheritance: Difference between revisions

Content deleted Content added
Avoiding drawbacks: Ref for PHP
No edit summary
Line 231:
}}</ref>
 
Initial design is simplified by identifying system object behaviors in separate interfaces instead of creating a hierarchical relationship to distribute behaviors among business-___domain classes via inheritance. This approach more easily accommodates future requirements changes that would otherwise require a complete restructuring of business-___domain classes in the inheritance model. Additionally, it avoids problems often{{weasel word}} associated with relatively minor changes to an inheritance-based model that includes several generations of classes.
Composition relation is more flexible as it may be changed on runtime, while sub-typing relations are static and need recompilation in many languages.