News for hackers. Stuff that matters.
Re:When hiring developers, have the candidate read existing ... by twblalock on Saturday April 16, 2022 @12:07AM (#31049376)
Don't do it unless you are going to treat keeping comments up to date the same way you treat keeping the code up to date.

I've lost count of the number of times I've seen comments that were just wrong -- they applied to the code as it was written years ago, not today.

Write good code, and it should be obvious how it works. Use comments sparingly and only when things are not obvious. Update the comments when you change the code, and make sure your code review process doesn't let outdated comments slip by.

If you can't commit to the above policies, then don't comment your code at all.

Re:When hiring developers, have the candidate read existing ... by pkolaczk on Saturday April 16, 2022 @12:44AM (#31049556)
Code comments that are wrong can be very useful. I've found many bugs that way. If I find a comment that states an assumption that does not hold in the code, that's the first place I analyze when looking for a bug. And very often it turns out the comment was right, but the code was wrong.
Re:When hiring developers, have the candidate read existing ... by enraged_camel on Saturday April 16, 2022 @12:23AM (#31049444)
>> Don't do it unless you are going to treat keeping comments up to date the same way you treat keeping the code up to date.

This should be easy enough to verify during code review, no?

Re:When hiring developers, have the candidate read existing ... by isbvhodnvemrwvn on Saturday April 16, 2022 @12:04PM (#31053392)
Only if the comment is very local, and not e.g. two calls up the stack.