The naming method of Hungarian teeth and the method of hump naming

Source: Internet
Author: User
Tags naming convention

Hump Naming Act (camel-case)

the Hump nomenclature (camel-case) is a set of naming conventions (conventions) when a computer program is written.

Programmers are able to communicate more easily between peers for their own code, so it is better to have a unified and readable naming method. For example: Some programmers like all lowercase, some programmers like to underline, so if you want to write a variable of my name, they often use the wording of myname, my_name, myname or myname. Such a naming convention is not suitable for all programmers to read, and the use of the Camel name method to express, can increase the readability of the program.

The hump naming method is when a variable name or function name is a unique identifier that is composed of one or more words, the first word starts with a lowercase letter, the first letter of the second word is capitalized, or the first letter of each word is in uppercase letters, for example: MyFirstName, Mylastname, Such variable names look like camel peaks, so they get their name.

The term Hump nomenclature (camel-case) comes from the commonly used case-and-write format in Perl, while Larry Wall's bestseller, Programming Perl (o& #039; The cover picture of Reilly Publishing is just a camel.

The naming rules of hump nomenclature can be regarded as a convention, and there is no absolute and mandatory, in order to increase the recognition and readability.

Hungarian Naming Act

The Hungarian (Hungary) nomenclature is a programming naming convention, also known as HN Naming Law .

Principle

  The Hungarian nomenclature is a naming convention when programming. The basic principle is: variable name = attribute + Type + object description, where each object name requires a clear meaning, you can take the full name of the object or part of the name. Naming is based on the principle that easy memory is easy to understand. It is very important to ensure the consistency of the name.

Example

For example, if the name of the form is form, then the Hungarian nomenclature can be abbreviated as FRM, then when the form variable When the name is switchboard, the full variable should be frmswitchboard. This makes it easy to see from the variable name that switchboard is a form, and similarly, if the variable type is a label, it should be named Lblswitchboard. It can be seen that the Hungarian nomenclature is very easy to remember, and makes the variable name very clear and understandable, thus enhancing the readability of the code, convenient for each programmer to communicate with each other code.

History

It is said that this kind of nomenclature is called Charles Simonyi Hungary programmer invented it, and later he was in Microsoft For a few years, the nomenclature spread to the world through Microsoft's various product and documentation materials. Today, most programmers Use this nomenclature, no matter what software they use to develop them. The starting point of this nomenclature is to combine variable names by: The Order of attribute + Type + object description, so that programmers have a visual understanding of the types of variables and other properties when they make variables, the following is the HN variable naming convention.

Properties Section :

G_ Global Variables

c_ Constants

m_ C + + class member Variables

S_ Static variables

Type section:

  Pointers P

FUNCTION fn

Invalid V

Handle h

  Long Integer type L

  Boolean b

  floating Point Type (sometimes referred to as a file) F

Dual-word DW

String sz

Short-integer n

Double precision floating point D

Count C (usually CNT)

  character ch (usually in C)

  Integral type I (usually with N)

  bytes by

Word w

Real Type R

unsigned u

Description section:

Max Max

Min min

Initialize Init

Temp variable T (or temp)

Source Object Src

Destination Object Dest

The naming method of Hungarian teeth and the method of hump naming

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.