1. 类的命名使用名词
2. 接口的命名使用名词或形容词,例如 Runnable ,Accessable
3. 用复数表示提供静态方法的类,如Beans ,Types
4. 方法的命名使用动词
5. 变量的命名使用名词
6. 集合变量使用复数命名,如 Vector orderItems;
7. 使用this关键字标识对象属性,使其与局部变量区分
8. 常量命名,大写+下划线,如MAX_VALUE
9. 使用C风格的注释来注解暂时不用的方法 /**/
10. 在注释的描述性文字以及java doc标签中保留空行,如
/**
* Descriptive text for this entity.
*
* @tag Descriptive text for this tag.
*/
11. java doc 标记
<code></code>标记包名、类名、字段名
<pre></pre>告诉浏览器保留原有格式,一般用于注释代码
{@link #Flag(String)}在文档中提供超链接
类或接口的一般注释为:
/**
* Description.
*
* @author
* @version
*
* @see
* @since
* @deprecated
*/
方法一般注释格式为:
/**
* Description.
*
* @param
* @return
* @exception
*
* @see
* @since
* @deprecated
*/
11. 使用统一的标签标注未解决的问题,如:
// :UNRESOLVED: EBW, 11 July 1999
// This still does not handle the case where
// the input overflows the internal buffer!!
12. 对于没有break的switch语句加入注释//Fall through!