Effective Java

Joshua Bloch

出版时间

2018-01-06

ISBN

9780134685991

评分

★★★★★

标签

编程

书籍介绍

The Definitive Guide to Java Platform Best Practices—Updated for Java 9

Java has changed dramatically since the previous edition of Effective Java was published shortly after the release of Java 6. This Jolt award-winning classic has now been thoroughly updated to take full advantage of the latest language and library features. The support in modern Java for multiple paradigms increases the need for specific best-practices advice, and this book delivers.

As in previous editions, each chapter of Effective Java, Third Edition, consists of several “items,” each presented in the form of a short, stand-alone essay that provides specific advice, insight into Java platform subtleties, and updated code examples. The comprehensive descriptions and explanations for each item illuminate what to do, what not to do, and why.

The third edition covers language and library features added in Java 7, 8, and 9, including the functional programming constructs that were added to its object-oriented roots. Many new items have been added, including a chapter devoted to lambdas and streams.

New coverage includes

Functional interfaces, lambda expressions, method references, and streams

Default and static methods in interfaces

Type inference, including the diamond operator for generic types

The @SafeVarargs annotation

The try-with-resources statement

New library features such as the Optional<T> interface, java.time, and the convenience factory methods for collections

AI导读
核心看点
  • 涵盖Java 9最新特性,提供最佳实践指南
  • 通过独立条目形式,深入解析平台细节
  • 包含大量JDK内部代码示例与避坑建议
适合谁读
  • 具备一定Java基础的中高级开发者
  • 希望提升代码质量与可维护性的工程师
  • 需要深入理解Java平台机制的技术人员
读前提醒
  • 建议阅读英文版,中文翻译质量参差不齐
  • 结合项目实战经验阅读,共鸣感更强
  • 无需通读,可根据当前需求选择性查阅
读者共识
  • Java领域公认的经典必读之作
  • 能显著减少开发弯路,提升编码规范
  • 内容详实但需一定基础,新手慎入

本导读基于书籍简介、目录、原文摘录、短评和书评生成,不等同于全文精读。

精彩摘录
  • "例如,构造器 BigInteger(int, int, Random)会返回一个为可能素数(probable prime)的 BigInteger, 但如果用一个名为 BigInteger.probablePrime 的静态工厂方法来表示,效果会更好。"
  • "大多数程序员都不需要这个方法(指枚举的ordinal方法),他是设计成用于像EnumSet和EnumMap这种基于枚举的通用数据结构的,除非你在编写的是这类数据结构,否则最好完全避免使用ordinal方法。"
  • "如果类具有从客户端得到或返回到客户端的可变组件。类就必须保护性的拷贝这些组件。如果拷贝的成本受到限制,并且信任他的客户端不会不恰当的修改组件,就可以在文档中指明客户端的职责是不得修改受到影响的组件,以此来代替保护性拷贝"
  • "谨慎地选择方法的名称"
  • "不要过于追求提供便利的方法"
  • "避免过长的参数列表"
  • "要调用哪个重载(overloading)方法是在编译期做出决定的 重载方法(overloaded method)的选择是静态的,而对于被覆盖的方法(overridden method)的选择则是动态的"
  • "“能够重载方法”并不意味着就“应该重载方法”。一般情况下,对于多个具有相同参数数目的方法来说。应该尽量避免重载方法。"
作者简介
Joshua Bloch is a professor at Carnegie Mellon University. He was formerly the chief Java architect at Google, a distinguished engineer at Sun Microsystems, and a senior systems designer at Transarc. He led the design and implementation of numerous Java platform features, including the JDK 5.0 language enhancements and the Java Collections Framework. He holds a Ph.D. in computer science from Carnegie Mellon University and a B.S. in computer science from Columbia University.
目录
Preface
About the Author
Chapter 1: Introduction
Chapter 2: Creating and Destroying Objects
Chapter 3: Methods Common to All Objects

显示全部
用户评论
Java Programming Bible
读过2rd的人,diff ## Chapter 2 - Creating and Destroying Objects - Item 5: Prefer dependency injection to hardwiring resources. 优先用框架支持(Spring)依赖注入,而不是手写单例 - Item 9: Prefer try-with-resources to try-finally. Java 7 特性,语法糖 ## Chapter 4 - Classes and Interfaces - Item 21: Design interfaces for posterity. interface default 实现,大家都会的 - Item 25: Limit source
对着第二版的笔记, 把第三版英文版撸了一遍. 确实英文版的体验很不一样. 有些内容比如并发和序列化, 还需要在实践中多运用体会一下.
相见恨晚,非Java程序员也可以算必读书之一了。
很不错,中阶java书籍,在当下版本也比较新
大家回头看看自己以前写的代码,都会无地自容,想要头顶内裤跳海,我以为这是天才特有的折磨,其实大家都一样,区别嘛,无非是飞机经过,飞行员看到大家的内裤,就会笑着对副驾驶说:看,内裤!而看到我的内裤时,可能会大吃一惊,连忙比照航图:什么时候多出来一个岛?
不写Java也要看
很棒 但是套话有点多……
mark工具书那个凡味就上来了😰
Java进阶很棒的一本书籍
收藏