# YAGNI

> Build a capability when you actually need it, never when you merely foresee needing it.

**Field:** Software & systems · **Reliability:** Heuristic

*Also known as: You Aren't Gonna Need It; You Ain't Gonna Need It; You're NOT gonna need it*

## What it means

A feature you add because you expect to want it later costs you now and usually turns out to be the wrong feature. The principle says to wait: implement the capability at the moment a real requirement arrives, not at the moment somebody imagines one.

## How it works

A presumptive feature is a bet on a forecast, and software forecasts are poor. If the guess is wrong you have paid for something nobody uses; if it is right, you have often built the wrong shape of it, because the real requirement arrives with details the forecast lacked. Martin Fowler enumerates four costs that land either way: the cost of building it, the cost of delaying the features you could have built instead, the cost of carrying the extra complexity in every subsequent change, and the cost of repairing it once the real need contradicts the guess. Waiting converts a bet into a decision made with information.

## Examples

- **The configurable everything:** A setting is made configurable 'in case someone wants to change it'. Nobody ever does, and every code path that reads it must now handle values that never occur in production.
- **The premature abstraction:** An interface with one implementation is introduced because a second is expected. When the second arrives it does not fit the interface, so the abstraction is rewritten: having cost indirection in the meantime.
- **Multi-tenancy on day one:** A product for one customer is built to serve many. The second customer arrives two years later wanting something the design did not anticipate, and the generality built for them is discarded.

## Why it matters

It is the clearest statement of a bias that costs software teams more than almost any other: the instinct to build for an imagined future. It reframes 'flexible' from a virtue into a cost with a name and a bill, and it gives a reviewer a short, quotable reason to ask why a capability exists now rather than later.

## Where it breaks down

It assumes change stays cheap, which is exactly what its own methodology has to supply: the practice was stated inside Extreme Programming alongside continuous refactoring, automated tests and continuous integration, and without those the deferred work becomes rework rather than saved effort. It also bites hardest on reversible decisions. Choices that are expensive or impossible to revisit later (a data model that silently discards information, a public API, an encryption scheme, a regulatory obligation) are precisely the ones where anticipating is cheaper than repairing.

## Common misreadings

It is not an argument for careless code, for skipping design, or for refusing to think about the future. It says nothing against making a system easy to change; it says only that building a capability before a requirement exists is a bet you usually lose. Nor does it license shipping a known-inadequate design where the inadequacy is already a present, not a future, problem.

## Origin

Stated as a practice of Extreme Programming in the late 1990s and most often quoted from Ron Jeffries, one of XP's three founders, in the form "Always implement things when you actually need them, never when you just foresee that you need them." The acronym circulated on the WikiWikiWeb before entering general use; Martin Fowler's 2015 bliki entry gave it the four-costs analysis now usually cited with it. No single publication is the first appearance of the phrase.

## Related

- [The DRY Principle](https://conyso.com/lawtome/laws/dry/) — kindred
- [The KISS Principle](https://conyso.com/lawtome/laws/kiss-principle/) — kindred
- [Knuth's Optimization Principle](https://conyso.com/lawtome/laws/knuths-optimization-principle/) — kindred

## Sources

- [Fowler, M. (26 May 2015). "Yagni." martinfowler.com — the cost-of-build, cost-of-delay, cost-of-carry, cost-of-repair analysis, and the distinction between presumptive features and modifiability.](<https://martinfowler.com/bliki/Yagni.html>)
- ["You aren't gonna need it." Wikipedia — the Jeffries formulation and the dependency on refactoring, unit testing and continuous integration.](<https://en.wikipedia.org/wiki/You_aren%27t_gonna_need_it>)

---
Source: https://conyso.com/lawtome/laws/yagni/ · The Law Tome — a sourced index of named laws.
