This is an old revision of the document! Rosegarden Coding StyleRosegarden house style is as follows, in approximately descending order of importance:
namespace Rosegarden { // 1 // 2 class SomeUsefulClass { // code }; // 1 // 2 }
int SomeClass::someMethod(int f) { int result = 0; if (f >= 0) { for (int i = 0; i < f; ++i) { result += i; } } else { result = -1; } return result; }
if (something) somethingElse(); if (something) { somethingElse(); } but not: if (something) somethingElse();
connect(detailsButton, SIGNAL(clicked(bool)), this, SLOT(slotDetails())); but not: connect( detailsButton, SIGNAL( clicked(bool) ), this, SLOT( slotDetails() ) );
connect(m_pluginList, SIGNAL(activated(int)), this, SLOT(slotPluginSelected(int))); but not: connect(m_pluginList, SIGNAL(activated(int)), this, SLOT(slotPluginSelected(int)));
//&&& This code was deleted temporarily // for (int m = 0; m <= n; ++m) { // int x = s.x() + (int)((m * ((double)m * ax + bx)) / n); // int y = s.y() + (int)((m * ((double)m * ay + by)) / n); // } but not: //&&& This code was deleted temporarily /* for (int m = 0; m <= n; ++m) { int x = s.x() + (int)((m * ((double)m * ax + bx)) / n); int y = s.y() + (int)((m * ((double)m * ay + by)) / n); } */ (The reason C++-style comments are preferred is not arbitrary. C++-style comments are much more obvious when viewing diffs on the rosegarden-bugs list, because they force the entire block of text to be displayed, instead of only the starting and ending lines.)
#include "MyHeader.h" #include "MyCousinClassHeader.h" #include "MyOtherCousin.h" #include "RosegardenHeader.h" #include "base/SomeOtherHeader.h" #include <QSomeClass> #include <QSomeOtherClass> #include <some_stl_class> #include <some_other_stl_class> |