|
| 1 | +# Development Guidelines |
| 2 | +effective_java_notes: |
| 3 | + chapter_2: |
| 4 | + title: "Creating and Destroying Objects" |
| 5 | + items: |
| 6 | + - "Consider static factory methods instead of constructors" |
| 7 | + - "Consider a builder when faced with many constructor parameters" |
| 8 | + - "Enforce the singleton property with a private constructor or an enum type" |
| 9 | + - "Enforce noninstantiability with a private constructor" |
| 10 | + - "Prefer dependency injection to hardwiring resources" |
| 11 | + - "Avoid creating unnecessary objects" |
| 12 | + - "Eliminate obsolete object references" |
| 13 | + - "Avoid finalizers and cleaners" |
| 14 | + - "Prefer try-with-resources to try-finally" |
| 15 | + |
| 16 | + chapter_3: |
| 17 | + title: "Methods Common to All Objects" |
| 18 | + items: |
| 19 | + - "Obey the general contract when overriding equals" |
| 20 | + - "Always override hashCode when you override equals" |
| 21 | + - "Always override toString" |
| 22 | + - "Override clone judiciously" |
| 23 | + - "Consider implementing Comparable" |
| 24 | + |
| 25 | + chapter_4: |
| 26 | + title: "Classes and Interfaces" |
| 27 | + items: |
| 28 | + - "Minimize the accessibility of classes and members" |
| 29 | + - "In public classes, use accessor methods, not public fields" |
| 30 | + - "Minimize mutability" |
| 31 | + - "Favor composition over inheritance" |
| 32 | + - "Design and document for inheritance or else prohibit it" |
| 33 | + - "Prefer interfaces to abstract classes" |
| 34 | + - "Design interfaces for posterity" |
| 35 | + - "Use interfaces only to define types" |
| 36 | + - "Prefer class hierarchies to tagged classes" |
| 37 | + - "Favor static member classes over nonstatic" |
| 38 | + - "Limit source files to a single top-level class" |
| 39 | + |
| 40 | + chapter_5: |
| 41 | + title: "Generics" |
| 42 | + items: |
| 43 | + - "Don't use raw types" |
| 44 | + - "Eliminate unchecked warnings" |
| 45 | + - "Prefer lists to arrays" |
| 46 | + - "Favor generic types" |
| 47 | + - "Favor generic methods" |
| 48 | + - "Use bounded wildcards to increase API flexibility" |
| 49 | + - "Combine generics and varargs judiciously" |
| 50 | + - "Consider typesafe heterogeneous containers" |
| 51 | + |
| 52 | + chapter_6: |
| 53 | + title: "Enums and Annotations" |
| 54 | + items: |
| 55 | + - "Use enums instead of int constants" |
| 56 | + - "Use instance fields instead of ordinals" |
| 57 | + - "Use EnumSet instead of bit fields" |
| 58 | + - "Use EnumMap instead of ordinal indexing" |
| 59 | + - "Emulate extensible enums with interfaces" |
| 60 | + - "Prefer annotations to naming patterns" |
| 61 | + - "Consistently use the Override annotation" |
| 62 | + - "Use marker interfaces to define types" |
| 63 | + |
| 64 | + chapter_7: |
| 65 | + title: "Lambdas and Streams" |
| 66 | + items: |
| 67 | + - "Prefer lambdas to anonymous classes" |
| 68 | + - "Prefer method references to lambdas" |
| 69 | + - "Favor the use of standard functional interfaces" |
| 70 | + - "Use streams judiciously" |
| 71 | + - "Prefer side-effect-free functions in streams" |
| 72 | + - "Prefer Collection to Stream as a return type" |
| 73 | + - "Use caution when making streams parallel" |
| 74 | + |
| 75 | + chapter_8: |
| 76 | + title: "Methods" |
| 77 | + items: |
| 78 | + - "Check parameters for validity" |
| 79 | + - "Make defensive copies when needed" |
| 80 | + - "Design method signatures carefully" |
| 81 | + - "Use overloading judiciously" |
| 82 | + - "Use varargs judiciously" |
| 83 | + - "Return empty collections or arrays, not nulls" |
| 84 | + - "Return optionals judiciously" |
| 85 | + - "Write doc comments for all exposed API elements" |
| 86 | + |
| 87 | + chapter_9: |
| 88 | + title: "General Programming" |
| 89 | + items: |
| 90 | + - "Minimize the scope of local variables" |
| 91 | + - "Prefer for-each loops to traditional for loops" |
| 92 | + - "Know and use the libraries" |
| 93 | + - "Avoid float and double if exact answers are required" |
| 94 | + - "Prefer primitive types to boxed primitives" |
| 95 | + - "Avoid strings where other types are more appropriate" |
| 96 | + - "Beware the performance of string concatenation" |
| 97 | + - "Refer to objects by their interfaces" |
| 98 | + - "Prefer interfaces to reflection" |
| 99 | + - "Use native methods judiciously" |
| 100 | + - "Optimize judiciously" |
| 101 | + - "Adhere to generally accepted naming conventions" |
| 102 | + |
| 103 | + chapter_10: |
| 104 | + title: "Exceptions" |
| 105 | + items: |
| 106 | + - "Use exceptions only for exceptional conditions" |
| 107 | + - "Use checked exceptions for recoverable conditions and runtime exceptions for programming errors" |
| 108 | + - "Avoid unnecessary use of checked exceptions" |
| 109 | + - "Favor the use of standard exceptions" |
| 110 | + - "Throw exceptions appropriate to the abstraction" |
| 111 | + - "Document all exceptions thrown by each method" |
| 112 | + - "Include failure-capture information in detail messages" |
| 113 | + - "Strive for failure atomicity" |
| 114 | + - "Don't ignore exceptions" |
| 115 | + |
| 116 | + chapter_11: |
| 117 | + title: "Concurrency" |
| 118 | + items: |
| 119 | + - "Synchronize access to shared mutable data" |
| 120 | + - "Avoid excessive synchronization" |
| 121 | + - "Prefer executors, tasks, and streams to threads" |
| 122 | + - "Prefer concurrency utilities to wait and notify" |
| 123 | + - "Document thread safety" |
| 124 | + - "Use lazy initialization judiciously" |
| 125 | + - "Don't depend on the thread scheduler" |
| 126 | + |
| 127 | + chapter_12: |
| 128 | + title: "Serialization" |
| 129 | + items: |
| 130 | + - "Prefer alternatives to Java serialization" |
| 131 | + - "Implement Serializable with great caution" |
| 132 | + - "Consider using a custom serialized form" |
| 133 | + - "Write readObject methods defensively" |
| 134 | + - "For instance control, prefer enum types to readResolve" |
| 135 | + - "Consider serialization proxies instead of serialized instances" |
0 commit comments