Chapter 12. YAGNI

Einstein repeatedly argued that there must be simplified explanations of nature, because God is not capricious or arbitrary. No such faith comforts the software engineer.

Fred Brooks, The Mythical Man-Month: Essays on Software Engineering

12.0 Introduction

YAGNI, which stands for “You Ain’t Gonna Need It,” advises developers to only implement features or functionality that are actually needed at the moment, rather than adding unnecessary features or functionality that may not be used in the future. The idea behind YAGNI is to minimize accidental complexity and keep the focus on the most important tasks at hand.

The YAGNI principle can be seen as a counterpoint to the common tendency in software development to overengineer solutions or add unnecessary features in anticipation of future needs or requirements. This can lead to unnecessary complexity, wasted time and effort, and inflated maintenance costs.

The YAGNI principle encourages developers to keep their focus on the immediate needs of the project and only add features or functionality that are necessary to meet those needs. This helps to keep the project simple and focused and allows developers to be more agile and responsive to changing requirements.

12.1 Removing Dead Code


You have code that is no longer used or needed.


Do not keep code “just in case I need it.” Remove it.


Dead code hurts maintainability and violates the KISS principle (see Recipe 6.2, “Removing Empty ...

Get Clean Code Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.