3 Amazing Ways To Write Simple Code

You need to draw a line in the sand of exactly how good this product really needs to be and stick to that, otherwise, you’ll never finish.You Aren’t Gonna Need ItYouArentGonnaNeedIt (often abbreviated YAGNI) is an Extreme Programming practice which states:“Always implement things when you actually need them, never when you just foresee that you need them.”Even if you’re totally, totally, totally sure that you’ll need a feature, later on, don’t implement it now.There are two main reasons to practice YagNi:You save time because you avoid writing code that is not requiredYour code is better because you avoid polluting it with ‘guesses’ that turn out to be more or less wrong but stick around anyway.Make the Simplest Thing that could possibly work.Extreme programming mentions two golden rules to write simple code.· First, implement a new capability in the simplest way you can think of that “could possibly work”..Don’t build a lot of amazing superstructures, don’t do anything fancy, just put it in to make it work..Make the code pass the Unit Tests for the new feature (and all features, as always).· Second and this is critical to the rule, refactor the system to be the simplest possible code including all the features it now has..Follow the rule of OnceAndOnlyOnce and the other code quality rules to make the system as clean as it can possibly be.Always remember, We’re not looking for the quickest way; we’re looking for the simplest result..So, we first break the existing method into pieces..That leaves the existing test cases running..Then we modify (simply, now) one of the little methods to handle the next test case and so on.Next time you’re stuck, try the duckSorting through bugs, problems, and general conundrums is a fundamental part of programming..So developing techniques to swat your way through the bugs and find your way out of the binds is as crucial as learning all of the syntaxes.And when you are stuck and nothing seems to be working, try the rubber duck.So go out and find your own rubber duck, be it the classic yellow bath toy, or one dressed up like a pirate — pick one that you’re comfortable with and fits your personality.Go ahead; Talk to him, ask questions, explain your problems aloud, clear your cobwebs and deliver great value in your code.As Chris Pine has rightly said.“Programming isn’t about what you know; it’s about what you can figure out.”About the author-:Ravi Rajan is a global IT program manager based out of Mumbai, India..He is also an avid blogger, Haiku poetry writer, archaeology enthusiast, and history maniac..Connect with Ravi on LinkedIn, Medium and Twitter.This story is published in The Startup, Medium’s largest entrepreneurship publication followed by +402,714 people.Subscribe to receive our top stories here.. More details

Leave a Reply