Hungarian nomenclature

xiaoxiao2021-03-05  28

Hungarian nomenclature

Naming Specification for MFC, handle, control and structure

Windows type sample variable MFC class sample variable HWNDhWnd; CWnd * pWnd; HDLGhDlg; CDialog * pDlg; HDChDC; CDC * pDC; HGDIOBJhGdiObj; CGdiObject * pGdiObj; HPENhPen; CPen * pPen; HBRUSHhBrush; CBrush * pBrush; HFONT hFont; CFont * pFont ; HBITMAP hBitmap; CBitmap * pBitmap; HPALETTE hPaltte; CPalette * pPalette; HRGN hRgn; CRgn * pRgn; hMENU hMenu; CMenu * pMenu; HWND hCtl; CState * pState; HWND hCtl; CButton * pButton; HWND hCtl; CEdit * pEdit; HWND hCtl; CListBox * pListBox; HWND hCtl; CComboBox * pComboBox; HWND hCtl; CScrollBar * pScrollBar; HSZ hszStr; CString pStr; POINT pt; CPoint pt; sIZE size; CSize size; RECT rect; CRect rect;

General prefix naming specification

Prefix type example Class C or structure cDocument, CPrintInFom_ member variable m_pdoc, m_ncustomers

Variable naming specification

Prefix Type Description Instance Chchar8 Bit Character Chgradech Tchar If _unicode definition, 16-bit character chnamebbool Boolean Benablen int integer (whose size depends on operating system) NLENGTHN UINT No symbol value (whose size depends on operating system) NHEighTW Word 16 Non-symbolic WPOSL Long 32-bit Symbol Integer LoffSetDW DWORD 32-bit No Symbol Integer DWRANGEP * Pointer PDOCLP FAR * Far Pointer LPSZNAMELPSZ LPSTR 32 Bit Characters LPSZNAMELPSZ LPCSTR 32-bit Constant string pointer Lpsznamelpsz lpctstr If _unicode definition, The 32-bit constant string pointer lpsznameh handle windows object handle hwndlpfn callback points to the far pointer to the Callback function

Application symbol naming specification

Examples of types of symbols prefixed range IDR_ Help context HIDD_SPELL_CHECK plurality of different types of resource-sharing identification IDR_MAIINFRAME1 ~ 0x6FFFIDD_ dialog resource IDD_SPELL_CHECK 1 ~ 0x6FFFHIDD_ dialog resource 0x20001 ~ 0x26FFIDB_ bitmap resource IDB_COMPANY_LOGO 1 ~ 0x6FFFIDC_ cursor resource IDC_PENCIL 1 ~ 0x6FFFIDI _ icon resource IDI_NOTEPAD 1 ~ 0x6FFFID_ command from the menu or toolbar ID_TOOLS_SPELLING 0x8000 ~ 0xDFFFHID_ command Help context HID_TOOLS_SPELLING 0x18000 ~ 0x1DFFFIDP_ message box prompts IDP_INVALID_PARTNO 8 ~ 0xDEEFHIDP_ message box Help context HIDP_INVALID_PARTNO 0x30008 ~ 0x3DEFFIDS_ string resources IDS_COPYRIGHT 1 ~ 0x7eefidc_ dialog box Control IDC_Recalc 8 ~ 0xdeefmicrosoft MFC Macro Name Specification Name Type_AFXDLL Unique Dynamic Library (DLL) version _alpha only compile DEC Alpha processor _debug includes the diagnostic debug version _mbCS Compile multibyte character set _unicode Open UnicodeafxAPI MFC in an application Callback passed the function library identifier nomenclature by pointer callback

Identifiers and Meaning U ANSI (N) or Unicode (U) D debug or release: d = debug; ignore the identifier is issued. Static library version naming specification

Description Nafxcwd.lib debug version: MFC Static connection library NAFXCW.LIB Release: MFC Static connection library uafxcwd.lib debug version: MFC static connection library with Unicode support UAFXCW.LIB Release: MFC static connection library supported by Unicode Dynamic connection library naming specification

Name Type_AFXDLL Unique Dynamic Connection Library (DLL) Version WINAPI Windows Functions WINDOWS.H China New Naming Specification

