Tuesday, April 20, 2010

Naming Conventions To Be Used While Coding(Exclusively for Win32 programming)

The following table lists common prefixes.
PrefixDescription
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)

These are often combined, as in the following.
Prefix combination Description
pszMyString                              A pointer to a string.
m_pszMyString                           A pointer to a string that is a data member of a class.

Other conventions are listed in the following table.
ConventionDescription
CMyClass                            Prefix 'C' for C++ class names.
COMyObjectClass                           Prefix 'CO' for COM object class names.
CFMyClassFactory                           Prefix 'CF' for COM class factory names.
IMyInterface                           Prefix 'I' for COM interface class names.
CImpIMyInterface                           Prefix 'CImpI' for COM interface implementation classes.

No comments:

Post a Comment