Effective Java: programming language guide

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

"An excellent book, crammed with good advice on using the Java™ programming language and object-oriented programming in general."—Gilad Bracha, Computational Theologist, Sun Microsystems, Inc., and co-author of The Java™ Language Specification, Second Edition "I sure wish I had this book ten years ago. Some might think that I don't need any Java books, but I need this one."—James Gosling, Fellow and Vice President, Sun Microsystems, Inc., and inventor of the Java™ programming language Are you looking for a concise book packed with insight and wisdom not found elsewhere? Need to really understand the Java programming language; that is, really understand it? Do you want to write code that is clear, correct, robust, and reusable? Look no further! The book you are holding will provide you with this and many other benefits you may not even know you were looking for. Become a more effective programmer. Featuring fifty-seven valuable rules of thumb, Effective Java™ Programming Language Guide contains working solutions to the programming challenges most developers encounter every day. Offering comprehensive descriptions of techniques used by the experts who developed the Java platform, the book reveals what to do—and what not to do—in order to produce clear, robust, and efficient code. Each rule appears in the form of a short, stand-alone essay offering insight, code examples, and "war stories" from this uniquely qualified author. The essays include specific advice and insights into the subtleties of the language and are illustrated with exceptional code examples. Throughout the book, common language idioms and design patterns are examined and insightful and enlightening tips and techniques are provided. Coverage includes: • Customary and effective language usage that is saturated with expert advice in a concise, readable, and easy-to-access format. • Patterns, antipatterns, and idioms to help you get the most out of the Java platform. • Commonly misunderstood subtleties of the language and its libraries: how to avoid the traps and pitfalls. • Focus on the language and its most fundamental libraries: java.lang, java.util, and, to a lesser extent, java.io. • Detailed coverage of serialization, including practical advice that is not available elsewhere. Appealing to a broad spectrum of the programming community, Effective Java™ Programming Language Guide presents the most practical, authoritative guidelines available for writing efficient, well-designed programs for the Java platform.

Author(s): Joshua Bloch
Series: The Java series
Edition: 1
Publisher: Addison-Wesley
Year: 2001

Language: English
Commentary: watermark on page 180
Pages: 272

Cover......Page 1
Table of Contents......Page 3
Foreword......Page 5
Preface......Page 7
Acknowledgments......Page 8
1. Introduction......Page 9
Item 1: Consider providing static factory methods instead of constructors......Page 12
Item 2: Enforce the singleton property with a private constructor......Page 15
Item 4: Avoid creating duplicate objects......Page 17
Item 5: Eliminate obsolete object references......Page 20
Item 6: Avoid finalizers......Page 23
Item 7: Obey the general contract when overriding equals......Page 27
Item 8: Always override hashCode when you override equals......Page 35
Item 9: Always override toString......Page 39
Item 10: Override clone judiciously......Page 41
Item 11: Consider implementing Comparable......Page 48
Item 12: Minimize the accessibility of classes and members......Page 52
Item 13: Favor immutability......Page 54
Item 14: Favor composition over inheritance......Page 61
Item 15: Design and document for inheritance or else prohibit it......Page 65
Item 16: Prefer interfaces to abstract classes......Page 69
Item 17: Use interfaces only to define types......Page 73
Item 18: Favor static member classes over nonstatic......Page 75
Item 19: Replace structures with classes......Page 79
Item 20: Replace unions with class hierarchies......Page 80
Item 21: Replace enum constructs with classes......Page 84
Item 22: Replace function pointers with classes and interfaces......Page 92
Item 23: Check parameters for validity......Page 95
Item 24: Make defensive copies when needed......Page 97
Item 25: Design method signatures carefully......Page 100
Item 26: Use overloading judiciously......Page 101
Item 27: Return zero-length arrays, not nulls......Page 105
Item 28: Write doc comments for all exposed API elements......Page 107
Item 29: Minimize the scope of local variables......Page 111
Item 30: Know and use the libraries......Page 113
Item 31: Avoid float and double if exact answers are required......Page 116
Item 32: Avoid strings where other types are more appropriate......Page 118
Item 33: Beware the performance of string concatenation......Page 120
Item 34: Refer to objects by their interfaces......Page 121
Item 35: Prefer interfaces to reflection......Page 122
Item 36: Use native methods judiciously......Page 125
Item 37: Optimize judiciously......Page 126
Item 38: Adhere to generally accepted naming conventions......Page 128
Item 39:Use exceptions only for exceptional conditions......Page 131
Item 40:Use checked exceptions for recoverable conditions and run-time exceptions for programming errors......Page 133
Item 41:Avoid unnecessary use of checked exceptions......Page 134
Item 42:Favor the use of standard exceptions......Page 136
Item 43: Throw exceptions appropriate to the abstraction......Page 137
Item 44:Document all exceptions thrown by each method......Page 139
Item 45:Include failure-capture information in detail messages......Page 140
Item 46:Strive for Item 47:Don't ignore exceptions......Page 143
Item 48: Synchronize access to shared mutable data......Page 145
Item 49: Avoid excessive synchronization......Page 149
Item 50: Never invoke wait outside a loop......Page 153
Item 51: Don't depend on the thread scheduler......Page 155
Item 52: Document thread safety......Page 158
Item 53: Avoid thread groups......Page 160
Item 54: Implement Serializable judiciously......Page 162
Item 55:Consider using a custom serialized form......Page 165
Item 56:Write readObject methods defensively......Page 170
Item 57: Provide a readResolve method when necessary......Page 175
References......Page 178