Wacky Programming Tales

Ben Caradoc-Davies bmcd at es.co.nz
Sun Aug 15 18:18:59 EDT 1999


On Sun, 15 Aug 1999 20:15:44 GMT, Kaz Kylheku <kaz at ashi.FootPrints.net> wrote:
[reinventing "for"]
>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.

The question is not one of efficiency but one of expressing the intent of the
programmer. Seeing this written as a while loop made me double take ...
where's the trick? What is going on here?

There is nothing wrong with i = i + 1 (especially for us Pythonistas :-), but
taken together with the loop it suggests an unfamiliarity with the accepted
idioms of the language.

>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 wish this were the case, but given the rest of the code, I doubt it. You are
however, most charitable and tolerant :-)

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

[Warning: may contain traces of rants]

The program did have some annoying bugs, and it was in the hunt for these that
the, er, unusual code was found. However, the program did mostly fulfil its
functional, performance, and reliability requirements, as they existed at the
time. And here's the rub:

A program must fulfil more than just those requirements, but also that of
maintainability. I'm sure I don't have to remind anyone here that a piece of
source code is a living document, and should be amenable to change (which is
why I was working on it in the first place).

The real problem I had with the project in question was that (except for some
crucial headers), the entire source code was almost uncommented except for a
copyright notice at the top of each source file. Understanding the code was an
exercise in reverse-engineering the intent of the programmer. I've seen this in
scientific software (such as the 49000 LOC of uncommented Fortran 77 written by
an engineer with english as a second language, with no use of procedures and
the entire flow-control managed by circuitous GOTOs and global variables), but
in a business environment it is unforgiveable.

When I left, I passed the [C++] project on to my successor, who was quite a
greenhorn. Meanwhile, the original author had fled the country. Now the current
project manager ("ANSI C? No I haven't heard of that company.") is leaving too.
The only record of what the code is meant to do is some outdated manuals and
the source code. This is mission-critical business software.

>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).

I'm sure he would have only seen a tiny slice of what the multinational charged
for his time. However, I think his price was due more to the gullibility of the
client and wandering project control than the domain. This is a bog-standard
database front-end!

Phew!

-- 
Ben Caradoc-Davies <bmcd at es.co.nz>




More information about the Python-list mailing list