Notes for writing Ruby code Annotations:

Source: Internet
Author: User

Notes for writing Ruby code Annotations:


Write the code of the self-explanatory document and let this part rest. This does not mean playing.
Write comments in English.
Use a space to separate comments from symbols.
When more than one word is commented, the first sentence should be capitalized and punctuation marks should be used. Use a space after the end

Avoid unnecessary comments.

  # bad  counter += 1 # increments counter by one

Update comments at any time. No comments are better than expired ones.

Do not write comments for bad code. Refactor them to make them "self-explanatory ". (Do or do not-there is no try .)

The annotation should be written above the relevant code.
The annotation keyword is followed by a colon and space, and then a record describing the problem.

If multiple lines are required to describe the problem, the subsequent lines must be indented with two spaces after.

  def bar   # FIXME: This has crashed occasionally since v3.2.1. It may   # be related to the BarBazUtil upgrade.   baz(:quux)  end

If the problem is obvious, any document will be redundant. Annotations can also be (non-compliant) at the end of the line without any remarks. This usage should not be generally used or a rule.

  def bar   sleep 100 # OPTIMIZE  end

Use TODO to comment on missing features or add features later.

Use FIXME to note the code to be fixed.

Use OPTIMIZE to note slow or inefficient code that may cause performance problems.

The use of HACK to comment on the use of problematic code may need to be reconstructed.

Use REVIEW to note the code that requires repeated check and confirmation. For example, REVIEW: Are you sure how the client completes X correctly?

Use another custom keyword if you think it is appropriate, but make sure that it is specified in your project's README or similar.

Related Article

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.