DEV Community

Cover image for The Art of Clean Code: Mastering the SOLID Principles

The Art of Clean Code: Mastering the SOLID Principles

Krishna kumar Shakya on July 29, 2024

In the vast world of software engineering, there's a hidden treasure known only to the true craft masters. This treasure is not gold or jewels but ...
Collapse
 
kelvinriker profile image
Kelvin Riker

Nice writeup and very usefull information.

One tip, could be to add "wrong" approach first and then correct after.
It highlights the differences and makes it even more clear.

Collapse
 
optim_scaria profile image
Alen Scaria

Agree!

Collapse
 
martinbaun profile image
Martin Baun

Great writeup! The thing to really understand, IMO, is state. How many states can your code be in, where is that state stored, how can it be corrupted, and what state are your external dependencies in if someone pulls the plug on your computer at any given line of code?

Collapse
 
whattheportal profile image
WTP | WhatThePortal.com

Good to see these occasional refreshers on important concepts.

All too often when getting into the weeds of product development we can forget the underlying motivation behind some patterns & behaviors.

Just need a linter to enforce now so humans don't have to!

Collapse
 
watcherx profile image
Bobby

Interface Segregation Principle (ISP) example is wrong. Chef should also extend eatable, else your eat method is out of contract.

Collapse
 
littlerobotguys profile image
MicahWoodrowPhillips

I feel like your discussion around ISP is nearly the same one as in SRP. It's not that it's exactly wrong, but they both "Only do what you need to do." The difference is that ISP is not borrowing from other interfaces that they don't use. ISP is more about not adding clutter, where SRP is more about sticking to one focus, which are similar, but different.

Collapse
 
andrel profile image
André Portela

The way that you explain, is fantastic!

Collapse
 
alexandermirzoyan profile image
Alex Mirzoyan

Nice explanation!

But at the ISP principle's code example I think there is a problem as the Eatable class is not being used anywhere.

Collapse
 
obie_kenobie profile image
Eren Jaeger

Interesting read !

Collapse
 
kocreative profile image
Kat

Thanks for this! Very interesting read and well explained.

Collapse
 
rafaeljohn9 profile image
JohnKagunda

SOLID made easier 👍, thanks