Programming Languages-Comments

Source: Internet
Author: User
Tags comments documentation
1. Annotation analogy life
Use the examples in your life to compare the comments in the code, the Minutes the meeting was made, and the minutes of the meeting. When someone needs to see the content of the meeting, whether he is involved or not, he can quickly check the contents of the meeting. Imagine if there were no minutes, and 10 days later, everyone forgot to clean up. The function of the note is equivalent to the minutes of the meeting, giving a glimpse of what was going on at the time, how to discuss the problem, how to solve it, and how to decide. In the code, let others know what the code is used for, then why the code design, so the benefits of design and so on, or after a long time, very few people will remember the purpose of the code. Again, such as mobile phone product specification, it will be various keys, mobile phone existing functions in graphic and text form, even if the small white people, see the instructions in the text and illustrations can be played with the mobile phone. The notes are the text and illustrations in the product specification, and anyone can use the phone at any time and place, just look at them.

2. Why does the note exist?
Through the above analogy, the existence of annotations so that we do not have to worry about the code, even after a long time, take a look at the comments to know that the original code is the implementation of the function. Forget the phone a function how to use, open the product specification a look, no problem.

3. What is the comment.
Note is a memo and note, notes and notes are in some way the same, forget what this thing is doing, how to do it, how to design, how to think. Valuable comments will let us look at the same to solve their own inner doubts.

4. How the annotation is expressed.

Comments in the C language have single-line comments//and multiline comments/* * * * *, as implies, single-line comments can comment on one line, multiline comments can comment on multiple lines, and also include a row.


5. Comparison with Java
There are single-line comments//and multiline comments */* in Java, as well as documentation comments, which can generate comments for the API documentation, using/** */notation.

6. Annotations and Code execution
Comment To participate in code execution. This question is equivalent to the mobile phone playing music, mobile phone manual also sing. At the meeting, the minutes of the meeting were also discussed with you. It is only a reminder and a description of the role of the conference and mobile phone use will not be any direct intervention.

7. Comments are for people, the code is a computer, and we use annotations to see what the description code is.


If 0 basis see my blog, can understand the role of annotations, then my blog is valuable.

2016-09-20 First Revision

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.