Don't Repeat Yourself (DRY)

Don’t Repeat Yourself, usually abbreviated DRY, is a design principle aimed at eliminating duplication of knowledge in a software system. The motivating problem is that when the same logic or fact is expressed in two places, the two copies tend to drift apart over time, and a change made in one is easily forgotten in the other - a frequent source of bugs.

The principle was stated by Andy Hunt and Dave Thomas in their 1999 book “The Pragmatic Programmer.” As tip number 15 in the book, DRY reads: “Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.”

Read carefully, DRY is about knowledge rather than mere text. Two passages of code that happen to look alike are not necessarily a violation; what matters is whether they encode the same decision or fact. When they do, that knowledge should live in exactly one place, so that updating it is a single edit.

DRY has become one of the most widely cited maxims in software design, and it sits alongside related ideas such as separation of concerns and refactoring as part of the everyday vocabulary programmers use to talk about keeping a codebase maintainable.

Sources

Last verified June 8, 2026