iTexico software-development-kiss-yagni-dry-3-principles-to-simplify-your-life

KISS, YAGNI & DRY, 3 Principles to Simplify Your Life as a Developer

As software app developers you will agree with me that we face all type of scenarios; from the easiest to the most complex projects and solutions our clients want. But, why fall into the trap of design them in a more complex way than they really are?

In the years I have spent in this fantastic world of programming, I have seen some really complex codes that don’t make sense to me, in other words, I have seen code that only the programmer who writes it would know what to really do (and maybe God!). However, when one asks the programmer to explain what the code does, he or she would only say “Only God know that”. Don’t misunderstand me; I know there are scenarios when there are no easy ways to solve the issues, but why complex them more if you could solve them with a simpler way?

That is why I will try to let you know, or remember if you already know about them, some basic (but very powerful) principles that will make your life (and most of your collaborators life) easier.

KISS

Keep It Simple, Stupid!” – I would add some extra exclamation marks (!!!!) to try to keep this in your mind. The simpler your code is, the simpler it will be to maintain it in the future, and of course, if other people see it, they will thank you for that.

The KISS principle was coined by Kelly Johnson, and it states that most systems work best if they are kept simple rather than making them complex; therefore simplicity should be a key goal in design and unnecessary complexity should be avoided.

My advice is to avoid using fancy features from the programming language you’re working with only because the language lets you use them. This is not to say that you should not use those features, but use them only when there are perceptible benefits to the problem you’re solving. With this premise, I introduce you to the next principle.

YAGNI

You Aren’t Gonna Need It” – Sometimes, as developers, we try to think a lot in the future of the project coding some extra features “just in case we need them” or “we will eventually need them”. Just one word… Wrong! I’ll repeat it this way: You didn’t need it, you don’t need it and in most of the cases… “You Aren’t Gonna Need It”.

YAGNI is a principle behind the extreme programming (XP) practice of “Do the Simplest Thing That Could Possibly Work”. Even when this principle is part of XP, it is applicable in all kind of methodologies and own processes of development.

When you feel an unexplained anxiety to code some extra features that in the moment are not necessary but you think they will be useful in the future, just calm down and see all the pending work you have at this moment.  You can’t waste time coding those features that maybe you will need to correct or change because they do not fit to what is needed, or in the worst scenario, they will not be used.

DRY

Don’t Repeat Yourself” – How many times do you see that there are similar codes, in different parts of a system. Well, this principle is formulated by Andrew Hunt and David Thomas in their book The Pragmatic Programmer that every piece of knowledge must have a single, unambiguous, authoritative representation within a system.  In other words, you must try to maintain the behavior of a functionality of the system in a single piece of code.

In the other hand, when the DRY principle is violated it is called as WET solutions, which is stand for either Write Everything Twice or We Enjoy Typing.

I know this principle is very useful, especially in big applications where they are constantly maintained, changed and extended by a lot of programmers. But you also should not abuse of DRYing all things you do, remember the first two principles KISS and YAGNI, in first place.

There are a lot of other principles and good coding practices of software development, but I believe that these three are the basics. Putting them into practice will rescue you and your team from a lot of headaches trying to maintain code that who knows how it works, who understands it at all and the most important … who wants to work with it!.

About the Author

Jonathan San Miguel is a .NET software developer with experience in .NET systems. He loves to code and enjoys reading about new technologies, methodologies, and all kinds of stuff related to the world of programming.

Leave a Reply

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