Difference between revisions of "Coding Style"
Jump to navigation
Jump to search
m | |||
* '''Indentation''': 2 spaces | * '''Indentation''': 2 spaces | ||
| − | * '''Class names''': | + | * '''Class names''': PascalCase (e.g.: '''FurnaceManager'''). |
| − | * '''Variable and method names''': | + | * '''Variable and method names''': camelCase, (e.g.: '''updateWorld''', '''userCommands'''). |
** '''Pointer variables''': Use '''Foo* bar''' instead of '''Foo *bar''' | ** '''Pointer variables''': Use '''Foo* bar''' instead of '''Foo *bar''' | ||
** Using short names for loop variables is ok, e.g. '''i''', '''j'''. Otherwise use descriptive names and don't use abbreviations all over the place, to make the code more readable. | ** Using short names for loop variables is ok, e.g. '''i''', '''j'''. Otherwise use descriptive names and don't use abbreviations all over the place, to make the code more readable. | ||
** '''Static (class) variables''' should start with just an underscore, e.g. '''_instance''', '''_users''' etc. | ** '''Static (class) variables''' should start with just an underscore, e.g. '''_instance''', '''_users''' etc. | ||
* '''Namespaces''': We probably should use them. | * '''Namespaces''': We probably should use them. | ||
| − | * '''Codeblocks''': | + | * '''Codeblocks''': Use braces always for clarity and to prevent bugs while editing code |
| − | if(true) | + | if (true) |
{ | { | ||
foo = bar; | foo = bar; | ||
} | } | ||
| − | if(true) | + | if (true) |
{ | { | ||
foo = bar; | foo = bar; | ||
Foo* bar = new Foo(); | Foo* bar = new Foo(); | ||
fooBar(param1, param2, param3); | fooBar(param1, param2, param3); | ||
| − | for(int i = 0; i < 1; i++) | + | for (int i = 0; i < 1; i++) |
{ | { | ||
| − | + | ... | |
} | } | ||
