-
Notifications
You must be signed in to change notification settings - Fork 4
Coding conventions
Variable names should be descriptive, but not overly long.
Single objects have singular names; containers have plural names. For example
ParticleCombination ParticleCombination_;
ParticleCombinationVector ParticleCombinations_;Public member variables are written in camel-case with an initial lowercase letter.
Private member variables are written in camel-case with an initial capital letter and end in an underscore. For example,
ParticleCombinationVector ParticleCombinations_;
DecayTreeVector DecayTrees_;
RealParameter Mass_;Function argument parameters should not be written in camel case. They may be capitalized or lowercased, but underscores should be used instead of camel-casing (so as to clearly denote arguments from member functions or variables). For examples
DecayingParticle::DecayingParticle(const std::string& name, const QuantumNumbers& q, double radial_size, std::shared_ptr<MassShape> mass_shape)with radial_size and mass_shape instead of radialSize and massShape.
Member functions are written in camel-case with an initial lowercase letter.
-
Getter functions are named for the variable they get and are not prefixed with
get. -
Setter functions are enamed for the variable they set and are prefixed with
set.
If a variable has both a setter and a getter, they must have identical naming but for the prefix set in the setter. For example,
/// The getter
const DecayTreeVector& decayTrees() const;
/// The setter
void setDecayTrees(const DecayTreeVector& dtv);Nonmember functions are written in lowercase with underscores between words. For example,
const std::string to_string(const DecayTree& dt);
const std::vector<double> fit_fractions(const ModelIntegral& MI);Any member function that does not change the state of the object must be marked const.
Fundamental-type return values and object-return values that are not to be acted upon must be marked const.
Prefer writing nonmember functions to member functions.