YAGNI Principle

You aren't gonna need it

A design principle from Extreme Programming (XP) states that a programmer shouldn't add any functionality until it's actually necessary.

Ron Jeffries, one of the founders of XP wrote that programmers should "always implement things when you actually need them, never when you foresee that you need them" and "do the simplest possible thing that will work".

Why is it useful?

  • This can help you iterate really quickly.

  • It helps prevent design fatigue or fear of a large all-encompassing up-front design.

But!

YAGNI is meant to be combined with continuous refactoring, automated unit testing, and continuous integration.

Failure to refactor code early could require huge amounts of technical debt and rework.

Therefore, in order to do YAGNI well, developers first need to know how to:

  • write code that's testable

  • run automated tests

Last updated