好书推荐 好书速递 排行榜 读书文摘

Effective Java

Effective Java
作者:Joshua Bloch
副标题:3rd Edition
出版社:Addison-Wesley Professional
出版年:2018-01
ISBN:9780134685991
行业:计算机
浏览数:82

内容简介

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

......(更多)

作者简介

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

Chapter 4: Classes and Interfaces

Chapter 5: Generics

Chapter 6: Enums and Annotations

Chapter 7: Lambdas and Streams

Chapter 8: Methods

Chapter 9: General Programming

Chapter 10: Exceptions

Chapter 11: Concurrency

Chapter 12: Serialization

Index

......(更多)

读书文摘

大多数程序员都不需要这个方法(指枚举的ordinal方法),他是设计成用于像EnumSet和EnumMap这种基于枚举的通用数据结构的,除非你在编写的是这类数据结构,否则最好完全避免使用ordinal方法。

如果类具有从客户端得到或返回到客户端的可变组件。类就必须保护性的拷贝这些组件。如果拷贝的成本受到限制,并且信任他的客户端不会不恰当的修改组件,就可以在文档中指明客户端的职责是不得修改受到影响的组件,以此来代替保护性拷贝

It is critical to check the validity of constructor parameters to prevent the construction of an object that violates its class invariants.

do not use the clone method to make a defensive copy of a parameter whose type is subclassable by untrusted parties.

......(更多)

猜你喜欢

点击查看