3 ms·
One way to think of the composition versus inheritance debate is to view inheritance as a relation specification, while composition is how you implement (ie mix
by Edmond 8y ago
One way to think of the composition versus inheritance debate is to view inheritance as a relation specification, while composition is how you implement (ie mixin=copy some props from A-to-B) the relation.
The problem is that languages such as Java mix up the specification and the actual implementation, as a result you end up with an inheritance model that is rigid and doesn't account for the messiness of the real word, in other words things in the real world are not often related in a neat parent/child way.
Granted, Java does provide interfaces which can be viewed as a way to specify composition even though that doesn't appear to be it's intended use.