Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It must depend on what programming culture you find yourself in, but I've seen more undercommenters than overcommenters, often with the excuse that the code is "obvious" or the comment would be literal.

Sometimes literal comments tell you things that you wouldn't pick up skimming the code: for(var i=0;i<length-1;i++) // skip the last element

Or, a comment could give a reason, like "iterate backwards because..."

Sometimes it takes half an hour to work what what two concise lines of code should say -- there may be something tricky going on, or you may be working around a bug in a driver or library or something -- and you should record what you were thinking.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: