7 ms·
I read "Comments are more dangerous than we thought" and was expecting a discussion about comments in source code. A comet will kill you instantly and painless
by 4lejandrito 6y ago
I read "Comments are more dangerous than we thought" and was expecting a discussion about comments in source code.
A comet will kill you instantly and painlessly. A misleading and outdated comment however can make your life miserable for a while.
- m_mueller 6y agomight not be so instant if a planetary killer hits on the far side and the acid rain / global winter / famine is what does you in. in such a case it would almost match my feelings about outdated comments...
- pkolaczk 6y agoThe number of times I was misguided by an outdated comment: 0 The number of times a comment saved my ass, despite being slightly inaccurate: 435 The number of times I struggled to understand what the authors thought when writing "self-documenting" code, because they left no comments: 249579
- leephillips 6y agoThe number of times I’ve been obliterated by a comet: 0. Draw your own conclusions.
- SideburnsOfDoom 6y agoLevel of risk = probability of the harmful event occurring, multiplied the severity of the harm. granted, the probability of comet-strike in your lifetime is low, but the severity is off the charts high.
- LudwigNagasena 6y agoThis definition of level of risk is relevant only when you have a von Neumann-Morgenstern utility function though.
- Dudeman112 6y agoWe should totally act as if we had a von Neumann-Morgenstern utility function though
- formerly_proven 6y ago// Do not remove. // This comment repels comets.
- dotancohen 6y agoSurvivor's bias.
- KMag 6y agoW.r.t. "self-documenting" code: at best, clear code tells you what it does. What it's supposed to do and why will always be left to comments. I can't count the number of times I've read some code that was very clear that it generally did the correct thing, but clearly wasn't handling some corner case, and it wasn't clear if I had missed something that obviously made the corner case impossible, the author had missed the corner case, or something else was going on.
- eXpl0it3r 6y agoAnd how should someone write a comment about that they intentionally forgot about some corner-cases? Or if they did add a similar comment and in the meantime someone implemented it, but didn't remove the comments, how many people will only read the comment and not look at the code?
- KMag 6y agoIf the explanation of intended behavior left out the corner case, then it would be much more likely that the author hadn't considered the corner case. More insight into the author's thought process gives you more confidence in your assessment.
- em-bee 6y agocorner-cases should either be mentioned in the comments or be handled in the code. if they are neither, then the author missed them. a future developer potentially forgetting to update a comment is not an excuse to avoid commenting.
- slowmovintarget 6y agoIn a perfect world... You'd find that in the commit log for the code. Comments aren't the right place for things you forgot to do, or things that occur to you after the code sort of works. The commit message, and unit tests, are where those ideas can be best captured. I tend to point my team at this as a practice: https://chris.beams.io/posts/git-commit/ https://chris.beams.io/posts/git-commit/
- tikhonj 6y ago
- LordAtlas 6y agoWait till you're outdated by a misguided comet.
- josephorjoe 6y agoI read "Camels are more dangerous than we thought" and expected no discussion beyond "of course camels are scary dangerous,wth?"