4 ms·
"The comment for the code tells you what the author intended it to do." Not quite. The comment for the code tells you what the author of the comment understoo
by readthenotes1 2y ago
"The comment for the code tells you what the author intended it to do."
Not quite.
The comment for the code tells you what the author of the comment understood the code to do when hen wrote the comment.
- PlunderBunny 2y agoIt could be that too, but I think that presumes an order - that the comment was written after the code. If the comment was written before the code, then it would describe what the author was trying (intended) to do. Which also implies an order of course.
- g-b-r 2y agoYeah, absolutely check who wrote a comment before relying on it It's luckily rare for people to add wrong comments, though (and those who do should be publicly fustigated). By the way, please never state something as it were the truth if you're not sure that it is. Saying "I think" is perfectly fine, and might save people days of investigation.
- kristiandupont 2y agoNot the comments I write. I don't write what the code does or even what "I understand the code to do". I explain choices, especially ones that the next developer or my future self is likely to misunderstand when looking at the code.
- readthenotes1 2y agoBut what about a year later when someone's changed the code but not the comment?
- kristiandupont 2y agoI would say that I have observed something like this about as many times as someone has changed some semantics in a way that a variable or function name is no longer correct. That is to say: probably a few times in 25 years, but nothing compared to how much value I have received from them.
- ykonstant 2y ago>when hen wrote the comment. I've always said coding is a cottage industry!
- CRConrad 2y agohttps://en.wikipedia.org/wiki/Hen_(pronoun) https://en.wikipedia.org/wiki/Hen_(pronoun)