6.04.2010

Reducing Exceptional Cases

We have a third party control suite that provided some aggregation functionality. The third party controls had some built in aggregate functions but was missing some other more business centric functions.

We ended up coding every aggregate as a separate custom class and not using any of the built in aggregates. My team member asked me why not use the built in aggregates?

The reasoning is that if we used some built-in aggregates and then built the custom aggregates for the other functions, we would have 2 methods of aggregation to maintain. If we treat all the aggregates as custom, then instead of having 2 scenarios, we have one. We don’t have any exceptions. All aggregates are custom aggregates.

Not only do we simplify our code and future maintenance, we eliminate any dependency on the third party aggregates. Now we are free to change control vendors and not worry about losing our aggregation functionality.

The point I want to make is look to simplify your code. Eliminate exceptional cases as much as possible. Make everything the same and you achieve simplicity and flexibility.

1 comments:

  1. While allowing yourself to swap control vendors is nice, I think you missed another key point: change. Not every vendor is as stalwart as Microsoft at maintaining backwards compatibility. What happens if in two months, your vendor releases an update that you need to fix another control, but it also changes another control on which you rely? Now you've got a mess on your hands trying to figure out which control broke and what to do about it. Sure, that's probably as unlikely as switching vendors, but something similar happened to us on our last project.
    ReplyDelete