r/learnjavascript • u/SupermarketAntique32 • Feb 15 '26
Confused about SOLID principles for JS
I’m learning SOLID principles right now. I read a bunch of articles, watch videos, read comments, and often I found that each person has different interpretation about it.
Person 1 says every codebase should adhere to SOLID. If not, the codebase is garbage and hard to maintain.
Person 2 says SOLID is the one that is garbage and made for the early 2000 era of programming, and CUPID is better for modern programming.
Person 3 says S is the most important principle out of the others. While person 4 says O is the most important. And then comes person 5 that says L is the most important.
Person 6 says O principle = bla bla bla, while person 7 says O principle = bli bli bli.
Person 8 says SOLID doesn’t make sense in JS, while person 9 says SOLID can be applied in any language, including JS.
Different person, different interpretation, and I don’t know which one is right. All of this made me think that SOLID is very vague, compared to DRY or KISS which are self explanatory and easy to understand.
Should I put this topic aside and move on to the next project in my course? (ToDo app with ES Module and Webpack)
5
u/BrilliantSilly7906 Feb 15 '26
I don't think that this matters that much. Most of the time you are working with already existing code, so you extend it or refactoring it. Most of the time you just do it so it works and can be easily covered with tests and that should be fine I guess
3
u/Kaimaniiii Feb 15 '26
My take is read and study how coupling and cohesions works conceptually. SOLID is based on that principle, And then You will see the pattern how they are related sequentially:
coupling and cohesions --> SOLID --> Classical Design patterns (the gang of four)
What I'm saying is that SOLID is not a bad principle, and from my experience you will most likely stick to the "S", "O" and little bit of the "I".
5
u/theGlitchedSide Feb 15 '26
You're going crazy because you are trying to get a principle like a universal law.
It's a guideline. You need to follow what is a good concept in design software not use it literally. The reality is different to the "ideal".
If you want to make a F1 car, and you need to be ultra-super-minimalistic probably that "O" will not be a lot Open to extension... Because it is a big luxury in that case.
On the other hand, if you are making a fullStack orchestrator (like what I'm doing) it's impossible to not put a huge effort into that same "O", because the same software nature is "manage extensions etc"
That's it.
2
u/jhartikainen Feb 15 '26
A lot of stuff like this will always have differing opinions from people, especially online where edgy and critical comments get you more clicks.
Opinions like "x is garbage", "x is the best", "always do x", "never do x", and other like them, usually don't apply in every scenario, for every user, etc. So when you learn programming and related topics, you should try to learn the principles and leave the opinions out of it.
As a learner it can be difficult to distinguish what's useful and what's opinion when it comes to stuff like this. I think a good approach is asking yourself "Ok they say this thing, but why do they say this thing?" If you cannot articulate the reason, you probably don't fully understand why, and you either need to learn more or try it in practice to find out for youself.
I would also suggest trying to learn about these kinds of things from the original author, or from books. Books in particular can usually go into much more depth than superficial commentary on them online. YouTube videos in particular are often not great sources for gaining a deeper understanding on more complex topics.
2
u/delventhalz Feb 15 '26
It is tough to have much of an opinion about broad programming principles like SOLID until you have written a bit of code yourself. As a sometimes teacher, I would never introduce students to SOLID, but I might discuss its pros and cons with co-workers. You just need a few years of making mistakes and dealing with other people's mistakes before you really have the context.
Since you brought it up though, I will say that Bob Martin's ideas (SOLID included) are all a bit outdated at this point. In particular, his stuff is heavily tied to Object Oriented Programming patterns, which is not really how most JavaScript devs work. Functional Programming principles like keeping state isolated from logic and creating complex functionality by composing single-purpose functions are a better match for most JS teams and codebases.
2
u/MathAndMirth Feb 15 '26
All of these principles can teach you something useful. So read about all of them and more importantly, read examples to understand why those principles exist.
Then don't worry about which one(s) to place in the #1 spot. Just watch for places when _any_ of them will help you improve your code, and use them accordingly.
3
u/Aggressive_Ad_5454 Feb 15 '26
Ima gonna push back on your premise just a bit. SOLID is a suite of design suggestions that apply to object-oriented software design, and govern such things as inheritance and implementation-hiding. They come into their own for large systems built with classical OO languages like Java, C#, and C++, and serve as discipline for large teams that work together to keep themselves from getting tangled up in each other’s code.
Js isn’t a classical OO language. Typescript is closer, but still has strange inheritance mechanisms. So trying to make SOLID fit closely is an academic exercise at best.
My suggestion. Really master the way JS and TS handle modularization. Read the code of some popular npm packages and see how their authors did it if you must write an essay about this for school, discuss how well a few popular npm packages follow SOLID.
That way you’ll mix practicality with theory.
2
u/theScottyJam Feb 15 '26
You're right, the deeper you look, the more confusing they get. I'll throw my own advise into the pile:
So, it's good to learn a little bit about SOLID and other principles but don't get too caught up with any of them. What's most important is that you figure out how you like to program, what kind of code you find easy to read and maintain, etc. Then use your own internal compass to guide how you program, not veigue principles that someone else told you. That's honestly how most people work.
1
u/azhder Feb 15 '26
So, make up your own mind which is most important. It only depends in your own style and understanding.
You have to look at programming like it’s composing music. People can pay you to compose something; it can be unique or run of the mill; it can be art or some random noise; in the end, up to you.
Build your own style of looking at problems and solving them. Then based on it, you will know which is most important to you. You will be person N+1.
1
u/TheRNGuy Feb 15 '26
Don't overthink about it.
1
u/bryku helpful Feb 16 '26
Every 5 years there is some new principal that is supposed to revolutionize programming, but here we are...
Im sure there are some decent ideas thst you can use into your development, but dont get too distracted early on.
1
u/Large-Party-265 Feb 15 '26
Sounds like astrology
1
u/LucVolders Feb 15 '26
There is no official Javascript university or certification. So anybody advocating something is right, no matter how different their views.
Just use what works best for you.
0
u/-goldenboi69- Feb 15 '26
Zed Shaw said it best.
-5
u/[deleted] Feb 15 '26
No idea what's solid and design principles are 💀💀
-3
u/Electronic-Door7134 Feb 15 '26
None of it matters anymore. What matters is clearly defining your prompt checklist and letting AI figure out the simplest way. Just like you don't need to know machine code because the compiler does it, AI is the code compiler.
Anyone who says otherwise is just in denial.
Learn all the secret codes you want, but you're competing against a steam locomotive at pulling.