Invisible Exception Handlers

An alternative to throwing exceptions, possibly an AntiPattern.

The idea is to just bury the code to handle exceptional cases in the object that does the normal action. This is much simpler than using exceptions or some other mechanism, but very difficult to test, breaks the OneResponsibilityRule, is low on communication, and so on.

ExceptionHandlingChallenge entry:

 UserDatabase.add(user);
 mailPassword(email, password);
 redirect("success");
(That is, when an exception occurs, you have the UserDatabase.add() and mailPassword() methods themselves do the database-recovery and redirection.)

Pros:

Cons:


CategoryException


EditText of this page (last edited January 12, 2013) or FindPage with title or text search