C + + code naming recommendations

Source: Internet
Author: User

The core idea: to describe exactly what the variable represents.

A good name is usually the expression of what, not how.

The variable name is exactly 8 to 15.

If you want to add qualifiers, then add to the last. For example: Revenutotal or Revenueaverage.

Variables that are tags should not have "flag" and should use enumerations and named constants. ‘

The temporary variable is also called "tmp" and should reflect its purpose.

Some of the most useful Boolean variables are: Done, error, found, success, or OK.
such as: SourceFile replaced with Sourcfilefound.

Enumerations are best prefixed by the fact that the quantities belong to a group.

Especially for C + +:
1. I and J are integer subscripts.
2. P is a pointer.
3. Constants, typedef, and preprocessing macros all uppercase.
4. The variable name and function name use camel-style.
5. Do not underline, unless it is a g_val class.

C + + code naming recommendations

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.