Hey Jan!
I thought it would be nice to have a wiki-page on redmine regarding coding-
style since you are obviously on the verge of using a new style and I am
trying to find out how it exactly looks. So I would ask just one favour from
you and I will send you the source of a redmine-wiki page you only need to
copy&paste then. This way other users can benefit from it, too.
The favour: Could you re-format the following code-snippets according to your
style? And maybe add a few if you think I forgot something?
#include <AHeader> //sort alphabetically
#include <BHeader>
class AHelperForwardDeclared; //sort alphabetically, too
class BHelperForwardDeclared;
class CHelperForwardDeclared;
namespace NameSpace {
class A : public B
{
public:
A();
explicit A(SomeThing *arg = defaultArg);
A(int a, int b);
~A();
void someFunc()const;
void someFunc(bool a, int b);
void booyaaahhh();
private:
int _privateIntMember;
double *_privateDoublePointerMember;
};
}//namespace NameSpace
... .cpp file:
namespace NameSpace{
A::A() : B(0), _privateIntMember(0), _privateDoubleMember(0)
{
}
A::A(SomeThing *arg) :
B(arg),
_privateIntMember(0),
_privateDoubleMember(0)
{
}
A::A(int a,int b)
:B(0)
,_privateIntMember(0)
,_privateDoubleMember(0)
{
}
void A::someFunc()const
{
//curly braces for one-liners?
if( someThingIsWrong() ){
doFoo();
}else{
doBar();
}
}
void A::someFunc(bool a, int b)
{
//spaces inside between a and the brackets?
if (a){
doFoo();
}else{
doBar();
}
//indent break along with the statements?
switch (b){
case 0:
zero();
break;
case 1:
one();
break;
case 2:{
notOne();
notZero();
}break;
default:
atLeastZero();
}
}
}//namespace NameSpace
void NameSpace::A::booyaaahhh()
{
std::cout<<"Booyaaahhh!\n";
}
You don't need to commet on the changes made, I will just put a side-by-side
comparison onto the wikipage and describe the differences myself.
Oh and: feel free to say you don't have time for this right now ;)
Thanks,
Thomas