3 ms·
That's a good point. But IME, when people complain about inheritance, they're primarily talking about implementation inheritance. Interface inheritance, used f
by whstl 3y ago
That's a good point. But IME, when people complain about inheritance, they're primarily talking about implementation inheritance.
Interface inheritance, used for polymorphism like in your example, is still considered a good practice and is not really criticized as much (an exception is when it is "abused" for other reasons, like in codebases that have one interface for every class, even without polymorphism).
- UncleMeat 3y agoEh, the meme has gotten so strong that I now see people say that subtyping in general is bad. It has escaped the gravity of concrete criticisms of implementation inheritance and morphed into a general “oop bad” thought system.
- whstl 3y agoThis is an uncharitable interpretation of the criticism. Several other programming paradigms also have subtyping, often more powerful than OOP, so people moving away from OOP are definitely doing some sort of subtyping in their own language and paradigm, unless they're going to some niche language... or Go. OOP criticism is often centered around two things: inheritance and state hiding via encapsulation. And this criticism often comes also from programmers that use OOP. And IMO it is pretty fair.
- kaba0 3y agoGUI widgets are one area where implementation inheritance is the best model.