Type Definition Description WinAPI uses the FAR Pascal location in the API declaration, if you are writing a DLL with exporting API people, you can use this type of Callback in your own API to use in the application recursive routine, such as windows and conversations The position LPCSTR of the FAR PASCAL in the frame is the same as LPSTR, just LPCSTR is used for read-only string pointers, which defines similar (const char far *) uint-free integer type, whose size is determined by host environment (for Windows NT and Windows 9x are 32 bits); it is the synonym of unsigned int LRESULT window program Return Value LPARAM declares that the type used by LPARAM, LPARAM is the fourth parameter of the window, WPARAM is used, WPARAM is a window. The third parameter of the program LPVOID general pointer type, with (void *), can be used instead of LPSTR

The above reprint comes from: http://www.9cbs.com.cn/program/5755.htm

A array array

B Bool (int) Boolean (integer)

By unsigned char (byte) No symbolic characters (bytes) C char characters (bytes)

CB Count of bytes bytes

Cr Color Reference Value Color (Reference) Value

CX Count of X (Short) X Collection (Short Integer)

DW DWORD (unsigned long) double word (no symbol length)

f Flags (USUALLY MULTIPLE BIT VALUES) Sign (generally multiple values)

Fn function function

G_ Global Global

H Handle handle

i integer integer

l Long long integer

LP Long Pointer long pointer

M_ Data Member of a Class A class of data members

N Short Int short integer

P P Pointer pointer

String string

SZ ZERO TERMINATED STRING string ends with 0

TM Text Metric Text Rules

u Unsigned int unsigned integer

UL unsigned long (ulong) unsigned long integer

W Word (unsigned short) no symbol short integer

X, Y X, Y Coordinates (Short) Coordinate Value / Short Integer

v void empty

The above reprint comes from: http://seanlee.blogbus.com/logs/2004/12/560998.html

Crust in Hungarian nomenclature

The Hungarian nomenclature is a naming specification when programming. Naming specifications are the most important places in program writing specifications, since ancient times, it is necessary to fight. What is the naming specification? Four words: name is smooth. It is divided into naming norms and bad naming specifications, which means that the famous naming namings and named naming nations are said to be named. Good dance shoes is to let dance shoes that don't feel their existing, and the bad dance shoes is to dance dancers. A bad naming specification has a much more creation than a good naming specification.

This article has to prove that the Hungarian naming method is a bad naming specification. The scope of this article is a static power type programming language. The analysis model of this article is C language and C language. The Huang Hungi is the abbreviation of the Hungarian nomenclature.

Cost of a Hungarian nomenclature

The manifestation of Huxiang is an additional name prefix to the variable name, such as NfoO, SZFOO, PFOO, CPFOO represents integer variables, string variables, pointer variables, and normallyte pin variables. It can be seen that Huather's type information of the variable is copied from a single location (declared variable) to multiple locations (using variables), which is redundant law. One of the costs of redundancy is to maintain the consistency of a copy. This cost is required to change the type of variable during writing and maintenance code. The cost of redundant methods is to take up extra space. A excellent writer will consciously follow a rule: the length of the code minimum organizational unit is suitable for 30 natural rows, if more than 50 lines should be reached. The writing space of a variable will add unnecessary difficulty to this method. End Hungarian nomenclature

Here to prove that the benefits of Hungarian nomenclature are vague and cannot be expected.

Model 1: STRCPY (PSTRFOO, PCSTRFOO2) VS STRCPY (Foo, Foo2) What is the benefit of Huather here? I can't see it. No programmer will admit that you don't know the parameter type of the strcpy function.

Model 2: Unknown_function (nfoo) VS UNKNOWN_FUNCTION (FOO) What is the benefit of Huather here? I can't see it. For a function that does not know the type of determination, the programmer should go to the document of the function, which is a cost. The only benefit of using the Huxiang is to see the code, knowing this function requires an integer parameter, what is the use of this? The function is an interface, the type of parameters is only a small part of the interface. Important information such as functionality, export information, thread security, abnormal security, parameter legitimacy, etc. must also be checked.

