
Java Pitfalls
Time-Saving Solutions and Workarounds to Improve Programs
Wiley (Publisher)
Published on 4. May 2000
Book
Paperback/Softback
XIV, 322 pages
978-0-471-36174-9 (ISBN)
Description
A lifesaver for any Java programmer-proven workarounds and time-saving solutions Although using the Java language provides a substantial boost to a programmer's productivity, it still has its share of subtleties andweaknesses. This book is designed to save you time and frustration by carefully guiding you through this potential minefield. A team of Java experts, led by programming guru Michael Daconta, offers a collection of proven solutions to 50 difficult, real-world problems chosen from their own extensive experiences. You'll find workarounds for problems caused by shortcomings in both the Java language itself and in its APIs and utilities, including java.util, java.io, java.awt, and javax.swing. The authors also share techniques for improving the performance of your Java applications. For easy reference, the book is organized into categories so that similar solutions are grouped together.
Examples of topics covered include: Language syntax, for example, using the String equals( ) method instead of the == operator (Item2) Language support, for example, method dispatching with reflection, interfaces, and anonymous classes (Item 16) Utilities and collections, like choosing between a PropertyFile and ResourceBundle (Item 20) Input/output, including subtleties in sending serialized objects over a network (Item 25) GUI presentation, for example, tackling the common pitfall of using repaint( ) instead of validate( ) for relaying out components (Item 29) Performance, including tips like lazy loading your way to better performance (Item 43)
Examples of topics covered include: Language syntax, for example, using the String equals( ) method instead of the == operator (Item2) Language support, for example, method dispatching with reflection, interfaces, and anonymous classes (Item 16) Utilities and collections, like choosing between a PropertyFile and ResourceBundle (Item 20) Input/output, including subtleties in sending serialized objects over a network (Item 25) GUI presentation, for example, tackling the common pitfall of using repaint( ) instead of validate( ) for relaying out components (Item 29) Performance, including tips like lazy loading your way to better performance (Item 43)
Reviews / Votes
"Any programmers office would benefit from having at lest one copy of this book hanging around." (Application Development Adviser, September 2000) "I found the book useful..."(Cvu, February 2001)More details
Language
English
Place of publication
New York
United States
Publishing group
John Wiley and Sons Ltd
Target group
Professional and scholarly
Illustrations
illustrations
Dimensions
Height: 23.5 cm
Width: 19 cm
Weight
586 gr
ISBN-13
978-0-471-36174-9 (9780471361749)
Schweitzer Classification
Content
LANGUAGE SYNTAX. When is an "Overridden" Method Not Really Overridden? Usage of String Equals() Method versus the "=="Operator. Java is Strongly Typed. Is That a Constructor? Cannot Access Overridden Methods. Avoid the "Hidden Field" Pitfall. Forward References. Design Constructors for Extension. Passing Primitives by Reference. Boolean Logic and Short-Circuit Operators. LANGUAGE SUPPORT. Reclaiming References When Using SoftReference Objects. Causing Deadlock by Calling a Synchronized Method from a Synchronized Method. Properly Cloning an Object. Overriding the equals Method. Avoid Using Constructor for Implementing clone(). Method Dispatching with Reflection, Interfaces, and Anonymous Classes. Handling Exceptions and OutOfMemoryError. UTILITIES AND COLLECTIONS. Ordered Property Keys? Handling Occasionally Huge Collections with Caching and Persistence. Property File or ResourceBundle? Properties Object Pitfalls. Using Vector as a Collection Instead of Old API. INPUT/OUTPUT. Serialization. Unicode, UTF, and Streams. Sending Serialized Objects over Sockets. Try, Catch... Finally? Flushing Image Resources. GUI PRESENTATION. Providing Progress Feedback. Using repaint () Instead of validate () for Re-Layout of Components. Z-Order and Overlapping Components. Solving the Validate, Revalidate, Invalidate Mystery. Stacking Items Vertically. How to Use GridBagLayout Properly. Avoiding Flicker. Components with Embedded HTML. GUI CONTROL. Better Data Validation. Desensitizing GUI Components Based on Application State. Use Threads in Event Handlers to Avoid Freezing Your GUI. Model View Controller and JTree. How to Data Transfer Something Other than Text. A KeyListener That Doesn't Listen? Printing Text, HTML, and Images in a JEditorPane. PERFORMANCE. Lazy Loading Our Way to Better Performance. Using Object Pools for Excessive Object Creation. Performance Watch: Array versus Vector. Avoid Using Temporary Arrays for Dynamic Array Growth. Use StringBuffer Instead of '+' for Concatenation inside a Loop. MISCELLANEOUS. Is There a Better Way to Debug? Encapsulating JNI Calls through Interfaces. Assertions. Index.