RAVL naming conventions
The naming conventions held in the RAVL library enable you to
determine the type of a language element without looking for its
definition. This is convenient when reading unfamiliar source
code. Furthermore, it is then possible to use a name that indicates
its type for variables in your program. For example
ListC list;
instead of
list my_list;
The naming conventions of RAVL files, classes, member functions, non-member functions,
types, objects, and macros are as follows:
Files
Files should be named after the key user class they contain, without
the final 'C'. C++ Header files should end in '.hh' and source files
with '.cc'.
Classes
In a class name the first letter of each word (including the first one)
is upper case. The name of the class ends with a capital
letter 'C' to avoid clashes with other libraries and to stress that the
name is a class name. The name should not contain underscores if not really
necessary. The examples are Vector3dC, ByteImageC, GraphC.
Namespaces
When naming namespaces the first letter
of each word (including the first one) is upper case. The name should
end with a capital letter 'N' . The name should not contain underscores
unless necessary for clarity. The examples are RavlN,
Types
In a type name the first letter of each word (including the first one)
is upper case. The name of the type ends with a capital
letter 'T' to avoid clashes with other libraries and to stress that the
name is a type name. The name does not contain underscores if not really
necessary. The examples are RealT, IntT, Vector3dC::CoorT. The last example
is a name of type CoorT inside the class Vector3dC.
Member function and Non-Member functions
In a function name the first letter of each word
(including the first one) is upper case.
The last letter cannot be the capital letter 'C' to avoid confusing with
a class name. The name does not contain underscores unless its is necessary
to avoid confusion. The examples are InitUserInterface(), Vector3dC::StartPoint().
The latter example is a name of the member function StartPoint() of the
class Vector3dC.
Identifiers of Objects
In an object name the first
letter of the first word should be lower case, but the first letter of
all subsequent words is upper case. The name does not contain
underscores unless needed to avoid confusion.
Macros
In general macros should be avoided, but where they are used
the name should be written in upper case letters. Words are
separated by underscores, e.g.
#define WIPE_IT() image.Fill(100)
Following above rules one can read a source code very easy:
Vector3dC vec; // The object vec as an instance of the class Vector3dC.
vec.Foo(); // Apply the member function Foo() on the object vec.
vec(); // Apply the operator() on the object vec.
Vec(); // Call the global function Vec;
Vector3dC(); // Create the object of the class Vector3dC.
vec.x(); // Apply the operator() on the member x of the object vec.