Where can I find a cheat sheet for Hungarian notation?

I am working on an old COM C ++ project that uses system Hungarian notation. Since this is a service for legacy code, the convention is to encode in the original style in which it was written - our new code is not encoded in this way. Therefore, I am not interested in changing this standard or discussing our past sins =)

Is there an online cheat sheet for systemic Hungarian notation?

The best I can find at the moment is a preliminary message about the stack overflow , but it is not quite all that I needed in the past. Does anyone have any other links?

(creating this wiki community in the hope that this list will become self-populated)

+5
source share
4 answers

If this is for an outdated COM project, you probably want to follow the Microsoft Hungarian Notation specifications that are documented on MSDN.

Please note that this is Hungarian Apps, that is, a “good” kind of Hungarian notation . Hungarian systems are a bad type, where names start with prefixes of their compiler types, for example, i for int .

Tables from an MSDN article

Table 1. Some examples of procedure names

  Name description

 InitSy Takes an sy as its argument and initializes it.

 OpenFn fn is the argument.  The procedure will "open" the fn.  No value is returned.

 FcFromBnRn Returns the fc corresponding to the bn, rn pair given.  (The names cannot tell us what the types sy, fn, fc, and so on, are.)

The following is a list of standard type designs. (X and Y mean arbitrary tags. According to standard punctuation, actual tags are lowercase.)

Table 2. Standard Type Designs

  pX Pointer to X.

 dX Difference between two instances of type X. X + dX is of type X.

 cX Count of instances of type X.

 mpXY An array of Ys indexed by X. Read as "map from X to Y."

 rgX An array of Xs.  Read as "range X."  The indices of the array are called:

 iX index of the array rgX.

 dnX (rare) An array indexed by type X. The elements of the array are called:

 eX (rare) Element of the array dnX.

 grpX A group of Xs stored one after another in storage.  Used when the X elements are of variable size and standard array indexing would not apply.  Elements of the group must be referenced by means other then direct indexing.  A storage allocation zone, for example, is a grp of blocks.

 bX Relative offset to a type X. This is used for field displacements in a data structure with variable size fields.  The offset may be given in terms of bytes or words, depending on the base pointer from which the offset is measured.

 cbX Size of instances of X in bytes.

 cwX Size of instances of X in words.

The following are standard qualifiers. (The letter X denotes a tag of any type. Actual type tags are indicated by lowercase letters.)

Table 3. Standard classifiers

  XFirst The first element in an ordered set (interval) of X values.

 XLast The last element in an ordered set of X values.  XLast is the upper limit of a closed interval, hence the loop continuation condition should be: X <= XLast.

 XLim The strict upper limit of an ordered set of X values.  Loop continuation should be: X <XLim.

 XMax Strict upper limit for all X values ​​(excepting Max, Mac, and Nil) for all other X: X <XMax.  If X values ​​start with X = 0, XMax is equal to the number of different X values.  The allocated length of a dnx vector, for example, will be typically XMax.

 XMac The current (as opposed to constant or allocated) upper limit for all X values.  If X values ​​start with 0, XMac is the current number of X values.  To iterate through a dnx array, for example:
           for x = 0 step 1 to xMac-1 do ... dnx [x] ...
           or
           for ix = 0 step 1 to ixMac-1 do ... rgx [ix] ...

 XNil A distinguished Nil value of type X. The value may or may not be 0 or -1.

 XT Temporary X. An easy way to qualify the second quantity of a given type in a scope.

Table 4. Some common types of primitives

  f Flag (Boolean, logical).  If qualifier is used, it should describe the true state of the flag.  Exception: the constants fTrue and fFalse.

 w Word with arbitrary contents.

 ch Character, usually in ASCII text.

 b Byte, not necessarily holding a coded character, more akin to w.  Distinguished from the b constructor by the capital letter of the qualifier in immediately following.

 sz Pointer to first character of a zero terminated string.

 st Pointer to a string.  First byte is the count of characters cch.

 h pp (in heap).
+4
source

Here is one for Systems Hungarian, which in my experience has been the most commonly used (and less useful):

But as all this followed, I have no idea.

Another form of Hungarian notation is “Apps Hungarian,” which seems to be the original intention of Simonyi (using a variable was encoded, not a type). See http://en.wikipedia.org/wiki/Hungarian_notation for more details.

+4
source

Since this is an inherited project, the software manager must have a copy of the style guide for any version of the Hungarian notation used by the original programmers. (I assume that original programmers have long fled to more enlightened jobs.)

You really need to rethink your use of Hungarian notation. This was originally a patch for the lack of strong typing (and compiler type checking) in C. Modern compilers use the correctness of the text, making the Hungarian notation superfluous at best and erroneous otherwise.

+1
source

It seems that there is not a single exhaustive resource for finding Hungarian notation prefixes, probably because many of them ranged from code base to code base. There, of course, were many very often used.

The best list I could find was here.

The rest covers commonly used conventions such as recording

MSDN enty on Hungarian Notation here and a few short articles on this subject (possibly overlapping) here and here

It would be best to see how variables are used, and that (may) help you determine the definition of prefixes (although in practice, names rarely reflect the use of a variable, unfortunately).

You may be able to put together some semblance of notation from these various references.

Just to be complete (!) As Hungarian Object Notation for Visual Basic from Microsoft Support no less.

+1
source

All Articles