September 19, 2022
September 19, 2022
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.
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.
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:
🐸 Real developers Keep It Simple and Straightforward! Stay tuned for more coding techniques, brought to you by FABA Technology. Until next time!