Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Hungarian notation
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=={{anchor|Systems|Apps}}Systems Hungarian vs. Apps Hungarian== Where Systems notation and Apps notation differ is in the purpose of the prefixes. In Systems Hungarian notation, the prefix encodes the actual data type of the variable. For example: *<code>lAccountNum</code> : variable is a ''long integer'' (<code>"l"</code>); *<code>arru8NumberList</code> : variable is ''an '''arr'''ay of '''u'''nsigned '''8'''-bit integers'' (<code>"arru8"</code>); *<code>bReadLine(bPort,&arru8NumberList)</code> : function with a byte-value return code. *<code>strName</code> : Variable represents a string (<code>"str"</code>) containing the name, but does not specify how that string is implemented. 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. *<code>rwPosition</code> : variable represents a ''row'' (<code>"rw"</code>); *<code>usName</code> : variable represents an ''unsafe string'' (<code>"us"</code>), 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) *<code>szName</code> : variable is a '''''z'''ero-terminated '''s'''tring'' (<code>"sz"</code>); this was one of Simonyi's original suggested prefixes. Most, but not all, of the prefixes Simonyi suggested are semantic in nature. To modern eyes, some prefixes seem to represent physical data types, such as <code>sz</code> for strings. However, such prefixes were still semantic, as Simonyi intended Hungarian notation for languages whose type systems could not distinguish some data types that modern languages take for granted. The following are examples from the original paper:<ref name="simonyi">{{cite web | author = Charles Simonyi | title = Hungarian Notation |date=November 1999 | publisher = [[Microsoft Corp.]] | work = MSDN Library | url = http://msdn2.microsoft.com/en-us/library/aa260976(VS.60).aspx | author-link = Charles Simonyi }} </ref> * <code>p''X''</code> is a pointer to another type ''X''; this contains very little semantic information. * <code>''d''</code> is 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. * <code>''sz''</code> is 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. * <code>''w''</code> marks a variable that is a word. This contains essentially no semantic information at all, and would probably be considered Systems Hungarian. * <code>''b''</code> marks 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.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)