logoalt Hacker News

ghosty141today at 3:02 PM5 repliesview on HN

What's the problem with SOLID? It's very very rare that I see a case where going against SOLID leads to better design.


Replies

GuB-42today at 4:02 PM

SOLID tend to encourage premature abstraction, which is a root of evil that is more relevant today than optimization.

SOLID isn't bad, but like the idea of premature optimization, it can easily lead you into the wrong direction. You know how people make fun of enterprise code all the time, that's what you get when you take SOLID too far.

In practice, it tends to lead to a proliferation of interfaces, which is not only bad for performance but also result in code that is hard to follow. When you see a call through an interface, you don't know what code will be run unless you know how the object is initialized.

srousseytoday at 4:30 PM

In a way, SOLID is premature optimization. You are optimizing abstractions before knowing how the code is used in practice. Lots of code will be written and never changed again, but a minority will see changes quite a bit. Concentrate there. Like you don't need to optimize things that aren't in hot code (usually, omg experience will tell you that all rules have exceptions, including the exceptions).

show 1 reply
dzjkbtoday at 3:12 PM

here's a nice critique of SOLID principles:

https://www.tedinski.com/2019/04/02/solid-critique.html

show 3 replies
someguyiguesstoday at 3:07 PM

It only applies to the object oriented programming paradigm

show 3 replies
paulddrapertoday at 5:02 PM

It causes excessive abstraction, and more verbose code.

L and I are both pretty reasonable.

But S and D can easily be taken to excess.

And O seems to suggest OO-style polymorphism instead of ADTs.

show 1 reply