next up previous contents
Next: Creating new files Up: Source Code Style Previous: Source Code Style

Naming conventions

Class names

Names of C++ classes should begin with a capital letter, and not contain any hyphens. Class names comprised of multiple words should have each word capitalized. Example:

DisplayDevice

Classes derived from a base class should generally prepend a descriptive word to the base class name, unless the new word begins with a number in which case the additional word should be added to the end of the base class name. Examples:
CaveDisplayDevice

and
Displayable3D

Class member variable names

Names of variables which are members of C++ classes follow the same formatting rules as names of classes, except variable names should begin with a lower case letter. Quite often, if the variable is an instance of a particular class, the name of the variable is identical to the class name but with a lower case initial letter.

Class member function names

Names of functions which are members of C++ classes should be in all lower case letters, and use hyphens to separate distinct words in their names. Example:

Scene::_draw( * )

Global variable names

The names of global variables in VMD follow the same rules as for variables which are members of a particular class. It is recommended to use one of the following suggestions when naming a global variable:

  1. Choose a single-word name, and use all lower case.
  2. Choose a name similar to the class name of the variable, and prepend ``vmd'' to the name.
  3. If it is assured there should be only one instance of a particular class, and the instance should be global, choose a name identical to the base class of the variable but with the first letter in lower case.
Examples:
scene
moleculeList

Global function names

Global functions, which are found mainly in the files utilities.C and Global.C, follow one of the following two rules:

  1. Functions in Global.C have the word VMD prepended, and contain no hyphens. Distinct words in the name begin with a capital letter, except the first word after the VMD prefix.
  2. Functions in utilities.C contain all lower case letters, and either contain no hyphens at all, or contain hypens to separate words.
Examples:
voidVMDinitUI (in Global.C)
doubletime_of_day ( in utilities.C)

Source code file names

Each C++ class, except for very small classes used by only a small number of other classes, should be placed in a separate .h file, and if necessary a .C file as well. The base name of the files for the class should be identical to the class name itself. Examples:

DisplayDevice.h and DisplayDevice.C
NameList.h (no NameList.C required)
C source code files should have a .c extension (that is, use a lower case c), while C++ files should have a .C extension. ALL header files should have a .h extension, and any Fortran files should have a .f extension. Latex files should end in .tex.

Documentation file names

Documentation files, which are in Latex format, all contain a .tex extension and begin with a prefix of one of the following: vmd, ig, pg, or ug. Files with a vmd prefix are used by all the Guides; files with the remaining prefixes are used only by that particular Guide. For all files except the main driver Latex files for the Guides and the Book, the filenames contain a hyphen after the prefix and a concluding descriptive word. No capital letters are used. Examples:

vmd_macros.tex
pg_chapters.tex
ug.tex


next up previous contents
Next: Creating new files Up: Source Code Style Previous: Source Code Style



Andrew Dalke
Wed May 15 02:25:03 CDT 1996