Creating and destroying objects 1. Consider replacing the constructor with a static factory method (static method that returns an instance of the class) 2. When encountering multiple constructor parameters, consider using the constructor 3. Hardening the Singleton property with a private constructor or enumeration type 4, the ability to strengthen the non-instantiation through the private constructor 5. Avoid creating unnecessary objects 6. Eliminate outdated object references 7. Avoid using the end-of-life (final) method methods that are common to all objects8. Please observe the General agreement when you overwrite equals 9. Overwrite equals when always overwrite Hashcode 10. Always overwrite ToString 11. Carefully overwrite clone 12. Consider implementing comparable interface Classes and Interfaces13. Minimize the accessibility of classes and members 14. Use Access methods in public classes instead of public domain 15, to minimize the variability of 16, compound better than inheritance 17. Either design for inheritance, provide documentation, or prohibit inheritance 18, interface is better than abstract class 19, the interface is only used to define the type 20, class level is better than label class 21. Use the function object to represent the policy 22. Prioritize static Member classes generic type23. Do not use the original ecological type in the new code 24. Eliminate non-inspected warnings 25, the list takes precedence over the array 26. Preference for generics 27. Preference for generic methods 28, the use of limited access to the Fraiti upgrade API flexibility 29. Preference for type-safe heterogeneous constructors Enumerations and annotations30. Use enum to bring up int constants 31. Replace ordinal with instance field 32, replace the bit field with Enumset 33. Replace ordinal index with Enummap 34. Simulating a scalable enumeration with an interface 35. Annotations take precedence over naming patterns 36. Insist on using override annotations 37. Defining the type with the tag interface Method38, check the validity of the parameters 39, if necessary, to carry out protective copies 40, careful design method signature 41, cautious use of heavy 42. Use variable parameters with caution 43. Returns an array or set of 0 lengths, not NULL 44. Write documentation comments for all exported API elements General Programming45. Minimizing the scope of local variables 46. The For-each cycle takes precedence over the traditional for loop, [why the For loop is hateful] http://justjavac.com/other/2012/05/15/whats-wrong-with-the-for-loop.html 47. Understanding and using class libraries 48. If precise answers are required, avoid using float and double 49, the basic type takes precedence over the boxing basic type 50. If other types are more appropriate, avoid using strings as much as possible 51, beware of String link performance 52. Referencing objects via interfaces 53, the interface takes precedence over the reflection mechanism 54. Use local methods with caution 55. Be careful to optimize 56. Adherence to universally accepted naming conventions Exception57. Use exceptions only for abnormal situations 58. Use the exception to the recoverable condition, use run-time exception for programming error 59. Avoid unnecessary use of the exception being inspected 60. Preferential use of standard exceptions 61. Throws the exception corresponding to the abstract 62, each method throws the exception to have the document 63. Contains the information of the capture failure in the detail message 64. Try to make the failure contain atomicity 65. Do not ignore exceptions Concurrency66. Simultaneous access to shared mutable data 67. Avoid over-synchronization 68. Executor and tasks take precedence over threads 69. Concurrency tools take precedence over wait and notify 70. Documentation of thread Safety ...... |