KISS YAGNI & DRY Principles | iTexico
YAGNI, DRY Code, KISS Programming and More
As software app developers, you will agree that we face all type of scenarios; from the easiest to the most complex projects and solutions our clients want. However, it is often the case that we fall into the trap of designing them in a more complex way than necessary.
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 understands how it works. However, when one asks the programmer to explain what the code does, he or she would only say “Only God knows that”. Don’t misunderstand me; I know there are scenarios when there are no easy ways to solve the issues, but why complicate them more if you could solve them with a simpler way?
That is why I would like to discuss some basic (but very powerful) principles that will make your life (and most of your collaborators’ lives) easier.
“Keep It Simple, Stupid” – The KISS programming, in particular, is really important. Try to keep this in your mind in your endeavors. The simpler your code is, the simpler it will be to maintain it in the future. This will be greatly appreciated by anyone else that needs to examine your code in the future.
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 follow the methodology of KISS software development and avoid using fancy features from the programming language you’re working with. 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 in mind, I introduce you to the next principle.
“You Aren’t Gonna Need It” – Sometimes, as developers, we try to think way ahead, into the future of the project, coding some extra features “just in case we need them” or thinking“we will eventually need them”. Just one word: Wrong! 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 kinds of methodologies and processes of development. By implementing the ideals of “You Aren’t Gonna Need It” programming, you will save yourself time and be able to move forward with projects efficiently.
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 you may end up needing to correct, change, or remove because they do not fit the needs of the product.
“Don’t Repeat Yourself” – How many times do you see that there are similar codes in different parts of a system? The DRY principle, formulated by Andrew Hunt and David Thomas in their book The Pragmatic Programmer, states 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.
On the other hand, when the DRY principle is not followed, this is known as WET solutions, which stands for either Write Everything Twice or We Enjoy Typing.
DRY programming is very useful, especially in big applications where code is constantly maintained, changed and extended by a lot of programmers. But, you also should not abuse DRY code and implement it in all ofyour projects. Remember the first two principles: KISS and YAGNI.
There are a lot of other principles and good software app development tips to increase productivity and efficiency, 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 people don’t understand. At iTexico, we practice what we preach and are always looking for ways to leverage technologies such as Blockchain and ASP .NET MVC to create seamless experiences for users. Contact us to learn more!
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.