慧与-济宁国际软件人才及产业基地 Java开发代码、注释规范
目录
1. 介绍......................................................................................................................................4
2. 命名规范...............................................................................................................................5
2.1. 项目命名规范 .......................................................................................................................5
2.2. 包命名规范 ...........................................................................................................................5
2.3. 类和接口命名规范 ................................................................................................................5
2.4. 方法命名规范 .......................................................................................................................5
2.5. 变量命名规范 .......................................................................................................................6
2.6. 常量命名规范 .......................................................................................................................6
2.7. 单词缩写的应用....................................................................................................................7
3. 排版规范...............................................................................................................................8
3.1. 缩进规范...............................................................................................................................8
3.2. 空行使用规范 .......................................................................................................................8
3.3. 空格使用规范 .......................................................................................................................8
3.4. 分界符(大括号“{”和“}”) ...................................................................................................9
3.5. 代码长度.............................................................................................................................10
4. 注释规范.............................................................................................................................11
4.1. 注释符号.............................................................................................................................11
4.2. 类和接口的注释..................................................................................................................11
4.3. 类属性注释 .........................................................................................................................11
4.4. 方法注释.............................................................................................................................12
4.5. 注释与所描述内容进行同样的缩排 .....................................................................................12
4.6. 将注释与其上面的代码用空行隔开 .....................................................................................13
5. 语句规范.............................................................................................................................14
5.1. 简单语句.............................................................................................................................14
5.2. return语句 ..........................................................................................................................14
5.3. 组合语句.............................................................................................................................14
5.4. if语句 ..................................................................................................................................15
5.5. switch语句..........................................................................................................................15
5.6. for语句................................................................................................................................16
5.7. while语句和do-while语句 ...................................................................................................16
5.8. try-catch语句 ......................................................................................................................16
6. 其他规范.............................................................................................................................18
6.1. 修饰符规范 .........................................................................................................................18
6.2. 声明规范.............................................................................................................................18