Commenting is amenable to several different techniques depending on the level to which the comments apply: program, file, routine, paragraph, or individual line.
In good code, the need to comment individual lines of code is rare. Here are two possible reasons a line of code would need a comment:
The single line is complicated enough to need an explanation.
The single line once had an error, and you want a record of the error.
Here are some guidelines for commenting a line of code:
Avoid self-indulgent comments. Many years ago, I heard the story of a maintenance programmer who was called out of bed to fix a malfunctioning program. The program's author had left the company and couldn't be reached. The ...