5 ms·
I met the guy who wrote this bit that I had to maintain: for(a=0;a<NbrOfAs;a++){ for(aa=0;aa<NbrOfAAs;aa++){ for(aaa=0;aaa<NbrOfAAAs;aaa++){ for(
by edw519 16y ago
I met the guy who wrote this bit that I had to maintain:
for(a=0;a<NbrOfAs;a++){
for(aa=0;aa<NbrOfAAs;aa++){
for(aaa=0;aaa<NbrOfAAAs;aaa++){
for(aaaa=0;aaaa<NbrOfAAAAs;aaaa++){
for(aaaaa=0;aaaaa<NbrOfAAAAAs;aaaaa++){
if(aaaaa==0)else{ExamineAAAAA()}
}
}
}
}
}
What really pissed me off was that he was such a nice guy.
He still works a lot. Makes a lot of money. And his customers love him. (No, I don't think they review his code.)
- bhousel 16y agoAt least that code is indented properly.. Much of the code that I need to fix seems to be written by people who learned on day one of programming that "whitespace doesn't matter to a computer" and never looked back.
- ldh 16y agoYes. I've even heard people justify their haphazard, random formatting by parroting the old "the compiler doesn't care about formatting" line they heard from the instructor at the technical college on the first day of their language course. If the compiler was the only other entity with which you're collaborating on a project, fine. But in the real world other humans have to read your garbage.
- arethuza 16y agoUnless there is a lot of creative abuse of operator overloading or macros lurking in there that code really doesn't look too awful compared to some monstrosities I've had to work with.
- rubergly 16y agoI agree. At first glance, I thought that the NbrofA/AA/etc names were just gibberish. The most nonsensical part to me is starting the for-loop iterator at zero, and then only executing the function if the iterator is non-zero.
- arethuza 16y agoI hadn't even noticed the if - I was thinking it was loops all the way down....
- Someone 16y agoHm, did you check that each loop worked with its own loop variable? If not, how do you _know_ it does what you think it does? If you code like this, you will have to be paranoid with each line you read. That is what makes such code bad, even if it does what it appears to do at first sight.
- brown9-2 16y agoDid you ever ask this person why he wrote this code in this manner? Did he trot out the "job security" crap or was there a legit reason?
- gaius 16y agoI met someone once who called every variable X. Yes really. The compiler was somehow just supposed to figure out that X on this line and X on that line were different things... What is baffling is that he did have code that worked, kinda.
- graywh 16y agoIs this equivalent? for(a=1; a < (NbrOfAs*NbrOfAAs*NbrOfAAAs*NbrOfAAAAs*NbrOfAAAAAs); a++){ ExamineAAAAA() } Or do I need a nap?
- Someone 16y agoIn most languages, it is not guaranteed to do the same thing; the multiplication may overflow.