Coding is an individualistic act, similar to writing. So the guidelines below should be taken as advice, not rules. The guidelines are intended to help you write easily readable code. Writing readable code is an important skill, and has several benefits.

So here are some guidelines for writing code. The details of writing comments are language dependent, but the overall guidelines are similar across languages.