Jerry Jalenak wrote:

Erik -

Thanks.  I'm beginning to look at ways to handle returning status using
exceptions.  The idea of 'wrapping' each exception by layer is very
appealing....

No problem. While exceptions are awesome, I don't want to give the impression that they should be used for everything -- while in other languages such as Python, it is traditional to use exceptions for basic execution control flow (i.e., an infinite loop that is only broken by a thrown exception), in Java the idiomatic use of exceptions is that they are only used in "exceptional circumstances", generally when there is a problem of some sort. Also, AFAIK throwing an exception uses more resources than simply making a conditional decision.


There is a great chapter in Joshua Bloch's book "Effective Java" on best-practices for using exceptions. If you find that a lot of your code looks like a long string of "if... else" statements or switch statements then you may wish to research Martin Fowler's "Replace Conditional with Polymorphism" refactoring.

Regards,

Erik


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to