Good code than lengthy documents.
1. File Encoding
Source file encoding format is UTF-8.
2. The package name in lowercase letters
3. import Do not use wildcards
That is, do not appear like this import statement: import java.util *;.
4. The column length limit
A project can select a row or column 80 character limit of 100 characters, the column length limit is exceeded wrap, for at least four rows indented spaces to indent Do not use tab.
Comments should be concise, critical of the code should have annotations, which can not mislead the reader.
6. The variable declaration
A time to declare a variable, do not use a combination of statements, such as int a, b;
We need only declare a variable, and initializes as soon as possible.
7. Naming Convention
Naming should: See the name to know Italy, concise, avoid spelling and English mix.
Class names are written in the style UpperCamelCase
Const field names, method names, parameter names, local variable names to write lowerCamelCase style
Constant names are written in the style CONSTANT_CASE
8. The order of class members
Each class should be some logic to sort its members, defenders should be able to explain the logic of this sort. For example, the new method does not habitually added to the end of the class.
9. caution System.out.println ()
Use log rather than System.out.println ()
10. Use braces (even optional)
Braces and if, else, for, do, while statements used together, even if only one statement (or empty) should also be written on the braces.
11. reduce code nesting
When the code is nested hierarchy of three or more layers, the average person will be difficult to understand.
There are many ways to reduce nesting: (1) The terms of the merger; (2) use to return later omitted else; (3) the use of sub-method
12. Exception Handling
Caught exception can not be ignored, the typical response mode is to print the log