Naming Conventions

When reading code, does a name refer to a language function, a function defined by the programmer, a local variable, something displayed on a form ... And if the name is a variable, what type is it?

In general,

Logical hierarchies which are not implemented or referenced using hierarchical dot notation should be named to indicate the hierarchical relationship. (For example, menus and toolbars in Visual Basic.) In these cases, place the hierarchy name first, then the variable name followed by the component type.

Many C users prefer to place a single letter variable type identifier first rather than last. Personally, I find that irritating because, when the variables are sorted, you can't find anything unless you remember what type a specific variable is. I prefer to remember just the variable's name and let the variable tell me its type. When extended to User Interface components, the same argument applies.

Visual Basic | Delphi | C++ Builder | Windows API

Visual Basic 6.0

All string names end with a dollar sign (temp$).


Menus

The menu system is basically an object hierarchy. Unfortunately, VB does not use object syntax to identify menu selections. Therefore, I suggest using the following hierarchical naming convention This provides the advantage that the components sort in a logical manner.

The associated routines will be named similar to
     UIMenu_File_Exit_Click()


ToolBars

A ToolBar is a frame (implemented using a PictureBox) which contains subordinate controls. In this case, prefix each subordinate control name with a common identifier and place an object type identifier at the end.


Delphi

Delphi is not case-sensitive.

The following definitions are followed but not enforced

"A good guideline is that method names have verbs in them. If you find that you create a lot of methods that do not have verbs in their names, consider whether those methods ought to be properties." from the Delphi Help

Most property methods start with either Set or Get; events start with On.

For more details, see Guidelines for Writing Delphi Programs.


C++ Builder

C/C++ function and variable names are case-sensitive.


Windows API

Normally, I would say "If its predefined, then leave it alone!" However, in this case, your code can be made much more readable if you use the Windows API alias feature to rename DLL function calls to indicate what they are. I suggest a prefix such as
   winAPI_FuncName


Author: Robert Clemenzi - clemenzi@cpcug.org
URL: http:// cpcug.org / user / clemenzi / technical / Languages / NamingConventions.htm