Xpsycle/developer/programming guidlines

example:
 * a variable is named with an "_"-literal.

private:

std::string _name; std::string street_;


 * declare variable`s only privat, use, when public or protected acces is needed, special set/and get methods.


 * use the variable name with'_'


 * naming of setter and getter

use the private variable name without '-' as getter, use the name of the variable with setVarName as getter name.

example:

public:

std::string name const; void setName( const std::string & name );

private:

std::string name_;

example:
 * class naming
 * * we use java formatting in xpsycle code. That means, class names start with upper case, and class names doesn't start with "C".

class MainWindow class SequencerGUI

example: void play; void setName; void setAdress; void setSamplerRate( int rate );
 * Method naming
 * * we use java formatting in xpsycle code. That means, we start with a lower case literal, and concat words simply by adding them upper case.

etc, etc ..

setWord1Word2Word3


 * use const

for getmethods we always use const at the end example: std::string name const; int bpm int;

for setMethods with a parameter we try to use as often const as possible example if we dont use : setName( std::string name); but setName( const std::string & name );

avoid c macro stuff like define, use instead const int etc ..


 * in general avoid macros

we use a compiler not a preprocessor :)


 * if really nessesary, use macros for crossform code:

ifdef __unix__
 * 1) example
 * 1) endif
 * 2) else

example: NK_Left and not XK_Left or VK_LEFT
 * avoid direct calls to xlib / windows.h etc


 * use stl, and never an c array:

example: use std::vector and not int a[max_size];

example
 * dont use namespace includes in .h files

test.h using namespace std; class DontDothis { public: string giveMeAStd_; here use instead std::string iHaveAStlNamespace. Note: in a .cpp file you can of course use a namespace.


 * if you use pointers in classes, don't forget to write an copy ctor


 * if you write an copy ctor always write an = operator, too


 * use a virtual dtor, if you plan that you have a base class. ( mostly you see that, if you have some methods virtual ).

( I find this helps on a sleepy afternoon aswell, the best coffee I've found, what a kick ^^ -> http://www.preisvergleich.org/pimages/Lavazza-Qualitr-Oro-Kaffeebohnen-1-Kilogramm_129__3300015_20.jpg)
 * dont forget to eat ( e.g pizza ) and sleep some minutes, if you programming xpsycle :)


 * back to main page