Skip to content

NamingConventions

Pavel Kryukov edited this page Oct 30, 2015 · 1 revision

General Rules

Mostly we would like to adopt QT Style API Design and inherit naming system for it. More rules will be given here explicitly. Read Qt Documentation for now

Types and Classes

Type names should reflect entities they represents. A name should begin with an uppercase letter. To distinct parts of name use uppercase letter at the beginning of every part.

Examples: NameOfTheClass, SomeMysteriousEntity

Function names

Class methods and function names should begin with a lowercase letter and highlight parts by uppercase letters. Exception for this rule is the Constructor and Destructor for classes - they aliased to the class names.

Examples: tryNotToGetWorried();``tryNotToTurnOnTo();``troublesThatUpsetYou();

Not all of the source code comply with that BUT it should. It mostly applies to Get/Set routines so if you see my_object->GetSmth() feel free to turn it into my_object->smth() and change the declaration for routine.

Variables and Class Members

Variables and class members should be all lowercase. Parts of name should be separated by ''.

Example:very_important_var

In order to use shorter name for getter routines the private class members should have some suffix ( like _priv or just _) after it.

Example:

class MyClass
{
    int num_priv;
public:
    inline int num() const
    {
        return num_priv;
    }
}

void f()
{
    MyClass my;
    int a = my.num();
}

Constants

All constants should be in UPPER_CASE with underscores substituting spaces.

Namespaces

All namespaces should seek one-word named, and all letters (even in acronyms) must be lowercased.

Template arguments

All template arguments should be styled by the underlining sense. If it is supposed to be a typename, it must be styled like any class name (see the corresponding section), if it is a regular value, it must be styled like a function parameter. Example:

template< class T > //A single letter is allowed in this 
...// exceptional case of a parametrisation of a template with only one 
   // type parameter, because it is a commonly adopted practice.

template< class Allocator, typename Model, int size >
...

template< typename KeyType, typename ValueType >
...

template< int number_of_dimensions >
...

Clone this wiki locally