Skip to content
Daniel Greenwald edited this page Nov 10, 2016 · 10 revisions

Naming conventions

Member variables

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

Public member variables are written in camel-case with an initial lowercase letter.

Private member variables

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_;

Functions

arguments

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

Member functions are written in camel-case with an initial lowercase letter.

Getters & Setters

  • 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

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);

Const'ness

Member functions

Any member function that does not change the state of the object must be marked const.

Function return values

Fundamental-type return values and object-return values that are not to be acted upon must be marked const.

Member vs. Nonmember

Prefer writing nonmember functions to member functions.