DEV Community

Cover image for S.O.L.I.D: The 5 Golden Rules to Level Up Your Coding Skills

S.O.L.I.D: The 5 Golden Rules to Level Up Your Coding Skills

Idan Refaeli on February 05, 2024

In the realm of software development, a field known for its diverse and strongly held opinions, few practices have achieved consensus as a guarante...
Collapse
 
mattzgg_94 profile image
Matthew Gong • Edited

Thanks for provding such a clear explantion to SOLID.

By the way, there is a small error in the article. The actual result and expected result in the following code snippet used in the LSP section should be swapped.
console.log(square.getArea()); //Expected: 50, Got: 100 (X)
should be:
console.log(square.getArea()); //Expected: 100, Got: 50 (X)

Collapse
 
idanref profile image
Idan Refaeli

Thanks for the comment Matthew!

The mentioned code block was meant to describe the Lisokv's principle violation, where increasing the square's width using increaseRectangleWidth() unexpectedly affects both dimensions (width & height) due to the Square class setter, eventually leading to an area of 100 instead of 50.

increaseRectangleWidth() by its own nature should increase only the width of the provided rectangle, however all the square's sides were increased, leading to the actual violation.

Collapse
 
nathan_tarbert profile image
Nathan Tarbert

I really enjoyed catching up on the SOLID principles. Thanks!

Collapse
 
idanref profile image
Idan Refaeli

Glad to hear Nathan, thanks for the feedback!

Collapse
 
verthon profile image
Krzysztof Sordyl

Do you have any linting solution to catch the SOLID violations automatically ?

Collapse
 
fer profile image
Fernando

From my experience that depends of language you are using
but any static analyzer would be work for you
Here are a list per language github.com/awesome-security/awesom...

Collapse
 
excellencyjumo profile image
Adedamola Adejumo

Nice Read

Collapse
 
idanref profile image
Idan Refaeli

Thanks for the feedback!

Collapse
 
krisbor3 profile image
Kristiyan Borisov

Great article! It is always more understandable and beneficial when the explanation has examples alongside the theory. :)

Collapse
 
idanref profile image
Idan Refaeli

Thanks! Glad you liked it :)

Collapse
 
overtureweb profile image
Overture Web

Great article about what is arguably one of the most useful principles in software development.

Collapse
 
idanref profile image
Idan Refaeli • Edited

Thanks for the feedback!

Collapse
 
szeredaiakos profile image
szeredaiakos • Edited

Single reason to change. Meaning that the product manager you initially presented is perfectly fine unless your analysis predicts high frequency changes form the start.

Otherwise you are looking at meaningless over engineering which is probably the worst you can do at the start.