|
|
|
|
|
by ratww
1881 days ago
|
|
Code-reuse via "Implementation Inheritance" is completely unnecessary for specialisation or polymorphism. When someone says that "inheritance is bad for code reuse" they're not talking about interfaces, or using inheritance for polymorphism. They're strictly talking about sharing code using implementation inheritance, which is the thing that has been widely criticised for more than 30 years now. One can argue that even the "Template Method Pattern" doesn't fall into "implementation inheritance", since the implementation lives in the subclass. If you read the posts, discussion is way more nuanced than "inheritance bad vs inheritance good". |
|
Here is more specifically what I meant with my comment about specialization above. There is a class with four methods, three of which are exactly what you need but the fourth one, you need to modify.
Solving this with inheritance is trivial (extend and override).
Solving this with any other paradigm is... much harder and requires a lot more boilerplate.