JAVA code development specification
- 2020-05-30 20:03:07
- OfStack
1. Development tool specification:
1. The development tool was determined after debugging by the project leader.
2. Development tool 1 is determined that it is not allowed to integrate any non-1 plug-in. If necessary, it will be added to the project team members with the approval of the project leader.
3. The coding format of development tools is not allowed to be modified.
2. Typesetting specification:
1. Add a space between the keyword (or variable) and the operator. For example, int iCont = 1; There is a space between the // operator and the value.
2. Add blank lines between relatively independent code blocks. For example, two methods need to be separated by a space.
3. Long statements, expressions, etc. should be written in multiple lines.
4. The long expression divides the new line at the low-priority operator, which is placed at the beginning of the new line.
5. The new line of the code and the previous line should be indented according to the logical relationship (1 table key) to make the layout neat and the sentences easy to read.
6. It is not allowed to write more than one phrase in one line, that is, only one statement in one line.
7. Indent the code at the beginning of a function or procedure, in the definition of a structure, in a loop, in a judgment, etc. Use the TABLE key to indent.
8. If there are long expressions or statements in the statements such as loop, judgment, etc., the appropriate division should be carried out.
9. If the parameters of a function or procedure are long, partition them appropriately.
10. When defining a one-paragraph block with curly braces' {' and '}', the block should be written with '{' and'}' each exclusive 1 row and in the same column, left-aligned with the statement that references them. The above indentation is used at the beginning of the body of the function, in the definition of the class, in the definition of the structure, in the definition of the enumeration, and in the if, for, do, while, switch, case statements.
JAVA code development specification (WISHSOFT)
11. main method: if the main(String[]) method is already defined, it should be written at the bottom of the class.
3. Naming specifications:
1. Name of Package(package)
The names of Package should all be made up of one lowercase word. For example: package com. wish;
2. Name of Class
The name of Class must be a word that begins with an uppercase letter and all other letters are lowercase, and for all identifiers, its
All the words contained in "1" should be next to "1" and capitalized with the first letter of the middle word. Such as:
public class DatabaseOperator {
}
3. The name of a named variable for a member variable in Class must begin with a lowercase letter, followed by a word that begins with an uppercase letter, and does not need to precede the data type
Compose. For example: userName size.
4. Name of the variable Static Final in Class
The name of the static Final variable should be capitalized and indicate the full meaning.
Such as:
public static final String DB_CONFIG_FILE_PATH ="com.neu.etrain.dbconfig";
5. The name of the method in Class must start with a lowercase letter, followed by an uppercase letter. For example :setName(), getMethod().
6. Use meaningful parameter names in the method declaration and, if possible, the names of fields like 1 to assign. Such as:
public void setCounter(int size)
{
JAVA code development specification (WISHSOFT)
this.size = size;
}
7. Name of variables within the method
Name of a member variable in Class.
8. Array naming
Arrays should always be named in the following way: byte[] buffer; Instead of: byte buffer[];
9. The variable of the number of lists per page in paging is pageSize, and the current page number is pageNumber.
4. Annotation specification:
1. Keep your notes simple and concise.
2. Comment while writing the code, modify the code and modify the corresponding comments at the same time, so as to ensure the 1 consistency between the comments and the code.
3. Comment where necessary and in moderation. The content of the comments should be clear, clear, accurate in meaning, to prevent the meaning of note 2. Keeping comments next to the code they describe is the proximity principle for comments.
4. The comments of variables and constants should be placed in the adjacent positions above or to the right, not below.
5. Global variables should be commented in detail, including their functions, value ranges, which functions or procedures access them, and what should be noted when saving.
6. Class and method comments are automatically generated by eclipse.
When the declaration of a class or method is completely written, the system will automatically generate their annotation template after typing :/** at the top of the class or method (no space allowed) in the English input method state. We only need to fill in the corresponding explanatory text.
7. Description of specific requirements:
n declarative (variable definition class)1 must have comments. For example: String myName; // user name n class definition must generate documentation (JavaDoc) annotations.
The n method must generate documentation (JavaDoc) comments (including the set, get methods of the entity class). The n member variable must generate documentation (JavaDoc) comments.
The logic part of the n method is written by the programmer according to the complexity.
8. Annotation information of class definition, including: author; Date; Module function description (such as function, main algorithm, internal parts
The relationship between the division, the relationship between the document and other documents, etc.); Historical modification record of this document; Version information, etc.
/**
* for what purpose (descriptive information)
JAVA code development specification (WISHSOFT)
* @author lifw20080320
* @modify lifw20080321
* @modify lifw20080322 (if you have multiple, write multiple @modify) * @copyright wishsoft
**/
9.javadoc annotation tag syntax
The description of the class by @author identifies the author who developed the module
The @version description of the class indicates the version of the module for that class
Reference to @see's description of classes, properties, and methods, that is, @param's description of methods -- a description of a parameter in a method
Description of a method description of a method's return value
Method description @exception explains the exceptions that the method might throw
5. Basic data type prefix table (other object types, supplement at any time):
Java 中数据类型 |
数据类型前缀 |
int |
i |
String |
str |
char |
c |
long |
l |
float |
f |
double |
d |
boolean |
b |
short |
s |
byte |
byte |
vector |
v |
6. Specification for use of log components (log4j)
1. Use of methods in Log:
a) log.debug () is placed in the middle of a line of code and used for debugging output.
b) log.error () is used to output error exception information in try{}catch(){} catch part.