Note: Supplemental materials are not guaranteed with Rental or Used book purchases.
Purchase Benefits
What is included with this book?
Joshua Bloch is chief Java architect at Google and a Jolt Award winner. He was previously a distinguished engineer at Sun Microsystems and a senior systems designer at Transarc. Bloch led the design and implementation of numerous Java platform features, including JDK 5.0 language enhancements and the award-winning Java Collections Framework. He coauthored Java™ Puzzlers (Addison-Wesley, 2005) and Java™ Concurrency in Practice (Addison-Wesley, 2006).
Foreword | p. xi |
Preface | p. xiii |
Acknowledgments | p. xvii |
Introduction | p. 1 |
Creating and Destroying Objects | p. 5 |
Consider static factory methods instead of constructors | p. 5 |
Consider a builder when faced with many constructorparameters | p. 11 |
Enforce the singleton property with a private constructor | p. 17 |
Enforce noninstantiability with a private constructor | p. 19 |
Avoid creating unnecessary objects | p. 20 |
Eliminate obsolete object references | p. 24 |
Avoid finalizers | p. 27 |
Methods Common to All Objects | p. 33 |
Obey the general contract when overriding equals | p. 33 |
Always override hashCode when you override equals | p. 45 |
Always override toString | p. 51 |
Override clone judiciously | p. 54 |
Consider implementing Comparable | p. 62 |
Classes and Interfaces | p. 67 |
Minimize the accessibility of classes and members | p. 67 |
In public classes, use accessor methods, not public fields | p. 71 |
Minimize mutability | p. 73 |
Favor composition over inheritance | p. 81 |
Design and document for inheritance or else prohibit it | p. 87 |
Prefer interfaces to abstract classes | p. 93 |
Use interfaces only to define types | p. 98 |
Prefer class hierarchies to tagged classes | p. 100 |
Use function objects to represent strategies | p. 103 |
Favor static member classes over nonstatic | p. 106 |
Generics | p. 109 |
Don't use raw types in new code | p. 109 |
Eliminate unchecked warnings | p. 116 |
Prefer lists to arrays | p. 119 |
Favor generic types | p. 124 |
Favor generic methods | p. 129 |
Use bounded wildcards to increase API flexibility | p. 134 |
Consider typesafe heterogeneous containers | p. 142 |
Enums and Annotations | p. 147 |
Use enums instead of int constants | p. 147 |
Use instance fields instead of ordinals | p. 158 |
Use EnumSet instead of bit fields | p. 159 |
Use EnumMap instead of ordinal indexing | p. 161 |
Emulate extensible enums with interfaces | p. 165 |
Prefer annotations to naming patterns | p. 169 |
Consistently use the Override annotation | p. 176 |
Use marker interfaces to define types | p. 179 |
Methods | p. 181 |
Check parameters for validity | p. 181 |
Make defensive copies when needed | p. 184 |
Design method signatures carefully | p. 189 |
Use overloading judiciously | p. 191 |
Use varargs judiciously | p. 197 |
Return empty arrays or collections, not nulls | p. 201 |
Write doc comments for all exposed API elements | p. 203 |
General Programming | p. 209 |
Minimize the scope of local variables | p. 209 |
Prefer for-each loops to traditional for loops | p. 212 |
Know and use the libraries | p. 215 |
Avoid float and double if exact answers are required | p. 218 |
Prefer primitive type | |
Table of Contents provided by Publisher. All Rights Reserved. |
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.