-
Notifications
You must be signed in to change notification settings - Fork 824
Robomongo Coding Style
In most cases we follow MongoDB style guides, which in turns tries to follow Google C++ Style Guide.
The most notable Robomongo rules are:
Use "double quotes" for Robomongo code, <angle brackets> for 3rd party or library headers, including MongoDB files:
#include <QStringList>
#include <boost/shared_ptr.hpp>
#include <mongo/client/dbclient.h>
#include "robomongo/core/Core.h"
#include "robomongo/core/MongoElement.h"All of a project's header files should be listed as descendants of the project's src/ source directory without use of directory shortcuts (. and ..).
Correct:
#include "robomongo/core/MongoElement.h"
Wrong:
#include "core/MongoElement.h"
#include "../core/MongoElement.h"
#include "MongoElement.h"
Follow this order:
-
#pragma onceat the top. Blank line. - Third party #includes, sorted. Blank line.
- Robomongo #includes, sorted. Blank line.
- Primary file #include, if applicable. Blank line.
- Third party #includes, sorted. Blank line.
- Robomongo #includes, sorted. Blank line.
Your class definition should be divided on 'access' sections in the following order:
public:signals:public slots:protected:protected slots:private:private slots:
If any of these sections are empty, omit them.
Within each section, the declaration should be in the following order:
- Typedefs and Enums
- Constants (`static const data members)
- Constructors
- Destructor
- Methods, including static methods
- Data members
Method definitions in the corresponding .cpp file should be the same as the declaration order.
Do not put large method definitions inline in the class definition. Usually, only trivial or performance-critical, and very short, methods may be defined inline.