> For the complete documentation index, see [llms.txt](https://private-26.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://private-26.gitbook.io/notes/design-patterns/you-arent-gonna-need-it-yagni-principle.md).

# You Aren't Gonna Need It (YAGNI) Principle

> <mark style="color:green;">**"Always implement things when you actually need them, never when you just foresee that you might need them."**</mark>

This principle is about avoiding over-engineering and focusing strictly on the present requirements. By adding unnecessary features or over-engineering solutions, we incur additional complexity, which slow down development, increase the likelihood of bugs, and make the codebase harder to maintain.

<figure><img src="https://37738610-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqCQ2gbstBRqQnMv4Qw2I%2Fuploads%2FsdHFJ8XOZoyQUySwbUje%2FScreenshot%202024-12-31%20at%205.14.27%E2%80%AFPM.png?alt=media&amp;token=85a2f19b-e479-451f-87f0-f115dfa07a5c" alt=""><figcaption></figcaption></figure>

<br>

### **Key Benefits of YAGNI**

1. **Reduced waste**: By only implementing what's necessary, you avoid wasting time and effort on unnecessary code.
2. **Simplified codebase**: YAGNI promotes a lean and simple codebase, making it easier to maintain and update.
3. **Faster development**: A laser focus on immediate needs  as not bogged down by potential "what ifs".

### When to Avoid YAGNI

Like any principle, YAGNI shouldn't be rigidly applied in every situation.&#x20;

* **Well-Known Requirements:** If you know with high certainty a feature is coming soon, building some basic support upfront might be wise.
* **Performance-Critical Areas:** Sometimes, a less-than-optimal but more general solution is necessary initially to ensure performance targets are met.<br>

### References

* [The YAGNI Principle](https://blog.algomaster.io/p/8c3c7da7-885b-4a9c-a6e4-70ee02de4772)

\ <br>
