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,特此记录下自己所体会到的东西,写篇博文会更加的加深印象,如有理解有误的地方,希望不吝赐教. 这章主题主要是介绍:何时以及如何创建对象,何时以及如何避免创建对象, ...
随机推荐
- Cocos2d-x SpriteFrameCache的使用
根据官方文档与其他c++属性实现的类似书中示例: 图中的小人是会动的. 首先使用texturepacker制作出一张拼图,导出plist等文件: plist类似: 3.x的cocos似乎不再鼓励使用什 ...
- sed用例
文件空行处理 1. 在文件中的每一行后面添加一个空行. sed 'G' test.txt 解释: Get命令是将保留空间的内容取出,并添加到当前模式空间的内容之后(添加一行).当保留空间为空时,效果为 ...
- .NET指定程序集的位置
有两种方法用来指定程序集的位置: 使用 <codeBase> 元素. 使用 <probing> 元素. 还可以使用 .NET Framework 配置工具 (Mscorcfg. ...
- 浅谈DOM性能考虑
浅谈DOM性能考虑 很多人都会忽视脚本对Web应用整体性能的影响.为保证应用的流畅运行,在为文档编写和应用脚本时,需要注意一些问题.一.尽量减少访问DOM和尽量减少标记 访问DOM的方式对脚本性 ...
- 警惕SQL语句陷井
以下SQL段,大家认为结果是什么呢? DECLARE @A VARCHAR(50) SET @A='Zuowenjun.cn' SELECT TOP 1 @A=ISNULL(FIELDNAME,'DE ...
- Android、iOS和Windows Phone中的推送技术
推送并不是什么新技术,这种技术在互联网时代就已经很流行了.只是随着进入移动互联网时代,推送技术显得更加重要.因为在智能手机中,推送从某种程度上,可以取代使用多年的短信,而且与短信相比,还可以向用户展示 ...
- Logger.getLogger和LogFactory.getLog的区别
Logger来自log4j自己的包.如果用Logger.getLogger,需要一个log4j的jar包,用此方式你只能依靠log4j: LogFactory来自common-logging包.如果用 ...
- [新手学Java]使用beanUtils控制javabean
使用BeanUtils设置/读取属性的值以及默认支持的自动转化: @Test //使用BeanUtils设置/读取属性的值以及自动转化 public void test1() throws Illeg ...
- 缺少google api密钥,因此chromium的部分功能将无法使用”的解决办法
使用Chromium时会遇到 "缺少google api密钥,因此chromium的部分功能将无法使用"提示,google了一下 setx Google_API_K ...
- 线段树或树状数组---Flowers
题目网址:http://acm.hdu.edu.cn/showproblem.php?pid=4325 Description As is known to all, the blooming tim ...