Let’s Clean that Code

Let’s Clean that Code

Reading Time: 8 minutes Writing a clean code that nobody mocks is a little difficult, but by cultivating a habit, following best practices, it is not impossible to achieve.

Imagine that you are starting with a new project with your team. You have the client’s legacy code and now your task is to go through it. Glancing over the code, you realise your worst nightmare as a Developer. The code has no comments, no explanation of what a method is achieving, methods are hundreds of lines long, there is a vague concept of encapsulating related items in a space. Every thought going through your head is sure to be a cuss word. If that’s what is happening in your head, then the code that you are reading is not a Clean Code.

As eloquently noted by Robert Martin in his book “Clean Code”, the only valid measurement of code quality is the number of WTFs per minute. If that count has reached a good number by just going through one of the modules, then that code is not an example of Clean Code.

Why do we need Clean Code?

On more formal terms, the quality of a code directly correlates to the maintainability of the product. Under the pressure of a deadline, you might rush to go faster, leaving a messy code. You get your feature to work, but now a bug pops up. You go back to your messy code, and even you are not able to make any sense out of it. This add-on of debugging the messy code will generally take much more time than the amount of time you spent on writing the code. On the other hand, if you would have written a “cleaner” code, with a second glance you would have been able to tell what every line of your code is doing, and debugging would have been that much easier.

Just keep in mind, Programmers are really authors, and their target audience should not be the computer, but other developers. If another developer can read your code without mocking you, then well you have written a clean code.

How to Write Clean Code ?

Meaningful Names

Every variable, method, class, package in our code has a name. So, naming each of them appropriately should be the first concern of a Good Programmer.

####### Use Intention Revealing Names

The name of a variable, function, or class, should answer all the big questions a developer might have. It should tell him why it exists, what it does, and how it is used. If the name requires a comment along with it, then the name does not reveal it’s intent.

scala tech blogs best practices for coding clean code healthy code

What is Geek Coin

What is GeekCash, Geek Token

Best Visual Studio Code Themes of 2021

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Best Practices to Write Clean Python Code

In this tutorial, we'll learn Best Practices to Write Clean Python Code. DO NOT MISS!!!

How to write clean code ? follow these best practices for writing clean code

This article is not about some java related feature or concept but more than that . Basically I’m going to explain what all mistakes a java developer does while writing the code and hence how you can minimize it and you don’t have to refactor your code .So this article is about BEST PRACTICES a developer should always follow .

Some Clean Code Best Practices

Being a developer these days involves sometimes developing features and fixing bugs at a fast pace, resulting in code that is difficult to maintain in the long-term. This is the best way of creating clean code, and it also helps to apply some guidelines, principles, and techniques, as described in the article.

Code Trashing Symptom

There are a set of skills and qualities which make the ideal software developer we are all searching to be or searching for to employ. However, right now I am going to emphasize the importance of a quality that is mostly found in senior developers.

Best Practices: Coding

Well Written Code = Happy Clients, Developers, Managers, User. Writing code is like cooking. No matter what you do, someone’s going to come up to you and tell you to add more salt, sugar, spices, and so on.