4 ms·
We forget that favoring composition over inheritance is one of the core ideas of OOP. It's supposed to be, at least. Textbooks have an example like "Dog inheri
by jrumbut 3y ago
We forget that favoring composition over inheritance is one of the core ideas of OOP. It's supposed to be, at least.
Textbooks have an example like "Dog inherits from Animal" as a way to demonstrate the concept of inheritance, but people took that as an invitation to become Linnaeus and create a hierarchical taxonomy of their domain.
It might be a useful exercise, actually, but it's rarely the best way to design software and you can do OOP (and do it better) with sparing use of inheritance (by replacing it with extensive use of composition).