73
unknown
7y

So, what should I do?

Comments
  • 10
    Write comments, if some of them are useless, chances are over time someone will delete it, but useful ones will stay forever
  • 22
    Code shows the what and how, comments tell the why.

    At best, comments are not needed as the code is as close to an English text describing the feature as possible.
  • 13
    Comment why something is done this way. If you need to work around a bug in library xy state that in a comment. If you banged your head against the table for a hour before realizing that something does not behave as expected leave a comment to avoid the next person having to go through the same process. If you make a decision or assumption, e.g. expecting time in ms vs. seconds document that
  • 6
    If something is a dirty hack, document that or else the next person to look at it might think it is a good way of doing it
  • 2
    Comments should be about the business, not the logic anyway.
  • 1
    Write code as if there were comments *checkmate*
  • 1
    They're not exclusives. You can write auto explained code and comment the things that you think they need more explanation or will be faster to understand with that comment.
  • 2
    Do both
  • 3
    Comment the why, the potential issues, caveats, assumptions, etc. Anything that will help you understand the code after being absent for six months.
  • 1
    Both are good advice but for different person.

    If you are like super veterans coder, the advice on top is for you. (I don't know who, maybe Linus)

    Below one for others.
  • 1
    // Get input textbox value
  • 1
    Both
  • 1
    Comments are part of code
  • 2
    Am I the only one who noticed the ++ are flipped horizontally?
  • 0
    @Gerrymandered what do you mean?
  • 1
  • 1
    @Gerrymandered oh haha :D I didn't notice that
  • 1
    Don't explain your code, but write irrelevant comments. Preferably funny ones for next developers
  • 2
    As @ausername said, but if a comment is useless *you* should delete it
Add Comment