News for hackers. Stuff that matters.
Re:Please do not attempt to simplify this code by jjnoakes on Tuesday August 06, 2024 @11:11PM (#41177902)
The why can also go out of date. Maybe not as frequently? I don't have a great intuition for the ratio, but it is certainly more often than never.
Re:Please do not attempt to simplify this code by marcus_holmes on Wednesday August 07, 2024 @12:44AM (#41178303)
I dunno, the "why" for me is "why are we doing this, and doing it this way?". If that changes, but somehow the comment isn't changed, that would feel really strange. It's not just tweaking a few lines, it's rewriting the whole routine. If all the code changed but not the comment, that would have to be deliberate, and definitely picked up in code review.

Though, obviously, accidents happen, etc. But then that also happens with tests and everything else. I have definitely seen out-of-date tests in code bases, where the test is no longer relevant but still maintained.

Re:Please do not attempt to simplify this code by knappe on Wednesday August 07, 2024 @12:43PM (#41183070)
So I actually find this helpful because if the why doesn't match the what (code), I know to look back at the history of changes and see why there is a mismatch. This is honestly a great signal that something might have gone sideways in the past while I'm trying to triage a bug or whatever. So even if the comments are out of date, they're still helpful, because I know to go look at why they're out of sync.
Re:Please do not attempt to simplify this code by marcus_holmes on Wednesday August 07, 2024 @08:49PM (#41187027)
really good point, and well worth mentioning in the "code should be self-documenting and comments are unnecessary" debate.