Tag Archives: Design Pattern

Acronyms that make you a better programmer

All trades have their tricks to help remind the artisans of how to best implement their knowledge. For programmers some of these tricks are short words to help remember longer best practices. The foremost three are KISS, DRY and YAGNI.  All three of them are used pretty much subconsciously by expert programmers because working in the way they prescribe is best practice.

KISS – Keep It Simple Stupid

Variations of the acronym are: “Keep it short and simple” and “Keep it simple and straightforward”.

Picture of Albert Einstein

Albert Einstein – “If you can’t explain it simply, you don’t understand it well enough.”

The principle reminds you to solve your problems without doing any fancy stuff. It does not mean it’s calling you stupid, it wants to tell you to only use techniques solvable by anyone trying to fix a problem that has occurred within the code.  A simple system is easier to maintain and debug than a complex system using lots of design patterns and undecipherable code. If you compare an experienced developer with one that hasn’t been at it for so long, you’ll probably notice that beginner programmer writes complicated, verbose code while the more experienced developer writes clean, simple and short code.

Imagine trying to fix a problem in code you wrote a year ago, or a month ago for that matter. Would you be able to quickly survey the code and be able to figure out what it does? If you can’t do that without scratching your head you have probably written the code a little more complex than it has to be. KISS it to make it better!

YAGNI – You Ain’t Gonna Need It

Picture of Donald Knuth

Donald Knuth – “Premature optimization is the root of all evil”

Are you a seer? Probably not. Then why did you write an API for sending pictures when all the customer wanted was to send text messages? You thought you would be saving time by doing it, but what you actually did was spending time on something you don’t know if you’ll ever need and you also just increased the cost of maintaining the code base.

Coding is actually one of the few areas where laziness is a good thing! The less code you write, the less code you will have to maintain and the less bugs you’ll introduce. You don’t have to write abstractions and super classes if the problem doesn’t require them at the moment.  What you want to strive for is minimalism, your specification should be your guideline, do as little as possible to make it work, no more and no less.

DRY – Don’t Repeat Yourself

This is one of the most fundamental rules every programmer should learn.

Every time you write a line of code, there is a potential risk of introducing a bug into your system, every line written is also more code to be maintained at an additional cost. So it is obvious that we don’t want to duplicate our code.

By duplication code you introduce accidental complexity and makes the system harder to understand by developers working on it. If you have duplicated code, every change you make needs to be checked to see if the logic has to be changed somewhere else too, it’s time consuming and error prone.

Many design patterns sole reason for existence is to prevent the duplication of code.

By following the dry principle you make sure that your applications are of high quality, simple to understand and more easy to maintain.


Write simple code, only write as much code as you need for your task and don’t write it twice.

If you like it, spread it.facebooktwittergoogle_plusredditlinkedin