Coding Style and Comment — A Simple Guide for Beginner

Dev. Hossain
2 min readMay 6, 2021

Syntax

An ideal programmer should keep the eye on this coding syntax. Because it represents his/her personality how he/she is organized personally.

Well, and organized coding is very helpful for others to understand it easily and quickly. It increases the readability of the coding.

So, let’s talk about some ideal coding practices.

Curly Braces

Programmers use curly braces in JavaScript in ‘Egyptian’ tradition. We use the opening brace in the same line beside the declared keyword.

We usually do not use it on a new line. The best practice is to use a space before the opening bracket.

Line Length

Line length is another important thing that every coder should keep in mind. It is difficult to read long horizontal lines.

The good uses are to split them into several lines if they are long in length. The ideal length of a line of code is 80 to 120 characters.

Indents

Every coder usually uses two types of indentation. One is horizontal and the other one is vertical.

We can use 2 to 4 spaces or 1 single press of tab key on the keyboard. To programmers using spaces is popular than tab key.

Because the space key is more flexible than the tab key. On the other hand, the vertical indent is used for blank lines into logical blocks.

Vertical indent is made the code much more readable.

Semicolons

Developers end every statement with semicolons. It is a good practice of coding. It helps us to avoid the possible pitfalls.

Most of the coders use semicolons as mandatory.

Though it is not mandatory a best practice. There are also separate coding styles for no-semicolon coders.

Style Guides

In every team of programmers, there are certain style guides. Such as they decide how many spaces they will use for indentation and what will be the maximum line length in characters.

They make the style guide to keep their code unique, uniform, and readable to one another. Everyone can recognize and understand it easily.

On the other hand, there is some existing style guide by some famous choices like Google, Airbnb, and so on.

Comments

Commenting in coding is a must for every programmer. There are two ways to comment in coding. One is a single line and the other one is a multiline comment.

Single line comment is used by // double forward slash. And the multiline comment is used by /* your comments */.

Programmers use comments to describe their coding to understand by others.

That’s all for today. Let me know your coding style. I will be happy to hear from you.

Take care.

--

--

Dev. Hossain
0 Followers

An enthusiastic programming language learner. Love to live with coding. Travelling is the addiction. Nature is my mate.