Effective Java 56 Adhere to generally accepted naming conventions
Typographical naming conventions
|
Identifier Type |
Type Examples |
|
Package |
com.google.inject, org.joda.time.format |
|
Class or Interface |
Timer, FutureTask, LinkedHashMap, HttpServlet |
|
Method or Field |
remove, ensureCapacity, getCrc |
|
Constant Field |
MIN_VALUE, NEGATIVE_INFINITY |
|
Local Variable |
i, xref, houseNumber |
|
Type Parameter |
T, E, K, V, X, T1, T2 |
Grammatical conventions
|
Identifier Type |
Type Examples |
|
Package |
no rules |
|
Class or Interface |
Timer, BufferedWriter, or ChessPiece. Collection or Comparator. Runnable, Iterable, or Accessible. BindingAnnotation, Inject, ImplementedBy, or Singleton |
|
Method |
append or drawImage isDigit, isProbablePrime, isEmpty, isEnabled, or hasSiblings. size, hashCode, or getTime toType(toString, toArray) asType(asList) typeValue(intValue), static factories(valueOf, of, getInstance, newInstance, getType, newType) |
|
Field |
initialized, composite, height, digits, or bodyStyle |
|
Constant Field |
MIN_VALUE, NEGATIVE_INFINITY |
|
Local Variable |
i, xref, houseNumber |
|
Type Parameter |
T, E, K, V, X, T1, T2 |
Summary
Internalize the standard naming conventions and learn to use them as second nature. The typographical conventions are straightforward and largely unambiguous; the grammatical conventions are more complex and looser. To quote from The Java Language Specification [JLS, 6.8], "These conventions should not be followed slavishly if long-held conventional usage dictates otherwise." Use common sense.
Effective Java 56 Adhere to generally accepted naming conventions的更多相关文章
- Effective Java Index
Hi guys, I am happy to tell you that I am moving to the open source world. And Java is the 1st langu ...
- 《Effective Java》读书笔记 - 8.通用编程
Chapter 8 General Programming Item 45: Minimize the scope of local variables local variables应该在他们要被用 ...
- Effective Java 目录
<Effective Java>目录摘抄. 我知道这看起来很糟糕.当下,自己缺少实际操作,只能暂时摘抄下目录.随着,实践的增多,慢慢填充更多的示例. Chapter 2 Creating ...
- 【Effective Java】阅读
Java写了很多年,很惭愧,直到最近才读了这本经典之作<Effective Java>,按自己的理解总结下,有些可能还不够深刻 一.Creating and Destroying Obje ...
- [Effective Java]第八章 通用程序设计
声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...
- Effective Java通俗理解(下)
Effective Java通俗理解(上) 第31条:用实例域代替序数 枚举类型有一个ordinal方法,它范围该常量的序数从0开始,不建议使用这个方法,因为这不能很好地对枚举进行维护,正确应该是利用 ...
- 《Effective Java(中文第二版)》【PDF】下载
<Effective Java(中文第二版)>[PDF]下载链接: https://u253469.pipipan.com/fs/253469-230382186 Java(中文第二版)& ...
- Effective Java 第三版——39. 注解优于命名模式
Tips <Effective Java, Third Edition>一书英文版已经出版,这本书的第二版想必很多人都读过,号称Java四大名著之一,不过第二版2009年出版,到现在已经将 ...
- 如何创建和销毁对象(Effective Java 第二章)
最近有在看Effective Java,特此记录下自己所体会到的东西,写篇博文会更加的加深印象,如有理解有误的地方,希望不吝赐教. 这章主题主要是介绍:何时以及如何创建对象,何时以及如何避免创建对象, ...
随机推荐
- jQuery对Table一个字段排序
最近做一个机票的系统,要对航班信息进行排序,所以整理了一下,把排序的方法写下来. 首先table的结构大概如下 最后显示的样式为 首先在每一个tr上加一个自定义属性:data-sort-field-f ...
- Week4 结对编程
1.照片 1.1 结对编程参与者:李文涛.黎柏文 1.2 展示照片 2.结对编程的优点&缺点 2.1 优点 2.1.1.两人分工合作,减少了工作量 2.1.2.结对编程的伙伴往往能提供不同 ...
- Mybatis choose (when, otherwise)标签
choose标签是按顺序判断其内部when标签中的test条件出否成立,如果有一个成立,则 choose 结束.当 choose 中所有 when 的条件都不满则时,则执行 otherwise 中的s ...
- JavaScript--DOM修改元素的属性
一旦你获得了要修改的元素,可以有2种方式,来读取和修改它的属性:一种老的方式(它被更多的用户代理所支持)和一种新的DOM方法的方式.老的和新的用户代理都允许你以对象属性的方式获取和设置元素的属性. 先 ...
- 2015 Multi-University Training Contest 1 - 1001 OO’s Sequence
OO’s Sequence Problem's Link: http://acm.hdu.edu.cn/showproblem.php?pid=5288 Mean: 给定一个数列,让你求所有区间上满足 ...
- Linux - root初始密码设置
Ubuntu刚安装后,不能在terminal中运行su命令,因为root没有默认密码,需要手动设定. 以安装ubuntu时输入的用户名登陆,该用户在admin组中,有权限给root设定密码. 给roo ...
- 2. npm 的使用
NPM是随同NodeJS一起安装的包管理工具,能解决NodeJS代码部署上的很多问题,常见的使用场景有以下几种: 允许用户从NPM服务器下载别人编写的第三方包到本地使用. 允许用户从NPM服务器下载并 ...
- 重新想象 Windows 8.1 Store Apps 系列文章索引
[源码下载] [重新想象 Windows 8 Store Apps 系列文章] 重新想象 Windows 8.1 Store Apps 系列文章索引 作者:webabcd 1.重新想象 Windows ...
- 与众不同 windows phone (45) - 8.0 语音: TTS, 语音识别, 语音命令
[源码下载] 与众不同 windows phone (45) - 8.0 语音: TTS, 语音识别, 语音命令 作者:webabcd 介绍与众不同 windows phone 8.0 之 语音 TT ...
- SignalR+Asp.net高频率实时消息传递应用
1.概述: 使用 ASP.NET 和SignalR 2高频率的实时消息功能.高频率消息在这种情况下就意味着更新发送以固定的速率; 本教程中创建的应用程序显示一个用户可以拖动的形状.在所有其他连接浏览器 ...