Clean Code, not a part of skincare routine
By: Inez Nabila
Tags: Development, Clean Code, Programming

As a skincare lover, I know for sure that cleaning is the basic, most important thing in skincare. Not just skincare, nowadays since the pandemic happened, cleanliness plays a big part in staying healthy. Unsurprisingly, it does not only apply in skincare and health but in coding too.

Photo by Lee Campbell on Unsplash

What is Clean code?

here is an explanation of what a clean code is.

clean code is a simple, non-complex code.

clean code is not confusing and complicated. It is straightforward, to the point and precise.

Clean code is a code that is easy to understand.

Clean code means that the code can be understood with ease by other developers. Each task, the role of each class and function must be clear and concise. The intention of each component of the code must be revealed and comprehendible for other developers (clean code reveals the intent of the written code).

Clean code is a code that is maintainable.

A code is considered clean if it is easily maintainable by other developers. Other developers must be able to add new things, change some functions and features easily.

Why do we need a clean code?

We need a clean code to make sure that the application could be developed, not just by the original developer who writes the code but also other developers that works within the team and/or company. Since developing a product is not a stagnant process (even the development is an agile development), the code must be versatile too.

Photo by AltumCode on Unsplash

How to write a clean code?

Only write what is necessary

Writing codes that are not necessary might confuse other people who are working on the code. It might distract them from understanding the usage and point of the code, which makes the intention of the code unclear. Removing dead/unused things

Just like point number one, unused things are in the way of understanding the intention of the code. Because something is there, people might think that it is important but when they are looking for the usage within the flow, they might become worried since there are some elements that lack functions when actually it is dead/unused. Duplication means automation is required

This is the application of the DRY principle, or Don’t Repeat Yourself principle. Duplication means doing the same thing, but for different things. This means that it could be written as a function. Clear naming for Variables, Functions and Classes

In order to know what this is for, or what value this variable hold (for easier apprehension for other developers) we need a clear naming for all the elements inside the code. This makes it easier for other people to identify the elements inside the code in no time.

Tools to know clean up the code

My team uses Sonarqube as a tool to see the bugs and the code smells that might exist in our code.

We can see the percentage of the code duplication

we can also see the maintainability and code smells of the code.

We try to keep them as low as possible to make it easier for other teammates/developers to work on. The Sonarqube is fairly easy to use and it is a staple tool to check and use to support a clean code!

Good luck on your journey for a cleaner code!