Discussion on the programming style 2

Source: Internet
Author: User

Second, the naming rule:

1. Naming rules for variable names

The naming rules for ① and variables require "Hungarian law". That is, the beginning of the letter with the type of variable, the remainder of the variable in the English meaning or the abbreviation of its English meaning, as far as possible to avoid using Chinese pinyin, the first letter of the word should be capitalized.

That is: variable name = variable type + The English meaning of the variable (or abbreviation)

For a variable that is not generic, add a comment description at the time of the definition, and the variable definition can be placed at the beginning of the function as much as possible.

See table below:

BOOL (BOOL) with B opening bisparent

Byte (byte) Byflag by Start

Short (int) begins with n Nstepcount

Long (long) beginning with L Lsum

char (char) begins with C Ccount

Float (float) begins with F Favg

Double (double) with D opening Ddeta

void (void) begins with V Vvariant

unsigned short (WORD) starts with W Wcount

unsigned long (DWORD) begins with DW Dwbroad

HANDLE (HINSTANCE) begins with H Hhandle

DWORD begins with DW Dwword

LPCSTR (LPCTSTR) begins with Str strstring

With the 0 end of the string with the SZ opening szFileName

Propose and give a naming recommendation to the Technical Committee for the type of variable not given.

The basic principles for naming ② and pointer variables are:

The basic principles for a pointer variable are:

"P" + Variable type prefix + naming

such as a float* type should be expressed as Pfstat

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.