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」
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.
「Interface inheritance vs. Implementation inheritance」
「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」