Skip to content

Robomongo Coding Style

schetnikovich edited this page Jan 9, 2013 · 41 revisions

In general, we follow MongoDB style guides, which in turns tries to follow Google C++ Style Guide.

The most important rules are:

#includes

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"

Header (.h) files

Follow this order:

  1. #pragma once at the top. Blank line.
  2. Third party #includes, sorted. Blank line.
  3. Robomongo #includes, sorted. Blank line.

Implementation (.cpp) files

  1. Primary file #include, if applicable. Blank line.
  2. Third party #includes, sorted. Blank line.
  3. Robomongo #includes, sorted. Blank line.

Clone this wiki locally