64.

What We've Learned

In this chapter on the Null Flag bug pattern, we've learned the following:

  • Calling methods can cause this problem if they don't check for null pointers as return values.

  • Exceptional conditions are usually handled by throwing and catching exceptions. If a NullPointerException is thrown, it is not much of a diagnostic help.

  • Throwing checked exceptions provides more safety than throwing unchecked exceptions, since client code cannot compile without handling the exception. However, this may be impossible if you've elected to employ a high level of code reuse.

  • There are often trade-offs between the goals of static checking and code reuse.

  • Exceptions are a great tool to increase the robustness of code. During an exceptional condition, they allow control to quickly pass to the best place to handle the exception.

    In Chapter 11, we will discuss a bug pattern related to ClassCastExceptions.



Bug Patterns in Java
Bug Patterns In Java
ISBN: 1590590619
EAN: 2147483647
Year: N/A
Pages: 95
Authors: Eric Allen

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net