Hacker News new | ask | show | jobs
by parpfish 261 days ago
i've been beating the drum for a long time that we teach OO programming wrong.

we always start with inheritance (Car is subtype of Vehicle; Cat is subtype of Animal).

we need to teach encapsulation as the primary use for OO.

ime, the most effective way of using "OO" in practice is that you define data classes for different entities and then affix a few fancy constructors that let you build entities out of other entities. inheritance rarely gets used.

1 comments

This is my experience as well. I use encapsulation so often that to me it seems that that's the "point" of OOP, whereas inheritance I use extremely rarely.
I think the reason for this is, that encapsulation is not at all specific to OOP, that was already common before. What OOP adds really is inheritance and RTTI. Even polymorphism was already standard.