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++ ) {
Yes! (Score:1)
His argument was that the commented-out code, for a feature we were removing, would probably be needed again soon. He was expecting the feature to be re-added again. I pointed out that:
1) Predicting the future is hard, and every time you're wrong you just clutter up the code
2) The old code still existed in the old versions i
for loops (Score:1)
for( my $up = 1; $up = $height; $up++ ) {
be more easily read if it were written as:
for my $up (1
?
Re:for loops (Score:2)
Re: (Score:1)
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…
better than #ifdef (Score:1)
I have a co-worker who always changes the code that he fixes by wrapping it in #ifdef tags, like
#ifdef _BUGS_
...old broken code
#else
...new working code
#endif
This drives me crazy, but he won't change, and no one here with authority wants to enforce anything against, this, so I just take them out when I get a chance to work on the affected files.
Re:better than #ifdef (Score:2)
It'll drive him nuts for hours.
In our non-perl code base (Score:1)
Just ignore it (Score:2)
It works well enough when you're starting out on an existing codebase. At the end of the day, 3-year old (and incomplete) edit histories aren't that important, and commentary on why something changed into its current state is useless, because you're not likely to see the conditions that triggered the change way back when.
Additionally, focusing on just the code helps you fo
Fluff (Score:2)
--
xoa