内容摘要:
1 规格概要................................................................................................................................................3
1.1 目标.................................................................................................................................................3
1.2 设计原则.........................................................................................................................................3
2 命名规范................................................................................................................................................4
2.1 通用规则.........................................................................................................................................4
2.1.1 包(小写....................................................................................................................................4
2.1.2 类(((大小写字母混合组成,头字母大写。..........................................................................4
2.1.3 接口(大小写字母混合组成,头字母大写,常以"able"、"ible"结尾(。............................4
2.1.4 方法(大小写字母混合组成,第一个单词的首字母小写,其后单词的首字母大写。....4
2.1.5 变量、参数(小写(,不推荐使用下划线(,简短明晰。......................................................4
2.1.6 集合、数组(应该从命名中体现其复数的含义,例如加后缀 s 或前缀 some。................5
2.1.7 在定义类时,应该按照访问权限的大小分别排列属性和方法。.....................................5
2.2 ANDROID 规则................................................................................................................................5
2.2.1 ANDROID 的代码风格规则..................................................................................................5
2.2.2 JAVA 语言规则......................................................................................................................5
2.2.3 JAVA 库规则..........................................................................................................................5
2.2.4 JAVA 的风格规则..................................................................................................................6
2.2.5 JAVATESTS 样式规则...........................................................................................................6
2.2.6 JAVA 语言规则......................................................................................................................6
2.2.7 FINALIZERS..........................................................................................................................8
2.2.8 IMPORTS................................................................................................................................8
2.2.9 注释/JAVADOC......................................................................................................................8
2.2.10 简短的方法...........................................................................................................................9
2.2.11 局部变量.............................................................................................................................10
2.2.12 IMPORTS............................................................................................................................11
2.2.13 缩进.....................................................................................................................................11
2.2.14 域(FIELD)命名...................................................................................................................11
2.2.15 花括号.................................................................................................................................11
2.2.16 行长度.................................................................................................................................12
2.2.17 String.xml............................................................................................................................12
2.2.18 布局文件的命名规则.........................................................................................................12
2.2.19 单位使用.............................................................................................................................12
2.2.20 范例.....................................................................................................................................13
2.3 JAVA 1.5 的注解...........................................................................................................................15
2.3.1 ECLIPSE 代码格式化...........................................................................................................15
2.4 经验积累.......................................................................................................................................15