Improve software quality----consistency

Source: Internet
Author: User

Improve software quality----consistency

Moakap

One important criterion in designing and writing programs is consistency. Consistency is when you have a set of functions, such as all the member functions of a class, and the design of function names and parameters should be consistent. This is also the beginning of good turning skills.

The simplest example, for example, is to design two member functions, respectively, to set the length and width of the rectangle. The function that sets the length we define as BOOL SetLength (float L);

So, to set the wide function we should not write the BOOL setw (float W); or bool Setwide (float W); Instead, you should keep the function name consistent and set to BOOL SetWidth (float W).

Similarly, this consistency criterion should be maintained for function parameters, return values, and so on.

In addition, consistency is not limited to functions, it also includes the naming of a set of related classes, the type of member functions, and so on. Following a consistent design program can greatly increase the readability and programming efficiency of the 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.