-
Use checked exceptions for recoverable conditions and runtime exceptions for programming errors:Runtime exceptions should be used only to indicate programming errors, such as precondition violations.
-
Use exceptions only for exceptional conditions:That is, do not use exceptions for control flow.
-
Avoid unnecessary use of checked exceptions: In other words, don’t use checked exceptions for conditions from which the caller could not possibly recover, or for which the only foreseeable response would be for the program to exit.
-
Throw exceptions appropriate to the abstraction:In other words, exceptions thrown by a method should be defined at an abstraction level consistent with what the method does, not necessarily with the low-level details of how it is implemented.
Tip - Java Exception designing
Posted on:July 10, 2011 at 05:30 AM