this post was submitted on 26 Nov 2025
29 points (96.8% liked)

Programming

23594 readers
116 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 2 years ago
MODERATORS
top 6 comments
sorted by: hot top controversial new old
[–] FishFace@piefed.social 1 points 3 hours ago (1 children)

Great article.

A lot of people are on the "composition over inheritance" bandwagon now, but I've honestly not seen a situation where I felt that inheritance was used and was the wrong choice. (Though most of my experience is in python where there's no diamond problem, mixin classes are common, etc)

What I noticed is that everyone seems to agree that inheriting implementation is useful, because you have that with traits in rust (which are agreed to be good, afaik), so in languages without traits, it seems reasonable to want to use the next best thing

[–] TehPers@beehaw.org 2 points 2 hours ago (1 children)

Mixins are composition! They don't describe what a type is ("circle" is a "shape", etc) but rather what they can do ("circle" can have its area calculated, it can be drawn, it can be serialized, etc). Mixins in Python just so happen to be implemented by adding base classes.

Inheritance itself isn't really a problem. It usually only matters when you have unnecessarily deep hierarchies, where a change in a base class can change functionality in dozens of classes in an unintentional way. Similarly, it can add complexity once the hierarchy is deep enough, but only really if you throw too much into the base classes.

Python's ABCs are more of interfaces though, which is why despite Python using base classes to "inherit" them, a lot of that is really composition (or putting a class together from parts) rather than inheriting and overriding implementation details from a parent/grandparent/etc type.

[–] FishFace@piefed.social 1 points 2 hours ago

My feeling was always that it was deep hierarchies that were the real problem. But people don't always articulate it that way!

[–] wesker@lemmy.sdf.org 11 points 13 hours ago (2 children)

Greate writeup.

Don't ever mention OOP during an interview. I swear it's such an odd topic of contention, you will flat out get passed up for mentioning it in any sort of positive light.

Yet if you employ the paradigm cleanly and in the right context, devs get impressed and start borrowing designs.

So weird.

[–] FishFace@piefed.social 1 points 3 hours ago

You can also just refer to the principles; at this point OOP is more of a buzzword with too much association with enterprise Java

[–] TehPers@beehaw.org 5 points 8 hours ago

OOP debates usually turn into inheritance vs composition which is weird because every modern used language has objects and most OOP languages lean towards composition these days.

The core OOP concepts are universal and important.