What is KISS?
KISS, since you are reading this post on a technology blog it is not a dictionary word but an acronym which stands for Keep it Simple Stupid.
In this article, we will be understanding the principle and its usefulness of this simple yet powerful design principle.
Fun Facts about the KISS Design Principle
The KISS design principle was first used by the US Navy in 1960.
Thought to be coined by Kelly Johnson.
Used to design systems so that they can be repaired with simple tools and minimal experience in combat situations.
This has various other full forms to it
Keep it simple straightforward.
Keep it simple and short.
Keep it simple and silly.
Keep it small and simple
Description
This design principle states that whenever it is possible refrain yourself from creating elaborate solutions for any problem which can be achieved in simple and easy steps.
The simple reason is that nobody likes complex things in their life and no programmer likes them either.
Examples
Pay attention to below two points below.
The resplendent and radiant orb in the sky, known as the sun, is presently emitting its luminous rays in a dazzling display of celestial grandeur, bathing the terrestrial landscape in a warm and comforting glow.
The sun is shining.
They both mean the same thing, so what do you think which one is better to understand, I leave this judgment to you, dear reader.
Here are a few examples for all my developer friends.
configSettings.DevelopmentEnvironment
= environment == "PROD" ? "PROD"
: environment == "PAT" ? "PAT"
: environment == "INT" ? "INT"
: string.Empty;
configSettings.DevelopmentEnvironment = environment switch
{
"INT" => "INT",
"PAT" => "PAT",
"PROD" => "PROD",
_ => string.Empty,
};
In the above example, although I have made the ternary expression simple and easily readable, instead of using a nested ternary operator which will be confusing sometimes, we can use a simple switch expression or even a simple switch statement to do the same thing.
Note:- Some of you may say that this is more of a clean code concept than KISS but I am trying to show the point that simplicity is the best solution at times.
Below is another example of the same thing with different use cases.
if(passed)
{
message = "Conrgats!!!"
}
else
{
message = "Better luck next time."
}
message = passed ? "Congrats!!!" : "Better luck next time."
In this above case, the ternary operator is making the code sample simpler and easier to read, so contradictory to the first example this time the ternary operator is the better choice.
So it goes to the decision of the developer to understand which solution is a better fit and which will keep the solution simple. There is no solid rule to it.
Some points on How to Apply
Use smaller classes in your projects.
Remove anything which is not needed(you can always get them from the source control system if you are using any).
Write human-readable code (snippets above).
Use Modular programming
Conclusion
In conclusion, design principles serve as invaluable guiding lights in the complex world of design. They provide clarity, direction, and a solid foundation upon which creative ideas can flourish. By embracing principles such as KISS (Keep It Simple, Stupid), we unlock the potential to create elegant, effective, and user-friendly solutions. Simplicity is not a limitation but a powerful tool that empowers us to communicate, innovate, and connect with our audience. It's a reminder that in a world often marked by complexity, beauty lies in the simplicity of thoughtful design. So, let us continue to adhere to these principles, elevating our craft and enriching the lives of those who interact with the products and experiences we create.
Comments