- •Table of Contents
- •Foreword
- •Preface
- •Acknowledgments
- •Item 1: Consider providing static factory methods instead of constructors
- •Item 2: Enforce the singleton property with a private constructor
- •Item 3: Enforce noninstantiability with a private constructor
- •Item 4: Avoid creating duplicate objects
- •Item 5: Eliminate obsolete object references
- •Item 6: Avoid finalizers
- •Item 7: Obey the general contract when overriding equals
- •Item 8: Always override hashCode when you override equals
- •Item 9: Always override toString
- •Item 10: Override clone judiciously
- •Item 11: Consider implementing Comparable
- •Item 12: Minimize the accessibility of classes and members
- •Item 13: Favor immutability
- •Item 14: Favor composition over inheritance
- •Item 15: Design and document for inheritance or else prohibit it
- •Item 16: Prefer interfaces to abstract classes
- •Item 17: Use interfaces only to define types
- •Item 18: Favor static member classes over nonstatic
- •Item 19: Replace structures with classes
- •Item 20: Replace unions with class hierarchies
- •Item 21: Replace enum constructs with classes
- •Item 22: Replace function pointers with classes and interfaces
- •Item 23: Check parameters for validity
- •Item 24: Make defensive copies when needed
- •Item 25: Design method signatures carefully
- •Item 26: Use overloading judiciously
- •Item 27: Return zero-length arrays, not nulls
- •Item 28: Write doc comments for all exposed API elements
- •Item 29: Minimize the scope of local variables
- •Item 30: Know and use the libraries
- •Item 31: Avoid float and double if exact answers are required
- •Item 32: Avoid strings where other types are more appropriate
- •Item 33: Beware the performance of string concatenation
- •Item 34: Refer to objects by their interfaces
- •Item 35: Prefer interfaces to reflection
- •Item 36: Use native methods judiciously
- •Item 37: Optimize judiciously
- •Item 38: Adhere to generally accepted naming conventions
- •Item 39:Use exceptions only for exceptional conditions
- •Item 40:Use checked exceptions for recoverable conditions and run-time exceptions for programming errors
- •Item 41:Avoid unnecessary use of checked exceptions
- •Item 42:Favor the use of standard exceptions
- •Item 43: Throw exceptions appropriate to the abstraction
- •Item 44:Document all exceptions thrown by each method
- •Item 45:Include failure-capture information in detail messages
- •Item 46:Strive for </vetbfailure atomicity
- •Item 47:Don't ignore exceptions
- •Item 48: Synchronize access to shared mutable data
- •Item 49: Avoid excessive synchronization
- •Item 50: Never invoke wait outside a loop
- •Item 51: Don't depend on the thread scheduler
- •Item 52: Document thread safety
- •Item 53: Avoid thread groups
- •Item 54: Implement Serializable judiciously
- •Item 55:Consider using a custom serialized form
- •Item 56:Write readObject methods defensively
- •Item 57: Provide a readResolve method when necessary
- •References
Effective Java: Programming Language Guide
References
[Arnold00] Arnold, Ken, James Gosling, David Holmes. The Java™ Programming Language, Third Edition. Addison-Wesley, Boston, 2000. ISBN: 0201704331.
[Beck99] Beck Kent. Extreme Programming Explained: Embrace Change. Addison-Wesley, Reading, MA, 1999. ISBN: 0201616416.
[Bloch99] |
Bloch |
Joshua. Collections. In The Java™ Tutorial Continued: The Rest of |
the JDK™. |
Mary |
Campione, Kathy Walrath, Alison Huml, and the Tutorial Team. |
Addison-Wesley, Reading, MA, 1999. ISBN: 0201485583. Pages 17–93. Also available as <http://java.sun.com/docs/books/tutorial/collections/index.html>.
[Campione00] Campione, Mary, Kathy Walrath, Alison Huml. The Java™ Tutorial Continued: A Short Course on the Basics. Addison-Wesley, Boston, MA, 2000. ISBN: 0201703939. Also available as <http://java.sun.com/docs/books/tutorial/index.html>.
[Cargill96] Cargill, Thomas. Specific Notification for Java Thread Synchronization.
Proceedings of the Pattern Languages of Programming Conference, 1996.
[Chan00] Chan, Patrick. The Java™ Developers Almanac 2000, Addison-Wesley, Boston, MA, 2000. ISBN: 0201432994.
[Chan98] Chan, Patrick, Rosanna Lee, Douglas Kramer. The Java™ Class Libraries Second Edition, Volume 1, Addison-Wesley, Reading, MA, 1998. ISBN: 0201310023.
[Collections] The Collections Framework. Sun Microsystems. March 2001. <http://java.sun.com/j2se/1.3/docs/guide/collections/index.html>.
[Doclint] Doclint. Ernst de Haan. March, 2001. <http://www.znerd.demon.nl/doclint/>.
[Flanagan99] Flanagan, David. Java™ in a Nutshell, Third Edition, O'Reilly and Associates, Sebastopol, CA, 1999. ISBN: 1565924878.
[Gamma95] Gamma, Erich, Richard Helm, Ralph Johnson, John Vlissides. Design Patterns: Elements of Reusable Object-Oriented Software, Addison-Wesley, Reading, MA, 1995. ISBN: 0201633612.
[Gong99] Gong, Li. Inside Java™ 2 Platform Security, Addison-Wesley, Reading, MA, 1999. ISBN: 0201310007.
[Heydon99] Allan Heydon Marc A. Najork. Performance Limitations of the Java Core Libraries. In ACM 1999 Java Grande Conference pages 35–41. ACM Press, June 1999. Also available as <http://research.compaq.com/SRC/mercator/papers/Java99/final.pdf>
[Horstman00] Horstmann, Cay, Gary Cornell. Core Java™ 2: Volume II—Advanced Features, Prentice Hall, Palo Alto, CA, 2000. ISBN: 0130819344.
[HTML401] HTML 4.01 Specification. World Wide Web Consortium. December 1999. <http://www.w3.org/TR/1999/REC-html401-19991224/>.
174
Effective Java: Programming Language Guide
[J2SE-APIs] Java™ 2 Platform, Standard Edition, v 1.3 API Specification. Sun Microsystems. March 2001. <http://java.sun.com/j2se/1.3/docs/api/overview-summary.html>.
[Jackson75] Jackson, M. A. Principles of Program Design, Academic Press, London, 1975. ISBN: 0123790506.
[JavaBeans] JavaBeans™ Spec. Sun Microsystems. March 2001. <http://java.sun.com/products/javabeans/docs/spec.html>.
[Javadoc-a] How to Write Doc Comments for Javadoc. Sun Microsystems. January 2001. <http://java.sun.com/j2se/javadoc/writingdoccomments/>.
[Javadoc-b] Javadoc Tool Home Page. Sun Microsystems. January, 2001. <http://java.sun.com/j2se/javadoc/index.html>.
[JLS] Gosling, James, Bill Joy, Guy Steele, Gilad Bracha. The Java™ Language Specification, Second Edition, Addison-Wesley, Boston, 2000. ISBN: 0201310082.
[Kahan91] Kahan, William, J. W. Thomas. Augmenting a Programming Language with Complex Arithmetic, UCB/CSD-91-667, University of California, Berkeley, 1991.
[Knuth74] Knuth, Donald. Structured Programming with go to Statements. Computing Surveys 6 (1974): 261–301.
[Lea01] Overview of Package util.concurrent Release 1.3.0. State University of New York, Oswego. January 12, 2001. <http://g.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html>.
[Lea00] Lea, Doug. Concurrent Programming in Java™: Design Principles and Patterns, Second Edition, Addison-Wesley, Boston, 2000. ISBN: 0201310090.
[Lieberman86] Lieberman, Henry. Using Prototypical Objects to Implement Shared Behavior in Object-Oriented Systems. Proceedings of the First ACM Conference on Object-Oriented Programming Systems, Languages, and Applications, pages 214–223, Portland, September 1986. ACM Press.
[Meyers98] Meyers, Scott. Effective C++, Second Edition: 50 Specific Ways to Improve Your Programs and Designs. Addison-Wesley, Reading, MA, 1998. ISBN: 0201924889.
[Parnas72] Parnas, D. L. On the Criteria to Be Used in Decomposing Systems into Modules.
Communications of the ACM 15 (1972): 1053–1058.
[Posix] 9945-1:1996 (ISO/IEC) [IEEE/ANSI Std. 1003.1 1995 Edition] Information Technology—Portable Operating System Interface (POSIX)—Part 1: System Application: Program Interface (API) [C Language] (ANSI), IEEE Standards Press, ISBN: 1559375736.
[Pugh01a] The Java Memory Model, Ed. William Pugh. University of Maryland. March 2001. <http://www.cs.umd.edu/~pugh/java/memoryModel/>.
175
|
|
|
Effective Java: Programming Language Guide |
|
[Pugh01b] |
The “Double-Checked Locking is Broken” Declaration. Ed. William Pugh, |
|||
University |
of |
Maryland. |
March |
2001. |
<http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html>. |
|
[Serialization] Java™ Object Serialization Specification. Sun Microsystems. March 2001. <http://java.sun.com/j2se/1.3/docs/guide/serialization/spec/serialTOC.doc.html>.
[Smith62] Smith, Robert. Algorithm 116 Complex Division. In Communications of the ACM, 5.8 (August 1962): 435.
[Snyder86] Synder, Alan. Encapsulation and Inheritance in Object-Oriented Programming Languages. In Object-Oriented Programming Systems, Languages, and Applications Conference Proceedings, 38–45, 1986. ACM Press.
[Thomas94] Thomas, Jim, Jerome T. Coonen. Issues Regarding Imaginary Types for C and C++. In The Journal of C Language Translation, 5.3 (March 1994): 134–138.
[Vermeulen00] Vermeulen, Allan, Scott W. Ambler, Greg Bumgardener, Eldon Metz, Trevor Mesfeldt, Jim Shur, Patrick Thompson. The Elements of Java™ Style, Cambridge University Press, Cambridge, United Kingdom, 2001. ISBN: 0521777682.
[Weblint] The Weblint Home Page. Weblint.org. March 2001. <http://www.weblint.org/>.
[Wulf72] Wulf, W. A Case Against the GOTO. Proceedings of the 25th ACM National Conference 2 (1972): 791–797.
176