Skip to content

5 guidelines for clean, well-presented and perfectly readable code

Good coding is not only about getting a module to work. It’s also about doing things the right way, observing the right practices. Why? Simply because at some point, the code will have to be evolved. And if a code is well written and presented, its easier to work on.

In this light, I have written 5 guidelines for you to follow. If followed, these will make your code look clear and much more readable. Here it goes.

#1 Indent your code

I don’t even need to stress on that. Indentation is essential if you want readable lines of code. Remember, nothing says amateur programmer more than unintended lines of code.

#2 Avoid excessive white lines

Most programmers use white lines to separate blocks of code. If you are the type of person to leave white lines randomly in your codes, you are probably not doing any favor to the next programmer that will be working on your codes. Think of white lines as separators, not as beautifiers.

#3 Use comments moderately

I read an article once that said, “Good code does not need comments”. That is a very good advice. Your code should properly describe what it is doing. This is achieved by using meaningful variable and method names. Comments should only be used to describe confusing operations.

#4 Use meaningful variable and method names

Many programmers shorten their variable and method names so that they can code faster. To me, this is ridiculous. A good variable name should be descriptive. Also, most IDEs come with code completion nowadays. Meaning you always type the first few letters of any variable or method name, before you get all the possibilities in a box. So why choose short, meaningless variables over long, meaningful ones?

#5 Group your declarations on top

Variable declarations should be on top. Be it inside a method, a loop or anything else. The reason is simply because it has been this way for ages, and anything the other way round would seem uncanny.

There it goes. You have my 5 guidelines for clean, well-presented and perfectly readable code.

6 tips to have clean and well-presented code
Published inCoding
Twitter Profile Picture

Jevin Sew

1645 Tweets
274 Following