Good Programming habits in C Language (4)

Source: Internet
Author: User

1. Try to reduce the memory overhead when writing a program.

2. The content of the comment should be clear and accurate, so as to prevent ambiguity.

3. Do not use abbreviations for comments.

4. The comments should be similar to the described code, and the comments to the code should be placed at the top or right of the Code.

5. Using indentation to write programs can reduce unnecessary syntax errors and facilitate debugging.

6. When editing a C program that implements certain functions, you must first have a clear idea, such as what functions need to be implemented. What is the key. How to control the statement flow. Although it may not be written out, I should at least be aware of it.

7. develop the habit of writing and debugging.

8. check whether any compilation error is caused before compilation to avoid wasting time.

9. It is a good programming habit to avoid recursion in environments with high operational efficiency requirements. Because recursion has irreparable defects in time complexity.

10. Define as few parameters as possible for the function, which looks concise and easy to read and maintain.

11. execute some important cleanup tasks in the program after exiting the main function, so as to avoid making the program unavailable too early, it also provides convenience for unified cleaning and code maintenance.

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.