Skip to content

Java KISS Principle#

What Is The KISS Principle?#

  • KISS (Keep It Simple, Stupid) is a principle that aims to avoid complexity in code. Complexity can make your code harder to understand, test, and modify. KISS encourages you to write code that is clear, concise, and self-explanatory. This way, you can avoid unnecessary features, dependencies, or abstractions that can confuse you or other developers who work on your code.
  • After all, programming languages are for humans to understand — computers can only understand 0 and 1 — so keep coding simple and straightforward. Each method should only solve one small problem, not many use cases. If you have a lot of conditions in the method, break these out into smaller methods. It will not only be easier to read and maintain, but it can help find bugs a lot faster.

How To Apply KISS?#

  • Try to write simple code. Think of many solutions for your problem, then choose the best, simplest one and transform that into your code. Whenever you find lengthy code, divide that into multiple methods — right-click and refactor in the editor. Try to write small blocks of code that do a single task.

Benefit#

  • if the code is written simply, then there will not be any difficulty in understanding that code, and also will be easy to modify and maintain by other developers.

See Also#

References#