Second week homework

Source: Internet
Author: User

There are now many ways to name it, please give examples.

1. Hungarian nomenclature

Presented by Microsoft programmer Charles Simonyi (Charles Simonyi).

The main idea is: To add a prefix to the variable and function names to facilitate people's understanding of the program.

Its name is: File name: "F" + name (capitalized), for example: FName.cpp

Constant name: "C" + name (all uppercase, multiple words with "_" connection), for example: #define C_MIN_NUM 20;

Variable name: prefix + First name (capitalized), for example: Char szName;

Function Name: Capitalize the first letter of each word, for example:int convertnumber (int ix);

struct type name: "_" + First name (all uppercase, multiple words with "_" connection); struct variable name: "m_" + First name (capitalized), such as:

typedef struct _DATABAS

{

Char m_ szproductname[20];

... ...

}dbs_database;

This naming method can easily identify variable types, for interface programming, relatively short functions or beginners are more practical. However, it is not suitable for strongly typed languages such as C #, which have strict requirements on types.

2. Camels (camel) nomenclature

Mix uppercase and lowercase letters to form the name of the identifier, the first letter in lower case, and the first letter of the remaining words capitalized. For example: Printemployeepaychecks ()

3. Pascal (PASCAL) nomenclature

Similar to the Camel nomenclature, but the first letter of Pascal's name is capitalized. For example: Printemployeepaychecks ()

In C #, Pascal's nomenclature and camel nomenclature are used more often, and even many programmers combine these two methods with practicality.

4. Underline naming method

The underscore is popular after the advent of C, in many old programs and unix/liunx such environments, and the GNU code is used very commonly.

Each logical breakpoint in the function name is marked with an underscore (camel-named notation in uppercase letters). For example: Print_employee_paychecks ()

Reference: http://wenku.baidu.com/view/391ddd3431126edb6f1a101e.html

Http://wenku.baidu.com/view/abea561bb7360b4c2e3f6421.html?from=search

Second week homework

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.