Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

...

2. Why checked exceptions?

  • From the Java Language Specification: "This compile-time checking for the presence of exception handlers is designed to reduce the number of exceptions which are not properly handled".
  • If you are throwing an exception for an abnormal condition that you feel client programmers should consciously decide how to handle, throw a checked exception.
  • Unchecked exceptions indicate software bugs.
  • Precisely because unchecked exceptions usually represent software bugs, they often can't be handled somewhere with more context.

3. Preserve encapsulation. Never let implementation-specific checked exceptions escalate to the higher layers. For example do not propagate SQLException from data access code to the business objects layer. Most of the time client code cannot do anything about SQLExceptions, do not hesitate to convert them into unchecked exceptions.

...