design·lab

Core principle

KISS — Keep It Simple

Prefer the plain, obvious solution over the clever one — code is read far more often than it's written.

✗ The problem

Clever-but-cryptic code

Both snippets check if a number is even. Both "work." Neither is a favor to the next reader.

// bitwise trick — quick if you already know it, opaque if you don't
const isEven = n => !(n & 1) ? true : Boolean(0);

// needlessly "generic" one-liner via reduce
const isEven = n =>
  [n].reduce((_, x) => !((x % 2 + 2) % 2), false);
Nobody can read this at a glance. Cleverness feels good to write once — it's a cost every future reader pays, forever.
✓ The refactor

Say what you mean

Same result, zero decoding required. The modulo check is the definition of "even."

// clever — works, but makes you think
const isEven = n =>
  !(n & 1) ? true : Boolean(0);
isEven
n % 2 === 0
=
obvious
reads like the spec
Simple code doesn't need a comment to explain what it does — only complex code does.
✓ See it live

Clever ⇄ Simple — same output, different cost

Toggle the implementation. Both pass the same test cases — only the time-to-understand changes.

🐢
~30s to understandbitwise trick, hard to parse
✓ Takeaway

Simple is a feature

  • Prefer the simplest thing that works — not the shortest, not the smartest-looking.
  • Optimize for reading: code is read far more often than it's written.
  • Cleverness and unnecessary abstraction are debt — someone pays interest later.
  • Caution: simple ≠ naive. Don't drop real requirements, edge cases, or correctness just to make code shorter.