LDMX Software
|
The following guidelines must be followed by all new code. Existing code that does not yet follow should be adapted when possible. You might disagree with some guidelines, but in a large code base as this one consistency is more important than personal opinion. All guidelines have a short identifier label, e.g. N.1, for easier reference in discussions.
For cases and constructs not explicitly mentioned here, code should fall back to the C++ Core Guidelines.
Always use the appropriate enum values to access components. This clearly states the semantic meaning and is easier to understand.
Example:
Do not use plain numbers as this can lead to inconsistencies if the order changes. It reduces the readability and makes it harder to spot errors.
Do not use the .{x,y,z,w}()
accessors available for small fixed-size vectors. While this should produce correct results in most cases, the accessor name does not always match the semantic meaning, e.g. for momentum vectors, and it only works for vectors but not for matrices. Always use the entries in enum CoordinateIndices
for a consistent way of accessing both vectors and matrices.
Namespaces use CamelCase with an upper case initial.
Example:
The only exception is the nested detail
namespace with always uses the lower-case name. There is no particular strong reason but existing practice for this. The detail
namespace must be never be the top-most namespace.
Example:
All concrete types, i.e. classes, structs, enums, and typedefs for both fundamental and external types, use CamelCase with an upper case initial.
Example:
Prefer semantic names over descriptive names. This applies in particular to typedefs of external types or standard containers. Types are checked by the compiler, while semantic meaning is only checked by the user; optimize for the latter.
Example:
Avoid abbreviations and prefer full names. If abbreviations must be used, only use upper case for the initial letter of the abbreviation. The abbreviation is semantically a single word and this provides better visual consistency with the CamelCase naming.
Example:
All functions and methods use mixedCase with a lower case initial. This applies also to private helper functions, e.g. in the detail
namespace. These are not fundamentally different from other functions and do not warrant a separate convention just by virtue of being e.g. in the detail
namespace.
Example:
Local variables, including function arguments, and public member variables use mixedCase with lower case initial.
Example:
Private member variables have an additional m_
prefix.
Example:
Static variables, i.e. local, global, and member ones, have an additional s_
prefix to mark them as the satanic tools that they are.
Variables representing constant values use CamelCase with a k
prefix. Only variables marked as constexpr
are considered constant values.
Example:
Variables defined in the Acts::UnitConstants
namespace are exempted for usability reasons and use regular variable naming instead.
Enum values use CamelCase with a e
prefix. They are not really constants but symbolic values, e.g. they can never have an address, and warant a separate convention.
Example:
Template parameter types use lower case words, separated by underscores, with a _t
suffix. The separate naming convention from concrete types clarifies that these are variable types and avoids naming collisions when reexporting the type.
Example:
Do not use macros. You want to use macros? Do not use them! Are you even listening? Ok, you are not: macros use UPPER_CASE
with underscores as word separators and a mandatory ACTS_
prefix.
Example:
Files use CamelCase with upper case initial. If the file defines a single class/struct, the filename must match the typename. Otherwise, a common name describing the shared intent should be used.
Source files use the .cpp
extension, Header files use the .hpp
extension, inline implementation files use the .ipp
extensions.
Files that contain only symbols in the detail
namespace should be moved in adetail/
directory in the module directory. This should not be done for corresponding source files.
See [](howto_format)