| « Avoiding Continuums Bits | The Corruption of Dennis » |
Seen any absurdly bad code lately? Send it on in!
It couldn't be simpler, right? It takes a teeny little loop and a mod. At least, that's what Anne thought. When she was doing developer training at a certain mailhouse, she just happened to be looking into the program that printed a simple name and address block on the piece. Curious as to why it was thousands of lines of code, she dove in and saw this.
counter=0;
if (zipcode >= 34200 AND zipcode <= 34299){
zzipcode = zipcode - 34200
counter = counter + 3 + 4 + 2;
}
if (zipcode >= 34600 AND zipcode <= 34799){
zzipcode = zipcode - 34600
if (zzipcode > 99){
counter = counter + 1
}
counter = counter + 3 + 4 + 6;
}
... snip ...
if (zzipcode < 10){
counter = counter + zzipcode;
}
if (zzipcode = 10) counter = counter + 1
if (zzipcode = 20) counter = counter + 2
if (zzipcode = 30) counter = counter + 3
if (zzipcode = 40) counter = counter + 4
... snip ...
if (zzipcode = 98) counter = counter + 17
if (zzipcode = 99) counter = counter + 18
Naturally, this is just a small subsection of the code (with proper indentation added). The original programmer apparently didn't realize there were math or, at the very least, string manipulation functions.
As for the most wondrous thing about this program? The coder took special care to find out exactly what ZIP code ranges aren't used by the postal service, so as to avoid unnecessary coding for those ranges.
| « Avoiding Continuums Bits | The Corruption of Dennis » |