1. Comments for the "mandatory" class, class properties, class methods must use the Javadoc specification, use the/** content */format, and do not use
XXX way.
Note: In the IDE editing window, the Javadoc method will prompt related comments, generate Javadoc can correctly output the appropriate note
In the IDE, when the project calls the method, the method can be suspended without entering the meaning of the method, parameter, return value, improve
Reading efficiency.
2. "Force" all abstract methods (including methods in the interface) must be annotated with Javadoc, in addition to return values, parameters,
Exception description, you must also indicate what the method does and what functions are implemented.
Description: The implementation requirements for the child class, or the invocation considerations, please note.
3. "Enforce" All classes must add creator information.
4. The "force" method inside a single line comment, a line above the comment statement, using//comment. Method Inner Multiline Comment
Use the/* * */Note to align with the code.
5. "Force" all enum type fields must have a comment that explains the purpose of each data item.
6. "Recommended" and "Dabbler" in English to comment, it is better to use Chinese comments to clarify the problem. Proper nouns and keywords remain
English text can be.
Inverse example:"TCP connection Timeout" interpreted as "Transmission Control Protocol Connection Timeout", understanding instead of the brain.
7. The "recommended" code is modified, and the annotation is modified, especially the parameters, return values, exceptions, Core logic
and other modifications.
Description: The code is not synchronized with the comment update, just as the network is not synchronized with the navigation software update, if the navigation software is seriously lagging,
It loses the meaning of navigation.
8. The "Reference" commented out code as much as possible to match the description, rather than simply comment out.
Description: The code is commented out with two possibilities: 1) Subsequent recovery of this code logic. 2) Permanent use. The former if not
It is difficult to know the motive of the note. The latter suggests a direct deletion (the code repository holds the historical code).
9. "Reference" Requirements for annotations: first, the ability to accurately respond to design ideas and code logic; second, can describe the business including
So that other programmers can quickly understand the information behind the code. A large piece of code that is completely annotated is for the reader
The heavenly Book, the note is for oneself to see, even if a long time, also can clearly understand the thought of the time; comments are also for the successor
, so that it can quickly take over his job.
10. "Reference" good naming, code structure is self-explanatory, comments to streamline accurate, express in place. Avoid the appearance of comments
An extreme: too much excessive comment, once the logic of the code is modified, it is a considerable burden to modify the annotations.
Counter Example:
Put Elephant into fridge
Put (elephant, fridge);
The method name put, plus two meaningful variable names Elephant and fridge, has been explained what this is doing, the language
No additional annotations are required for the code that is clearly defined.
11. "Reference" special note mark, please indicate the mark and mark time. Note that these tags are processed in a timely manner, through tag scanning,
This type of markup is often cleaned up. On-line faults are sometimes the code that comes from these marks.
1) Todo (TODO): (tag person, mark time, [estimated processing time])
Represents a feature that needs to be implemented, but is not yet implemented. This is actually a Javadoc tag, the current Javadoc
has not yet been implemented, but has been widely used. Can only be applied to classes, interfaces, and methods (because it is a Javadoc label).
2) Error, unable to work (FIXME): (tag person, mark time, [expected processing time])
It is wrong to mark a code with FIXME in a comment, and it does not work and needs to be corrected in a timely manner.
Java Programming Specification-Annotation specification