-
Notifications
You must be signed in to change notification settings - Fork 56
Coding conventions and style guide
In general, every .cc
file should have an associated .h
file. There are some common exceptions, such as unittests and the .cc
files containing just a main()
function.
A correct use of header files can make a huge difference to the readability, size and performance of your code.
The following rules will guide you through the various pitfalls of header and source files.
- Use forward declarations where possible.
- In
#ifndef
-#define
guards, use the name of the class in capital letters +_H
at the end. - Use trailing underscores for global variables.
- Add a brief description of the purpose of the class (also in
.cc
files). Use an existing class as an example of the format. - Try not to copy and paste the
#include
from another class, because you'll end up with a lot of them that you'll not use. Keep them to the minimum set needed by your code.
In macro files, group the commands of the same class and use the same order as in one of the existing files.
The length of each line of code should be at most 80-100 characters. A developer should not change the indentation of someone else's code, unless the line is longer than 100 characters.
Since it is quite inconvenient to have long names in the output files, the names of the geometry volumes must be kept under 20-30 characters. Brevity is good.
When using the G4Exception
class use the following convention:
G4Exception("[ClassName]", "Function()", Exception, "error message")
- Home
- Installation
- Contributing to NEXUS
- Code documentation
- Releases
- User guide