The Artima Developer Community
Sponsored Link

Uncle Bob's Software Craftsmanship Corner
by Robert C. Martin
February 27, 2004
There's a lot of emotional reaction and baggage surrounding this controvertial saying. And yet it's synonymous with the old KISS principle. Keep It Simple Stupid.


I haven't gotten angry in a classroom setting for a very long time. But I lost my cool today. I was teaching an XP Immersion in Nashville. One of the students was clearly upset by some of XP's more flagrant sayings. YAGNI (You Aren't Going to Need It) was one of them. He made his annoyance known by repeating these saying with a Rosenberg-like satirical flair. Eventually I lost my temper with him. I apologized later, and we had a good talk that I hope settled a few things.

I'm left wondering what the big deal is. Why do people get so upset when we say YAGNI, but not when we say KISS. What is it about YAGNI that is so offensive and contrary. To me they mean the same thing.

I think focussing on simplicity is simply good engineering practice. I think it always has been, and always will be. I think challenging everything with YAGNI is simply good sense.

Databases for example. Are you going to need one? If your application manipulates persistent data you will almost certainly want to use a database of some kind. So should you start development with the database in place? YAGNI would ask you to consider otherwise. If you follow the rules of simple design you would avoid making the database decision for as long as possible. You'd write the bulk of your application while keeping the data structures in RAM. When you finally needed minimal persistence you might write the data to some flat files. You'd hold off on integrating with a full blown database until very late. Again, I think there are many cases where this is just good engineering practice.

When we wrote FitNesse, for example, we knew we'd need to store the wiki pages on disk. But we ignored this issue at first. We wrote our WikiPage object to be RAM resident. We kept it this way for a few months while we worked through the behavior of the system and the design of its components. We had a lot of code written before we ever wrote any persistence code. And when we did write persistence, we used flat files instead of a database.

This left us with a system whose nearly 600 unit tests run in 20-30 seconds, and whose 60+ acceptance tests run in less than 10 seconds. The reason they run so fast is that almost all of them run using the InMemory version of the WikiPage object. It also left us with a system that has a very clear and precise partitioning between behavior and persistence. There is a very obvious line between the two. So when one of our users decided that he'd rather have the pages in a database than in flat files, it took him no more than two days to write the DB back end. The interfaces were already there, and all he had to do was implement them.

The point to all this rambling is that YAGNI does not mean to act stupidly. It does not mean to hack a bunch of code together without a design, or without thought. It simply means to keep the damned system as simple as you can, for as long as you can. It always pays to keep things simple.

Talk Back!

Have an opinion? Readers have already posted 36 comments about this weblog entry. Why not add yours?

RSS Feed

If you'd like to be notified whenever Robert C. Martin adds a new entry to his weblog, subscribe to his RSS feed.

About the Blogger

Robert C. Martin (Uncle Bob) has been a software professional since 1970 and an international software consultant since 1990. He is founder and president of Object Mentor Inc., a team of experienced consultants who mentor their clients worldwide in the fields of C++, Java, OO, Patterns, UML, Agile Methodologies, and Extreme Programming. In 1995 Robert authored the best-selling book: Designing Object Oriented C++ Applications using the Booch Method, published by Prentice Hall. From 1996 to 1999 he was the editor-in-chief of the C++ Report. In 1997 he was chief editor of the book: Pattern Languages of Program Design 3, published by Addison Wesley. In 1999 he was the editor of "More C++ Gems" published by Cambridge Press. He is co-author, with James Newkirk, of "XP in Practice", Addision Wesley, 2001. In 2002 he wrote the long awaited "Agile Software Development: Principles, Patterns, and Practices", Prentice Hall, 2002. He has published many dozens of articles in various trade journals, and is a regular speaker at international conferences and trade shows.

This weblog entry is Copyright © 2004 Robert C. Martin. All rights reserved.

Sponsored Links


Copyright © 1996-2014 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us