[ Programmer's Guide ]

[ Coding Conventions ]

Identifier Spellings #

Generally speaking identifiers in both the VB and C/C++ code consist of one or more words with each word being initial capitalized, the remainder of the word being in lower case. The exception to this are C/C++ "#defines" and VB global constants which are often in all uppercase with underscores between the words.

Generally speaking the name of C/C++ functions and VB subroutines and functions are unadorned except that the names of most of the C/C++ routines called from VB are prefixed with two or three lower case letters to indicate which module they are in (e.g., "tn" for TRANSACT.CPP or "st" for STATE.CPP). However, a minor convention is to suffix versions of C/C++ routines intended to be called by Visual Basic code with the letters "VB". Typically this applies when there is a version of the routine which takes or returns a null terminated string and another version which takes or returns a VB string.

Identifiers of variables are usually prefixed with certain lower case letter sequences to indicate their type and form and, in later modules, sometimes also their scope. Occasionally, temporary variable names consist of just this prefix. For example, a variable length string which is used in only a small fragment of code might be called simply "sz".

This prefixing of identifiers is common in Microsoft software and is often referred to as "Hungarian notation" in honour of Microsoft's Charles Simonyi. Microsoft's conventions are adapted slightly for use in Max.

Sometime the letters "p", "l", "m", "g" are used to indicate the scope of variables. The introduction of this convention is the main change made as the project has proceeded. Sometimes the scope letter is followed by an underscore to distinguish it from other uses of the letter. Module TRANIDX.CPP (one of the most recently created) follows this convention most thoroughly with class members with names like "m_pNext" (member which is a pointer) and parameters with names like "p_nDayOfMonth" (parameter which is a number) or event "p_pEnum" (parameter which is a pointer).

Here are the main letter sequences used in prefixes:

a #


b #

Boolean. In C/C++ the value can be TRUE (1) or FALSE (0). In VB the values can be TRUE (0xFFFF) or FALSE (0). (See also "vbb").

g #

"Global" scope - that is, shared between more than one VB or C/C++ module.

h #

Handle. That is, an integer value which is treated as an opaque reference to an object.

Sometimes these are genuine 16 bit Microsoft Windows handles created using GlobalAlloc (e.g., handles to transaction enumerators) or MS-DOS file handles created using open, etc.

Other times they are actually 32 bit (selector and offset) pointers which are dereferenced as such in the C/C++ code but treated as handles within the VB code. The session "handle" is a typical example of this.

l #

Long value. Sometimes also used to indicate "local" scope.

lp #

Long pointer.

n #

Number or count, integer or long.

m #

"Member" scope.

p #

Pointer (usually actually a long pointer, we don't use near pointers). Sometimes also used to indicate "parameter" scope.

r #

Reference (C/C++).

s #

"Structure". In C/C++ an object of a struct or class type. In VB an object of a programmer defined type.

sz #

C/C++: null (zero) terminated string.

VB: variable length string.

sf #

Fixed length string.

t #

"Type". In VB, programmer defined types. In C/C++, the name of a type defined by typedef, struct or class.

u #

Unsigned integer.

vbb #

VB Boolean. Used in C/C++ code to reference values which follow the VB conventions. Typically these are parameters or function return values. (See also "b").