DRY is stands for “Don’t Repeat Yourself”. In the book of ‘The Pragmatic Programmer’, we can see this definition for DRY:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system. This means that, you must try to maintain the behavior of a functionality of the system in a single piece of code, it should not have duplicated code or design item.
Since we are looking these principles for system design, we will follow same concepts with software development. It’s easier to maintain a code or system that is only in one place, because if you need to change something in the code or system, you just need to change in one place.
Besides that, if you have the same code in two or more places, the code can be change during the time, and when this happens it will become bugs in your system. Duplicated code also makes the code more complex and unnecessarily larger.
xxxxxxxxxx
DRY Principle: "Don't Repeat Yourself."
It means avoid code duplication by defining
functions or constants once and reusing them.
This reduces bugs and improves code
maintainability.