did-you-know? rent-now

Amazon no longer offers textbook rentals. We do!

did-you-know? rent-now

Amazon no longer offers textbook rentals. We do!

We're the #1 textbook rental company. Let us show you why.

9780471361749

JavaTM Pitfalls: Time-Saving Solutions and Workarounds to Improve Programs

by ; ; ;
  • ISBN13:

    9780471361749

  • ISBN10:

    0471361747

  • Format: Paperback
  • Copyright: 2000-04-01
  • Publisher: Wiley
  • Purchase Benefits
  • Free Shipping Icon Free Shipping On Orders Over $35!
    Your order must be $35 or more to qualify for free economy shipping. Bulk sales, PO's, Marketplace items, eBooks and apparel do not qualify for this offer.
  • eCampus.com Logo Get Rewarded for Ordering Your Textbooks! Enroll Now
List Price: $39.99

Summary

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)

Author Biography

MICHAEL C. DACONTA is President of Synergy Solutions, Inc., where he conducts training seminars and develops advanced systems with Java, JavaScript, and XML. He is a Sun-certified Java programmer and author of Java 2 and JavaScript for C and C++ Programmers and C++ Pointers and Dynamic Memory Management.

Table of Contents

Acknowledgments ix
Introduction xi
PART ONE LANGUAGE SYNTAX 1(38)
When Is an ``Overridden'' Method Not Really Overridden?
2(3)
Usage of String equals() Method versus the ``=='' Operator
5(3)
Java Is Strongly Typed
8(4)
Type Conversion
9(1)
Widening
9(1)
Narrowing
10(1)
Implicit Type Conversion
11(1)
Is That a Constructor?
12(2)
Cannot Access Overridden Methods
14(3)
Avoid the ``Hidden Field'' Pitfall
17(8)
Kinds of Java Variables
18(1)
Variable Scope
19(1)
Which Kinds of Variables Can Be Hidden?
20(1)
How Instance Variables and Class Variables Get Hidden
20(2)
How to Access a Hidden Field Member
22(1)
How Hidden Variables Differ from an Overridden Method
23(2)
Forward References
25(1)
Design Constructors for Extension
26(7)
Passing Primitives by Reference
33(3)
Boolean Logic and Short-Circuit Operators
36(3)
PART TWO LANGUAGE SUPPORT 39(52)
Reclaiming References When Using SoftReference Objects
40(10)
A Word about Garbage Collection
40(2)
The SoftReference Class
42(6)
Reference Queues
48(2)
Causing Deadlock by Calling a Synchronized Method from a Synchronized Method
50(10)
Review of Threads, Monitors, and the ``Synchronized'' Keyword
51(4)
Example of Deadlock Scenario
55(5)
Properly Cloning an Object
60(6)
Overriding the equals Method
66(4)
Using StringBuffer Objects as Hashmap Keys
68(2)
Avoid Using Constructor for Implementing clone()
70(5)
Method Dispatching with Reflection, Interfaces, and Anonymous Classes
75(10)
Handling Exceptions and OutOfMemoryError
85(6)
Exception Syntax
86(1)
Exception Hierarchy
86(1)
Catching Exceptions
87(1)
Running Out of Memory
88(3)
PART THREE UTILITIES AND COLLECTIONS 91(30)
Ordered Property Keys?
92(4)
Handling Occasionally Huge Collections with Caching and Persistence
96(12)
Property File or ResourceBundle?
108(3)
Properties Object Pitfalls
111(6)
Using Vector as a Collection Instead of Old API
117(4)
PART FOUR INPUT/OUTPUT 121(24)
Serialization
122(4)
What Really Happens When We Serialize an Object?
123(1)
The Externalizable Interface
124(2)
Unicode, UTF, and Streams
126(6)
Unicode
126(1)
UTF
127(1)
Streams
128(3)
Input or Output
128(1)
Bytes or Characters
129(1)
Low Level or High Level
130(1)
Data Sink or Filter
130(1)
Chaining
130(1)
Configurable Encoding
131(1)
Sending Serialized Objects over Sockets
132(3)
Try, Catch ... Finally?
135(4)
Flushing Image Resources
139(6)
PART FIVE GUI PRESENTATION 145(52)
Providing Progress Feedback
146(6)
Using a Busy Cursor
147(2)
Using a Progress Monitor
149(3)
Using repaint() Instead of validate() for Re-Layout of Components
152(4)
Z-Order and Overlapping Components
156(8)
Layout Managers
157(5)
JLayeredPane
162(2)
Solving the Validate, Revalidate, Invalidate Mystery
164(4)
Stacking Items Vertically
168(10)
How to Use GridBagLayout Properly
178(8)
Avoiding Flicker
186(6)
Painting in AWT
187(4)
Painting in Swing
191(1)
Components with Embedded HTML
192(5)
PART SIX GUI CONTROL 197(68)
Better Data Validation
198(11)
Tailored Components
199(1)
Filtering
199(1)
Consuming Events
200(1)
Post-Entry Validation
201(1)
Design Issues
202(1)
Asynchronous Validation
202(2)
Validation Adapter
204(2)
Validation Techniques
206(1)
Validation Using Exceptions
206(2)
Chained Validators
208(1)
End Notes
209(1)
Desensitizing GUI Components Based on Application State
209(7)
The Over-Reactive Approach
210(1)
The Brute-Force Approach
210(1)
The Abstract Approach---A StateMonitor Class
211(2)
List Viewer
213(2)
Adaptive Sensitization
215(1)
Use Threads in Event Handlers to Avoid Freezing Your GUI
216(8)
Implementing an Effective Cancel with Threading
218(4)
Implementing an Effective Cancel with SwingWorker
222(2)
Model View Controller and JTree
224(3)
How to Data Transfer Something Other Than Text
227(23)
Data Transfer Overview
227(2)
Three Types of Data Transfer
229(1)
Intra-JVM Example
229(5)
Determining What Support Is Available for Data Transfer
234(1)
Inter-JVM and Native-JVM Example
235(15)
A KeyListener That Doesn't Listen?
250(4)
Printing Text, HTML, and Images in a JEditorPane
254(11)
PART SEVEN PERFORMANCE 265(24)
Lazy Loading Our Way to Better Performance
266(3)
Using Object Pools for Excessive Object Creation
269(5)
Object Recycling
269(1)
A Comparison to Caching
269(1)
Implementation
270(2)
The Good
272(1)
The Bad
272(1)
The Ugly
273(1)
Performance Watch: Array versus Vector
274(6)
Why is a Vector so much slower than an Array?
277(1)
When should I use a Vector?
278(1)
The ArrayList Class
279(1)
Avoid Using Temporary Arrays for Dynamic Array Growth
280(6)
Use StringBuffer Instead of `+' for Concatenation inside a Loop
286(3)
PART EIGHT MISCELLANEOUS 289(26)
Is There a Better Way to Debug?
290(2)
Encapsulating JNI Calls through Interfaces
292(15)
Discussion of Concept
292(2)
An Example Interface
294(2)
Pure Java Implementation
296(2)
Native Implementation
298(4)
Windows Specifics
302(5)
Assertions
307(8)
Assertions in Java
308(1)
Using Assertions
308(1)
How Not to Use Assertions
309(1)
Sample Implementation
310(5)
Index 315

Supplemental Materials

What is included with this book?

The New copy of this book will include any supplemental materials advertised. Please check the title of the book to determine if it should include any access cards, study guides, lab manuals, CDs, etc.

The Used, Rental and eBook copies of this book are not guaranteed to include any supplemental materials. Typically, only the book itself is included. This is true even if the title states it includes any access cards, study guides, lab manuals, CDs, etc.

Rewards Program