Absender : Andreas Karl Wittwer @ 2:246/1803 (AUXILIA, Bad Liebenzell) Betreff : Ungarische Notation ? === verfasst von einem guten Freund vor langer Zeit === Hungarian Notation ================== The variables, function parameters and structure fields used in the code have to follow the Hungarian Notation. ('Hungarian' refers to the nationality of the original developer of these conventions, Charles Siminyi of Microsoft.) Each name is composed of three elements: prefix, base type and qualifier: CHAR achPipeBuffer[9]; The base type (in the example above 'ch' = character) is used to indicate the type of the used variable. Table: Standard base types -------------------------- Type Name Base Type Description BOOL f a flag or a boolean variable CHAR ch signed 8 bit character SHORT s signed 16 bit quantity LONG l signed 32 bit quantity USHORT us unsigned 16 bit quantity ULONG ul unsigned 32 bit quantity The more complex variables are normally derived from some combination of simple types, so the base type is not sufficient to describe the type of the variable. Therefore, the prefix (in the example above 'a' = array) is used to indicate a composed type. While the prefix and base type specify the type of a variable, the qualifier (in the example above 'PipeBuffer') is a short description of the purpose of the variable. Each word of the qualifier is capitalised, not only the first, to improve readability of the whole variable name. Table: Standard prefixes ------------------------ Prefix Description p pointer (usually far) a array i index to an array (When used as variable in a loop, often only 'i' is used as variable name.) c count h handle which uniquely identifies an object Das ganze hoert sich am Anfang wohl recht laestig an, es ist aber sehr nuetzlich, wenn man an einem Programm rumbastelt, dass nicht von einem selbst ist, oder dessen Codiereung schon etwas laenger her ist, oder das einfach nur komplexer ist. Man braucht naemlich nicht jedesmal bei einer Variablen nachschauen, wie sie jetzt deklariert ist, man verlaesst sich einfach auf die Notation; das spart viel Zeit und Arbeit. Der Pferdefuss daran ist der, wenn Du schon laenger damit arbeitest, und Du bekommst ploetzlich ein Programm vorgesetzt, bei dem die Variablen nicht nach der Ungarischen Notation - oder noch schlimmer falsch - benannt werden. Da hangelt es dann nur noch Compiler Fehler, weil Du Dich so daran gewoehnt hast, Dich auf den impliziten Typ zu verlassen. === cut ===