Hacker News new | ask | show | jobs
by cturner 5804 days ago
I'd go further. I think inheritance is the modern day goto. I used to consider myself a bit of a 'framework engineer'. I was wrong. Inheritance creates structures that are difficult for you to refactor and others to understand.

As I moved away from java and settled into the vibe with python, I've abandoned inheritance. I use simple objects, but tend to orient encapsulation around modules, at to do real encapsulation at this higher level (rather than with classes). It's faster to write, easier to read and much easier to refactor.

I like the Kay quotes that dpapathanasiou raises in another comment here. Are there books or other references that seek to teach "message-oriented programming" with mainstream languages like C or Java?

(On the author's main point I disagree. If you're going to do a lot of inheritance you need private variables, otherwise it's easy for descendants to create hard-to-diagnose bugs.)

1 comments

The interface between a superclass and its subclasses is just another interface (or rather say, a pair of interfaces: sub-calls-super and super-calls-sub). However, many if not most superclass-subclass interfaces are not designed and documented like proper interfaces.