2 ms·
Yep. Inheritance is 3 or 4 different features in a trenchcoat, and most of them are bad. Interfaces are good. Method overloading for specialization or for cre
by whstl 3y ago
Yep. Inheritance is 3 or 4 different features in a trenchcoat, and most of them are bad.
Interfaces are good.
Method overloading for specialization or for creating mini-DSLs (Template Method pattern) is often problematic and is better replaced by composition, or by having the "overloaded" methods in a separate class.
Implementation Inheritance is certainly the worst form of "code reuse", and there's a reason people recommend composition over it since the 90s.
Using it for hierarchies (Dog inherits from Mammal, Mammal inherits from Animal) is just terrible and a joke at this point.