Saturday, August 9, 2008

Lazy web programmers (or are they just stupid?)

I'm setting up some online auto-billing to save the pain-in-the-ass of stamps and checks here... this always gives me a chance to see some fine web programming on display. Here's an error message I just got that, unfortunately, is not at all uncommon:
Please enter 10 digits, leaving out characters such as "-" or "/".

My first response is: you lazy piece-of-crap programmer, how hard is it to strip out the character.

But then I realized something — the programmer isn't exactly lazy, they're stupid, because they took the time to write the code that generates the error message, but didn't take the time to just do what the user wants.

Here's some pythonic pseudo-code to illustrate:

To do it the right way
inputstring = get_idno_from_webform()
inputstring = inputstring.replace('-','').replace('/','')

To do it the wrong way...
inputstring = get_idno_from_webform()
def confirm_idno ()
inputstring = get_string_from_webform()
try:
assert(inputstring.isalphanum())
except:
show_obnoxious_error_message()
confirm_idno()
else:
do_the_right_thing()


Grrr... makes you wonder -- who hires these people and how much do they make?

(Note: I realize that even in the ideal code you'd need an error message for cases where the user typed something totally invalid, so maybe they're just lazy after all. Still, the error code that handles things like a user typing "!)(*@!$#KJ" should pretty much never run, whereas the code that handles dashes (which are printed on the bill as part of the number) is really much more important and will be called for more often than not.)

No comments: