DEV Community

Discussion on: What’s an unpopular software opinion you have?

Collapse
 
jamesmh profile image
James Hickey

Inheritance is 99.9% of the time (e.g. always...) the wrong decision.

Inheritance, after-all, is one of the strongest forms of coupling you can introduce into your code ;)

There's usually a way to use composition to achieve the same thing.

Collapse
 
rhymes profile image
rhymes • Edited

Agreed.

Composition is 99% of the times a better choice :D

Collapse
 
deleugyn profile image
Marco Aurélio Deleu

The Template pattern happens a lot more than just 0.1%

Collapse
 
ben profile image
Ben Halpern

Yeah, I kind of wish that hadn’t been such a big part of my formal education.

I only did some CS and so much of it revolved around inheritance in Java that I found myself looking for opportunities to use inheritance in the wrong places.

Collapse
 
jamesmh profile image
James Hickey

I feel you there. Been there done that 😋

Collapse
 
garfbradaz profile image
Gareth Bradley

James, didn't you do a Composition over inheritance post?

Collapse
 
jamesmh profile image
James Hickey

I don't think so... but it's something I've had in my head to do someday!

Collapse
 
hryggrbyr profile image
Thomas Rigby

MPJ has a video on it. Very good imo 😀
youtu.be/wfMtDGfHWpA