The Artima Developer Community
Sponsored Link

Weblogs Forum
YAGNI

36 replies on 3 pages. Most recent reply: May 28, 2012 9:11 AM by Manny Bonet

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 36 replies on 3 pages [ 1 2 3 | » ]
Robert C. Martin

Posts: 111
Nickname: unclebob
Registered: Apr, 2003

YAGNI (View in Weblogs)
Posted: Feb 27, 2004 7:48 PM
Reply to this message Reply
Summary
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.
Advertisement
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.


Adrian Howard

Posts: 11
Nickname: ajh
Registered: May, 2003

Re: YAGNI Posted: Feb 28, 2004 8:53 AM
Reply to this message Reply
"Why do people get so upset when we say YAGNI, but not when we say KISS."

I find some people take it as a personal criticism. Saying "You aren't going to need it" seems to enter some people's heads as "Bah - you are a complete idiot for doing this".

The problem is that, at face value, the phrase can be seen as foolish. Obviously at some point I do need a persistence layer (or whatever). People miss the implicit "at the moment - so don't implement it now. You may even find when you do need it, what you need isn't exactly what you thought you need." at the end of YAGNI.

After some people have the YAGNI==foolish in their head I find it very hard to get it out again. Because of this I tend not to mention the YAGNI phrase until after I've talked about the issues. Then it becomes a useful hook to remember a set of concepts rather than something to be battled against.

Hopefully this makes some vague sort of sense :-)

Paolo Perrotta

Posts: 2
Nickname: nusco
Registered: Feb, 2004

Re: YAGNI Posted: Feb 28, 2004 1:58 PM
Reply to this message Reply
YAGNI tends to be counter-intuitive for developers (it was for me, at least). The software engineering culture has been dominated by big up-front designs for many years. The only developers who didn't plan beforehand were the quick code hackers. So, if you avoid long-term plans you immediatly join the ranks of cowboy coders in the eyes of many experienced persons. It's a prejudice, but an understandable one. It will take some time to eradicate it.

Also, I suspect that we should find an alternative to the common "database" example. It always made me uncomfortable, and I think I just understood why: persistence tends to be a risky subject. At least, it's usually more risky that the domain objects - I know I can do those. On the persistence side I often have hairy issues to deal with, including performance and scalability. As much as most engineers appreciate KISS, they also know that they should deal with the high-risk parts of the project first. Maybe the suggestion to defer the database decisions, as sensible as it may be in many situations, just pulls the wrong levers for some persons.

Gregg Wonderly

Posts: 317
Nickname: greggwon
Registered: Apr, 2003

Re: YAGNI Posted: Feb 28, 2004 8:20 PM
Reply to this message Reply
> 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 <i>always</i> pays to keep things
> simple.

In fact, the creation of the interface simplified your task by providing a concrete set of operations that you could use to manage the persistence model. You may have done more work without the interface. I could imagine that you would have started storing things in orthoginal ways just because your data was available in that form. Then you'd have a very non-extensible solution.

Whereas now you have flexibility that only interface based design helps to provide.

Chris Dailey

Posts: 56
Nickname: mouse
Registered: Dec, 2002

Re: YAGNI Posted: Feb 28, 2004 10:31 PM
Reply to this message Reply
I get "But we know we're going to need it, so we may as well do it now." from guys that started working there 3 years before I did, and they cannot be convinced, and they are the decision makers.

"C'est la vie. C'est la guerre. C'est la pomme de terre." -- Eddy Izzard

Ian Rae

Posts: 21
Nickname: ianrae
Registered: May, 2003

Re: YAGNI Posted: Feb 29, 2004 8:18 AM
Reply to this message Reply
YAGNI is another way of saying "Stop and Think", or as that poster in IBM said more succintly: Think. People like to do what they're good at, so if they're good at creating database access layers then that's where their eye will be drawn. YAGNI also leads to the other XP slogan "WorstThingsFirst". If building a DAL is no sweat then tackle something in the project that is a risk!

A stronger reason for balking at YAGNI is in programmer attitude. Some programmers feel that their job not just to solve a problem, but to do it in a novel, creative, or fancy way. To tell them to _just_ solve the problem is galling. That would be boring! It may even suggest they aren't capabable of doing more! In its extreme form this is the programmer-as-artist syndrome.

Isaac Gouy

Posts: 527
Nickname: igouy
Registered: Jul, 2003

Re: YAGNI Posted: Feb 29, 2004 12:23 PM
Reply to this message Reply
"What is it about YAGNI that is so offensive and contrary"
1) It says "they" are wrong and "you" are right. Try "We aren't going to need it".

2) It sounds dishonest. Try "We aren't going to need it yet."

3) If we are going to need it for this project (even if "we aren't going to need it yet") then someone needs to get a handle on the schedule risks that could be introduced.
("We aren't going to need it yet" sounds too much like sweeping unpalatable details under the rug.)


Databases for example. Are you going to need one?
Over the last 15 years there have been plenty of examples where the database decision was deferred, and lots of code was written (lots of it re-inventing the multi-user synchronization that databases provide). And then the projects ground-to-a-halt while they tried to make the software work with the database.


It always pays to keep things simple
No.
"Everything should be made as simple as possible, but not simpler."

Dale Emery

Posts: 4
Nickname: dhemery
Registered: Feb, 2004

