Main Page | See live article | Alphabetical index

Hungarian notation

Hungarian notation is a naming convention in computer programming, under which the name of a variable also gives its type.

Whilst in some programming languages the type of a variable is usually explicitly stated (eg: name$, count% in Basic are a string and an integer), others (such as Perl) will let you concatenate 1 and 6, and then let you square-root it - and still give the right answer, and yet others (Pascal) have strong typing, many such as C do little to check whether an string is being multiplied by a pointer. Unintentional errors of this sort generally result in pseudo-random numbers.1 This is made worse by the hundreds of different types typically held within complex OOP-programmed software.

Hungarian notation attempts to remedy this by adding the type of the variable to the name. Examples from Microsoft include dlgFileOpen, keyCaps and rptQtr1Earnings. The use of Camel case allows for easy determination of the individual words within the name.

Hungarian notation was invented by Charles Simonyi, a GUI programmer whom Microsoft got from Xerox (and whose roots originated in Hungary). The name was probably a pun on Polish notation, a stack-based method of implementing computer languages.


  1. Unfortunately, not random enough for cryptography. In some incredibly rare cases, this can be done deliberately, but usually only to produce obfuscated code.

External link