-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
185b8b4
commit 951aee5
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
## 代码规范(Java) | ||
|
||
- 缩进 | ||
|
||
缩进使用4个空格(Tab) | ||
|
||
- 变量命名 | ||
|
||
变量名采用lowerCamelCase风格,使用驼峰命名法,变量名只包含字母和数字,首个单词首字母大写,后面单词首字母小写,有数字的话在最后。使用有意义的名字作为变量名方便阅读代码(作用域很小的临时变量使用 i、j、k....等命名方式),命名使用英文单词不使用拼音 | ||
|
||
- 每行最多字符数 | ||
|
||
一行最多只有一个语句,一行最多不超过100个字符 | ||
|
||
- 函数最大行数 | ||
|
||
单个函数最多包含50行代码 | ||
|
||
- 函数、类命名 | ||
|
||
函数命名采用lowerCamelCase风格,使用驼峰命名法,首个单词首字母大写,后面单词首字母小写,取有函数的功能作为函数名;类名采用UpperCamelCase风格,使用驼峰命名法,首字母大写,类名包含具体含义,可以指明一类事物。 | ||
|
||
- 常量 | ||
|
||
常量命名全部使用大写,单词之间使用‘ _ ’分隔 | ||
|
||
- 空行规则 | ||
|
||
不同的功能模块之间会留有空行,如函数之间,或函数内部不同部分之间会空行便于阅读。 | ||
|
||
- 注释规则 | ||
|
||
单行注释用//,短的注释直接跟在语句后面,长的注释另起一行 | ||
|
||
多行注释使用/**/ | ||
|
||
- 操作符前后空格 | ||
|
||
操作符前后均留有一个空格 | ||
|
||
- 其他规则 | ||
|
||
... |