I was bored today and, while not wanting to work on something bigger,
wanted contribute something to Haiku again. So I decided to clean up
some sources / headers and to check for uninitialized variables and
unneeded leftovers.
But when trying to apply "the code guideline" I noticed that there is
not really one complete guideline. As I understand it the official style
guideline is the one from OpenTracker, which is also linked from
Haiku-OS.org (Contribute -> Coding Guidelines). I read them some times
in the past and just read them again.
But I came to the conclusion that they are just not in line with the Be
header style I adapted to and use since quite some time (which rather
surprised me as the OpenTracker headers should be similar to the Be
headers).
The very first bit of "Indendting and Whitespaces" describes a class you
may have in a header (I used spaces here because of possible tab-width
issues):
Guideline:
class Foo : public Bar { public: Foo(int32); virtual ~Foo();
virtual void SomeFunction(SomeType *); // you may omit argument names if they don't help // documenting their purpose
virtual const char *FunctionWithLotsOfArguments( const char *name, const char *path, const char *user); // indent long argument lists by a tab
private: int32 fMember1; int32 fMember2; const char *fMember3; };
Be:
class Foo : public Bar {
public: Foo( int32 indented_to_align_args, int32 if_wrapped_over, int32 multiple_lines); virtual ~Foo();
Foo(BMessage *data); static BArchivable *Instantiate(BMessage *data); virtual status_t Archive(BMessage *data, bool deep) const;
virtual void Pulse(); virtual void FrameMoved(BPoint new_position);
private: int32 fMember1; int32 fMember2; const char *fMember3; };
This: { int32 variable = 0; float another = 1.0; <-- line starts here while () { // more code } }
Vs. that: { int32 variable = 0; float another = 1.0; <-- line starts here while () { // more code } }
Thoughts?