Some Tips and Tricks to Become a Good Programmer

Md. Masud Rana
4 min readMay 6, 2021

Today I’m talking about how to become a good programmer. In this world, there are so many programmers. Everybody trying to write well-decorated code. But few have to know how to write properly. There are some tricks to become a smarter programmer. That why I decided to write something about it. I’m a JavaScript Developer that’s why I’m cover JavaScript-related examples. All programming languages are pretty much the same. You can apply any language that you prefer.

Error handling

First thing first you are a programmer you have to know how to handle an error. Every programmer in this world whether good or bad, junior or senior everybody face error on his/her code.

The Try … catch syntax, I’m talking about the javaScript try…catch method.
Syntax construct try…catch that allows us to “catch” errors so the script can, instead of dying, do something more reasonable.

The “try…catch” syntax

The try…catch construct has two main blocks: try, and then catch:

First work like this :
1. First, the code in try {…} executed.
2. If there are no errors, then catch(err) is ignored, the execution retch end of try and goes on, skipping catch.
3. If an error occurred in the code. Ignore the rest to try then execute the catch block.

I’m trying to cover some basics of try catch.

Coding Style

The second thing you should know about coding style. A good programmer writes well-decorated code. So if you want to write code like a ninja man you have to follow some coding style.

Our code has to be as clean and easy to read as possible. Programming is like art.

Curly Braces

In the JavaScript project, curly braces are written as “Example” style with the opening brace on the same line as the corresponding keyword — not on a new line. There should also be a space before the opening bracket, like this:

A kids programmer does something that. Bad!

It’s bad practice.

Somebody is extremely does something very bad. Split to a separate line without braces. Don’t do that kids.

Line Length

Somebody is written a long horizontal line of code. But nobody likes to see this type of code. You should split them.

And for function… You should organize your code.

Indents

There are two types of indents.

  1. Horizontal indents: 2 or 4 spaces.
    A horizontal indentation is made using either 2 or 4 spaces or the horizontal tab symbol (key Tab).
    When a programmer writes an object they are following horizontal indents.

2. Vertical indents: empty lines for splitting code into logical blocks.
Even a single function can often be divided into logical blocks. In the example below, the initialization of variables, the main loop, and returning the result are split vertically:

There are so many things you can follow to improve yourself. I’m just cover a little bit.

That’s for today guys. I will catch you in the next one.

--

--