Amazing Books
Temporary Blank

Friday, May 21, 2010

Effective Java: Programming Language Guide











Table of Contents
Foreword.............................................................................................................................. 1
Preface .................................................................................................................................. 3
Acknowledgments................................................................................................................ 4
Chapter 1. Introduction....................................................................................................... 5
Chapter 2. Creating and Destroying Objects .................................................................... 8
Item 1: Consider providing static factory methods instead of constructors ....................... 8
Item 2: Enforce the singleton property with a private constructor................................... 11
Item 3: Enforce noninstantiability with a private constructor.......................................... 13
Item 4: Avoid creating duplicate objects.......................................................................... 13
Item 5: Eliminate obsolete object references ................................................................... 16
Item 6: Avoid finalizers.................................................................................................... 19
Chapter 3. Methods Common to All Objects .................................................................. 23
Item 7: Obey the general contract when overriding equals............................................ 23
Item 8: Always override hashCode when you override equals...................................... 31
Item 9: Always override toString.................................................................................. 35
Item 10: Override clone judiciously ............................................................................... 37
Item 11: Consider implementing Comparable................................................................. 44
Chapter 4. Classes and Interfaces..................................................................................... 48
Item 12: Minimize the accessibility of classes and members .......................................... 48
Item 13: Favor immutability ............................................................................................ 50
Item 14: Favor composition over inheritance .................................................................. 57
Item 15: Design and document for inheritance or else prohibit it.................................... 61
Item 16: Prefer interfaces to abstract classes ................................................................... 65
Item 17: Use interfaces only to define types .................................................................... 69
Item 18: Favor static member classes over nonstatic....................................................... 71
Chapter 5. Substitutes for C Constructs .......................................................................... 75
Item 19: Replace structures with classes.......................................................................... 75
Item 20: Replace unions with class hierarchies ............................................................... 76
Item 21: Replace enum constructs with classes ................................................................ 80
Item 22: Replace function pointers with classes and interfaces....................................... 88
Chapter 6. Methods............................................................................................................ 91
Item 23: Check parameters for validity............................................................................ 91
Item 24: Make defensive copies when needed................................................................. 93
Item 25: Design method signatures carefully................................................................... 96
Item 26: Use overloading judiciously .............................................................................. 97
Item 27: Return zero-length arrays, not nulls................................................................. 101
Item 28: Write doc comments for all exposed API elements......................................... 103
Chapter 7. General Programming.................................................................................. 107
Item 29: Minimize the scope of local variables ............................................................. 107
Item 30: Know and use the libraries............................................................................... 109
Item 31: Avoid float and double if exact answers are required.................................. 112
Item 32: Avoid strings where other types are more appropriate .................................... 114
Item 33: Beware the performance of string concatenation ............................................ 116
Item 34: Refer to objects by their interfaces .................................................................. 117
Item 35: Prefer interfaces to reflection........................................................................... 118
Item 36: Use native methods judiciously ....................................................................... 121
Item 37: Optimize judiciously........................................................................................ 122
Item 38: Adhere to generally accepted naming conventions ......................................... 124
Chapter 8. Exceptions ...................................................................................................... 127
Item 39:Use exceptions only for exceptional conditions ............................................... 127
Item 40:Use checked exceptions for recoverable conditions and run-time exceptions
for programming errors .................................................................................................. 129
Item 41:Avoid unnecessary use of checked exceptions ................................................. 130
Item 42:Favor the use of standard exceptions................................................................ 132
Item 43: Throw exceptions appropriate to the abstraction............................................. 133
Item 44:Document all exceptions thrown by each method ............................................ 135
Item 45:Include failure-capture information in detail messages .................................... 136
Item 46:Strive for vetbfailure atomicity ..................................................................... 138
Item 47:Don't ignore exceptions .................................................................................... 139
Chapter 9. Threads .......................................................................................................... 141
Item 48: Synchronize access to shared mutable data ..................................................... 141
Item 49: Avoid excessive synchronization..................................................................... 145
Item 50: Never invoke wait outside a loop ................................................................... 149
Item 51: Don't depend on the thread scheduler .............................................................. 151
Item 52: Document thread safety ................................................................................... 154
Item 53: Avoid thread groups......................................................................................... 156
Chapter 10. Serialization ................................................................................................. 158
Item 54: Implement Serializable judiciously ............................................................ 158
Item 55:Consider using a custom serialized form.......................................................... 161
Item 56:Write readObject methods defensively .......................................................... 166
Item 57: Provide a readResolve method when necessary ............................................ 171
References ......................................................................................................................... 174

Download this book click here

No comments:

Post a Comment

Related Posts with Thumbnails
There was an error in this gadget

Put Your Ads Here!
There was an error in this gadget