Composition over inheritance: Difference between revisions

Content deleted Content added
Composition and interfaces: rm inappropriate quotation marks, replace with link
Tags: Mobile edit Mobile web edit Advanced mobile edit
Benefits: capitalisation
Tags: Mobile edit Mobile web edit Advanced mobile edit
Line 213:
 
==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 is 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 (''[[HAShas-Aa]]'') than extend what it is (''[[ISis-Aa]]'').<ref name="FHDPs">{{cite book
| last1 = Freeman
| first1 = Eric