First page Back Continue Last page Summary Text

Notes:


Before looking at the examples that follow I'd like to make a couple of points:
A maintenance problem is caused by failure to use finally idiomatically. It is legal to exit from a finally-block using return, continue or break – but doing so defies the ‘principle of least surprise’. The next programmer to work on the code (and it may be you a few months later) will, quite reasonably expect that the exception continues to propagate. If the exception may be handled, say so by using catch!
Not considering unchecked exceptions is another frequent cause of errors. Two factors contributing to this are: a tendency for developers to rely on the compiler to indicate any failure to consider exceptions, and that error handling is often omitted from demonstrative code – as it obscures the point.