Wacky Programming Tales

Aahz Maruch aahz at netcom.com
Sun Aug 15 17:45:57 EDT 1999


In article <slrn7re808.77t.kaz at ashi.FootPrints.net>,
Kaz Kylheku <kaz at ashi.FootPrints.net> wrote:
>On 15 Aug 1999 03:14:48 GMT, Ben Caradoc-Davies <bmcd at es.co.nz> wrote:
>>
>>The most confidence uninspiring piece of code I ever had the displeasure to
>>maintain contained something like this (allegedly C++, but mainly it's 
>>intersection with C):
>>
>>	i = 0;
>>	while( i < max_index ) {
>>		/* some copying or update (not modifying i) goes here */
>>		i = i + 1;
>>	}
>>
>>This was written by a *very* expensive consultant working for a large
>>multinational accountancy firm.
>
>So what's wrong with that? Granted, the for loop construct would have
>been better for the task instead of while, and the expensive consultant
>should have seen that. But what about the i = i + 1 increment? It
>smacks of BASIC, but there is nothing wrong with it.  It's not any less
>efficient than i++ or ++i.

Not only that, but perhaps that was the third or fourth draft of the
code, and a while loop was more appropriate for the original draft.
It's often the case that even when I know there's a more "appropriate"
structure for code that I'm modifying, I leave the old code intact as
long as there's nothing actually *wrong* with it -- fewer changes
equates to fewer bugs (not always, but in general).
--
                      --- Aahz (@netcom.com)

Androgynous poly kinky vanilla queer het    <*>      http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6  (if you want to know, do some research)




More information about the Python-list mailing list