DRY

Abbreviation · Principle · Slang & Abbreviations · Origin: 1999

Definitions

  1. Don't Repeat Yourself — a principle that every piece of knowledge should have a single, unambiguous, authoritative representation within a system. Violation is called WET code: We Enjoy Typing (or Write Everything Twice).

    In plain English: A programming rule that says: if you find yourself writing the same code in multiple places, you should combine it into one place that everything references.

  2. DRY taken to an extreme leads to premature abstraction — creating shared code before you understand the use cases, resulting in wrong abstractions that are harder to change than duplication would have been. The 'Rule of Three' suggests waiting until you've duplicated something three times before abstracting.

    Example: 'I DRY'd the code too early and created a shared utility that neither service actually needed. Sometimes duplication is cheaper than the wrong abstraction.'

    Source: over-application critique

Etymology

1999
Andy Hunt and Dave Thomas coin DRY (Don't Repeat Yourself) in 'The Pragmatic Programmer,' defining it as 'every piece of knowledge must have a single, unambiguous representation'
2000s
DRY becomes a mantra, sometimes applied too aggressively — leading to over-abstraction in the name of eliminating duplication
2014
Sandi Metz writes 'duplication is far cheaper than the wrong abstraction,' providing a healthy counterpoint to DRY absolutism

Origin Story

The principle that says every piece of knowledge should live in exactly one place

**DRY** (Don't Repeat Yourself) was coined by Andy Hunt and Dave Thomas in their 1999 book *The Pragmatic Programmer*. The principle states: 'Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.'

DRY is often misunderstood as 'don't write similar-looking code twice.' The actual principle is about **knowledge duplication**, not code duplication. Two functions that look identical but represent different business concepts should *not* be merged -- they'll diverge later.

Overzealous DRY leads to **premature abstraction** -- creating shared modules for code that coincidentally looks similar. Sandi Metz's counter-advice is famous: 'Duplication is far cheaper than the wrong abstraction.' The WET acronym (Write Everything Twice) emerged as a humorous corrective.

Coined by: Andy Hunt, Dave Thomas

Context: *The Pragmatic Programmer*, 1999

Fun fact: Hunt and Thomas stress that DRY applies to all knowledge, not just code: database schemas, documentation, build scripts, and even team knowledge. If a business rule exists in both code and documentation, they'll inevitably diverge. That's a DRY violation.

Related Terms