Tall, Dark, and Mysterious

1/3/2006

The Gentle Art of Driving Your Employees Insane

File under: Sound And Fury, Welcome To The Occupation. Posted by Moebius Stripper at 7:12 pm.

A few weeks ago, a friend of mine sent me this marvelous guide to writing unmaintainable code. Though long, it’s an easy read, and it’s too good to excerpt, so go. But impressed as I am by the deliberate use of accented letters, comments masquerading as code, and variable names that sound like keywords, none of this holds a candle to my own employer’s practice of maintaining uncodability. And they do it all without even trying! You can’t nurture this kind of talent; some are born with it, and others can but gaze upon it from afar and wonder, “indexing a record in four distinct ways, storing those indices in eight different tables in seven directories, and using each type of index for a different purpose? That would never have even occurred to me.” It’s beautiful in its own way, really, kind of like…you know that Far Side comic where a fidgity passenger’s movement could cause the wings of a plane to fall off? Sort of like that.

As the resident accidental database developer, though, I get to deal with this genius more intimately than most of my coworkers, save one, the IT guy who’s got his own database going. I asked him if he had any advice for me. He did.

“You can’t fight City Hall,” he said, staring vacantly at his own monitor. “So don’t waste your time trying.”

Anything else?

“City Hall’s a bitch.”

Noted. But I plodded ahead anyway, creating an interface that was useful and more or less maintainable. The database was centred around a form that contained data that I use regularly - one page for each warehouse I deal with, and a button on each page that brings up the monthly warehouse report.

The paths and filenames for the monthly warehouse reports were easy enough to generate: each month had its own directory, and each filname was of the form followed the template [Warehouse code][Item code].doc. The monthly reports themselves were not all produced at the same time, so I’d have to poke around in the code every now and again to make sure that I was pointing to the right directory, but other than that, the thing ran itself.

Until the December reports came in, and suddenly I was getting “File Not Found” errors.

I poked around in the December directory, and lo, all of a sudden the filenames were following a completely different convention. Instead of [Warehouse code][Item code].doc, we had [Supplier name][random eight-digit string].doc.

I spent a few minutes searching for a table that decoded the eight-digit strings before realizing that there was no point trying to search for those things. I figured the IT guy would know.

“Eight-digit string? Yeah,” he said, “that’s the item number. Sometimes the filenames follow that convention.”

“Item number?” I said. “How is that different from the item code?”

“The item code,” explained the IT guy, peering over the tops of his glasses, “has six alphabetic characters. The item number has eight digits.”

“I can see that, but -”

Right. He had a file relating item numbers to item codes, and I imported it into my database, tweaked my code, and -

FILE NOT FOUND. Again.

Back to the directory, where I discovered that the eight-digit codes in the IT guy’s table didn’t match the eight-digit codes in the folder of December warehouse reports. Some of them different in one place. Others differed in three or four. Still others were completely different.

“These numbers aren’t the item numbers,” I regretfully informed the IT guy. “Do you have any idea what else they could be?”

Of course he did; he’s been with the company eleven years. “Probably the product numbers.”

The product numbers? And these are different from the item numbers how?

“Well,” explained the IT guy, “If you look at the table of product numbers and item numbers you’ll see that they’re clearly different numbers.”

Oh, so that table existed? I could get one relating the product numbers to the item numbers?

“Yeah, of course we have that table,” said the IT guy. “I mean, product is just another word for item.”

I didn’t ask. I just returned to my desk, imported the relevant data, checked the eight-digit strings against the ones I had, changed a few field names, and ran the program, confident that I wouldn’t get any errors.

The first warehouse report came up without any problems. So did the second. And the third. And the fourth. And the fifth. Programmers who work with sane datasets might be satisfied with those sorts of results, but I am not a programmer who works with sane datasets. Indeed, I got an error on the sixth report.

Peeking into the directory of December reports, I saw that Product #6 had a completely different product number than the one generated by my program. I approached the IT guy again.

“What did I tell you about City Hall?” he asked.

“Big bitch?”

He nodded. “What you’ve got there is the other version of the report for Product #6. Some of the warehouses have the first version. Others have the second. Others have both.”

“Is there any way to tell whi-”

“No.”

Because I am sucker for punishment, I poked around the December directory to find some products for which there were two version of the report. I found one, and opened the two files, and compared them.

They were identical. Word. for. word. identical.

I asked the IT guy if there was something I was missing, because I couldn’t see why we’d have two versions when there isn’t a difference and was there any way to tell which version I’d get so as to avoid errors, because I couldn’t see -

“City Hall,” he said.

I gave up on the program. The way I see it, come time for the January reports, we’ll be back to the old naming conventions anyway.