8 ms·
This is an often used example in defense of not writing comments but in practice I rarely have encountered an out of date or misleading inline comment. In my e
by mattacular 5y ago
This is an often used example in defense of not writing comments but in practice I rarely have encountered an out of date or misleading inline comment. In my experience, everything in code tends to stay up-to-date because it is often written and reviewed by multiple people who have some incentive to keep it correct. It's other documentation outside of code that frequently goes stale.
- cutemonster 5y agoAlso, function names sometimes get out of date too, 'addHorizontalScrollBar()' in the example above -- let's say someone adds vertical scroll too but forgets to update the function name.
- Jetrel 5y agoHaving had a lot of experience myself, I sadly can't echo this. A lot of it has to do with stick-and-carrot incentivization, stack ranking, and other stuff. Unfortunately every place I've worked at sort of accidentally pits their programmers against each other in a sort of "who can get it done first" competition, with those who do a quick-and-dirty job getting credit, and those who clean up their proverbial workbench getting none. We've had gentlemen's agreements to not do this, and have even been able to collectively oust (i.e. get fired) a few serial violators, but there's just SUCH pressure to ship quickly that code review is basically a fictional thing like the flying spaghetti monster. It's telling that we've got a MLOC codebase, and basically not a single piece of documentation - and every single place I've worked, in almost 2 decades, has been exactly like this. Enterprise software is a wild ride. :|
- IlliOnato 5y agoI would not agree to work in a place like you describe if they doubled my current salary. I really hope these companies compensated you well...
- emodendroket 5y agoConsider yourself lucky then. I've wasted tons of time because of them.
- drran 5y agoConsider reviewing of your code review process.
- emodendroket 5y agoCode review can miss because the inaccurate comments might not be close enough to show up in the diff viewer Generally if I see something happen in every job I've had throughout my career I start to doubt that there is a simple process solution.
- drran 5y agoConfirmed. We found a problem! Let start a startup: "Intelligent code review tool for smart developers, which want to keep comments in their code up to date". The tool will use AI to learn which parts of code are modified often in unison, and then propose to check them also during code review. It will also check for copy-pasted code blocks, and for snippets from StackOverflow with known bugs. The tool will reduce code review time by 10%, reduce number of bugs slipped trough code review by 20%, improve time to ship by 7%, bla bla bla, and instruct the coffee machine to prepare a coffee just in time for the review.
- mattacular 5y agoI guess I have been lucky but I don't really get this. You read comments along with the actual code right? They complement one another. An out of date comment should not ipso facto render code indecipherable and if it does that speaks to a bigger problem with the code itself. I find it strange that people want to throw the baby out with the bathwater when it comes to commenting code just cause they've been bit before.
- emodendroket 5y ago