Dept. of Egregious Programming Jokes

In web development, you’re always working to minimize the amount of intelligence in the web page itself while maximizing user-friendliness. It’s a hard thing to balance, of course, and nowhere is this problem more obvious than in validation of inputs, like dates. Usually, dates are put in using two or three “select” controls, though sometimes the year is a text box. Of course, unless you imbue these controls with a bit of intelligence, you can get dates that make no sense (September 31, for example, but with leap years it’s more complex than that).

For a couple days, I’ve been working with a client on how we might deal with yet-another-date-entry, this time for a birthday. While I’ve coded the fancy Javascript and DHTML stuff required to make one of these work in the past, I’ve come to believe that depending on Javascript is bad juju, and so we were trying to think of ways around it (there aren’t really any; you just have to do your validation on the server). In thinking of options, though, my partner and I jokingly suggested that we could just put in a list of all the birthdays, and have the user pick. This would mean:

  • We’d have no chance of getting invalid input; and
  • We’d have NO client-side scripting involved.

This combination of factors respresents, at first blush, a sort of web programming Holy Grail, but only until you inspect how it’s been accomplished. This particular approach is untenable on its face for lots of reasons, but that doesn’t make it any less funny to deploy just long enough to get a laugh out of the project manager and client, so I set out do just that.

Creating such a select-box involves having a defined list of options; the only difference here is that the list of options would be very, very long. Here some interesting things to note about this particular list of options:

  • It contains every date between January 1, 1900, and August 25, 2004.
  • This means the file — and the resulting select-box on the page — contains some 38,233 entries. Next time you complain about how many entries there are on FedEx.com’s country picker, remember this little experiment.
  • The list took too long to generate on the fly (i.e., every time the page loaded), so I wrote another script to dump the whole long option list to a file that I then included in the HTML template.
  • The file containing the list is 2.1 megabytes all by itself, so the page takes a couple minutes to download even on broadband; best not to try it at all on dial-up.

I put the thing together and called the project manager, mentioning that I’d found a way to solve the date entry problem that (as the list above notes) ensures we’ll only get valid data, but wholly eschews scripting. He was shocked and very pleased, so I told him where he could inspect it and asked him to call me if he had any questions.

Two minutes later, the phone rang. The project manager (whom we’ll call Andy, as that’s his name {unless you’re flying a jet with him [HDANCN?]}) was amused enough that he’s having a hard time talking, and insisted that I leave it live long enough to spring the joke on the actual clients. Heh.

Sometimes, being a geek is fun.

Comments are closed.