영문목차
Foreword=xi
Preface=xiii
Acknowledgments=xv
1. Introduction=1
2. Creating and Destroying Objects=5
Item 1: Consider providing static factory methods instead of constructors=5
Item 2: Enforce the singleton property with a private constructor=10
Item 3: Enforce noninstantiability with a private constructor=12
Item 4: Avoid creating duplicate objects=13
Item 5: Eliminate obsolete object references=17
Item 6: Avoid finalizers=20
3. Methods Common to All Objects=25
Item 7: Obey the general contract when overriding equals=25
Item 8: Always override hashCode when you override equals=36
Item 9: Always override tostring=42
Item 10: Override clone judiciously=45
Item 11: Consider implementing Comparable=53
4. Classes and Interfaces=59
Item 12: Minimize the accessibility of classes and members=59
Item 13: Favor immutability=63
Item 14: Favor composition over inheritance=71
Item 15: Design and document for inheritance or else prohibit it=78
Item 16: Prefer interfaces to abstract classes=84
Item 17: Use interfaces only to define types=89
Item 18: Favor static member classes over nonstatic=91
5. Substitutes for C Constructs=97
Item 19: Replace structures with classes=97
Item 20: Replace unions with class hierarchies=100
Item 21: Replace enum constructs with classes=104
Item 22: Replace function pointers with classes and interfaces=115
6. Methods=119
Item 23: Check parameters for validity=119
Item 24: Make defensive copies when needed=122
Item 25: Design method signatures carefully=126
Item 26: Use overloading judiciously=128
Item 27: Return zero-length arrays, not nulls=134
Item 28: Write doc comments for all exposed API elements=136
7. General Programming=141
Item 29: Minimize the scope of local variables=141
Item 30: Know and use the libraries=145
Item 31: Avoid float and double if exact answers are required=149
Item 32: Avoid strings where other types are more appropriate=152
Item 33: Beware the performance of string concatenation=155
Item 34: Refer to objects by their interfaces=156
Item 35: Prefer interfaces to reflection=158
Item 36: Use native methods judiciously=161
Item 37: Optimize judiciously=162
Item 38: Adhere to generally accepted naming conventions=165
8. Exceptions=169
Item 39: Use exceptions only for exceptional conditions=169
Item 40: Use checked exceptions for recoverable conditions and run-time exceptions for programming errors=172
Item 41: Avoid unnecessary use of checked exceptions=174
Item 42: Favor the use of standard exceptions=176
Item 43: Throw exceptions appropriate to the abstraction=178
Item 44: Document all exceptions thrown by each method=181
Item 45: Include failure-capture information in detail messages=183
Item 46: Strive for failure atomicity=185
Item 47: Don't ignore exceptions=187
9. Threads=189
Item 48: Synchronize access to shared mutable data=189
Item 49: Avoid excessive synchronization=196
Item 50: Never invoke wait outside a loop=201
Item 51: Don't depend on the thread scheduler=204
Item 52: Document thread safety=208
Item 53: Avoid thread groups=211
10 Serialization=213
Item 54: Implement Serializable judiciously=213
Item 55: Consider using a custom serialized form=218
Item 56: Write readObject methods defensively=224
Item 57: Provide a readResolve method when necessary=230
References=233
Index of Patterns and Idioms=239
Index=241