Coding Principles

|

5

minutes read

Real developers code with KISS

Travis

Ponyo

September 19, 2022

feature image

What is KISS?

Short for “Keep It Simple, Stupid”, or formally “Keep It Simple and Straightforward,” KISS is a principle stating that a system should be constructed in a way so that its components are as simple as possible.  As a result, future code maintenance will require minimal effort.

In the concept of KISS, we neither want just less nor more, we simply wish to have only as much as is required.

KISS in Practice

To understand this principle better, let’s first take a look.


Looking at this example, there’s zero clarity in what this method does. The codes are repeated with each case with no clear responsibility. Everything is sore to the eye, and even sorer to maintain.

Now look at its simpler version:


This version is way easier to read while having only one responsibility to create user using input. It’s also easier to extend if there’s a new user type without changing the createUser method. And of course, no code smell as well.

Why Keep It Simple?

  1. The simpler and more straightforward your code is, the easier it is to maintain in the future. No more dealing with painful existing code bases.
  2. When code consistency is required, the KISS concept makes it easier for others to understand the process. Don’t try to outsmart your colleagues, write your codes so that even beginners can understand.
  3. The simpler the system is, the more efficient it is for automated testing. A simple system is always easier to test.

How to KISS your codes better?

It’s pretty easy to give your codes a magic KISS, the only thing you should do is to strive to reduce complexity and keep your coding process transparent, and secure. Here are a few points to note down:

  • Ensure your classes has a single responsibility
  • Ensure your variable names describes the variable properly
  • Ensure your method name translates to the purpose of that method
  • Avoid global states and behaviors as much as you can
  • Delete instances, methods, or redundant processes within the codebase that are not in use

🐸 Real developers Keep It Simple and Straightforward! Stay tuned for more coding techniques, brought to you by FABA Technology. Until next time!