Video in progress

How does the KISS principle show up in everyday backend code?

KISS (Keep It Simple, Stupid) means choosing the simplest solution that solves the problem. In practice: instead of needless patterns, extra layers and "clever" one-liners, write code the next developer understands quickly.

📖 Answer

Overcomplicated:

boolean isAdult = Optional.ofNullable(user)
        .map(User::getBirthDate)
        .map(d -> Period.between(d, LocalDate.now()).getYears())
        .filter(age -> age >= 18)
        .isPresent();

Simple:

if (user == null || user.getBirthDate() == null) return false;
int age = Period.between(user.getBirthDate(), LocalDate.now()).getYears();
return age >= 18;

The second one is easier to debug and to read.

In day-to-day work, KISS looks like this:

  • don't build "Strategy + Factory + Registry" where there is one implementation and no other is expected;
  • don't open a separate microservice for plain CRUD; write it as a module first;
  • instead of a 200-line regex, write a few simple checks.

Simple code doesn't mean "primitive" code. It reflects the real complexity of the problem and doesn't add any of its own.