DEV Community

Cover image for SOLID, KISS, YAGNI and DRY Principles

SOLID, KISS, YAGNI and DRY Principles

Nguyen Khac Nghiem on November 13, 2023

SOLID This principle was given by Robert C. Martin and Michael Feathers to encourage us to create more maintainable, understandable, and...
Collapse
 
alexmario74 profile image
Mario Santini • Edited

About the DRY principle, I think you put it in a too simplistic way. Actually DRY is not about code repetition, the principle rather refers on information, and knowledge in the system.
When you find duplicated code in your system, you should check if all the different part with that code are actually working on the same piece of information.
In that case you can try to find an abstraction, and you can refactor your code base in a way that this logic is placed in one place and just used where it is needed, getting rid of the duplicated code.
If the code is the same, but is working on differen business entities, you may better to leave it duplicated, as it may will diverge in the future.
If you change it and then you have to implement a new requirement that change the behaviour in one place, but not in the other, then you are forced to introduce complexity to handle the feature.

Collapse
 
nknghiem profile image
Nguyen Khac Nghiem

Thanks for your feedbacks!

Collapse
 
__junaidshah profile image
Junaid

Great share and welcome to dev.

Collapse
 
nknghiem profile image
Nguyen Khac Nghiem

Thank you so much!!!

Collapse
 
aatmaj profile image
Aatmaj

Nicely explained. The examples make it clear to understand👍🏻

Collapse
 
nknghiem profile image
Nguyen Khac Nghiem

Thank you so much!!!

Collapse
 
bogomil profile image
Bogomil Shopov - Бого

Useful! Thanks!

Collapse
 
nknghiem profile image
Nguyen Khac Nghiem

You're welcome.

Collapse
 
shoptinhyeuvn profile image
Shop tình yêu shoptinhyeu.vn

Excellent. You're really good.

Collapse
 
nknghiem profile image
Nguyen Khac Nghiem

You are too kind.

Collapse
 
__masashi__ profile image
Masashi

Amazing post. Keep it up buddy!

Collapse
 
nknghiem profile image
Nguyen Khac Nghiem

Thank you so much!!!

Collapse
 
dolphin profile image
Olavi Jokela

I have learned so much. Thanks.

Collapse
 
asyncnavi profile image
Navraj Sandhu

Amazing 💝