Using Exceptions to Escape from Third-Party Libraries

While this point is not strictly speaking related to zen-level (as it is not about preventing programming errors) it remains a useful tool in the software designer’s toolbox:

Unchecked typed exceptions found in Java and many other languages can be used as a very powerful break statement. Common wisdom says that using exceptions for control flow is inefficient and confusing, and defeats the original purpose of exceptions. I will show that, when certain basic principles are followed, they can be efficient and easy to read. (About the last point, if you have read my previous articles you should know that I use programming constructs in unusual ways in almost all of my articles, because I assume you already know how to use them in the standard way)

Continue reading “Using Exceptions to Escape from Third-Party Libraries”