Code cleanliness (3)

Source: Internet
Author: User
  1. Comments cannot beautify bad code
  2. Use code to describe your ideas
  3. What is a good comment?
    1. Legal information
    2. Provide information comments
    3. Explanation of intent
    4. Warning: for example, // don't run unless you have some time to kill
    5. Todo comments
    6. Javadoc for public APIs
  4. What are bad comments?
    1. Additional comments
    2. Misleading comments
    3. Track-based annotation: It is silly to say that every function requires javadoc to live and every variable requires annotations. Such annotations can only make the code messy.
    4. Log Annotation
    5. Nonsense comment: default constructor
    6. Too much information: Do not write anything in comments, and write all the details... My God.
Error Handling
  1. Use uncontrollable exceptions whenever possible
  2. Environment Description of exceptions
  3. Do not return NULL values
  4. Do not pass null values

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: 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.