Classification |
Importance |
Check items |
Note |
Named |
|
|
|
|
Important |
Whether the naming convention is consistent with the specification being used. |
member variables, method parameters and so on need to use the first letter lowercase, the remaining words in the first capital of the naming method, prohibit the use of an underscore (_) number and other ways to name Do not appear local variables, member variables, such as the beginning of capital problems |
|
So so |
Whether the minimum length maximum information principle is followed. |
Various naming as short as possible, the ideographic accuracy, except 2 instead of ' to ', 4 instead of ' for ', do not recommend the use of numbers in the naming |
|
Important |
Whether the function of the has/can/is prefix returns a Boolean type. |
member variables, method arguments, local variables, and so on, if has/can/is begins, remove these words |
|
Important |
Whether the class name has a duplicate problem. |
Your own implementation of the class as far as possible and other people's class name, although not under the same package, especially the subclass and the parent class name of the case |
Comments |
|
|
|
|
Important |
Whether the comment is clear and necessary. |
Method Javadoc Note that the parameters, return values and exception descriptions need to be explained, parameter description should be in accordance with the parameter name and the intention of the corresponding labeling |
|
Important |
Whether the complex branching process has been commented. |
|
|
So so |
If the distance is longer, the} has been commented. |
|
|
Important |
Whether the function already has a document comment. (function, input, return and other optional) |
Files, classes (including interfaces, enumerations, etc.), member variables, Javadoc comments required before methods |
|
So so |
Whether the special usage is commented. |
|
Declaration, blank, indent |
|
|
|
|
So so |
Whether only one variable is declared for each row. (especially those types that may be wrong) |
|
|
Important |
Whether the variable has been initialized at the same time as defined. |
|
|
Important |
Whether the class properties are initialized. |
|
|
So so |
Whether the code paragraph is properly delimited by a blank line. |
|
|
So so |
Is it reasonable to use a space to make the program clearer. |
The space characters in the basic code format are indispensable, and these spaces appear in the?,:, +,-, *,/,=,==,>,<,>=,<=,!=, and various parentheses around |
|
Tips |
Whether the line length of the code is within the requirement. |
No more than 120 characters per line |
|
Important |
Controller,service, do not declare a stateful variable in DAO. |
This variable cannot be modified. If modifications are to be made, they must be controlled by a lock. |
|
So so |
The wrapping is appropriate. |
|
|
So so |
Whether the collection is defined as a generic type. |
When defining a collection, it is recommended to define its generic type, reducing type conversions and warning errors |
Statement/function Distribution/scale |
|
|
|
|
So so |
Whether the {} containing the compound statement appears paired and conforms to the specification. |
|
|
Important |
Whether to add {} to a single loop, condition statement. |
If,else,else if,while,for,case such as code blocks must be surrounded by {} |
|
So so |
Whether a single variable is only used for a single purpose. |
|
|
Important |
Whether a single line has only one function. (Do not use; Make multiple-line merges) |
|
|
Important |
Whether a single function performs a single function and matches its name. |
|
|
So so |
operator + + and--the application of the operator conforms to the specification. |
|
Scale |
|
|
|
|
Important |
A single function does not exceed the specified number of lines. |
|
|
Important |
Whether the indent layer does not exceed the specified number. |
|
Reliability (General/variable and statement) |
|
|
|
|
Important |
Whether all warnings have been eliminated. |
Warnings for development tools |
|
Important |
Whether the constant variable is declared final. |
|
|
Important |
Whether the object was checked before it was used. |
|
|
Important |
Member variable, whether the local variable is assigned before it is used. |
Objects that are initialized to null must be re-assigned before they are called, and if the assignment statement is in a try block, the call operation must be in the try Block |
|
So so |
Whether the local object variable is reset to null after it is used. |
In particular, the array collection Map |
|
Important |
Whether access to the array is secure. (The legal index value is [0, max_size-1]). |
|
|
Important |
Are you sure that there are no local duplicate definitions of variables with the same name? |
Local variable names and class or object member variables with the same name are strictly forbidden |
|
So so |
Only simple expressions are used in the program. |
|
|
Important |
Whether or not the operator precedence has been clarified with (). |
|
|
Important |
All judgments are used (constant = = variable or constant. Equals (variable)) in the form. |
Constants can be effectively lowered before the comparer to write assignment statements, reducing NULL pointer exceptions |
|
Important |
Whether each If-else If-else statement has the last else to ensure that the complete work is handled. |
|
|
Important |
Whether each Switch-case statement has the last default to ensure that the complete collection is processed. |
|
|
So so |
Whether the For loop uses a form that contains a lower bound without a cap. (k=0; K<max) |
|
|
Important |
is the XML markup writing complete and the string spelled correctly? |
|
|
Important |
Is there a finally action to close the stream object for the exception capture of the stream operation code? |
You need to determine if the stream object is empty before closing |
|
Tips |
Did you dispose of the temporary object when exiting the code snippet? |
|
|
Important |
Whether it is appropriate to determine the equality of floating-point numbers. |
It is strictly forbidden to use = = directly judge floating point value. Provides a common approach |
|
Important |
Equals is used for object comparisons. |
Objects (including wrapper classes) must be compared using equals instead of = = or! = Operations |
|
Important |
Ensures that the two object types that are compared are consistent when compared using equals. |
The objects that are compared by the Equals method are recommended for the same type if the object type is determined, such as Integer and "" Using Equals is not advocated |
|
So so |
Manipulate the map or properties structure object to define the key as a constant when passing values. |
The key of the Setattribute,getattribute method for objects such as Session,request is recommended to use constants and not to enter strings manually |
|
Important |
Whether type compatibility is ensured prior to type conversion. |
Unless explicitly guaranteed object type |
|
Important |
Whether the packaging class is guaranteed non-empty before making a simple budget. It is recommended that you use wrapper classes. |
A non-null (null! = XX) judgment is recommended to prevent null pointer exceptions before the wrapper class is manipulated |
|
Important |
Whether the object property is correctly assigned before it is used. |
Read-only property (a member variable that provides only a Get method) unless a fixed value is deliberately returned, you must provide a set method or assign a value to another method call |
|
Important |
Whether there is a non-null judgment before the method call. |
A non-null judgment on a parameter must be present before the method call, otherwise the description may result in a null pointer or the latter judgment is not necessary, non-null judgment, which is provided by the caller by default |
|
Important |
Whether non-thread-safe objects are properly secured for threading. |
The Format method Call of the DateFormat instance is not thread-safe, and a similar situation is not appropriate for the use of the static definition, which is recommended using the Threadlocal method, see Unifiedcodegenerator |
|
So so |
Whether the same intent member variable uses the same naming. |
Different entities entity, VO, Bo represents the same meaning of the member variables, it is recommended to use the same name, try not to appear, some places with username, some places with username such circumstances |
Reliability (function) |
|
|
|
|
Important |
Whether the entry object has been judged is not empty. |
|
|
Important |
Whether the legal scope of the entry data has been judged. |
|
|
Important |
Try...catch protection is performed on methods that have exception throws. |
|
|
Important |
Whether all branches of a function have return values. |
|
|
Important |
Whether the return value of int is reasonable. (negative value is failure, non-negative value succeeds) |
|
|
So so |
For repeated int return values determine whether a function is defined for processing. |
|
|
So so |
Does the critical code do catch exception handling? |
|
|
So so |
The dictionary table defines whether an enumeration is used, or there is a uniform definition. |
|
|
Important |
Does a null check on the method return value object be initialized when the return value is defined? |
|
|
Important |
Do you have code synchronization for traversal access to the synchronization object? |
|
|
Important |
Confirm that there are no additions or deletions to the map object using the iterative traversal process. |
The map passes the increment and decrement element operation will throw the concurrentmodificationexception, does not propose the increment element operation to the collection object traversal. |
|
Important |
Is there an exception capture process inside the thread-handling function loop that prevents the thread from throwing an exception and exiting? |
|
|
Important |
Atomic operation code is abnormally interrupted, is the associated external variable used to restore the previous state? |
|
|
Important |
The function is appropriate for handling errors. |
|
|
Important |
Whether a log record or exception continues to be thrown after the exception is captured. |
It is recommended that the Exception log be logged if it cannot be processed after the exception is caught and needs to continue to be thrown |
|
Important |
Whether the construction method of the current object is not called in the constructor method |
It is forbidden to new a current object in the constructor method |
maintainability |
|
|