this post was submitted on 03 Nov 2025
121 points (96.9% liked)

Programming

23557 readers
171 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
 

As a Java engineer in the web development industry for several years now, having heard multiple times that X is good because of SOLID principles or Y is bad because it breaks SOLID principles, and having to memorize the "good" ways to do everything before an interview etc, I find it harder and harder to do when I really start to dive into the real reason I'm doing something in a particular way.

One example is creating an interface for every goddamn class I make because of "loose coupling" when in reality none of these classes are ever going to have an alternative implementation.

Also the more I get into languages like Rust, the more these doubts are increasing and leading me to believe that most of it is just dogma that has gone far beyond its initial motivations and goals and is now just a mindless OOP circlejerk.

There are definitely occasions when these principles do make sense, especially in an OOP environment, and they can also make some design patterns really satisfying and easy.

What are your opinions on this?

(page 2) 50 comments
sorted by: hot top controversial new old
[–] SorteKanin@feddit.dk 2 points 2 weeks ago

My somewhat hot take is that design patterns and SOLID are just tools created to overcome the shortcomings of bad OOP languages.

When I use Rust, I don't really think about design patterns or SOLID or anything like that. Sure, Rust has certain idiomatic patterns that are common in the ecosystem. But most of these patterns are very Rust-specific and come down to syntax rather than semantics. For instance the builder pattern, which is tbh also another tool to overcome one of Rust's shortcomings (inability to create big structs easily and flexibly).

I think you're completely correct that these things are dogma (or "circlejerking" if you prefer that term). Just be flexible and open minded in how you approach problems and try to go for the simplest solution that works. KISS and YAGNI are honestly much better principles to go by than SOLID or OOP design patterns.

[–] termaxima@slrpnk.net 2 points 2 weeks ago (1 children)

99% of code is too complicated for what it does because of principles like SOLID, and because of OOP.

Algorithms can be complex, but the way a system is put together should never be complicated. Computers are incredibly stupid, and will always perform better on linear code that batches similar operations together, which is not so coincidentally also what we understand best.

Our main issue in this industry is not premature optimisation anymore, but premature and excessive abstraction.

[–] douglasg14b@lemmy.world 2 points 2 weeks ago* (last edited 2 weeks ago) (1 children)

This is crazy misattribution.

99% of code is too complicated because of inexperienced programmers making it too complicated. Not because of the principles that they mislabel and misunderstood.

Just because I forcefully and incorrectly apply a particular pattern to a problem it is not suited to solve for doesn't mean the pattern is the problem. In this case, I, the developer, am the problem.

Everything has nuance and you should only use in your project the things that make sense for the problems you face.

Crowbaring a solution to a problem a project isn't dealing with into that project is going to lead to pain

why this isn't a predictable outcome baffles me. And why attribution for the problem goes to the pattern that was misapplied baffles me even further.

[–] termaxima@slrpnk.net 2 points 2 weeks ago (1 children)

No. These principles are supposedly designed to help those inexperienced programmers, but in my experience, they tend to do the opposite.

The rules are too complicated, and of dubious usefulness at best. Inexperienced programmers really need to be taught to keep things radically simple, and I don't mean "single responsibility" or "short functions".

I mean "stop trying to be clever".

[–] Guttural@jlai.lu 1 points 2 weeks ago

Wholeheartedly agree. OOP was supposed to offer guardrails that make it harder to write irremediably bad code. When you measure the outcomes in the wild, the opposite is true. Traditional OOP code with inheritance makes it hard to adapt code and to reuse it, as far I've been able to measure.

[–] Corbin@programming.dev 2 points 2 weeks ago

Java is bad but object-based message-passing environments are good. Classes are bad, prototypes are also bad, and mixins are unsound. That all said, you've not understood SOLID yet! S and O say that just because one class is Turing-complete (with general recursion, calling itself) does not mean that one class is the optimal design; they can be seen as opinions rather than hard rules. L is literally a theorem of any non-shitty type system; the fact that it fails in Java should be seen as a fault of Java. I is merely the idea that a class doesn't have to implement every interface or be coercible to any type; that is, there can be non-printable non-callable non-serializable objects. Finally, D is merely a consequence of objects not being functions; when we want to apply a functionf to a value x but both are actually objects, both f.call(x) and x.getCalled(f) open a new stack frame with f and x local, and all of the details are encapsulation details.

So, 40%, maybe? S really is not that unreasonable on its own; it reminds me of a classic movie moment from "Meet the Parents" about how a suitcase manufacturer may have produced more than one suitcase. We do intend to allocate more than one object in the course of operating the system! But also it perhaps goes too far in encouraging folks to break up objects that are fine as-is. O makes a lot of sense from the perspective that code is sometimes write-once immutable such that a new version of a package can add new classes to a system but cannot change existing classes. Outside of that perspective, it's not at all helpful, because sometimes it really does make sense to refactor a codebase in order to more efficiently use some improved interface.

[–] melsaskca@lemmy.ca 1 points 2 weeks ago

OOP is good in a vacuum. In real life, where deadlines apply, you're going to get some ugly stuff under the hood, even though the app or system seems to work.

[–] Jankatarch@lemmy.world 1 points 2 weeks ago* (last edited 2 weeks ago)

What's wrong with making a public static singleton class "isEven" and inheriting it to accomplish your goal class, "isOdd."

[–] brian@programming.dev 1 points 2 weeks ago

most things should have an alternate implementation, just in the unit tests. imo that's the main justification for most of SOLID.

but also I've noticed that being explicit about your interfaces does produce better thought out code. if you program to an interface and limit your assumptions about implementation, you'll end up with easier to reason about code.

the other chunk is consistency is the most important thing in a large codebase. some of these rules are followed too closely in areas, but if I'm working my way through an unfamiliar area of the code, I can assume that it is structured based on the corporate conventions.

I'm not really an oop guy, but in an oop language I write pretty standard SOLID style code. in rust a lot of idiomatic code does follow SOLID, but the patterns are different. writing traits for everything instead of interfaces isn't any different but is pretty common

load more comments
view more: ‹ prev next ›