33 ms·
Why even comment out? We have version control for a reason
by ulucs 6y ago
Why even comment out? We have version control for a reason
- Zelphyr 6y agoI guess I've been assuming they did that because they wanted to temporarily disable whatever was within the conditional block but, yeah, you're right. Just delete it if you don't want that to run. Either way, that code should never be committed.
- slaymaker1907 6y agoVersion control is not immediately visible to future developers. You need to know that there is something to look for, particularly if it is a frequently changed file.
- gregmac 6y agoReally the only time a future developer will care about the old code is when there's a bug in the current code. (Or maybe an edge case like a request to "make it work like it used to in v1.0"). Looking at history via "blame" is useful to see why a bug was introduced (was it fixing another bug, and if so, is your fix going to break that bug again?), and how long it's existed for. Leaving old code commented out doesn't help either with of those things. Unless maybe it's accompanied by lots of comments and date stamps, in which case you've not only re-invented a very crappy, half-baked version control system, but also made the code hard to read and work with.
- slaymaker1907 6y agogit blame only tells you information about the last time a line was changed. If the code is commented out, I can quickly find the version said code was commented out. Git blame also doesn't help when the history gets truncated for performance reasons.
- Cthulhu_ 6y agoI kind of agree; I've never looked in a file's history to see if something had been solved previously. I don't recall looking in history more than a week back to restore some deleted code either. In practice, I just rewrite code instead, also with the mindset that I'm a better programmer today than I was yesterday, and that in my head at least, writing that bit of code is trivial. But overall, if commented code ends up in version control, it probably could have been removed.
- SkyBelow 6y agoI've been at enough companies that have decided to change version control without pulling over history that I have developed a trust issue with version control. It is a great tool when used correctly, but comments are even more resistance to certain kinds of corner cutting.