5 ms·
Code that breaks is much more likely and damaging than comments that are out of date. In my life I've never had a case where the bad outweighed the good for com
by Salgat 2y ago
Code that breaks is much more likely and damaging than comments that are out of date. In my life I've never had a case where the bad outweighed the good for comments.
- kmoser 2y agoAlso, if you're doing regular code reviews, wouldn't that include making sure the comments are up-to-date? As for the argument that it wastes time to update comments, I've never seen a codebase where the comments were so voluminous that it would be a significant burden to update them. Devs avoid updating comments because there is usually no penalty for doing so (boss doesn't call them on it, and the code still runs), and they think they've saved a few minutes when in fact they're just kicking the can down the road for the next dev who has to decipher the incorrect (or missing) comment.
- 8n4vidtmkvmk 2y agoNo. If the comment isn't highlighted in green or red in the commit, I'm not likely to read it.
- PeterisP 2y agoWell, that's a problem.
- 8n4vidtmkvmk 2y agoCode breaks because people read the comment and assume it speaks truth when in fact it's full of lies. And as soon as you don't trust comments you have to start reading the code. And if you're at that point now..... Why have the comment?
- bottlepalm 2y agoComments don't replace reading code, they prime your brain for the code you're about to read. There is often context and reason behind the code that is not in the code itself.
- Salgat 2y agoIf you ever trust comments over code you really need to adjust your approach. Comments are there to help guide you towards the intent of code, not to let you ignore code. Same reason why if a function has a bug, you don't ignore that bug just because the function's doc says otherwise.
- CRConrad 2y agoCode sometimes breaks because people read the comment and assume it speaks truth when in fact it's full of lies. And often for completely different reasons. Blithely assuming it's all about "lying" comments is totally unsupported by any evidence.