gingerandjohn.com

Removing all doubt.

gingerandjohn.com random header image

The world’s worst variable names

March 27th, 2004 by John

Andy Lester at the O'Reilly Network has a really funny entry about naming variables in code. My favorite anecdote involves a self-taught programmer (hacker) whom we'll call "Charles". Charles was hired to develop an application that translate data in an Access database into another Access database. Really, it was schema migration, with a few business rules thrown in. Charles had been spinning for about 6 months on this and didn't have anything to show for it, so I was brought in as a player/coach to ship product and get the code base ready to act as a platform (so the data wouldn't have to be maintained in two places).

Charles had a lot going for him. He liked coding, and he wasn't bad; he'd just never had someone else look at and critique his code on a regular basis, and he didn't have any formal software development skills. And critique it I did. Mark Pilgrim talks about blog writer ability falling into three categories:

  1. those who write well
  2. those who write poorly but don't know it
  3. those who write poorly but don't care

That works for coders too. From the pushbacks I'd get about any suggestions or comments, I'd suspect that Charles fit squarely into Number 3.

The kicker was finding a routine named "EMAIL0409". WTF? It didn't have anything to do with email. In fact, it was handling an exception to a business rule. If I had named the routine, it probably would have been something like (based on what the code did) "RemoveInvalidHydros" or "ValidateCommissionDate". Of course, there weren't any comments to give me any clue as to why EMAIL0409. I scratched my head, debated leaving it alone, and decided to ask (just in case I was missing something, you know).
"Hey Charles, why is this routine named EMAIL0409?"
"That's some stuff that Diane [the old business lead] told me to add."
"But why EMAIL0409?"
"Because that's the date of the email she sent that had the logic in it."

If I'dve had anything in my mouth at the time, I'd still be cleaning it off my monitor today.

Oh, and the kicker? I got Charles to send me the eponymous email; not only did EMAIL0409 not have anything to do with what was actually going on in the code, it now (because of later rule changes) didn't have anything to do with the rule in the email.

Tags: No Comments

Leave A Comment

0 responses so far ↓

  • There are no comments yet...Kick things off by filling out the form below.