SIRIUS 7.5.0
Electronic structure library and applications
|
Below are some basic style rules that we follow:
Indentation: 4 spaces (no tabs)
Exception: class access modifiers are idented with 2 spaces
We use clang-format utility to enforce the basic formatting style. Please have a look at .clang-format config file in the source root folder for the definitions and use helper script 'clang_format.x'.
Class naming convention.
Problem: all 'standard' naming conventions are not satisfactory. For example, we have a class which does a DFT ground state. Following the common naming conventions it could be named like this: DFTGroundState, DftGroundState, dft_ground_state. Last two are bad, because DFT (and not Dft or dft) is a well recognized abbreviation. First one is band because capital G adds to DFT and we automaticaly read DFTG round state.
Solution: we can propose the following: DFTgroundState or DFT_ground_state. The first variant still doens't look very good because one of the words is captalized (State) and one (ground) - is not. So we pick the second variant: DFT_ground_state (by the way, this is close to the Bjarne Stroustrup's naiming convention, where he uses first capital letter and underscores, for example class Io_obj).
Some other examples:
Exceptions are allowed if it makes sense. For example, low level utility classes like 'mdarray' (multi-dimensional array) or 'pstdout' (parallel standard output) are named with small letters.