this post was submitted on 10 Feb 2026
278 points (95.1% liked)

Programmer Humor

29647 readers
820 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] tatterdemalion@programming.dev 72 points 1 day ago (7 children)

In over ten years of professional programming, I have never used inheritance without regretting it.

[–] wewbull@feddit.uk 2 points 11 hours ago (1 children)

Do you include "traits" and "interfaces" under the title "inheritance"?

[–] tatterdemalion@programming.dev 1 points 3 hours ago

No because those are different things.

[–] Shanmugha@lemmy.world 1 points 11 hours ago

Just don't use inheritance where more than a few descendants are predicted

When it's the right tool, it's incredibly useful. When it's the wrong tool, and it often is, it racks up tech debt at an incredible rate.

[–] AudaciousArmadillo@piefed.blahaj.zone 19 points 1 day ago (1 children)

It works great for technical constructs. E.g. A Button is a UI element. But for anything business logic related, yeah it'll suck.

[–] FooBarrington@lemmy.world 5 points 14 hours ago

Even then there's rarely a good reason to use inheritance instead of composition.

[–] red_tomato@lemmy.world 18 points 1 day ago

And not once have I regretted removing inheritance.

[–] Supercrunchy@programming.dev 6 points 1 day ago

It might be nice to use in some very specific cases (e.g. addition-operation is a binary-operation AST node which is an AST node).

In most of the cases it just creates noise though, and you can usually do something different anyway to implement the same feature. For example in rust, just use enums and list all the possible cases and it's even nicer to use than inheritance.

[–] Valmond@lemmy.dbzer0.com 4 points 1 day ago (1 children)

That's wild. What did you use it for?

[–] tatterdemalion@programming.dev 1 points 3 hours ago

Some legacy Python code that already used inheritance. I had to extend it, and it was pretty infeasible to refactor the whole thing to not use inheritance. Not sure if I technically regretted that decision, but it was definitely painful, since Python inheritance makes it really hard to follow program control flow.