Re: YAGNI Posted: Feb 29, 2004 1:59 PM
Reply to this message Reply
> Why do people get so upset when we say YAGNI

Have you asked the people who get upset? What did they say?

> To me they mean the same thing.

Let's test that: Are you willing to drop YAGNI and use only KISS? If not, then maybe you mean different things after all.

Dale

Steve

Posts: 4
Nickname: patterncha
Registered: Jan, 2004

Re: YAGNI Posted: Mar 1, 2004 1:24 AM
Reply to this message Reply
There's only so long you can peddle rationality and common sense before someone notices, Uncle Bob! *Then* what will you do? ;-) Keep up the good work!

Pattern-chaser

"Who cares, wins"

Carl Manaster

Posts: 24
Nickname: cmanaster
Registered: Jun, 2003

Re: YAGNI Posted: Mar 1, 2004 2:28 AM
Reply to this message Reply
> 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 YAGNI may be threatening to a lot of programmers. If poorly understood, it means, "forget everything you know." Really, I think, it means, "set aside for the moment some of the things you know, because they don't help with the immediate problem," but it can be hard to distill the things-you-know-that-are-useful-at-the-moment from all-of-the-things-you-know.

Programmers are heavily invested in knowing a lot; our egos are stroked by showing off just how much we know. Take that away, and what are we left with? I think that's where the threat comes in.

When you say KISS, instead, even with the explicit insult of the last word, it's perceived more as a challenge, to show off what you know and how you can apply it to create simplicity.

YAGNI is sort of a turn-it-over-to-the-higher-power-of-process, while KISS still leaves the programmer in charge.

Kevin Williams

Posts: 1
Nickname: kevinw
Registered: Mar, 2004

Re: YAGNI Posted: Mar 1, 2004 7:46 AM
Reply to this message Reply
> ... 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.

Assuming there are no stupid questions, I'll enter my query and see how how it goes.

If persistence was not considered int the design, following the YAGNI idea, why were there interfaces that could be used to implement persistence? In other words, why did you bother to write interfaces that would allow you to implement something you assume is not needed?

Every time I try to follow YAGNI and end up needing something I thought I wouldn't need, I have to refactor a lot of code to implement the change. There seems to be a missing part of YAGNI that says "Allow for it just in case you need it in the future". Am I missing something?

Celia Redmore

Posts: 21
Nickname: redmore
Registered: Jun, 2003

Re: YAGNI Posted: Mar 1, 2004 9:21 AM
Reply to this message Reply
The student’s reaction was the result of the way we (or rather colleges) train programmers. It’s easier to tell someone to always cover all possibilities than to explain the fuzzy reality.

It takes experience to know what is a sensible possible extension and what is overkill. Somewhere we’ve lost the idea that everything can’t be reduced to a simple of rules. You can dumb programming down just so far…

Isaac Gouy

Posts: 527
Nickname: igouy
Registered: Jul, 2003

Re: YAGNI Posted: Mar 1, 2004 11:49 AM
Reply to this message Reply
Somewhere we’ve lost the idea that everything can’t be reduced to a simple of rules. You can dumb programming down just so far…

Is your point that YAGNI is a simplistic rule that dumbs-down programming?

Bill Venners

Posts: 2284
Nickname: bv
Registered: Jan, 2002

Re: YAGNI Posted: Mar 1, 2004 12:57 PM
Reply to this message Reply
Charles Miller has posted a good explanation of what YAGNI means to him:

http://fishbowl.pastiche.org/2004/03/02/defending_yagni

I think Charles' post pretty much sums up what lesson I took away from YAGNI, which is basically a kind of humility that I am bad at predicting the future. I think the database example that the XP folks always seem to use may turn some people off for the same reason the XP folks use it. Usually, the answer to the question of whether or not you're going to need a database seems plainly obvious to most people. I don't think I've ever been wrong when deciding up front whether or not I would need a database. For the proponents of YAGNI, this is a good example because it shakes the foundations of people's confidence in their ability to predict the future. But for many, it comes across as too extreme.

I have also had YAGNI thrown at me to "diss" plans I had to implement some feature. YAGNI should be applied with some thought and judgement. You *are* going to need some things, otherwise you'll have nothing. Unless you want to be a Zen master, I guess. Perhaps I'm more of a moderate programmer than an extreme programmer, but I think you need to place some bets. YAGNI can help by reminding you that you're ability to predict the future is poor. That can help you manage risks and make better choices. But you shouldn't avoid all risks. You have to use your judgement and place your best bets.

Ian Rae

Posts: 21
Nickname: ianrae
Registered: May, 2003

Re: YAGNI Posted: Mar 1, 2004 3:11 PM
Reply to this message Reply
>but I think you need to place some bets

This has been an excellent discussion. I now think YAGNI might better be named You Don't Need It Now. That better reflects the notion that you *may* need it later but you don't need to bet now.

YAGNI may have come out of the resistance encountered to the idea of frequent releases. Bi-weekly releases require that the team moves quickly. There are a lot of people whose experience has been that you need six weeks just to get going in a project. That you need to develop a couple of entire sub-systems before you can address the first use case. YAGNI counters this. You may need the sub-systems eventually (and maybe not), but not right now for today's feature.

Flat View: This topic has 36 replies on 3 pages [ 1  2  3 | » ]
Topic: Summer Workshops: Gentle Intro to Scala & Get Your Groove Back Previous Topic   Next Topic Topic: The Management Myth

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use