Java code annotation specification (power node sorting)

Code annotation is a communication bridge between program designers and program readers to maximize the efficiency of team development cooperation. It is also one of the important links of program code maintainability. So we don't write comments for comments. Let's talk about the code annotation specifications we use in our daily development for your reference.

1. Unified annotation form

Throughout the application, annotations are constructed using styles with consistent punctuation and structure. If you find that their annotation specifications are different from this document in other projects, write code according to this specification and do not try to introduce new specifications into the existing specification system.

2. The notes are accurate and concise

The content should be simple, clear and accurate, so as to prevent the ambiguity of notes. Wrong notes are not only useless but harmful.

Note condition:

1. Basic notes

(a) Annotation of class (Interface)

(b) Constructor comments

(c) Method comments

(d) Comments for global variables

(e) Comments for fields / attributes

Note: simple code can be annotated with no more than 10 words. In addition, getter and setter methods of persistent objects or VO objects do not need to be annotated. Please refer to the following examples for the specific annotation format.

2. Special notes are required

(a) Typical algorithms must be annotated.

(b) There must be comments where the code is unclear.

(c) Add comments on the modification identification at the code modification.

(d) Annotate the code consisting of loops and logical branches.

(e) Interfaces provided to others must be annotated in detail.

Note: there is no example of such note format. The specific annotation format is self-defined, and the annotation content is required to be accurate and concise.

Note format:

1. Single line comment: "/ /..."

2. Block comment: "/ *... * /"

3. Document comment: "/ * *... * /"

4. Javadoc annotation label syntax

@The author's description of the class indicates the author @ h who developed the class module_ 502_ 71 @ @ version the description of the class indicates the version @ h of the module_ 502_ 71 @ @ see refer to the related topic @ h for the description of classes, attributes and methods_ 502_ 71 @ @ param description of the method description of a parameter in the method @ h_ 502_ 71 @ @ return description of the method description of the returned value of the method @ h_ 502_ 71 @ @ exception describes the method and describes the exceptions that may be thrown by the method

Reference examples:

1. Class (Interface) notes

For example:

2. Construction method notes

For example:

3. Method notes

for example

4. Global variable annotation

For example:

5. Field / attribute notes

For example:

In fact, the norms are set by ourselves. As long as everyone in the team abides by them and unifies the norms, good results will be achieved. I hope it will be helpful to friends who usually don't add notes@ H_ 502_ 71@

The above is the Java code annotation specification (power node sorting) introduced by Xiaobian. I hope it will be helpful to you. If you have any questions, please leave me a message, and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>