Coding-style Guidelines Motivations
- The public, protected and private keywords must be used
explicitly in the class declaration in order to make easier code readability.
- English and self-explaining names for constants, variables and functions
should be used for code readability. Possibly avoid the use of underscore
"_" characters within variables or function names (ex. theTotalEnergy,
SetEnergyTable(), GetTrackPosition(), ...).
- The code must be properly indented (ex. 2 characters indentation
when inside a control structure) for readability reasons.
- Each GEANT4 class name should begin with G4 (ex. G4Particle,
G4GeometryManager, G4ProcessVector, ...) to keep an homogeneous
naming style for GEANT4 specific classes.
- Each header file should contain only one or related class declarations.
For maintainability reasons and to make easier retrieval of classes' definitions
across each category.
- Each class implementation source code should go into a single source file.
For maintainability reasons and to make easier retrieval of classes' implementations
across each category.
- Each header file must be protected from multiple inclusions in order to
avoid multiple declarations and circular dependences in the code. Ex.:
#ifndef NAME_HH
#define NAME_HH
...
#endif
- Each file should contain a short header about the author, updates (CVS) and date.
All files should begin with:
// $Id: motivations_coding_style.shtml,v 1.1 2006/05/16 06:20:58 gcosmo Exp $
and a half line comment with the name of the original author, update notes and dates.
The $Id: motivations_coding_style.shtml,v 1.1 2006/05/16 06:20:58 gcosmo Exp $ expands to filename and last updater in CVS.
|