3 ms·
The problem with all those examples is that they are specializations, but that's not really how inheritance works in OOP languages and more resembles refinement
by legulere 4y ago
The problem with all those examples is that they are specializations, but that's not really how inheritance works in OOP languages and more resembles refinement types. A square is a rectangle with the condition, that both sides have the same length.
Inheritance in OOP languages is used to either for interfaces, or for tacking on data and maybe functionality because you are too lazy to implement out composition instead.