
KISS
Keep It Simple, Stupid
“Simplicity should be a key goal in design, and unnecessary complexity should be avoided.” – Kelly Johnson
Most systems work best if they are kept simple rather than made complicated.
When to use
Always. Every time you write code, ask: “Is there a simpler way to do this?”
Why it matters
- Maintainability: Simple code is easier to read and understand.
- Bugs: Complex code hides bugs. Simple code exposes them.
- Onboarding: New developers can understand the system faster.
Signs of Violation
- Over-engineering: Building a generic framework when a simple function would do.
- Hard-to-read code with too many abstractions.
- Solutions that require 10 files to do a “Hello World”.
Explanation
Problem
Developers often try to be “clever” or anticipate future needs that never happen, leading to complex, bloated codebases.
Solution
Write the simplest code that works for the current requirements.
Real world analogy
Tools. A hammer is a simple tool that does one thing well. A Rube Goldberg machine to crack an egg is the opposite of KISS.
Pros and Cons
| Pros | Cons |
|---|---|
Comparison
- YAGNI: KISS implies YAGNI (don’t add complexities you don’t need).
Code example
Typescript
Bad (Violation)
Good (Adherence)
PHP
Bad (Violation)
Good (Adherence)