Composition over inheritance: Difference between revisions

Content deleted Content added
m Removing link(s) undefined (XFDcloser)
Line 211:
 
==Benefits==
To favor composition over inheritance is a design principle that gives the design higher flexibility. It is more natural to build business-___domain classes out of various components than trying to find commonality between them and creating a family tree. For example, an accelerator pedal and a steering wheel share very few common [[Trait (computer programming)|traits]], yet both are vital components in a car. What they can do and how they can be used to benefit the car isare easily defined. Composition also provides a more stable business ___domain in the long term as it is less prone to the quirks of the family members. In other words, it is better to compose what an object can do (''[[has-a]]'') than extend what it is (''[[is-a]]'').<ref name="FHDPs">{{cite book
| last1 = Freeman
| first1 = Eric