Be aware that this is controversial. I happen to fall in the camp that thinks there is a place for it. Read the exceptions chapter in Bruce Eckell's Thinking In Java (available online) for a balanced overview of the controversy.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Originally posted by Stan James: Be aware that this is controversial. I happen to fall in the camp that thinks there is a place for it. Read the exceptions chapter in Bruce Eckell's Thinking In Java (available online) for a balanced overview of the controversy.
If I could object just slightly. You will not find a balanced overview in this text. Simply, there is (at least) a third camp, who just "sit back and watch" and believe that both sides of the argument ride on a flawed premise and that failure to identify this flawed premise will result in what we observe today. This "camp" can also reliably predict the next movement (i.e. shift of reality) of both sides of the argument, and for this reason, proclaim a better understanding (e.g. using the scientific method is more plausible than ad hoc).
my personnal rule of thumb: RuntimeException means BUG
- only throw one when you are sure that you've encountered buggy situation you can't recover from - do not catch a runtime but rather try to remove the cause
Now, in real life coding, there are plenty of cases when catching things like NullPointerException makes the code actualy more robust so the above rule is probably idealistic, but it's a good guide line anyway.
It is a mistake to think you can solve any major problems just with potatoes.<br />--Douglas Adams