The KISS principle proposes choosing the simplest solution that meets the requirements. In the world of development, we sometimes have a bit of an inflated ego: we love writing code that seems “smart,” using the most obscure language features and building architectures that would make NASA jealous.
But the reality is that complex code is the enemy.
KISS stands for “Keep It Simple, Stupid”. Although there are friendlier versions like “Keep It Simple and Short”, the message associated with the term is clear: unnecessary complexity increases the likelihood of failure.
What “simple” really means
It’s worth distinguishing between Simple and Easy.
- Easy is what is close at hand, what I know how to do quickly (like copy-pasting code).
- Simple is something that has few parts, is easy to understand, and can be maintained without surprises.
Sometimes, making something simple requires a lot of work and prior design. As Blaise Pascal said: “I have made this letter longer than usual because I have not had time to make it shorter.”
The mistake of “smart code”
One of the biggest enemies of KISS is trying to be too clever. Let’s look at an example. We want to check if a number is even.
The “movie hacker” approach (not KISS)
// ❌ Unnecessary complexity
public bool IsEven(int number)
{
// Using bitwise operations because "it's faster" (in 1980)
// and looks really pro.
return (number & 1) == 0;
}
Does it work? Yes. Is it efficient? Yes. Is it readable for a junior who just joined? They’d probably have to stop and think about it.
The KISS approach
// ✅ Simple and straightforward
public bool IsEven(int number)
{
return number % 2 == 0;
}
The modulo operator directly expresses the intent. It doesn’t force you to think about the binary representation of the number to understand the check.
Over-engineering: killing flies with a cannon
Where we violate KISS the most is in architecture.
Imagine you are asked: “Read a text file and display its content on the console.”
The overqualified architect:
“We need an
IFileReaderFactorythat returns anIReaderStrategy. We’ll create an implementation for local files and prepare another for AWS S3 (just in case). We’ll use aDecoratorfor exception handling and anObserverto notify when the reading is finished.”
The KISS developer:
string content = File.ReadAllText("file.txt");
Console.WriteLine(content);
If someday we need to read from AWS S3, we’ll change it then. But today, setting up all that structure is noise, it’s code that needs to be tested and maintained for a feature that doesn’t exist.
KISS does not mean “hack job” Writing simple code is not an excuse to write dirty or unstructured code.
KISS means using the simplest solution that works and is maintainable, not the first one that comes to mind.
The best code is the code that needs no explanation. When you write a function or design a class, ask yourself:
- Will my colleague understand this in six months?
- Will I understand it in six months?
- Do I really need all these layers of abstraction?
Simplicity is the ultimate sophistication.