Programmer should know

Abdul Jabbar Babu
1 min readMay 6, 2021

Error Handling

Error is the best friend of a programmer. No matter how expert in programming errors can happen at any time. try…. catch is one of the error handling method.

The (try….catch) syntex

try { // code… } catch (err) { // error handling }

This syntext allows to handle runtime errors. It nomrmaly allows to “try” running the code and “catch” errors that may occur in it.

Code style

A programmer's code must be clean and easy to read. Code it in a way that is both correct and human-readable.

As a beginner one should follow this:

No space: between the function name and the parentheses and between the parentheses and the parameter.

A space between parameters, arguments, for, while, if, etc.

Spaces around operators.

2/4 spaces for horizontal indention.

An empty line between logical blocks.

Semicolon after every statement.

Lines are not very long.

else without a line break.

Spaces around a nested call.

Comments

Comments can be two ways :

  1. Single line comments start with //
  2. Multiline comments are /* … */

Commenting is a good practice but sometimes it looks ugly. In a comment do not need to say how it works. To avoid unnecessary comments functions should name the way that it can describe its work itself.

--

--