Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I think avoiding deep class hirarchies is an accepted best practice nowadays. In academia, people still don’t know it (I left in 2017) but it is accepted by everyone I talk to nowadays. I do not use any implementation inheritance anymore, only interface inhertance.


The problems with implementation inheritance are quite a bit deeper than "ontology is overrated", though - even where ontologies are appropriate, it's still bad!

It's "sold" as enabling extensibility and code reuse, but the only feature it adds to good old-fashioned composition is 'open recursion' a.k.a. late binding, which inherently leads to the "fragile base class" problem-- making behavior of base-class implementations dependent on preserving complex and generally unspecified invariants in the derived classes - so it's basically never what you actually want!

Full-blown OOP (including implementation inheritance and polymorphism) doesn't work. It's a terrible idea that only ever became popular because we didn't quite grok its implications.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: