DRY, short for Don’t Repeat Yourself, is the principle that demands that no code duplications exists. More broadly:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system
The reason for that is simple:
- More code requires more maintenance. That is bad.
- More code is more surface for bugs. That is bad.
- Duplication invites divergence, inconsistencies. That is bad.
As a result, DRY implies modularization of code, into re-usable components. It also implies the use of constants (instead of repeated, same literals), externalized configuration (instead of inline) and even abstraction (as a means to generalize use).