Monday, September 22, 2014

EJ-57 Use Exceptions only for Exceptional Conditions

Ref: Effective Java by Joshua Bloch

When used to best advantage,exceptions can improve a program's readability, reliability, and maintainability. When used, inappropriately, they can have the opposite affect.

Exceptions, as their name implies, to be used only for exceptional conditions; they should never be used for ordinary control flow.

This principle also has implications for API design. A well-designed API must not force its clients to use exceptions for ordinary control flow.

No comments: