DRY vs YAGNI

DRY (Don't Repeat Yourself) and YAGNI (You Aren't Gonna Need It) both come up in technology conversations and get confused. Here's the plain-English difference, side by side, so you can use each one with confidence.

The key difference: DRY refers to don't repeat yourself, while YAGNI refers to you aren't gonna need it — they describe different things even when they show up in the same sentence.

DRY — Don't Repeat Yourself

Principle that every piece of knowledge should have a single, unambiguous representation in a system. DRY done badly creates the wrong abstractions — duplication is cheaper than the wrong coupling.

Full DRY definition →

YAGNI — You Aren't Gonna Need It

Principle that says don't build features until they're actually required. YAGNI is the antidote to speculative generality — most "we might need this someday" code never gets used.

Full YAGNI definition →

When to use DRY

Reach for "DRY" when the conversation is specifically about don't repeat yourself. Principle that every piece of knowledge should have a single, unambiguous representation in a system. DRY done badly creates the wrong abstractions — duplication is cheaper than the wrong coupling.

When to use YAGNI

Reach for "YAGNI" when the conversation is specifically about you aren't gonna need it. Principle that says don't build features until they're actually required. YAGNI is the antidote to speculative generality — most "we might need this someday" code never gets used.

FAQs

What is the difference between DRY and YAGNI?

DRY stands for Don't Repeat Yourself — Principle that every piece of knowledge should have a single, unambiguous representation in a system. DRY done badly creates the wrong abstractions — duplication is cheaper than the wrong coupling. YAGNI stands for You Aren't Gonna Need It — Principle that says don't build features until they're actually required. YAGNI is the antidote to speculative generality — most "we might need this someday" code never gets used.

Are DRY and YAGNI the same thing?

No. They're often used in the same conversation because they're related, but they describe different concepts. DRY = Don't Repeat Yourself. YAGNI = You Aren't Gonna Need It.

When should I use DRY vs YAGNI?

Use DRY when you're specifically referring to don't repeat yourself. Use YAGNI when the topic is you aren't gonna need it.