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
  • Each file should contain a short header about the author, class description and date.
    All files should include:
    few lines description about what the class is meant for and its functionalities/use
    and a half line comment with the name of the original author and date.