Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
W
wiki-java
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • Operations
    • Operations
    • Incidents
  • Analytics
    • Analytics
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • 老徐
  • wiki-java
  • Wiki
  • java code specification

java code specification · Changes

Page history
ulindows deleted page: JavaCodeSpecification authored Jun 13, 2016 by 老徐's avatar 老徐
Show whitespace changes
Inline Side-by-side
Showing with 28 additions and 1 deletion
+28 -1
  • java-code-specification.md java-code-specification.md +28 -1
  • No files found.
java-code-specification.md
View page @ 42d27077
### 1 简介 ### 1 简介
  对于软件开发遵循统一的规范,有利于增强代码的可读性,同时防范错误,更好的发挥所使用的语言的优点,提高工作效率。所以我们制定此编程规范,指导公司的编码活动。本规范适用于公司各个使用Java作为开发语言的项目,作为源程序编写的规范,必须遵守。使用其他语言所编写的程序,比如Perl,在不和所使用的语言冲突的情况下,可以参考本规范的要求来编写源程序。   对于软件开发遵循统一的规范,有利于增强代码的可读性,同时防范错误,更好的发挥所使用的语言的优点,提高工作效率。所以我们制定此编程规范,指导公司的编码活动。本规范适用于公司各个使用Java作为开发语言的项目,作为源程序编写的规范,必须遵守。使用其他语言所编写的程序,比如Perl,在不和所使用的语言冲突的情况下,可以参考本规范的要求来编写源程序。
  **参考资料**   参考资料
| 文档名称 | 作者 | 发布日期 | | 文档名称 | 作者 | 发布日期 |
...@@ -118,9 +118,36 @@ String yetAnotherArg, Object andStillAnother) ...@@ -118,9 +118,36 @@ String yetAnotherArg, Object andStillAnother)
``` ```
#### 4.4 一行只写一条语句 #### 4.4 一行只写一条语句
  **示例:**
  如下例子不符合规范:
```
rect.length = 0; rect.width = 0;
```
  应如下书写:
```
rect.length = 0;
rect.width = 0;
```
#### 4.5 if for do while等语句自占一行,其后无论执行语句多长,都应该使用{} #### 4.5 if for do while等语句自占一行,其后无论执行语句多长,都应该使用{}
  例外的情况是:如果存在多个if…else…语句并列,则else可以和if放在同一行。
  示例:
  如下的写法不合规范:
```
if (0 == a) return null;
```
  应该这样写:
```
if (0 == a)
{
return null;
}
```
#### 4.6 右大括号}要单独占一行,左大括号不作结强制规定,但在单个文件中要统一 #### 4.6 右大括号}要单独占一行,左大括号不作结强制规定,但在单个文件中要统一
  右大括号要单独占一行,并且和它的控制语句有相同的缩进。但也有例外:
  * **1. do-while循环中,}和while放在一行**
#### 4.7 代码行之间应该留有适当的空格 #### 4.7 代码行之间应该留有适当的空格
### 5 命名规范 ### 5 命名规范
#### 5.1 命名基本规范 #### 5.1 命名基本规范
......
Clone repository
  • git configuration and simple use
  • Home
  • java code specification
  • maven environment configuration
  • shuidi js develope
  • ucs_project environment configuration