« Be careful of what you measure | Main | Ahhh... but does it come with a trophy? »

November 16, 2004

The Parable of the (Two) Blind Men and the Elephant

I was pair on a story with my collegue Pat yesterday and we were trying to design a solution to a fairly tricky problem. Basically, the story was to develop a page allowing the user to make a number of updates to values displayed as cells in a table.

The complexity revealed itself in the validation rules for the changes. In short, for any given set of updates, the state of the cells both to the right and left of each pending update determined whether the update was to be considered successful.

The number of cells to look ahead and behind varied from submission to submission.

Note: The specifics of these rules are not really the focus of this post, so I wont go into any further details here.

The updates also had to happen atomically (i.e., any validation problems would reject the entire batch of changes). In the end, this requirement made things considerably simpler from an implementation perspective.

We spent a good hour or so yesterday morning using decision trees and diagrams to develop an algorithm for determining whether a particular updates was valid or not. In the end, we weren't really any closer to something simple enough to implement. For each rule we had, enough subtle variations existed to make the solution overly complex.

Then, at almost the exactly the same time, we both had a classic Warner Bros. "lightbulb" moment and came up with a relatively straightforward solution:

- Apply all the updates as though there was no validation (without committing anything visible to the user), then check the final result for patterns indicating invalid updates.

So whilst we couldn't easily devise a way to detect a single erroneous update within a set of updates, the end result of an invalid set of updates was easy to detect.

By slightly changing the perspective we were using to address the problem, we'd sidestepped what would have been an 'orribly nasty set of validation rules in favour of a single check of moderate complexity.

I'm not sure either of us would ever have come up with that solution in non-pair mode; it needed the presence of the pair as a sounding board and someone to talk over design.

Curious about the title?

Posted by Andy Marks at November 16, 2004 02:14 PM

Comments

Post a comment

Thanks for signing in, . Now you can comment. (sign out)

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)


Remember me?