Java annotation Specification

Source: Internet
Author: User

The purpose of defining this specification is to make all the documents in the Project look as written by one person, increase readability, and reduce the loss caused by substitution in the project team. (These specifications are not always strictly observed, but must make the program readable ).

Java syntax is similar to C ++. Do you know how many Java annotations are there? Yes?

// Comment a row

/* ...... */Annotate several rows

Not completely correct. In addition to the above two types, there is also the third type. document notes:

/**... */Annotate several lines and write them into the javadoc document.

  1. Annotations must be simple and clear.
    String username = NULL; // User Name
  2. Write and annotate the code, modify the code, and modify the corresponding comments to ensure the consistency between the comments and the code.
  3. Note where necessary, the amount of comments should be moderate. The content of the comment must be clear, clear, and accurate.

    Comments. Keep comments adjacent to the code described by them, that is, the proximity principle of comments.

  4. Comments to the code should be placed in adjacent locations above it, and should not be placed below. Comment on the data structure should be placed in

    The adjacent positions above the structure cannot be placed below; comments to each field in the structure should be placed on the right of the field;

    Annotations for different domains in the same structure must be aligned.

  5. Comments of variables and constants should be placed on the adjacent positions or the right side above them.
  6. A global variable must have more detailed comments, including its functions, value ranges, and which functions or processes access it

    And precautions for access.

  7. Note the necessary information in the header of each source file, including the file name, version number, author, and generation date.

    Module function description (such as the function, main algorithm, the relationship between the internal parts, the file and other

    Main functions or process list and historical modification records of this file. Java code {
    DP. Sh. toolbar. copytoclipboard (this); Return false;
    } "Href =" http://jiajunde.javaeye.com/blog/359968# ">

    1. /**
    2. * Copy right information: Neusoft IIT
    3. * Project: etrain
    4. * JDK version used: jdk1.3.1
    5. * Comments: config path
    6. * Version: 1.01
    7. * Modification history: 2003.5.1
    8. * Sr date modified by why & what is modified
    9. * 1. 2003.5.2 Kevin Gao new
    10. **/
    /**   * Copy Right Information   : Neusoft IIT   * Project                        : eTrain   * JDK version used           : jdk1.3.1   * Comments                  : config path   * Version                       : 1.01   * Modification history     :2003.5.1   * Sr Date   Modified By   Why & What is modified   * 1. 2003.5.2 Kevin Gao     new   **/
  8. Comment information necessary before each function or process, including: function or process name; Function Description

    Description; Description of input, output, and return values; Description of call and called relationships

    Java code {
    DP. Sh. toolbar. copytoclipboard (this); Return false;
    } "Href =" http://jiajunde.javaeye.com/blog/359968# ">
    1. /**
    2. * Description: checkout withdrawal
    3. * @ Param hashtable cart info
    4. * @ Param orderbean order info
    5. * @ Return string
    6. */
    7. PublicString checkout (hashtable htcart, orderbean)ThrowsException
    8. {}
    /*** Description: checkout withdrawal * @ Param hashtable cart info * @ Param orderbean order info * @ return string */Public String checkout (hashtable htcart, orderbean) throws exception {}
  9. Javadoc annotation label syntax

    @ Author the description of the class indicates the author who developed the class module.
    @ Version the description of the class indicates the version of the class module.
    @ See references to classes, attributes, and methods, that is, related topics
    @ Param: Description of a parameter in the other method
    @ Return description of the method description of the return value of the Method

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.