OOP: 3 types of inheritance
Excellent explanation of what is actually 3 different kinds of inheritance seen in object-oriented programming (OOP), and how they should be distinguished.
「Why inheritance never made any sense」
https://www.sicpers.info/2018/03/why-inheritance-never-made-any-sense/
Summary:
Subset ⇒ Ontological inheritance (square ⊆ rectangle)
Subtype ⇒ Interface inheritance (obeying Liskov Substitution Principle)
Subclass ⇒ Implementation inheritance (bastard child [my own words])
Liskov Substitution Principle allows covariance / contravariance to work correctly.
Related:
「Interface inheritance vs. Implementation inheritance」
https://stackoverflow.com/questions/3774204/difference-between-interface-inheritance-and-implementation-inheritance/3774277#3774277
「Prefer composition over implementation inheritance」
http://whats-in-a-game.com/prefer-composition-over-implementation-inheritance/
<<On the whole, we don’t do implementation inheritance. F# object-oriented programming has a much stronger emphasis on delegation than implementation inheritance for [code] sharing.
It’s really important to understand the problems that implementation inheritance cause. The thing about implementation inheritance is that you’re always taking something that’s already complex, and making it more complex. And that’s the nature of it. And you can’t hide that complexity away like you can with delegation. So please delegate. Don’t use implementation inheritance.>> 「F# Code I Love — Don Syme」
https://www.youtube.com/watch?v=1AZA1zoP-II