Giving your code some tender loving care | Writing clean code

By September 10, 2019 2019, Opinions

Confession; I was a terrible programmer when I first started out. By terrible I mean my code was never structured, it didn’t have a flow, I was horrible at naming things, I copy-pasted bits of code on random places, and my indentation was very very sad. My only agenda was to get a program to run, anything else did not seem important. In other words, my code was like spaghetti and I thought I was pretty good… until I realized I had to debug some projects I built on my own. The thought of it did not seem so hard, because I was the only developer, but when I began going through my own code and realized I could not understand a single thing, that’s when it hit me. I was a bad programmer and my work was a mess!

 

Clean Code

Clean code is code that is easy in everything. Easy to read, easy to understand, easy to change, even easy to write. Clean code can easily be read by anyone else other than the writer. It is reader-focused and not just ‘get the work done ‘ kind of code.

It is code with a touch of TLC (tender loving care)

 

Why Clean Code Matters

 Considerate

Writing code that can easily be understood by any other developer or team members is not only considerate but respectful as well. “Do unto others what you want done to you” . It is easy to make the life of another developer easier by making sure your code is not a can of worms. Let your code be its own guide.

Programming is the art of telling another human what one wants the computer to do.

-Donald Knuth

 Self-Improvement

Knowing how to write clean code does not just happen overnight. It doesn’t only mean writing comments, but also figuring out the right naming patterns, keeping it as minimal and simple as possible, knowing the right vocabulary… etc. Clean code is intentional and requires regular focus plus lots of practice.

 

Good Reputation

Everyone wants to be teamed up with the developer who’s work is easy to read. If no one has to rewrite your work or keep calling you to ask what you meant by this or that, then you are definitely on the right track of becoming the developer everyone wants to work with.

 

Time Saving

Writing code is easy. Reading code is hard. When dealing with large projects, you may forget what you wrote last week or why you even wrote it. A lot of time is spent on debugging or trying to understand code, however, said time totally depends on whether the code is clean or not.

 

 Thinks about the future

I realized that putting extra TLC in the code I write meant that I would not have to struggle so much when I revisited it, maybe weeks, months or years later. I’m also able to measure my progress as a developer over time because I have documented evidence. Paying attention in writing code also reduces bugs caused and how frequent they appear.

 

How to write clean code

Here’s a common rule I apply to my work; KISS

Keep It Simple and Stupid.

What people care about is the end result; the working product. Not the behind the scenes of how you got it to work. So don’t stress about impressing people about being so complex in your code. Besides, keeping it simple is so much easier.

Comments

comments

Lulu Ngei

Lulu Ngei

Live a little Love a little Laugh a little