Download (direct link):
java.util.logging API has some hidden complexities and relationships that affect the level of reporting granularity. You must understand the relationship between loggers and handlers to effectively use this API.
The Wrong Way to Search a DOM (Item 8). With JDK 1.4, the Java platform provided native support for XML with the javax.xml package. Unfortunately, the most intuitive representation of a Document Object Model (DOM) is not the correct representation, and this pitfall goes under the hood to see why.
The Saving-a-DOM Dilemma (Item 9). While JAXP introduced standard ways to create and manipulate XML DOM trees, it provides weak capabilities for persisting them—forcing developers to use implementation-specific methods. This pitfall discusses those challenges.
The Failure to Execute (Item 13). Java Archives or JAR files are the primary binary distribution for Java components. Unfortunately, there is great confusion about how these files work and how to make them executable. This pitfall explores those problems and provides an explanation of the best practices in using JAR files.
When Posting to a URL Won't (Item 17). The URL and URLConnection classes in the java.net API were designed at a very high level of abstraction that can be confusing. This pitfall demonstrates several incorrect ways to use the API, the reasons behind the deficiencies, and both a solution and open-source alternative to the problem.
The existence of better alternatives is an ever-growing problem as the platform ages and poor alternatives are kept to maintain backward compatibility. In addition to new APIs in the platform, again, open-source alternatives are proving themselves to be the best solution for many services.
I Prefer Not to Use Properties (Item 3). This pitfall demonstrates some weaknesses of the Properties class and how java.util.prefs package offers a better solution.
When Information Hiding Hides Too Much (Item 4). A frequent problem with abstracting things from developers is that it can hide important information
The Client Tier 3
from developers. Exceptions are a classic example and this pitfall demonstrates how the new JDK 1.4 chained exception facility solves it.
When Implementations of Standard APIs Collide (Item 6). With XML becoming part of JDK 1.4, an immediate issue arose from the fact that the XML standards do not synchronize with JDK releases. This pitfalls address how JDK 1.4 supports upgrades to these endorsed standards.
My Assertions Are Not Gratuitous! (Item 7). There is often a lag between the introduction of a new feature and adoption of that feature by the majority of programmers. For key reliability enhancements like assertions, this adoption gap is a serious pitfall. This item walks you through this important facility.
Apache Ant and Lifecycle Management (Item 11). Though most pitfalls in this part occur at the language and API level, this pitfall takes a broader look at a better alternative for the software lifecycle. For team development, not using a build tool like Ant is a serious pitfall.
JUnit: Unit Testing Made Simple (Item 12). Much like the Ant build tool, JUnit is a critical tool in assuring the quality of code through unit tests. This pitfall demonstrates how to effectively use JUnit and why failing to use it is bad.
Use Iteration over Enumeration (Item 21). The Collection APIs have proven themselves both effective and popular. This pitfall uncovers a weakness in the Enumeration implementation, examines the internals to uncover the source of the problem, and reveals how Iteration solves the problem.
There are 22 pitfalls in this part of the book, covering a wide array of client-side traps to avoid. Using these workarounds and techniques will enable you to build robust client-side applications that make "good use of the machine." The remainder of the pitfalls in this section are:
Mouse Button Portability (Item 10). Java is an outstanding choice for cross development application development. Unfortunately, not all platforms are the same, especially when it comes to the most popular input device—the mouse. This pitfall shows the challenges involved in working with these different input devices.
What Do You Collect? (Item 14). The issue of over abstraction can be particularly acute when dealing with the Collection APIs. This pitfall shows examples of not knowing the type contained in a collection and discusses emerging strategies for solving this problem.
Avoid Singleton Pitfalls (Item 15). The Singleton pattern is a widely used pattern in Java development. Unfortunately, there are numerous mistakes that developers make in how they use a Singleton. This pitfall addresses these mistakes and suggests some remedies.
When setSize() Won't Work (Item 16). Frequently, developers, especially new developers, use methods without understanding the overall API associated with them. A perfect example is the use of setSize() which leads to unexpected results. This pitfall examines not only the mistaken use of setSize() but also the concepts of layout mangers.