-
Notifications
You must be signed in to change notification settings - Fork 803
Coding Style
The coding style of the project is based on the coding style of QT. An overview of this coding style can be found here:
Member variables should be prefixed with a underscore. For example write _myClassVariable
instead of myClassVariable
.
When possible use data structures from QT. For example use QVector
instead of std::vector
.
When possible use algorithms from the STL or QT. For example use std::copy_if
instead of coding it by hand.
QSharedPointer
should be used instead of std::shared_ptr
. However, it is okay to use a STL smart pointer if there is no equivalent in QT, like std::unique_ptr
.
Names of unit tests should follow the scheme proposed by Roy Osherove in his book The Art of Unit Testing. The general scheme is:
void testUnitOfWork_stateUnderTest_expectedBehaviour()
It is explained here.
The following shows how a class that inherits from QObject should be declared:
class Foo : public QObject
{
Q_OBJECT
Q_PROPERTY(....)
public:
enum Bar {
};
Q_ENUM(Bar)
static void staticMethods();
explicit Foo(QObject *parent = nullptr);
bool publicMethod() const;
signals:
void mySignal();
protected slots:
void protectedSlot();
protected:
void protectedMethod();
private slots:
void privateSlot();
private:
void privateMethod();
bool _member;
};