< KDevelop5
Revision as of 10:56, 11 March 2016 by Ochurlaud (talk | contribs) (Ochurlaud moved page Projects/KDevelop4/CodingStyle to KDevelop5/CodingStyle)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

KDevelop5/CodingStyle

The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

The current KDevelop code base is very inconsistent when it comes to the coding style. So please adhere to the file's coding style you are working on / patching.

For new files / projects / plugins, please use the Policies/Kdelibs_Coding_Style guidelines. Here are a few special additions:

QObject and Access Modifiers

// wrong
class Foo : public QObject {
Q_OBJECT
  public:
    Foo();
  private:
    int bla;
};

// correct foo.h
class Foo: public QObject
{
    Q_OBJECT
public:
    Foo();
private:
    int m_bla;
};

Class Initialization

// wrong foo.h
class Foo : public Bar {
public:
    Foo(int i, int j) : Bar(i), bla(j) { /* do stuff */ }
private:
    int bla;
};

// correct foo.h
class Foo: public Bar
{
public:
    Foo(int i, int j);
private:
    int m_bla;
};
// foo.cpp
Foo::Foo(int i, int j)
: Bar(i)
, m_bla(j)
{
    // do stuff
}

Using Namespaces

Never add a "using namespace ..." to a header. Do use that though in every .cpp file , esp. for the KDevelop namespace. Public API should always be in the KDevelop namespace.


This page was last edited on 11 March 2016, at 10:56. Content is available under Creative Commons License SA 4.0 unless otherwise noted.