理解Hungarian notation

  • Hungarian notation

    Hungarian notation is an identifier naming convention in computer programming, in which the name of a variable or function indicates its intention or kind, and in some dialects its type.

    The original Hungarian Notation is sometimes called Apps Hungarian as it became popular in the Microsoft Apps division in the development of Word, Excel and other apps.

  • History

    The original Hungarian notation, which would now be called Apps Hungarian, was invented by Charles Simonyi, a programmer who worked at Xerox PARC circa 1972-1981, and who later became Chief Architect at Microsoft.

    PARC(Palo Alto Research Center, formerly Xerox PARC) is a research and development company in Palo Alto, Califonia. Formed in 1969.

  • Coding Style Concentions From Microsoft

    From Microsoft, Hungarian Notation has become a common coding practice in Win32 programming. They include variable prefix notations that give to variable names a suggestion of the type of the variable.

    The following table lists common prefixes:

    Prefix Description
    a Array
    b BOOL (int)
    c Char
    cb Count of bytes
    cr Color reference value
    cx Count of x (short)
    dw DWORD (unsigned long)
    f Flags (usually multiple bit values)
    fn Function
    g_ Global
    h Handle
    i Integer
    l Long
    lp Long pointer
    m_ Data member of a class
    n Short int
    p Pointer
    s String
    sz Zero terminated String
    tm Text metric
    u Unsigned int
    ul Unsigned long (ULONG)
    w WORD (unsigned short)
    x,y x, y coordinates (short)

    Much more information could be found here.

  • Refrecences

  1. StackOverflow Tag: Hungarian notation
  2. Good Examples of Hungarian Notation? [closed]
  3. .NET General Naming Conventions
  4. Making Wrong Code Look Wrong
  5. Why shouldn’t I use “Hungarian Notation”?

你可能感兴趣的:(Software,Engineering,Hungarian,匈牙利命名法)