YAGNI Principle
They are guidelines that help software developers create system that are easy to understand, maintain, and extend. They are applied both at high-level and low-level design stages.
YAGNI: You Aren't Gonna Need It
It states that always implement things when you actually need them, never when you just forsee that you might need them. In simple terms, don't add functionality until it's necessary.
Importance
- Reduced waste
- Simplified codebase
- Faster Development
Example
Assume you've been asked to build a note-taking app that allows users to Create a note and view notes. Now, you start thinking ahead: “What if later they want categories? Or tagging? Or syncing with Google Drive? I should prepare for that!”. This creates a lot of unnecessary complexity and wastage of time.
When Not to Use
-
When requirements are well-known: If a feature is guaranteed and soon to be implemented, preparing for it now might be more efficient. For example:
- You're writing a messaging service that currently supports only text, but your product team has committed to image support in 2 sprints.
- Designing your data model to handle attachments now might save significant refactoring later.
-
Performance-Critical Areas: In systems where performance is a first-class concern, avoiding YAGNI might actually help. Preemptively building and testing real-world usage patterns can catch bottlenecks early.