Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As often the answer is: it depends. I think the reason you wrote a comment is very important for the decision, if the comment is good or bad. There are multiple possible reasons for comments:</p> <ul> <li>to make the structure clearer (i.e. which loop ended here)</li> </ul> <p><strong>Bad:</strong> This looks like a possible code smell. Why is the code so complicated, that it needs a comment to clear that up?</p> <ul> <li>to explain, what the code does</li> </ul> <p><strong>Very bad:</strong> This is in my opinion dangerous. Often it will happen, that you later change the code and forget about the comment. Now the comment is wrong. This is very bad.</p> <ul> <li>to indicate a workaround/a bugfix</li> </ul> <p><strong>Good:</strong> Sometimes a solution to a problem seems clear, but the simple approach has a problem. If you fix the problem, it may be helpful to add a comment, why this approach was chosen. Otherwise another programmer later can think, that he 'optimize' the code and reintroduce the bug. Think about the Debian OpenSSL-problem. The Debian-developers removed an unitialized variable. Normally an unitialized variable is a problem, in this case it was needed for randomness. A code comment would have helped to clear that up.</p> <ul> <li>for documentation-purposes</li> </ul> <p><strong>Good:</strong> Some documentation can be generated from special formatted comments (i.e. Javadoc). It is helpful to document public APIs, that is a must-have. Important is to remember, that documentation contains the intention of the code, not the implementation. So answers the comment the question 'Why you need the method (and how do you use it)' or What does the method?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload