《Effective Java》目录摘抄。
我知道这看起来很糟糕。当下,自己缺少实际操作,只能暂时摘抄下目录。随着,实践的增多,慢慢填充更多的示例。

Chapter 2 Creating and Destroying Objects

  • Consider static factory methods instead of constructors
  • Consider a builder when faced with many constructor parameters
  • Enforce the singleton property with a private constructor or an enum type
  • Avoid creating unnecessary objects
  • Eliminate obsolete object references
  • Avoid finalizers

Chapter 3 Methods Common to All Objects

  • Obey the general contract when overriding equals
  • Always override hashCode when you override equals
  • Always override toString
  • Override clone judiciously
  • Consider implementing Comparable

Chapter 4 Classes and Interfaces

  • Minimize the accessibility of classes and members
  • In public classes, use accessor methods, not public fields
  • Minimize mutability
  • Favor composition over inheritance
  • Design and document for inheritance or else prohibit it
  • Prefer interfaces to abstract classes
  • Use interfaces only to define types
  • Prefer class hierarchies to tagged classes
  • Use function objects to represent strategies
  • Favor static member classes over nonstatic

Chapter 5 Generics

  • Don't use raw types in new code
  • Eliminate unchecked warnings
  • Prefer lists to arrays
  • Favor generic types
  • Favor generic methods
  • Use bounded wildcards to increase API flexibility
  • Consider typesafe heterogeneous containers

Chapter 6 Enums and Annotations

  • Use enums instead of int costants
  • Use instance fields instead of ordinals
  • Use EnumSet instead of bit fields
  • Use EnumMap instead of ordinal indexing
  • Emulate extensible enums with interfaces
  • Prefer annotations to naming patterns
  • Consistently use the Override annotation
  • Use marker interfaces to define types

Chapter 7 Methods

  • Check parameters for validity
  • Make defensive copies when needed
  • Design method signatures carefully
  • Use overloading judiciously
  • Use varargs judiciously
  • Return empty arrays or collections, not nulls
  • Write doc comments for all exposed API elements

Chapter 8 General Programming

  • Minimize the scope of local variables
  • Prefer for-each loops to traditional for loops
  • Know and use the libraries
  • Avoid float and double if exact answers are required
  • Prefer primitive types to boxed primitives
  • Avoid strings where other types are more appropriate
  • Beware the performance of string concatenation
  • Refer to objects by their interfaces
  • Prefer interfaces to reflection
  • Use native methods judiciously
  • Optimize judiciously
  • Adhere to generally accepted naming conventions

Chapter 9 Exceptions

  • Use exceptions only for exceptional conditions
  • Use checked exceptions for recoverable conditions and runtime exceptions for programming errors
  • Avoid unnecessary use of checked exceptions
  • Favor the use of standard exceptions
  • Throw exceptions appropriate to the abstraction
  • Document all exceptions thrown by each method
  • Include failure-capture information in detail messages
  • Strive for failure atomicity
  • Don't ignore exceptions

Chapter 10 Concurrency

  • Synchronized access to shared mutable data
  • Avoid excessive synchronization
  • Prefer executors and tasks to threads
  • Prefer concurrency utilities to wait and notify
  • Document thread safety
  • Use lazy initialization judiciously
  • Don't depend on the thread scheduler
  • Avoid thread groups

Chapter 11 Serialization

  • Implement Serializable judiciously
  • Consider using a custom serialized form
  • Write readObject methods defensively
  • For instance control, prefer enum types to readResolve
  • Consider serialization proxies instead of serialized instances

Effective Java 目录的更多相关文章

  1. Effective Java目录

    创建和销毁对象 考虑用静态工厂方法代替构造器 遇到多个构造器参数时要考虑用构建器 用私有构造器或者枚举类型强化Singleton属性 通过私有构造器强化不可实例化能力 避免创建不必要的对象 消除过期的 ...

  2. Effective Java 第三版笔记(目录)

    <Effective Java, Third Edition>一书英文版已经出版,这本书的第二版想必很多人都读过,号称Java四大名著之一,不过第二版2009年出版,到现在已经将近8年的时 ...

  3. effective java —— 终结方法守卫者

    目录: effective java —— 终结方法守卫者 effective java 第2章:创建和销毁对象.第7条 : 避免使用终结方法.最后的“终结方法守卫者 (finalizer guard ...

  4. 《Effective Java(中文第二版)》【PDF】下载

    <Effective Java(中文第二版)>[PDF]下载链接: https://u253469.pipipan.com/fs/253469-230382186 Java(中文第二版)& ...

  5. Effective Java - 构造器私有、枚举和单例

    目录 饿汉式单例 静态常量 静态代码块 懒汉式单例 尝试加锁 同步代码块 双重检查 静态内部类单例 枚举单例 Singleton 是指仅仅被实例化一次的类.Singleton代表了无状态的对象像是方法 ...

  6. Java 高效编程(Effective Java)中文第三版(补档)

    来源:sjsdfg/effective-java-3rd-chinese <Effective Java, Third Edition>一书英文版已经出版,这本书的第二版想必很多人都读过, ...

  7. Effective java笔记(二),所有对象的通用方法

    Object类的所有非final方法(equals.hashCode.toString.clone.finalize)都要遵守通用约定(general contract),否则其它依赖于这些约定的类( ...

  8. 《Effective java》-----读书笔记

    2015年进步很小,看的书也不是很多,感觉自己都要废了,2016是沉淀的一年,在这一年中要不断学习.看书,努力提升自己!预计在2016年要看12本书,主要涉及java基础.Spring研究.java并 ...

  9. 《Effective Java》学习笔记——积累和激励

    从一个实际案例说起 国庆长假前一个礼拜,老大给我分配了这么一个bug,就是打印出来的报表数量为整数的,有的带小数位,有的不带,毫无规律. 根据短短的两个多月的工作经验以及猜测,最终把范围缩小到以下这段 ...

随机推荐

  1. 【RF库Collections测试】Set List Value

    Name:Set List ValueSource:Collections <test library>Arguments:[ list_ | index | value ]Sets th ...

  2. CentOS下安装vsftpd

    因为FTP的端口是 两个,一个是固定21端口,还有一个任意端口的数据通道.关键是任意端口不好搞. 首先在vsftpd的配置文件中设置 任意端口的范围 [root@localhost root]# vi ...

  3. Unity Animation需要Inspector右键打开Debug模式,然后勾选Legacy,最后再Inspector右键打开Normal

  4. U3D的控制

    做游戏少不了控制,但是一个成熟的游戏引擎,是不能简单仅仅获取键盘中或者遥感确定的按键来控制,要考虑到用户更改游戏按键的情况,当然也得考虑到不同设备的不通输入方式,比如U3D是可以运行在iphone上的 ...

  5. linux 开机自启脚本

    1.vi /home/dpf/mqtt.sh #!/bin/sh/home/dpf/Desktop/Udp_Single_Async_Mqtt_yuan/hwjc_udp_receive_mqtt & ...

  6. 使用Html和ashx文件实现其简单的注册页面

    记得上一次博客中实现的是其登录页面,其实学会了登录页面,注册页面自然就知道怎么写啦,都是一个意思的,但是今天不知道怎么个情况,写一个注册页面程序 中 一直在出错,大的问题小的问题一直出错,似乎是不在状 ...

  7. 关于linux下文件的权限问题

    今天在linux更新服务中的启动文件时,直接把更新的启动文件拷贝过来执行,报错:can't be execute 后来想了下列出了文件的详细信息中发现拷贝过去的执行文件是-r--r--r--(表示只有 ...

  8. 《C++ Primer Plus》第16章 string类和标准模板库 学习笔记

    C++提供了一组功能强大的库,这些库提供了很多常见编程问题的解决方案以及简化其他问题的工具string类为将字符串作为对象来处理提供了一种方便的方法.string类提供了自动内存管理动能以及众多处理字 ...

  9. Python pyQt4/pyQt5 学习笔记1(空白窗口,按钮,控件事件,控件提示,窗体显示到屏幕中间,messagebox)

    PyQt4是用来编写有图形界面程序(GUI applications)的一个工具包.PyQt4作为一个Python模块来使用,它有440个类和超过6000种函数和方法.同时它也是一个可以在几乎所有主流 ...

  10. oracle IMP-00085: 为无界导出文件指定了多个输入文件

    导入按表导出的数据的时候,提示为无界导出文件指定了多个输入文件 命令如下: imp user/user@database file=e:\test.dmp  提示信息: Import: Release ...