Effective Java

Joshua Bloch

Book - 2009

Saved in:

2nd Floor Show me where

005.133/JAVA/Bloch
1 / 1 copies available
Location Call Number   Status
2nd Floor 005.133/JAVA/Bloch Checked In
Subjects
Published
Upper Saddle River, NJ : Addison-Wesley 2009, c2008.
Language
English
Main Author
Joshua Bloch (-)
Edition
2nd ed
Item Description
"Revised and updated for Java SE 6"--Cover.
Physical Description
xxi, 346 p. ; 24 cm
Bibliography
Includes bibliographical references and index.
ISBN
9780321356680
  • Foreword
  • Preface
  • Acknowledgments
  • Chapter 1. Introduction
  • Chapter 2. Creating and Destroying Objects
  • Item 1. Consider static factory methods instead of constructors
  • Item 2. Consider a builder when faced with many constructorparameters
  • Item 3. Enforce the singleton property with a private constructor
  • Item 4. Enforce noninstantiability with a private constructor
  • Item 5. Avoid creating unnecessary objects
  • Item 6. Eliminate obsolete object references
  • Item 7. Avoid finalizers
  • Chapter 3. Methods Common to All Objects
  • Item 8. Obey the general contract when overriding equals
  • Item 9. Always override hashCode when you override equals
  • Item 10. Always override toString
  • Item 11. Override clone judiciously
  • Item 12. Consider implementing Comparable
  • Chapter 4. Classes and Interfaces
  • Item 13. Minimize the accessibility of classes and members
  • Item 14. In public classes, use accessor methods, not public fields
  • Item 15. Minimize mutability
  • Item 16. Favor composition over inheritance
  • Item 17. Design and document for inheritance or else prohibit it
  • Item 18. Prefer interfaces to abstract classes
  • Item 19. Use interfaces only to define types
  • Item 20. Prefer class hierarchies to tagged classes
  • Item 21. Use function objects to represent strategies
  • Item 22. Favor static member classes over nonstatic
  • Chapter 5. Generics
  • Item 23. Don't use raw types in new code
  • Item 24. Eliminate unchecked warnings
  • Item 25. Prefer lists to arrays
  • Item 26. Favor generic types
  • Item 27. Favor generic methods
  • Item 28. Use bounded wildcards to increase API flexibility
  • Item 29. Consider typesafe heterogeneous containers
  • Chapter 6. Enums and Annotations
  • Item 30. Use enums instead of int constants
  • Item 31. Use instance fields instead of ordinals
  • Item 32. Use EnumSet instead of bit fields
  • Item 33. Use EnumMap instead of ordinal indexing
  • Item 34. Emulate extensible enums with interfaces
  • Item 35. Prefer annotations to naming patterns
  • Item 36. Consistently use the Override annotation
  • Item 37. Use marker interfaces to define types
  • Chapter 7. Methods
  • Item 38. Check parameters for validity
  • Item 39. Make defensive copies when needed
  • Item 40. Design method signatures carefully
  • Item 41. Use overloading judiciously
  • Item 42. Use varargs judiciously
  • Item 43. Return empty arrays or collections, not nulls
  • Item 44. Write doc comments for all exposed API elements
  • Chapter 8. General Programming
  • Item 45. Minimize the scope of local variables
  • Item 46. Prefer for-each loops to traditional for loops
  • Item 47. Know and use the libraries
  • Item 48. Avoid float and double if exact answers are required
  • Item 49. Prefer primitive type

Preface to the Second Edition A lot has happened to the Java platform since I wrote the first edition of this book in 2001, and it's high time for a second edition. The most significant set of changes was the addition of generics, enum types, annotations, autoboxing, and the for-each loop in Java 5. A close second was the addition of the new concurrency library, java.util.concurrent , also released in Java 5. With Gilad Bracha, I had the good fortune to lead the teams that designed the new language features. I also had the good fortune to serve on the team that designed and developed the concurrency library, which was led by Doug Lea. The other big change in the platform is the widespread adoption of modern Integrated Development Environments (IDEs), such as Eclipse, IntelliJ IDEA, and NetBeans, and of static analysis tools, such as FindBugs. While I have not been involved in these efforts, I've benefited from them immensely and learned how they affect the Java development experience. In 2004, I moved from Sun to Google, but I've continued my involvement in the development of the Java platform over the past four years, contributing to the concurrency and collections APIs through the good offices of Google and the Java Community Process. I've also had the pleasure of using the Java platform to develop libraries for use within Google. Now I know what it feels like to be a user. As was the case in 2001 when I wrote the first edition, my primary goal is to share my experience with you so that you can imitate my successes while avoiding my failures. The new material continues to make liberal use of real-world examples from the Java platform libraries. The first edition succeeded beyond my wildest expectations, and I've done my best to stay true to its spirit while covering all of the new material that was required to bring the book up to date. It was inevitable that the book would grow, and grow it did, from fifty-seven items to seventy-eight. Not only did I add twenty-three items, but I thoroughly revised all the original material and retired a few items whose better days had passed. In the Appendix, you can see how the material in this edition relates to the material in the first edition. In the Preface to the First Edition, I wrote that the Java programming language and its libraries were immensely conducive to quality and productivity, and a joy to work with. The changes in releases 5 and 6 have taken a good thing and made it better. The platform is much bigger now than it was in 2001 and more complex, but once you learn the patterns and idioms for using the new features, they make your programs better and your life easier. I hope this edition captures my continued enthusiasm for the platform and helps make your use of the platform and its new features more effective and enjoyable. San Jose, California April 2008 Excerpted from Effective Java by Joshua Bloch All rights reserved by the original copyright owners. Excerpts are provided for display purposes only and may not be reproduced, reprinted or distributed without the written permission of the publisher.