Beginner's guide to writing comments?

Posted by Cameron on Programmers See other posts from Programmers or by Cameron
Published on 2011-11-14T04:47:41Z Indexed on 2011/11/14 10:11 UTC
Read the original article Hit count: 402

Filed under:
|

Is there a definitive guide to writing code comments, aimed at budding developers?

Ideally, it would cover when comments should (and should not) be used, and what comments should contain.

This answer:

Do not comment WHAT you are doing, but WHY you are doing it.

The WHAT is taken care of by clean, readable and simple code with proper choice of variable names to support it. Comments show a higher level structure to the code that can't be (or is hard to) show by the code itself.

comes close, but it's a little concise for inexperienced programmers (an expansion on that with several examples and corner cases would be excellent, I think).

© Programmers or respective owner

Related posts about language-agnostic

Related posts about comments