| « The Blight | The Receptionist Test » |
Call it confirmation bias, call it superstition, but as developers and human beings, we're all susceptible to it. Say you're working on a particularly tricky bit of code, so you've fallen back on the "try all kinds of crazy crap until it passes the specific test case" method, an invaluable tool for all developers. You find an approach that works, and while you're not sure exactly why it worked, you keep it in mind for the future.
In Robert L.'s case, he found the snippet below:
this.rect.X1 = Math.Min(this.rect.X1, this.rect.X1 - 0); this.rect.X2 = Math.Max(this.rect.X2, this.rect.X2 + 0); this.rect.Y1 = Math.Min(this.rect.Y1, this.rect.Y1 - 0); this.rect.Y2 = Math.Max(this.rect.Y2, this.rect.Y2 + 0);
Presumably, the developer made a whole bunch of changes, including the adding/subtracting of zero, and some change outside this code fixed the bug. "Oh well," he must have reasoned, "it worked for X1, might as well do this for the other coordinates."
I beg to differ. The *correct* action, regardless of whatever change you want to make to the code, is to COMMENT the damned thing so that future maintainers will understand why you're doing something so unobvious. |
Re: Math.Min(x, x - 0) = ?
2008-10-22 09:07
•
by
Sigh
(unregistered)
|
Time for another le's'son on apo'strophe's. You put them before every "'s" and 'sprinkle them rando'mly wherever el'se you think they might fit. They do'nt actually mean anything, 'so it do'e''s'nt really matter e'xactly where they go. |
|
'T'o 'b'e 's'u'r'e, 'y'o'u 's'h'o'u'l'd 'p'r'o'b'a'b'l'y 'p'u't 'a'n 'a'p'o's't'r'o'p'h'e 'b'e'f'o'r'e 'e'v'e'r'y 'l'e't't'e'r. 'T'h'a't 'w'a'y 'y'o'u''r'e 'b'o'u'n'd 't'o 'b'e 'r'i'g'h't 's'o'm'e 'o'f 't'h'e 't'i'm'e!
|
| « The Blight | The Receptionist Test » |