Model 3: nfoo = nbar vs foo = What is the benefit of Hux Hung? I can't see it. The only benefit of using the Huxian is to see the code, you know that there is a copy action of a integer variable. It sounds no problem, you can sleep well. If he sees nfoo = szbar, it may wake up from the dream. And slow, will something really do? I want to be awakened to be a compiler. On the other hand, nfoo = nbar is just legitimate in the grammar. People who look at the code are truly concerned about the legality of semantics. The Huang Huang has no help. On the other hand, an excellent writer will consciously follow a rule: the temporary variable in the minimum organizational unit is preferably one or two, if more than three should be reorganized. Combined with the aforementioned first rule, it can be drawn that it is easy to understand, which is easy to understand, which is easy to understand. This is the built-in high quality of the code. A good naming norm is quite limited to the high quality of the internal construction, and the bad naming norms are larger than the high quality damage than people.

Implementation of the three Hungarian nomenclature

Here to prove that the Hungarian nomenclature is difficult to implement in the C language, it is not possible in the C language. Logically, after the conclusion of the benefits of Huather's income, the feasibility of the Huxiang will come to the feasibility of the Huxiang. However, in view of the death of the enemy that has caused the enemy that has caused the enemy, I still step on a feet.

As many, the Huather is a redundancy of type systems, so the key to implementing Huxian is whether we can accurately copy the type system. This depends on the complexity of the type system.

Let's take a look at the C language:

1. Built-in type: int, char, float, double replication is N, CH, F, D? It seems that there is no problem. But who tells me how VoID said? 2. Combine type: Array, Union, Enum, Struct Copy is A, U, E, S? It seems to be more awkward. The difficulty here is not named for the primary type, but is named for the secondary type. AN represents an array? Sfoo, SBAR represents structural foo, structural bar? AUSFOO represents a joint structure foo array? Tired. 3. Special types: Pointer. Pointer should theoretically be a combination type, but in the C language can be considered a built-in type because C language does not have a very stringent area of ​​different pointer types. The following starting performance: pausfoo indicates the fed-structure foo array pointer? PPP indicates a pointer to the pointer of the pointer? The nightmare has not ended yet, then look at the type system more rich in C language:

1.Class: If the Struct in the C language can also use the STRU to push the past, do not dream to use CLS to slit C Class Class. Strictly speaking, Class is not a type, but a tool for creating types, in C , the number of language built-in types, and the number of customized types created by Class Customer is completely ignored. STDVECTORFOO indicates the standard library vector type variable foo? Crazy thought. 2. Name the space: BoostFilesystemIitratorfoo, indicating the Boost space FileSystem subclass space traversal directory type variable foo? The programmer is going to collapse. 3. Template: Do you remember std :: map The exact name of the type? I can't remember, it seems to have more than 255 characters, or I will spare me. 4. Template Parameters: Template Const T & Max (Const T & A, Const T & B, BinaryPredicate Comp) Smart You, please use the Huxian T. God is laughing. 5. Type modification: Static, Extern, Mutable, Register, Volatile, Const, Short, long, unsigned nightmare plus modified? Still a nightmare.

Are you willing to make a dancer on a shackle?

Crust in Hungarian nomenclature

The Hungarian nomenclature is a naming specification when programming. Naming specifications are the most important places in program writing specifications, since ancient times, it is necessary to fight. What is the naming specification? Four words: name is smooth. It is divided into naming norms and bad naming specifications, which means that the famous naming namings and named naming nations are said to be named. Good dance shoes is to let dance shoes that don't feel their existing, and the bad dance shoes is to dance dancers. A bad naming specification has a much more creation than a good naming specification.

This article has to prove that the Hungarian naming method is a bad naming specification. The scope of this article is a static power type programming language. The analysis model of this article is C language and C language. The Huang Hungi is the abbreviation of the Hungarian nomenclature.

Cost of a Hungarian nomenclature

The manifestation of Huxiang is an additional name prefix to the variable name, such as NfoO, SZFOO, PFOO, CPFOO represents integer variables, string variables, pointer variables, and normallyte pin variables. It can be seen that Huather's type information of the variable is copied from a single location (declared variable) to multiple locations (using variables), which is redundant law. One of the costs of redundancy is to maintain the consistency of a copy. This cost is required to change the type of variable during writing and maintenance code. The cost of redundant methods is to take up extra space. A excellent writer will consciously follow a rule: the length of the code minimum organizational unit is suitable for 30 natural rows, if more than 50 lines should be reached. The writing space of a variable will add unnecessary difficulty to this method. End Hungarian nomenclature

