# Don't Repeat Yourself (DRY)

> The rule that each piece of logic should live in one place in your code.

**Field:** Software Development  
**Category:** Programming Concepts  
**Also known as:** DRY, DRY Principle, Don't Repeat Yourself

## Think of it like

Think of it like one shopping list on the fridge. Three copies would soon stop matching.

## Definition

DRY is the rule that each piece of knowledge should live in one place in your code. If the same logic is copied into five files, a fix must be made five times. Usually one copy gets missed. Instead, put it in one function or setting and use that everywhere. Two bits of code that only look alike but mean different things can stay apart.

## Example

Jack's shop works out tax in four places. When the rate changes, he updates three and forgets one. After moving it into one function, a change is one line.

## Why it matters

Copied logic drifts apart. Keeping one copy means one fix, and no copy left behind with the old bug.

## Common mistake

Merging code that only looks the same. If the two parts change for different reasons, joining them makes both harder to change.

## Three principles

- **One place.** For each piece of logic.
- **One fix.** Not five.
- **Same meaning, not same look.** Look-alikes may stay apart.

## Related terms

- [Clean Code](https://learn.benibix.com/term/development/clean-code)
- [Function](https://learn.benibix.com/term/development/function)
- [Refactoring](https://learn.benibix.com/term/development/refactoring)
- [KISS Principle](https://learn.benibix.com/term/development/kiss-principle)

## Taught in

- [DRY, KISS and YAGNI](https://learn.benibix.com/learn/development-concepts/dry-kiss-and-yagni): Programming Basics, 18/18

---

Source: https://learn.benibix.com/term/development/dry-principle
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
