I hates nothing more than to find code like this:
# for( my $up = 1; $up <= $height + 1; $up++ ) { for( my $up = 1; $up <= $height; $up++ ) {
It causes my eyes to do a double take. If my brain made noise it would be that *tick tick* *tick tick* *griiiIIIIiinnndd* that a hard drive makes when trying to work with a bad block. "Its code so I should be reading it but its a comment so I should be ignoring it but its code... but its a comment... and it looks just like the next line of code so its probably a bug... but its a comment... but its code... "
I've been told syntax highlighting browsers help with this, but its not a problem I want to be helped with. And I'd love to see what code looks like after a few months of this sort of style. More comment than code.
Anyhow, it reflects a fundamental lack of trust in your version control system, or a fundamental lack of a version control system. All the more amusing because I received a diff today. It contained this:
- for( my $up = 1; $up <= $height + 1; $up++ ) { + # for( my $up = 1; $up <= $height + 1; $up++ ) { + for( my $up = 1; $up <= $height; $up++ ) {
Re:for loops
schwern on 2005-07-26T07:54:57
No, because $height can change inside the loop. The code is from Sub::Uplevel. There's an explainatory comment and everything.
ACK.
I do this a lot, temporarily, when I’m hunting bugs or when I just want to try something else. But as soon as I’ve decided which version I need, the commented crap goes out the window.
What I find particularly jarring is finding entire sections of code or complete routines commented out in someone else’s source. It doesn’t particularly inspire trust in the codebase to see that someone is littering it with his failed experiments…
Re:better than #ifdef
merlyn on 2005-07-26T15:48:52
That's simple. Just go in to the standard Makefile for your build, and add -D_BUGS_.It'll drive him nuts for hours.
Additionally, focusing on just the code helps you focus on the problem. Usually, projects like this have overly verbose idioms and massively over-engineered complicated logic. Once you start teasing out those idioms and logic, and replace them with something easier to read, the amount of code starts to shrink drastically. (You are testing against a regression test, and using version control, aren't you?
Interestingly, I picked up this pattern when working on a large FORTRAN codebase, where everyone commented out code and copied the old source into an archive directory before committing a change. When these antipatterns get out of hand, extreme measures are the quickest way to restore your sanity.