Coding Conventions

General

#include "kernel/system.h"
#include "framework/system.h"

// vim:ts=4:sw=4:

class Utils
{
        static B ConvertA2B(A a);
        static A ConvertB2A(B b);
};

class Server
{
        static Server *instance;
}

void function Class::DoSomething(int param)
{
        this->result = this->DoSomethingElse(param);
}

Code formatting

class Class
{
--->int nimber;________// number
--->char *string;______// string
}

Where ---> is tabulator, _ is space.

if (condition)
        OneLine();

if (condition)
{
        FirstLine();
        SecondLine();
}

if (condition1)
{
        if (condition2)
                SecondLine();
}

if (condition1 || condition2 || condition3 ||
        condition4 || condition5 || condition6)
{
        OneLine();
}

do
{
        OneLine();
} while (condition)

void Class::Function()
{
        FuncionBody();
}

Each block contains 'public', 'protected' or 'private' part (in this order).
For example:

class DataFile
{
//-- embeded
public:
        enum LoadState
        {
                STATE_UNLOADED,
                STATE_BLOCK_LOADED,
                STATE_LOADED
        };


//-- methods
public:
        bool Open();
        void Close();
        bool LoadData();

        void SetFileName(const string &file_name);
        LoadState GetState();
        bool IsOpened();

protected:
        DeleteData();


//-- variables
protected:
        string file_name;
        LoadState state;
        bool opened;
}

//=========================================================================
// Included files
//=========================================================================

//=========================================================================
// DataFile
//=========================================================================

//=========================================================================
// Methods
//=========================================================================

Comments

/**
	@file filename.h
	@ingroup Module_Name

 	@author Your Name
	@date Year

	@version 1.0 - Initial.
	@version 1.1 - Changes made...
*/

Input/output of functions.


Where to use Assert: at first everywhere, afterwards asserts can be changed to 'if' statements Where not to use Assert: when you want to check parameters that depends on user input (configuration fiels).


Please consider that Assert macro is not compiled into Release version. Therefore thay should be used for transfer of internal parameters. Asserts helps you to find bugs. You don't need to thrifty.


Generated on Sat Oct 20 14:47:30 2007 for Dark Oberon by  doxygen 1.5.3