Java Reference
In-Depth Information
We encourage you to read each solution, even if you succeed in solving the puzzle. The solutions
contain analysis that goes well beyond a simple explanation of the program's behavior. They discuss
the relevant traps and pitfalls, and provide lessons on how to avoid falling prey to these hazards.
Like most best-practice guidelines, these lessons are not hard-and-fast rules, but you should violate
them only rarely and with good reason.
Most solutions contain references to relevant sections of The Java Language Specification, Third
Edition [JLS] . These references aren't essential to understanding the puzzles, but they are useful if
you want to delve deeper into the language rules underlying the puzzles. Similarly, many solutions
contain references to relevant items in Effective Java Programming Language Guide [EJ] . These
references are useful if you want to delve deeper into best practices.
Some solutions contain discussions of the language or API design decisions that led to the danger
illustrated by the puzzle. These "lessons for language designers" are meant only as food for thought
and, like other food, should be taken with a grain of salt. Language design decisions cannot be made
in isolation. Every language embodies thousands of design decisions that interact in subtle ways. A
design decision that is right for one language may be wrong for another.
Many of the traps and pitfalls in these puzzles are amenable to automatic detection by static
analysis : analyzing programs without running them. Some excellent tools are available for detecting
bugs by static analysis, such as Bill Pugh and David Hovemeyer's FindBugs [Hovemeyer04] . Some
compilers and IDEs, such as Jikes and Eclipse, perform bug detection as well [ Jikes , Eclipse ]. If
you are using one of these compilers, it is especially important that you not compile a puzzle until
you've tried to solve it: The compiler's warning messages may give away the solution.
The appendix of this topic is a catalog of the traps and pitfalls in the Java platform. It provides a
concise taxonomy of the anomalies exploited by the puzzles, with references back to the puzzles
and to other relevant resources. Do not look at the appendix until you're done solving the puzzles.
Reading the appendix first would take all the fun out of the puzzles. After you've finished the
puzzles, though, this is the place you'll turn to for reference.
< Day Day Up >
 
 
Search WWH ::




Custom Search