网站首页 软件下载 游戏下载 翻译软件 电子书下载 电影下载 电视剧下载 教程攻略
书名 | Effective Java(第3版英文版)/原味精品书系 |
分类 | |
作者 | (美)约书亚·布洛克 |
出版社 | 电子工业出版社 |
下载 | ![]() |
简介 | 内容推荐 自从Java 6发布之后,Java又有了翻天覆地的变化。本书涵盖了Java 7、Java 8和Java 9中语言和库的各种新特性。让你能够深入了解Java平台的细微之处。通过对每一个项目的全面描述和解释,告诉你应该做什么、不应该做什么,以及为什么要这样做。 作者简介 约书亚·布洛克是卡耐基梅隆大学的教授。他曾经是Google公司的首席Java架构师、Sun公司的杰出工程师以及Transarc公司的不错系统设计师。Bloch曾带领团队设计并实现过无数的Java平台特性;包括JDK5.0语言增强版,并且Java集合框架上屡获殊荣。他拥有卡耐基梅隆大学的计算机科学博士学位以及哥伦比亚大学的计算机科学学士学位。 目录 1 Introduction1 2 Creating and Destroying Objects5 Item 1: Consider static factory methods instead of constructors5 Item 2: Consider a builder when faced with many constructor parameters10 Item 3: Enforce the singleton property with a private constructor or an enum type17 Item 4: Enforce noninstantiability with a private constructor19 Item 5: Prefer dependency injection to hardwiring resources20 Item 6: Avoid creating unnecessary objects22 Item 7: Eliminate obsolete object references26 Item 8: Avoid finalizers and cleaners 29 Item 9: Prefer try-with-resources to try-finally34 3 Methods Common to All Objects37 Item 10: Obey the general contract when overriding equals37 Item 11: Always override hashCode when you override equals50 Item 12: Always override toString55 Item 13: Override clone judiciously58 Item 14: Consider implementing Comparable66 4 Classes and Interfaces73 Item 15: Minimize the accessibility of classes and members73 Item 16: In public classes, use accessor methods, not public fields78 Item 17: Minimize mutability80 Item 18: Favor composition over inheritance87 Item 19: Design and document for inheritance or else prohibit it 93 Item 20: Prefer interfaces to abstract classes99 Item 21: Design interfaces for posterity104 Item 22: Use interfaces only to define types107 Item 23: Prefer class hierarchies to tagged classes109 Item 24: Favor static member classes over nonstatic112 Item 25: Limit source files to a single top-level class115 5 Generics117 Item 26: Don’t use raw types117 Item 27: Eliminate unchecked warnings123 Item 28: Prefer lists to arrays126 Item 29: Favor generic types130 Item 30: Favor generic methods135 Item 31: Use bounded wildcards to increase API flexibility139 Item 32: Combine generics and varargs judiciously146 Item 33: Consider typesafe heterogeneous containers151 6 Enums and Annotations157 Item 34: Use enums instead of int constants157 Item 35: Use instance fields instead of ordinals168 Item 36: Use EnumSet instead of bit fields 169 Item 37: Use EnumMap instead of ordinal indexing171 Item 38: Emulate extensible enums with interfaces176 Item 39: Prefer annotations to naming patterns180 Item 40: Consistently use the Override annotation188 Item 41: Use marker interfaces to define types191 7 Lambdas and Streams193 Item 42: Prefer lambdas to anonymous classes193 Item 43: Prefer method references to lambdas197 Item 44: Favor the use of standard functional interfaces199 Item 45: Use streams judiciously203 Item 46: Prefer side-effect-free functions in streams210 Item 47: Prefer Collection to Stream as a return type216 Item 48: Use caution when making streams parallel222 8 Methods227 Item 49: Check parameters for validity227 Item 50: Make defensive copies when needed231 Item 51: Design method signatures carefully236 Item 52: Use overloading judiciously 238 Item 53: Use varargs judiciously245 Item 54: Return empty collections or arrays, not nulls247 Item 55: Return optionals judiciously249 Item 56: Write doc comments for all exposed API elements254 9 General Programming261 Item 57: Minimize the scope of local variables261 Item 58: Prefer for-each loops to traditional for loops264 Item 59: Know and use the libraries267 Item 60: Avoid float and double if exact answers are required270 Item 61: Prefer primitive types to boxed primitives273 Item 62: Avoid strings where other types are more appropriate276 Item 63: Beware the performance of string concatenation 279 Item 64: Refer to objects by their interfaces280 Item 65: Prefer interfaces to reflection282 Item 66: Use native methods judiciously285 Item 67: Optimize judiciously286 Item 68: Adhere to generally accepted naming conventions289 10 Exceptions293 Item 69: Use exceptions only for exceptional conditions293 Item 70: Use checked exceptions for recoverable conditions and runtime exceptions for programming errors296 Item 71: Avoid unnecessary use of checked exceptions298 Item 72: Favor the use of standard exceptions 300 Item 73: Throw exceptions appropriate to the abstraction302 Item 74: Document all exceptions thrown by each method304 Item 75: Include failure-capture information in detail messages306 Item 76: Strive for failure atomicity308 Item 77: Don’t ignore exceptions 310 11 Concurrency311 Item 78: Synchronize access to shared mutable data311 Item 79: Avoid excessive synchronization 317 Item 80: Prefer executors, tasks, and streams to threads323 Item 81: Prefer concurrency utilities to wait and notify325 Item 82: Document thread safety330 Item 83: Use lazy initialization judiciously333 Item 84: Don’t depend on the thread scheduler336 12 Serialization339 Item 85: Prefer alternatives to Java serialization339 Item 86: Implement Serializable with great caution343 Item 87: Consider using a custom serialized form346 Item 88: Write readObject methods defensively353 Item 89: For instance control, prefer enum types to readResolve 359 Item 90: Consider serialization proxies instead of serialized instances363 Items Corresponding to Second Edition367 References371 Index377 |
随便看 |
|
霍普软件下载网电子书栏目提供海量电子书在线免费阅读及下载。