What does the DRY principle say?
Options
- Don't Repeat Yourself: each piece of knowledge lives in one place (Correct option)
- Do Refactor Yearly: review and clean the code every year
- Delete Redundant Years: remove old versions of the code
- Document Right away: write the docs with each commit
Answer
Don't Repeat Yourself: each piece of knowledge should live in one place
Why
If the same logic is copied in five places, a bug fix or rule change must be made five times, and someone will forget one.
DRY says: put that logic in one function, class or constant and reuse it.
But do not merge code that only looks similar by accident; sometimes a little duplication is clearer than the wrong abstraction.
Remember
One rule, one place.