← All Quizzes
What is the DRY principle and what are its limitations?
Explanation
The DRY (Don't Repeat Yourself) principle states that every piece of knowledge should have a single, unambiguous, authoritative representation in a system. DRY reduces maintenance burden: changes happen in one place. However, over-application can create premature abstractions, excessive coupling between unrelated code, and hard-to-understand indirection. Two pieces of code that look similar but serve different purposes (coincidental duplication) should sometimes remain separate. The complementary principle is WET (Write Everything Twice) or the Rule of Three: abstract only after the third occurrence, not the first.