Programming Tip of the Day – YAGNI principle

guvi   September 29, 2013   No Comments

Hello Programmers,

A short story about Mukund, a programmer.  Mukund’s manager used to give him lot of tasks, and Mukund used to write programs and programs.  Mukund’s manager was usually complaining that Mukund was too slow in writing programs and coming up with the required output.  Mukund was doing his best by writing good programs according to his knowledge.  Then his friend Vaibav came to his help.  He just scanned the latest piece of code that Mukund wrote and asked Mukund this question after seeing some overly optimized & unnecessary code.  The following is the conversation.

YAGNI

Image Courtesy:  rimmkaufman.com

Vaibav: “Why have you written this code even when you know you don’t need this now?”

Mukund:  “It is because I may need it later on”

Vaibav: “Are you sure you will need it later on?”

Mukund: “No, I am not.”

Vaibav: “Are you sure, this requirement/feature won’t change a lot after a few days?”

Mukund: “No, I am not sure.  It might change”

Vaibav:  “Then what’s the point in trying to write code that you may not require in the future.  You need to follow the YAGNI principle”

Mukund: “What’s that?”

Vaibav: “You Aren’t Gonna Need It.  If you are trying to do something apart from what is actually required, just go with the assumption in mind that you are not going to need it.”

After a few days, Mukund’s manager was more happier as Mukund was more quick in his turn around time and was responding well to the changes in the requirements.  Mukund was also happy.  Now Mukund knew the secret for this turnaround “YAGNI principle”

So programmers, please follow the YAGNI principle. :-)  Don’t try to over generalize, over optimize or do anything you won’t need for now.  Know the point to stop.  You Aren’t Gonna Need It after that point.

Leave a Reply

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">