Beginners and experts (Batchelder blog post)

Chris Angelico rosuav at gmail.com
Wed Sep 27 21:34:55 EDT 2017


On Thu, Sep 28, 2017 at 11:18 AM, Larry Hudson via Python-list
<python-list at python.org> wrote:
> <quote>
> It had turned out his company had paid for him to take the course. Since he
> failed, it suddenly came to the attention of his employer that he didn't
> know how to program, and now his job was in jeopardy. As I hung up the
> phone, I mused that his company shouldn't fire him. It was a perfect match:
> a programmer who couldn't program and a company that couldn't figure out
> sooner that he couldn't.
> </quote>

I had a coworker like that at my previous job. The boss basically was
paying him to learn to code, and yet (for reasons which to this day I
cannot fathom) let him make a lot of decisions about technology. Thus
we used PHP and MySQL (okay, it could have been worse), with a
multi-threaded daemon in addition to the actual web server (I take
that back, it WAS worse). I had to fight uphill to convince my boss of
the value of git ("why bother, I have daily backups for a week and
then weekly backups for two years"), and even then, this coworker
didn't commit or push until, well, pushed. Eventually he quit the
company (rumour has it he was hoping we'd beg him to stay, since we
were that short-handed), and I had to take over his code... and found
it full of The Daily WTF level abominations. Heard of the "For-Case
paradigm"? Check out this [1] old article if you're not familiar with
it. Well, he gave me this thrilling variant (reconstructed from
memory):

$i=1;
while ($i<3) {
switch($i)
{case 1:
    ... snip one set of validations
    $i=3;
    break;
case 3:
    ... some more validation work
    $i=2;
    break;
case 2:
    ... snip another set of validations
    $i=4;
    break;
}}

I don't remember the exact details, but it was something like this. It
looked like the code just stepped straight through the switch block.
So I stripped out the junk and just did the validations sequentially.

And the code stopped working.

Since I *had* been committing to git frequently, I checked out the
previous version. It worked. I redid the simplification. It broke
again. I stuck in some console output, and found that one of the
blocks of code was actually getting skipped... and due to the
compounding of two or three other bugs, valid input would get rejected
by the validation that wasn't happening.

I have no idea whether he intentionally removed part of the
validation, or if he just never noticed that it wasn't running. It was
a truly impressive piece of work.

ChrisA

[1] https://thedailywtf.com/articles/The_FOR-CASE_paradigm



More information about the Python-list mailing list