“5. When is classical inheritance an appropriate choice?”
Jakub Arnold

I agree with the general point you’re making — except I have never found a single use-case where class inheritance is a better approach than composition, and I’ve been searching for decades. In fact, I’ve been calling out other devs for years — hundreds of thousands of people have heard the challenge and had an opportunity to try to enlighten me. See “A Simple Challenge to Classical Inheritance Fans”.

Read the comments for some good discussion examining both sides of the issue. I think you’ll find that while Axel Rauschmayer makes a respectable case for inclusion of the class keyword in JavaScript, nobody presents a solid use-case where class inheritance is clearly a better choice than composition.

Now, this could mean that I’m deeply biased and I’m just blowing off use-cases because I’m hyper-sensitive to the dangers of class inheritance (once bitten, twice shy) — but that’s why there are comment sections on blogs. Maybe you’ll prefer Axel’s view, or agree with somebody else that shapes are a good gateway drug to taxonomies (beware though, we were doing graphics programming with shapes at the company described in “Inside the Dev Team Death Spiral” and that ended very badly.)

Personally, I agree with Dan Abramov’s pragmatic approach in “How to Use Classes and Sleep at Night”. He acknowledges that class inheritance can lead to trouble, but makes a reasoned case for using class in safe ways. TL;DR: Avoid inheriting from more than one level, and avoid exporting classes.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.