Clean Code, useful or useless ?

Clean Code, useful or useless ?
Hello World!

That’s the first program for most software engineers (if not all) that was written when we first started to learn coding.

From there, we started to take interest to figure out how to make other stuffs to work. In that journey, we will later find our first ever bug and try to solve it. Then, some of us will continue to take programming further as their career or as a hobby and some of us might think that programming is not for them so they choose to leave it.

For people who still continue programming especially as their career like myself, we will usually try to find something to improve our skills to climb to higher level. One of the improvement concept that I found back then is called clean code.

What exactly is clean code ?

Code is clean if it can be understood easily — by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability. -Uncle Bob

Of course, there are always some people who are pros and cons to that concept. Some of the words from people who are cons to it that I remembered are like below.

Why bother with writing clean code when we can just go write as we pleases as long as it works in the end ? -Anonymous

Trying to write clean code is just a hassle, it will slow you down because your care for the code that takes an extra effort is useless. -Anonymous

To be able to write a code that people can’t understand but you is the ultimate level of coding cause it makes you feel special. -Anonymous

I’ve met these statements in my programming career not long after I knew about clean code. In this article, I’ll try to show you whether clean code is actually useful or useless but I am not gonna tell you about clean code in detail cause it is too long, you can just explore it yourself later.

Example

Here, let me show you something.

Take a look at the code snippet below.

Now take a look at the other code snippet below.

Now after looking at both of them, which one of the code snippets that you think you were able to understand it easier ? Which one would you prefer to have in your codebase ?

I bet the answer to both questions must be the latter one. Because as you can see, even when you haven’t looked at the details, the function name has clearly told you what is its intention and the details is there to confirm what it does. That is actually only one of the many clean code practices called meaningful names. Imagine if you have to face codes like the former one, I bet you will scratch your head most of the time trying to figure out its intention and it will automatically lower the team morale too.

So, instead of writing cryptic codes, we try to write a descriptive code with meaningful names that can be understood by others easily. It resonates to what clean code means on the earlier section above which it to make it to be understood easily by everyone on the team.

Testimony

Taking care of your code is similar to taking care of your room or house. If everything is messy, it’s hard to understand what’s going on in the code and it’s hard to find things when you need it. But if you tidy it up and keep it clean then everything will be so organized that when you need something you can get it fast and easily because you know where to look for.

At this moment when writing this article, I’ve practiced clean code for more than 3 years in my career and with confidence I can tell you that clean code is indeed useful.

By writing clean code, it improve both my working life and code quality. It helps me and the team to deliver things faster and able to debug issue faster which benefit the company. I have never been this less stressful when working with a big project. Because in the past, usually adding some new feature or bug fixing will always take quite a while cause it’s hard to understand how the existing code works beside how complex the system was. So if you are part of the team that says clean code is useless, you might want to think again.

If you said you did it and it didn’t help, maybe it’s because you are doing it wrong or you are doing it alone. Because cleaning a huge codebase for a team is not a single person responsibility but it’s supposed to be the whole team responsibility. Because if a single person trying to clean a big mansion by themselves, they will surely get overwhelmed. But it will be different story if all the person who lives in it also takes part to clean it.

Closing

My advice is if you want to improve yourself as a software engineer, then practicing clean code is definitely one of the way I recommend as it has direct impact to your works. What you see in this article is only little portion of what clean code can do to yourself, you can try explore more about it and I bet you will love it. It takes time to practice, but it will be worth the while cause that’s what I’ve felt after all these 3 years practicing it.

Lastly, for y’all out there who read this, stay safe and stay hydrated ! :)