YAGNI
YAGNI – short for "you aren’t gonna need it" – is a principle of software development that holds a programmer should not add functionality until it is actually necessary. The acronym comes from Extreme Programming (XP), where it is paired with the heuristic do the simplest thing that could possibly work. Ron Jeffries, a co-founder of XP, framed it as: "Always implement things when you actually need them, never when you just foresee that you [will] need them."
The principle is a counterweight to speculative generality. It is tempting to anticipate future requirements, generalize early, or build in flexibility for scenarios that may never arrive. Each speculative abstraction is code that has to be read, tested, and maintained now, in exchange for a benefit that may never materialize. Abstractions built ahead of demand are usually wrong in shape as well as premature in timing, because the second use case that would have informed them has not yet appeared. YAGNI argues for letting the next problem reveal itself before paying for its solution.
YAGNI is part of a family of pragmatic design principles that share an instinct for deferred commitment. The KISS principle names simplicity as a goal in its own right. DRY warns against duplicating knowledge. Premature optimization makes the same argument about performance. All four push the cost of generality, duplication, and tuning past the point at which the need is real.
The principle depends on supporting practices. XP couples YAGNI with continuous refactoring, automated unit testing, and continuous integration. The point is not to write the smallest possible code once and leave it. It is to write the minimal code that works now, then reshape it as understanding grows. Used without refactoring, YAGNI leads to code accreting in whatever shape it was first written, which becomes technical debt rather than simplicity. The discipline is in the loop, not in the cut.
YAGNI is also misread in the other direction. "You aren’t gonna need it" is not a claim that the need will never arrive, only that building for it now is the wrong bet. Some capabilities – security controls, backwards compatibility boundaries, hard-to-retrofit architectural seams – are expensive or impossible to add later, and YAGNI is not a license to ignore them. The principle asks whether the cost is justified by a real requirement, not whether the requirement is possible to imagine.
See also
- Abstraction
- Design principles
- Do the simplest thing that could possibly work
- DRY
- Extreme Programming (XP)
- KISS principle
- Premature optimization
- Refactoring
- Technical debt
References
- Ron Jeffries, Ann Anderson, Chet Hendrickson (2001). Extreme Programming Installed. Addison-Wesley.
- Kent Beck, Cynthia Andres (2004). Extreme Programming Explained: Embrace Change (2nd ed.). Addison-Wesley.
- Wikipedia contributors. You aren’t gonna need it. Retrieved 2026-08-18.