DEV Community

Discussion on: The Four Pillars of Object Oriented Programming

Collapse
 
dakujem profile image
Info Comment hidden by post author - thread only visible in this permalink
Andrej Rypo

Your polymorphism example breaks the Liskov substitution principle. Just use composition and don't make cow1 instanceof Dog === true 🤦‍♂️ Did you study biology basics? 😉

Collapse
 
greedybrain profile image
Naya Willis

My bad, changed it to inherit from the Animal class. You happy now professor?

Collapse
 
dakujem profile image
Andrej Rypo

You're welcome. Just didn't want to write that the example missed the point completely, that's all. 🤷‍♂️ But you're definitely on a good path, keep going!

Collapse
 
andreidascalu profile image
Andrei Dascalu

Principle are "stuff that helps more often than not", not pervasive absolutes on the same level as God's word. But more to the point, it would be weird to talk about inheritance as a "pillar" of oop when general practices have been recommending composition over inheritance for years.

Some comments have been hidden by the post's author - find out more