Hack Frontend Community

KISS (Keep It Simple, Stupid)

KISS (Keep It Simple, Stupid) is software development principle that calls for striving for simplicity. According to KISS, if some part of system can be made simpler — it should be done. Complexity in code can lead to confusion, errors and complicate further maintenance.

Main idea is that simpler code is easier to read, test and maintain. Get rid of unnecessary complications, avoid excessive abstractions and stick to logical clarity in solutions.

// Example of excessive, complicated logic
function getGreeting(time) {
  let greeting;
  if (time >= 0 && time < 12) {
    greeting = "Good morning";
  } else if (time >= 12 && time < 17) {
    greeting = "Good afternoon";
  } else if (time >= 17 && time < 22) {
    greeting = "Good evening";
  } else if (time >= 22 && time < 24) {
    greeting = "Good night";
  } else {
    greeting = "Time error";
  }
  return greeting;
}

// Simplified version (assuming such division accuracy is sufficient for project)
function getSimpleGreeting(time) {
  if (time < 12) return "Good morning";
  if (time < 18) return "Good afternoon";
  if (time < 22) return "Good evening";
  return "Good night";
}