Wacky Programming Tales

Kaz Kylheku kaz at ashi.FootPrints.net
Sun Aug 15 16:15:44 EDT 1999


On 15 Aug 1999 03:14:48 GMT, Ben Caradoc-Davies <bmcd at es.co.nz> wrote:
>[strange programming]
>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.

Maybe the consultant is anally retentive about not using operators other than
assignment that have the side effect of modifying an object, and not using more
than one side effect in a full expression. That approach leads to uninsipiring
code, but nevertheless code that won't possibly have undefined behaviors due to
ambiguities.

In other words, with his ultra-conservative approach, the weenie is unlikely
to ever things like a[i] = i++.

I'm afraid you don't have a case, if the program otherwise fulfilled its
functional, performance and reliability requirements.

The guy programs for accounting firms. So it's a given that he can't possibly
be a great hacker who writes slick code. He does things that some of us
wouldn't touch with a ten foot pole.  His high cost could have something to do
with his domain specialization, and with a high profit margin on the part of
the contracting company (assuming he's not freelance).




More information about the Python-list mailing list