Parsing the technique of writing error-free code using C + + _c language

Source: Internet
Author: User

The best way to write error-free code is to put prevention errors first.

1, the null statement after the statement question?

A while statement is a circular statement that sometimes requires null statements and sometimes no empty statements. In order to avoid misuse of statements
We specify that when a while uses an empty statement, the following methods are used:
while (*pchto++ = *pchfrom)
NULL;
The advantage of using NULL is that the compiler does not generate the code for the task for the null statement, because NULL is just a constant.
2. Use lint to find out the errors that the compiler missed
3, if there is unit testing, the unit test
4, both maintenance of the delivery version of the program, but also maintain the debug version of the program.
5, to use the assertion of the function parameters to confirm
6, to remove the undefined feature from the program or use assertions in the program to check out the illegal use of undefined attributes.
7, do not waste other people's time--detailed description of unclear assertions
8, eliminate all implicit assumptions, or check their correctness with assertions
9. Use assertions to check for situations that cannot happen
10, in the error-proofing design, do not hide the wrong
11, to use different algorithms to confirm the results of the program
12, do not wait for errors to occur, to use the initial check program

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.