Voting for Checked Exceptions

      1 Comment on Voting for Checked Exceptions

Elliotte Rusty Harold has drawn at least one nasty comment for his remarks about checked vs. unchecked exceptions in Java: Voting for Checked Exceptions.

In fact he is exactly right. Unchecked exceptions are for errors in your code that should be found during testing. Checked exceptions are for unpredictable errors caused by the program’s environment. The trouble is that many Java programmers (probably most Java programmers) don’t really understand the distinction, leading to confusion, bad code and general resentment of the concept.

I blame Sun for this. They never did a good job of explaining the distinction, and even gave the exceptions misleading names. “RuntimeException” for unchecked exceptions is exactly backwards. It suggests that even some of the designers of the Java libraries didn’t understand the concept.

1 thought on “Voting for Checked Exceptions

Comments are closed.