I have a question relating programming and english language both: Whether to use third person or imperative when commenting single lines of code. Assume following line of code in a imperative language which should be commented:
object.doSomething();
My approach to comment this line would be to put the comment behind it using third person like this would be a ordinary english sentence containing the line as subject:
object.doSomething(); // does (referencing to the line of code) some action
But since we are in a imperative language and thus actually "commanding" the computer, one could even think of putting the comment before the code and using imperative:
//Do some action:
object.doSomething();
This is even useful when one need to comment multiple lines related to each other.
I personally prefer the first style but i often feel unsure about what style to use. It would be great if some could write their personal experience down here.
The first approach is definitely the more appropriate method of commenting, as it will be people reading your comments it is important that they are as easy to read as is possible. //Do something
sounds like you are talking to the computer as opposed to explaining what the code does.