My Journey to Cleaner Code

This article is the result of reading the book Clean Code by Robert C Martin. All the recommendations made here are suggested by Robert C Martin. 

Looking back on my code from before I read Clean Code to after, I can see huge changes. It’s very apparent now to be able to judge “good” code from “bad” code. My knowledge on this subject is not complete, as clean code is an art that continues to be perfected, but I am here to share the gleams of knowledge I have taken from this book so far. 

Note: This is not something to be picked up in a quick read through. It’s something that will stay with you constantly and give you the opportunity to improve your code. 

What is Clean Code?

The first way to start differentiating “clean” code from “messy” code is to define what it means to have clean code. 

Here are some ways to describe it taken from quotes from other software code experts.

  • One word: care. -> “Clean code always looks like it was written by someone who cares. There is nothing obvious that you can do it make it better…” – Michael Feathers, author of Working Effectively with Legacy Code 
  • Elegant and efficient ->“I like my code to be elegant and efficient. The logic should be straightforward to make it hard for bugs to hide…” – Bjarne Stroustrup, inventor of C++
  • Easily enhanced by other developers other than the original author –>“Clean code can be read, and enhanced by a developer other than its original author… It has meaningful names. It provides one way rather than many ways for doing one thing…” -“Big” Dave Thomas, founder of OTI, the godfather of the Eclipse strategy

With this as a small definition of the large concept of clean code, let’s get more into the details of everyday use. 

Naming Conventions 

Clean Code – Naming Conventions

Functions

Clean Code – Functions

Comments

To be written…

Formatting

To be written…

Object and Data Structures

To be written…

Error Handling

To be written…

Is Clean Code worth it??

As I stated above, my code from before and after reading this book has undertaken huge changes. Not only that but my code changes have started a movement in my team of developers at my job and given us a more concrete standard for what it means to have good coding conventions.

Once I started making the changes, I almost got obsessed with making things the cleanest it could be. The steps for creating code for a project was normally 1. Make it work 2. Make sure it works.

Now, I’ve added a step for refactoring the code and making it as clean and readable as possible. The old motto of “Get it done right as quickly as possible” takes on a new meaning. It isn’t so much getting it out the door once it works as it is getting it done and then taking the extra time to make sure other people will understand it. The added time repays itself down the road at least tenfold. So I would say it is definitely worth the time to learn and practice.

In the simplest of terms of what I’ve gained is a new way of looking at code that makes the feeling of coding new and exciting, a way to create real value for my co-developers, and now I know without a doubt that my code will be understood and is clean. The journey to clean code is almost never-ending but it is a worthy quest to undertake.