Skip to content

Code style conventions

Christian edited this page Nov 25, 2015 · 4 revisions

Code style conventions

Don't worry since this is no big project there are not so many code style conventions. However, it would be nice if the following conventions could be followed. If you see something that does not comly feel free to correct it.

Indentation

Always use 2 spaces to indent something. Never use tabs since they always look different depending on your IDE.

Line endings and encoding

Unix style LF. UTF8 file encoding.

Curly brackets

Use the following style for curly brackets:

if (somethingIsTrue)
{
  int i=0;
  i += 2;
}

If there is only one line of code you can also write:

if (somethingIsTrue)
  doSomething();

Variable naming

Since the project already uses a lot of CamelCase styled variables we will stick to this. I know there are good reasons to use snake_case but that would require a lot of changes to the existing code.

Class member variables

Don't mark class members with any prefix. E.g:

int iSomeName;             // Don't
int p_privateClassMember;  // Also don't
int m_anotherClassMember;  // No

If you have a modern IDE it can tell you what type/class the variable you are looking at is a member of. If you want to you can probably also configure it to highlight class members dirrefently compared to local variables so there is really no reason to put it in the name.

Clone this wiki locally