You aren't gonna need it
||This article may contain original research. (August 2009)|
"You aren't gonna need it" (acronym: YAGNI) is a principle of extreme programming (XP) that states a programmer should not add functionality until deemed necessary. Ron Jeffries writes, "Always implement things when you actually need them, never when you just foresee that you need them." The phrase also appears altered as, "You aren't going to need it" or sometimes interpreted as, "You ain't gonna need it".
YAGNI is a principle behind the XP practice of "do the simplest thing that could possibly work" (DTSTTCPW). It is meant to be used in combination with several other practices, such as continuous refactoring, continuous automated unit testing and continuous integration. Used without continuous refactoring, it could lead to messy code and massive rework. Continuous refactoring in turn relies on automated unit tests as a safety net (to detect unforeseen bugs) and continuous integration to prevent wider integration problems.
YAGNI is not universally accepted as a valid principle, even in combination with the supporting practices. The need for combining it with the supporting practices, rather than using it standalone, is part of the original definition of XP. It was never claimed that standalone YAGNI was a good idea.
According to those who advocate the YAGNI approach, the temptation to write code that is not necessary at the moment, but might be in the future, has the following disadvantages:
- The time spent is taken from adding, testing or improving the necessary functionality.
- The new features must be debugged, documented, and supported.
- Any new feature imposes constraints on what can be done in the future, so an unnecessary feature may preclude needed features from being added in the future.
- Until the feature is actually needed, it is difficult to fully define what it should do and to test it. If the new feature is not properly defined and tested, it may not work correctly, even if it eventually is needed.
- It leads to code bloat; the software becomes larger and more complicated.
- Unless there are specifications and some kind of revision control, the feature may not be known to programmers who could make use of it.
- Adding the new feature may suggest other new features. If these new features are implemented as well, this may result in a snowball effect towards feature creep.
See also 
- Extreme Programming Installed, Ronald E. Jeffries, Ann Anderson, Chet Hendrickson, 2001, 265 pages, p. 190, webpage: Books-Google-dIsC, quote: "YAGNI: 'You Aren't Gonna Need It.' This slogan, one of XP's most famous..., reminds us always to work on the story we have, not something we think we're going to need."
- Extreme Programming examined, Giancarlo Succi, Michele Marchesi, 2001, 569 pages, p., webpage: Books-Google-VSCh, quote: "XP says 'do the simplest thing that could possibly work ' because 'you aren't gonna need it'."
- Object-oriented & classical software engineering, Stephen R. Schach, 2007, 618 pages, p., webpage: Book-Google-hWwh, quote: "Two acronyms now associated with extreme programming are YAGNI (you aren't gonna need it) and DTSTTCPW (do the simplest thing that could possibly work)."
- Lowell Lindstrom; Carmen Zannier; Erdogmus, Hakan (2004). "Extreme Programming and Agile Methods". XP/Agile Universe 2004: 4th Conference on Extreme Programming and Agile Methods (Calgary, Canada, August 15–18ISBN 3-540-22839-X.) (Lecture Notes in Computer Science). Berlin: Springer. p. 121.
- Ron Jeffries. "You’re NOT gonna need it!". Practices. X Programming. Retrieved 2007-11-07.
- Martin Fowler; Kent Beck (8 July 1999). Refactoring: Improving the Design of Existing Code. Addison-Wesley Professional, 431 pages, p. 68, webpage: BGoogle-1M. ISBN 0201485672, ISBN 978-0201485677. Quote: "you aren't going to need it".
- Mary Poppendieck; Tom Poppendieck (2003). Lean Software Development: An Agile Toolkit, p.59, webpage: BGoogle-hQ. Quote: "Kent Beck, Extreme Programming Explained, Chapter 17, uses the acronym YAGNI (You Aren't Going to Need It) for this practice and explains its rationale."