Here to prove that the benefits of Hungarian nomenclature are vague and cannot be expected.

Model 1: STRCPY (PSTRFOO, PCSTRFOO2) VS STRCPY (Foo, Foo2) What is the benefit of Huather here? I can't see it. No programmer will admit that you don't know the parameter type of the strcpy function.

Model 2: Unknown_function (nfoo) VS UNKNOWN_FUNCTION (FOO) What is the benefit of Huather here? I can't see it. For a function that does not know the type of determination, the programmer should go to the document of the function, which is a cost. The only benefit of using the Huxiang is to see the code, knowing this function requires an integer parameter, what is the use of this? The function is an interface, the type of parameters is only a small part of the interface. Important information such as functionality, export information, thread security, abnormal security, parameter legitimacy, etc. must also be checked.

Model 3: nfoo = nbar vs foo = What is the benefit of Hux Hung? I can't see it. The only benefit of using the Huxian is to see the code, you know that there is a copy action of a integer variable. It sounds no problem, you can sleep well. If he sees nfoo = szbar, it may wake up from the dream. And slow, will something really do? I want to be awakened to be a compiler. On the other hand, nfoo = nbar is just legitimate in the grammar. People who look at the code are truly concerned about the legality of semantics. The Huang Huang has no help. On the other hand, an excellent writer will consciously follow a rule: the temporary variable in the minimum organizational unit is preferably one or two, if more than three should be reorganized. Combined with the aforementioned first rule, it can be drawn that it is easy to understand, which is easy to understand, which is easy to understand. This is the built-in high quality of the code. A good naming norm is quite limited to the high quality of the internal construction, and the bad naming norms are larger than the high quality damage than people.

Implementation of the three Hungarian nomenclature

Here to prove that the Hungarian nomenclature is difficult to implement in the C language, it is not possible in the C language. Logically, after the conclusion of the benefits of Huather's income, the feasibility of the Huxiang will come to the feasibility of the Huxiang. However, in view of the death of the enemy that has caused the enemy that has caused the enemy, I still step on a feet.

As many, the Huather is a redundancy of type systems, so the key to implementing Huxian is whether we can accurately copy the type system. This depends on the complexity of the type system.

Let's take a look at the C language:

1. Built-in type: int, char, float, double replication is N, CH, F, D? It seems that there is no problem. But who tells me how VoID said? 2. Combine type: Array, Union, Enum, Struct Copy is A, U, E, S? It seems to be more awkward. The difficulty here is not named for the primary type, but is named for the secondary type. AN represents an array? Sfoo, SBAR represents structural foo, structural bar? AUSFOO represents a joint structure foo array? Tired. 3. Special types: Pointer. Pointer should theoretically be a combination type, but in the C language can be considered a built-in type because C language does not have a very stringent area of ​​different pointer types. The following starting performance: pausfoo indicates the fed-structure foo array pointer? PPP indicates a pointer to the pointer of the pointer? The nightmare has not ended yet, then look at the type system more rich in C language:

1.Class: If the Struct in the C language can also use the STRU to push the past, do not dream to use CLS to slit C Class Class. Strictly speaking, Class is not a type, but a tool for creating types, in C , the number of language built-in types, and the number of customized types created by Class Customer is completely ignored. STDVECTORFOO indicates the standard library vector type variable foo? Crazy thought. 2. Name the space: BoostFilesystemIitratorfoo, indicating the Boost space FileSystem subclass space traversal directory type variable foo? The programmer is going to collapse. 3. Template: Do you remember std :: map The exact name of the type? I can't remember, it seems to have more than 255 characters, or I will spare me. 4. Template Parameters: Template Const T & Max (Const T & A, Const T & B, BinaryPredicate Comp) Smart You, please use the Huxian T. God is laughing. 5. Type modification: Static, Extern, Mutable, Register, Volatile, Const, Short, long, unsigned nightmare plus modified? Still a nightmare.

Are you willing to make a dancer on a shackle?

The above reprint comes from: http://www.9cbs.com.cn/program/7183.htm

转载请注明原文地址:https://www.9cbs.com/read-34421.html

New Post(0)