2 ms·
> If you simply want to comment the current state of the code, you should add a comment in the code. I think you mean "past state of the code"... These commen
by Izkata 3y ago
> If you simply want to comment the current state of the code, you should add a comment in the code.
I think you mean "past state of the code"...
These comments rarely get updated. My favorite recent one was several sentences describing a data structure and how it mapped out statuses, written about a decade ago. Barely a year after that comment and its code was written, the entire thing was re-written with completely different structure - and the comment left unchanged. Left a co-worker completely baffled due to inexperience with perl, we figured out what happened because of svn blame.
- metafunctor 3y agoMistakes can happen. But if code comments are frequently not updated as the code evolves, it is a level of lazy that will probably manifest in other ways as well.
- JetSetIlly 3y agoThe drifting of code from comments is a problem I would love to see solved. I've seen tools that can compare the git commit dates of code with nearby comments and that's a good start. However, there are potential problems with that, such as code and the comments that discuss the code not being near each other; or the code being updated and there being no need to update the comment I think literal programming might help here, but that's an entirely different topic really. Looking for more advanced tools that that and I suppose we're into the world of AI - asking the tool to understand both the code and the comment and to compare the underlying meaning. Code review is an option but outside of an organisation that's difficult to do and besides, I think the problem would be best solved by something that is repeatable and part of the build process. And I'd love to be able to have a git commit hook that can say, "hold on! you've updated code but there's a comment that now looks old". That's the dream.