Naming and coding style

From Fish Run Games SDK
Jump to: navigation, search

Spaces and braces

Braces must be put always, even if loop or condition have only one command inside. Braces are always go to next line:

if (a == b)
{
	b++;
}

Symbols and operators spaced:

b = a + 5 * (c + 2) / 2;

Commas spaced too:

func(5, 6, c);

Naming

  • Use CamelCase;
  • Avoid underscores whenever possible;
  • Data types starts from T, just like in Delphi;
  • Local variables and function/method params starts with small letter (means, that they are temporary);
  • Global variables, functions, class fields and methods start from capital letter (means – they are stable, not temporary);
  • Constants begins with "CONST_", and have capital letters, separated by underscores.

Example code

int ThisFunc(int paramOne, float paramTwo)
{
	int localVar;
}

class TThisClass
{
	float ClassField;
	void ThisClassMethod(float methodParam);
};

void TThisClass::ThisClassMethod(float methodParam)
{
	ClassField = methodMaram;
}

TThisClass ThisClass;
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox