No, this isn't yet another rant on checked vs non-checked exceptions. It's just a link to an excellent article on exception handling by Heinz Kabutz. Heinz drew me into reading the article with the very first sentence (which I completely agree with):
In my experience, all Java projects contain poorly written exception handling code.He then shows how exception handling is not nearly as simple or straightforward as many developers think it is (which has lead some to prefer old-fashioned error-codes instead) and how the upcoming JDK 1.5 makes things a little bit easier by adding the Java version of .NET's Application.ThreadException / AppDomain.UnhandledException / HttpApplication.Error events (but don't worry, everything else in JDK 1.5 is completely original and in no way shape or form influenced by .NET... ;-)
If you're a serious Java developer, I highly recommend not only reading Heinz' article, but also subscribing to his newsletter. Unfortunately there's no RSS feed (the blue XML icons on the archive page have nothing to do with RSS) so good ol' email will have to do.
SharpReader, my Love, my Hate ...
SharpReader, my Love, my Hate ...
In my experience, all projects contain [some] poorly written code.
In Java 2 1.4 or lower, we can do like this: (catch clauses are omit for brevity)
boolean done = false;
try {
...
...
done = true;
} finally {
if (!done) {
con.rollback();
}
con.close();
}