Vol. I a living index of named laws · est. mmxxvi no ads · no account
The Law Tomeindex of named laws

YAGNI

also known as — You Aren't Gonna Need It, You Ain't Gonna Need It, You're NOT gonna need it
"Build a capability when you actually need it, never when you merely foresee needing it."
In plain English

What does YAGNI mean?

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.

Reliability

Rated Heuristic: a dependable rule of thumb, not a proven theorem. The other 224.

Lineage
2015POPULAR
How it works

How does YAGNI work?

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.

Where you'll see it

What are examples of YAGNI?

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

Why does YAGNI matter?

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.

Working with it

How do you apply YAGNI?

  • Ask what breaks if you wait — if the answer is 'nothing, we add it then', that is the case for waiting. If the answer is 'the data would be unrecoverable', that is a real reason to act now.
  • Separate flexibility from features — Fowler's distinction is the useful one — Yagni is about capabilities built for presumed features, not about effort spent making the code easy to change. Refactoring, tests and clean seams are not violations of it.
  • Write the requirement down instead — record the anticipated need where the team will see it when it becomes real, rather than encoding the guess in the system.
Where it breaks down

What are the limits of YAGNI?

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.

What it doesn't say

What are common misconceptions about YAGNI?

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.

Is it real?

Is YAGNI real?

Real as a rule of thumb, not as a theorem. YAGNI is rated Heuristic here: dependable enough to plan with, and with no proof behind it.

Rated from two sources. 225 of the 1,116 entries carry this rating. How the scale works.

25 of 69entries in software & systems carry the same rating

The best-known laws are the least likely to rest on measurement.

Origin

Where did YAGNI come from?

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.

How the name spread

When did people start saying “YAGNI”?

18002019
How often “YAGNI” appears in printed English, which takes hold around 1800 and peaks around 2006. This tracks the phrase and not the idea. A law is usually older than the name for it. Source: Google Books Ngrams.
Sources

Sources & further reading

  1. 1Fowler, 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.primary
  2. 2"You aren't gonna need it." Wikipedia — the Jeffries formulation and the dependency on refactoring, unit testing and continuous integration.secondary

Everything above traces to martinfowler.com and en.wikipedia.org, two sources in all, one of them the original publication rather than an account of it. Nothing is written from memory, and the method is written down. Spot an error or a better source? Suggest a fix.

What we checked

  • 1,116entries in the tomeListed one by one on the browse page.
  • 1,116of them citing a sourceOpen any entry: its sources sit at the foot of the page.
  • 2,489source references in allEach is named, and linked wherever the source is online.