this post was submitted on 21 Apr 2024
131 points (95.8% liked)

Programming

17406 readers
94 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 1 year ago
MODERATORS
 

I don't entirely subscribe to the first paragraph – I've never worked at a place so dear to me that spurred me to spend time thinking about its architecture (beyond the usual rants). Other than that, spot on

you are viewing a single comment's thread
view the rest of the comments
[–] magic_lobster_party@kbin.run 4 points 6 months ago* (last edited 6 months ago)

I've never regretted using composition (and thus having a few extra lines and a little bit more boilerplate) over inheritance.

I second this. It doesn’t necessarily eliminate bad code, but it certainly makes it more manageable.

Every time inheritance is used, it will almost certainly causes pain points that’s hard to revert. It leads to all these overly abstracted class hierarchies that give OOP a bad rep. And it can be easily avoided in almost all cases.

Just use interfaces if you really need polymorphism. Often you don’t even need polymorphism at all.