Thursday, May 31, 2007

A Story Remembered

So, we were talking about coders and the crazy things we do to our applications when we're bored or confused and I happened to remember a particular story which I think I'll post here.

I used to work for a company called ASI that wrote software for cruise ships. Our flagship product at the time was the Tour Reporting System. It was designed to interface with the Tour Point of Sale system and was able to generate all kinds of reports for the tour office and other departments about what the passengers were doing and when, how much they had to pay the local agents, etc.

Now... the way it was set up is similar to any other heirarchy. An Itinerary had a collection of Ports, a Port had a collection of Tours and a Tour had a collection of Tickets. While working on a copy feature of the edit screen in the tour section one day, I was typing out all this code to verify that the parent objects existed. This was well before the days of database engines that were smart enough not to let you create orphaned records.

Now in order to set this up... the idea here was the ability to automagically create new itineraries based on existing ones. So one the user had entered the new itinerary structure information and selected the old one, it began the copy process. All the while, based on code that we had already written, validating the existence of the parent records. It occurred to me while writing the validation code that since it's a brand new Itinerary, I shouldn't have to validate it's existence after when creating the tours for it since I had just created the Itinerary record. If the Itinerary record creation had failed, it would have exited the copy function completely. So this was ridiculous code and unnecessary.

While I was writing this code, the client's representative... oh let's call her Monica for that was her name... was waiting patiently for me to go to dinner. When I stopped writing code and had the thought I just told you about, she asked what was going on.

Me: "Well, this code is required... but would never run. ... so I don't know what the point is of creating a message to the user about this... but it's a requirement."
Monica: "Let me write the message."

I had already written "The New Itinerary record is missing. This is a serious error." She then completed this with "You must be a complete idiot to have found yourself in such a pathetic state."

We had a good chuckle about it and then I closed the code and we went to dinner.

Note to self: There's no such thing as code that can not be executed.

Fast forward a few months... different client... different ship. I was building the database for the client and getting things ready to go. While creating multiple itineraries that were somewhat different from each other but mostly identical, we ran into a duplicate key error for an itinerary that was created manually previously. Therefore the creation of the itinerary record failed. While it was at the prompt, asking us what to do about the itinerary record, on another computer we opened the itinerary editor and changed the key values of the previously created itinerary so that the program could continue.

The error code logic was a module that presented the user with the typical options at the time: Abort, Retry, Ignore. Anyone who knows anything about life should know that one should never ignore anything out of the ordinary. And I had not coded for the Ignore response in the itinerary building process during a copy. So of course... what did the user do when I told him that he could "just ignore that message now?" You guessed it... he clicked ignore.

As a result, the code continued on, not knowing there wasn't an itinerary record and tried to create the ports... when the itinerary validation code discovered that the itinerary record was missing... history came back and bit me square in the ass.

Fortunately, the user did not require therapy from the rude comment the computer made about him. Just remember, if you put it out there... somewhere, sometime... it will come back to you.

Peace,
Jenna

No comments: