Joel Spolsky's Exceptions

I might as well jump on the bandwagon and say something about Joel Spolsky's comments on exceptions. Let's start with his criticism of the goto command. The problem with goto isn't as Joel says that they "create an abrupt jump from one point of code to another". Jumping control flow is a good thing. The problem stems from gotos ability to penetrate higher level, block oriented, control structures. Basically they are too primitive, too powerful and make it hard to understand the flow. The ironic thing is that these are essentially the exact same problems with return code based error management.



My second criticism is the statement "They create too many possible exit points". There is nothing that says a method needs to throw exceptions from multiple points anymore than you need to return from multiple points. The same techniques you use to manage the number of returns can be used just as well with throws. In Java you don't even have to worry about this because you can do all your cleanup in the finally block.



I don't pretend to love everything about working with exception based error handling code, but the idea that returns codes are a better tools is just plain wrong.

Comments

Popular posts from this blog

Shark Crackers

Running roughshod or ripshod

Axis, Axes, Axii?