Exceptions aren't just for exceptional situations. This seems
perfectly legit to me:

public class BankAccount {
    public void transferFundsTo(BankAccount other, int amount) throws
InsufficientBalanceException {}
}


The InsufficientBalanceException is not an exceptional situation. It
happens all the time, it's an intrinsic part of the design process.
It's exceedingly likely the calling code will need to deal with the
SITUATION that the bank account has insufficient funds. However, if
this method just returned a boolean, they might forget to check.

Proper usage of checked exceptions is actually that the exceptional
cases (IOException, SQLException...), AND cases where the condition
isn't particularly exceptional, but it is extremely unlikely that your
average caller can do anything about it, you ought to be using
runtimeexception (that would be the vast majority of them). For
conditions that are NOT exceptional, you should be using checked
exceptions. Of course, one mans exceptional usecase is another mans
alternate exit condition, so this is fuzzy logic at best.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to javaposse@googlegroups.com
To unsubscribe from this group, send email to 
javaposse+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to