Hungarian notation Guide, Meaning , Facts, Information and Description
Hungarian notation is a naming convention in computer programming, in which the name of an object indicates its type and intended use.It was designed to be used with the C programming language. Because the language has practically no restrictions on operations with different data types, it is prone to unintentional type errors. Hungarian notation aims to remedy this by providing the programmer with explicit indications of the variable's type.
In Hungarian notation, a variable name starts with one or more lower-case letters which are mnemonics for the type or purpose of that variable, followed by whatever the name the programmer has chosen; this last part is sometimes distinguished as the given name. The first character of the given name is capitalized to separate it from the type indicators (see also CamelCase).
While the notation always uses initial lower-case letters as mnemonics, it does not prescribe the mnemonics themselves. There are several widely used conventions (see examples below), but any set of letters can be used, as long as they are consistent within a given body of code.
| Table of contents |
|
2 Examples 3 Origin 4 External Links |
In some programming languages, a similar notation is built into the language. For example, in BASIC, name$ names a string and count% names an integer, while in FORTRAN, variables beginning with I, J, or K are automatically treated as integers. Other computer languages such as Perl deduce type from context, while some like Pascal and Java use strong typing to prevent operations involving incompatible types in the first place.
Similar notations in other programming languages
Examples
The mnemonics for pointers and arrays, which are not actual data types, are usually followed by the type of the data element itself:
While Hungarian notation can be applied to any programming language and environment, it was created for use with the C language for Microsoft Windows, and its use still remains largely confined to that area. Thus, many commonly-seen constructs of Hungarian notation are specific to Windows:
The notation is sometimes extended in C++ to include the scope of a variable, separated by an underscore:
- m_nWheels : member of a class, integer
Origin
Hungarian notation was invented by Charles Simonyi, a programmer working at Microsoft, and earlier at Xerox. The name comes from Simonyi's nation of origin, and was also probably inspired by the name of an unrelated concept, Reverse Polish notation. The term Hungarian notation is memorable for many people because the strings of unpronounceable consonants vaguely resemble the consonant-rich orthography of some Eastern European languages.
This is an Article on Hungarian notation. Page Contains Information, Facts Details or Explanation Guide About Hungarian notation External Links
