Sunday, September 14, 2008

simplify, eh?

One of the things that used to amaze me in Calculus class was how you could take a fairly innocuous looking little function, apply a few theorems to it, and it would suddenly explode into this half page nightmare monster of fractions, lost negative signs, and how in the hell did a csc() get in there?!?

And yet, that was the right answer. You had "simplified" the equation by wasting a bunch of #2 lead and paper. It was as far as you could go towards getting a solvable answer with the tools at your disposal. In other cases, some small precondition wouldn't be met and you could just write down "DNE" for "does not exist" and move on to the next problem. In these cases, the correct answer was to simply give up and not worry about the problem anymore.

As I'm getting back into the swing of CLI development, I'm struck by how many situations that a programmer can be tempted to just write "DNE" and move on. In GUI development, you must constantly check for errors/exceptions, and you must handle them gracefully lest your user think that your software is a piece of crap and uninstalls it. Sometimes the error checking can be larger than the actual code to run the program (and about 7 times less fun to write). But at the command prompt... ah... we can easily punish the user for incorrect input by saying, "WRONG ANSWER! Go to the back of the line and start over!!" and escape from having to write the error checking code.

It's a seductive trap, and one I'm finding I have to stay vigilant against falling into. Today's mantra is "DNE is not an acceptable answer".

No comments: