DEV Community

SOLID Principles: Write SOLID programs; Avoid STUPID programs

Shravan Kumar B on October 18, 2020

“Think Twice, Code Once” Hi everyone! This is a revised version of my article from my personal blog. Previously, in my last article, I had expla...
Collapse
 
adam_cyclones profile image
Adam Crockett 🌀

OOP and SOLID is not for everything.

Collapse
 
zhravan profile image
Shravan Kumar B

Just a fact that, SOLID makes you a better developer. Something you learn with experience.

Collapse
 
adam_cyclones profile image
Adam Crockett 🌀

Some of the solid principles certainly do apply to FP and OPP that is true. But when I was a junior I used to blindly quote SOLID for everything, not a mistake I wish others to repeat.

Thread Thread
 
zhravan profile image
Shravan Kumar B

Yes. Admit what you are saying.

Collapse
 
jwp profile image
JWP • Edited

Good OOP winds up as functional parts anyway. Why? The Single Responsibility Principle. Ultimately functional programming styles and OOP are the same thing when favoring composition over inheritance.
The whole Inheritance discussion is of much lesser importance; but unfortunately, many articles start off with discussing it.
Traditional inheritance is an advanced topic and not strictly needed or taught in Javascript. This is due to the excellent 'functions as true first class citizens' feature of Javascript.

C# and Java don't treat functions as true first class functions which leads to other solutions. All of which we are too familiar.

Collapse
 
zhravan profile image
Shravan Kumar B

Certain problem statements can fit perfectly into design patterns. Design Patterns where entity are considered as objects, are easily resolvable. FP is a great way of solving problems, but not serves all the purpose.

Collapse
 
evrtrabajo profile image
Emmanuel Valverde Ramos

Nice article, a few weeks ago I've posted mine talking about SOLID in PHP with real examples, I hope it may help you. dev.to/evrtrabajo/solid-in-php-d8e

Collapse
 
zhravan profile image
Shravan Kumar B

Thank you.

Collapse
 
ilumin profile image
Lumin

Always found Premature Optimizations and Premature Implementation 😢

Collapse
 
zhravan profile image
Shravan Kumar B

Did not get you

Collapse
 
ilumin profile image
Lumin

Sorry for my bad English, I'm not so good at it please be patien with me 😢

I mean, I've always found these anti pattern in my project

  • Premature Optimizations ~ like you said, reafctor for no reason
  • Premature Implementation ~ implement code to support future features
Thread Thread
 
zhravan profile image
Shravan Kumar B

Hey, no issues.

Premature Implementation and Optimisation is something we learn to avoid with experience.

Collapse
 
dualyticalchemy profile image
⚫️ nothingness negates itself

functional programming achieves SOLD more easily and with less side- effects than OOP. i'm sold!!

Collapse
 
zhravan profile image
Shravan Kumar B • Edited

Functional Programming definitely has its perks over OOPs in context with SOLID principles.

Collapse
 
jwp profile image
JWP • Edited

In the United States, a cycle is not ever a car.

Therefore, this is a bad example for the United States, because it violates inheritance rule #1, do not ever violate 'is-a' relationships.