our_dick/doc/coding_standard.txt
2020-08-17 09:57:00 -07:00

99 lines
2.1 KiB
Plaintext

naming:
class names, struct names, union names, enum names: underscores
variable names: underscores
internal member variables: underscores prefixed with 'm_'
internal static member variables: underscores prefixed with 's_'
no use of underscore capital identifiers or identifiers with double underscore: '_Identifier' 'id__thing'
template parameters: Capital camel case
#define : ALL_CAP_UNDERSCORES
enum values: ALL_CAP_UNDERSCORES
must do's:
general:
c++17 targetted standard
115 max line length
prefer // over /**/
format pointers as `char* thing;`
tabs not spaces
c++ casts
spaces around assignment, comparison, and arithmetic operators
spaces after semicolon in for loop
spaces after comma operator and after parameter commas
const wherever possible (const-correctness)
pass by pointer or by reference
prefer reference over pointer
keep implementation in source files with template and constexpr as exceptions
keep template/constexpr implementations in .tpp files alongside the .hpp files
prefer nullptr over NULL
functions:
50 max length
comments max 2 lines
no void in parameter list: void func(){}
brace formatting:
namespace thing{
}
void function(void){
}
if(thing){
}else if(thing){
}else{
}
for(){
}
switch(case){
case 1:
break;
}
struct thing {
int thingy;
};
union thing {
int thingy;
};
class thing
{
private:
int thingy;
public:
void func(void);
};
enum thing{
stuff,
};
no-no's:
goto (except when breaking from inner loop)
for(){
for(){
goto breakinner;
}
}
breakinner:;
using c++ exceptions
using <iostream>
asm blocks
use of 'friend'
nested ternary
ternary outside of variable initialization
lambdas
malloc/free
#pragma
structured bindings
range based for loops
`class` in template parameter list
struct keyword before an object declaration
struct game_state* gl; //bad boi
excess include directives
if body on the same line as the if keyword
else body on the same line as the else keyword
if(thing) do_stuff();