Systems Vs. Apps Hungarian
Where Systems notation and Apps notation differ is in the purpose of the prefixes.
lAccountNum: variable is a long integer (
arru8NumberList: variable is an array of unsigned 8-bit integers (
szName: variable is a zero-terminated string (
"sz"); this was one of Simonyi's original suggested prefixes.
bReadLine(bPort,&arru8NumberList): function with a byte-value return code.
Apps Hungarian notation strives to encode the logical data type rather than the physical data type; in this way, it gives a hint as to what the variable's purpose is, or what it represents.
rwPosition: variable represents a row (
usName: variable represents an unsafe string (
"us"), which needs to be "sanitized" before it is used (e.g. see code injection and cross-site scripting for examples of attacks that can be caused by using raw user input)
strName: Variable represents a string (
"str") containing the name, but does not specify how that string is implemented.
Most, but not all, of the prefixes Simonyi suggested are semantic in nature. The following are examples from the original paper:
pXis a pointer to another type X; this contains very little semantic information.
dis a prefix meaning difference between two values; for instance, dY might represent a distance along the Y-axis of a graph, while a variable just called y might be an absolute position. This is entirely semantic in nature.
szis a null- or zero-terminated string. In C, this contains some semantic information because it is not clear whether a variable of type char* is a pointer to a single character, an array of characters or a zero-terminated string.
wmarks a variable that is a word. This contains essentially no semantic information at all, and would probably be considered Systems Hungarian.
bmarks a byte, which in contrast to w might have semantic information, because in C the only byte-sized data type is the char, so these are sometimes used to hold numeric values. This prefix might clear ambiguity between whether the variable is holding a value that should be treated as a character or a number.
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.
It is possible for code using Apps Hungarian notation to sometimes contain Systems Hungarian when describing variables that are defined solely in terms of their type.
Read more about this topic: Hungarian Notation
Famous quotes containing the word systems:
“We have done scant justice to the reasonableness of cannibalism. There are in fact so many and such excellent motives possible to it that mankind has never been able to fit all of them into one universal scheme, and has accordingly contrived various diverse and contradictory systems the better to display its virtues.”
—Ruth Benedict (18871948)