Address
Whiteland, IN 46184

Work Hours
Monday to Friday: 9AM - 5PM
Weekend: 1PM - 3PM

Writing Clean Codes

Over some time now, my interest in the concept of clean codes has been on the rise, however, what does clean code mean and what are the advantages of it. There are infinite ways to write software, my way of coding will defer from someone else’s way of coding. This includes naming and ways of doing things. Even as we are all different we should as much as possible try to keep our code clean.
 
Let Me Tell You A Story
So what is clean code? Simply put, clean code is code that is easy to understand and change. Code is art, code is architecture, code is engineering. Let me give you a real-life example to help you understand what clean code is about. I was walking one day on a sidewalk listening to music, the sidewalk was built in the form of tiles and one of the tiles was cracked because I tend to be over-analytical, I started my analysis. Now, this may seem like what’s so wonderful about that kind of thing, but remove that thought from your mind and think deeper. Whoever came up with some idea of building the sidewalk in that manner is a genius. Why is this? Well to answer that question, just one of the tile is cracked and to fix the entire sidewalk all you need to do is replace that tile, there is no need to redo the entire sidewalk or break a large portion of the sidewalk and fix the crack, I hope you can see where I am going with this. This same concept applies to code. 
 
Whats God Gotta Do With It
One of the biggest problems in the software industry is that not many of the right people care about clean code. This can cause huge problems in the maintenance of code. We should have a clean code mentality from the start of the program to the end, this is because the software will continue to grow and if it does not have a defined structure maintaining the code can be hell on earth. To write clean code we should have this on our minds
 

  • Do not write God Functions: A God function is a piece of code that is doing so many things, this increases the complexity of code and part of your job as a programmer is to manage complexity, so do yourself and your teammates a favor and separate your code into smaller functions that do one thing each.

 

  • Naming: Give your functions descriptive names so that just looking at the name the reader of the code knows exactly what this particular function does without having to actually read the entire function.

 

  • Separating code in files and folders: As code gets larger and larger where to find things that are breaking get more and more difficult, so having a codebase that is structured by folders and files is key. For example, if a part of code is responsible for network calls you can include that part of code in a folder or package called the network and put all the code that belongs to networking and APIs there.

 
The Power Of Habit
Clean code can be a time-consuming process and you have deadlines to meet, yes this is true but you have to think of the future. Once you start on a bad note you will continue on a bad note, and as your codebase increases, you will find yourself regretting why you didn’t structure your code in a way you can easily maintain later.  Always write clean code and in a matter of time it becomes second nature, when this happens, know that you have arrived.
 

Get our Latest Insights right in your Inbox.

Enter your email address below to subscribe to our weekly newsletter.

Leave a Reply

Your email address will not be published. Required fields are marked *