-
Notifications
You must be signed in to change notification settings - Fork 4
/
styleguide.txt
156 lines (114 loc) · 3.61 KB
/
styleguide.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#pragma once
#include "fileFromThisProject.h"
#include "fileFromThisProject.h"
#include "fileFromThisProject.h"
#include <fileFromElsewhere>
#include <fileFromElsewhere>
#include <fileFromSTD>
#include <fileFromSTD>
static constexpr int CATS_PER_SQUARE_KILOMETER = 12;
#define SUPER_MACRO(nameOfSomething) nameOfSomething "is totally cool!"
// There are no rules for globals
// Because there are no globals
/*
Massive comment spanning many lines
Massive comment spanning many lines
Massive comment spanning many lines
Massive comment spanning many lines
Massive comment spanning many lines
Massive comment spanning many lines
Huge explanation about insane thing
Use one of these when you get to about 6 lines of //'s
*/
enum class SuperCoolDogs
{
MORKIE_POO = 0,
CORGI,
NEWFOUNDLAND
};
// If you have to make an enum for bitflags or other such, a normal enum is fine. No need to bend backwards for a feature
enum DogFlags
{
DF_LARGE = 0,
DF_SOFT = 1,
DF_KIND = 2,
DF_SLEEPY = 4
};
namespace NiceNamespace
{
// Contents should be organized by their purpose and ordered based on most use, with public first
// CPascalCase
class CClassName : public CNeatBase
{
public:
// Constructor first
CClassName();
~CClassName();
// Functions second, categorized by topic
void PascalCase();
virtual void Overriden() override;
virtual void PascalCase() = 0;
void FunctionAboutCats();
void AnotherThingAboutCats();
void DogFunction();
void PetTheDog();
int m_camelCase;
int* m_coolVariable;
private:
// Private functions first
void CoolerSecretFunction();
bool m_coolHiddenVariable;
};
// If this an accessor management style class, its accessor should return a reference
// A pointer is more mental overhead for the programmer
// PascalCase
CClassName& ClassName();
// camelCase_t
struct radStorageThing_t
{
// Ideally don't use a struct as a class, but go ham if you need deconstructors or etc
// Don't prevent functionality just because it's against the style guide
radStorageThing_t();
~radStorageThing_t();
int totallyRadicalNumber;
bool isMyDogBlue;
float percentPurple;
};
// If this is for external accessing, PascalCase
// Log::Debug()
void SuperCoolFunctionInANamespace();
namespace
{
// For hidden functions for internal use only, camelCase
// These most likely will be in .cpp files and not in headers
// It's an odd edge of the "camel out of class" rule and "pascal in class" rule
void totallySecretSuperCoolFunction();
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Big Division Title Between Two Things That Should Really Be In Separate Files But Aren't As They Share Some Strange Functions //
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// camelCase so we know when we're calling something in a class or outside of a class
// Blah blah
// - Cool thing here
// Yadah yah
// This function bricks their whole PC
// And calls the cops for their crimes
template<typename T>
inline void superCoolFunction(T coolArgument, int anotherCoolArgument)
{
bool isTheDogFlying = false;
std::vector<T> dogList;
// If our dog is flying, we need all red dogs that exist to bark 10 times
// This is a hack, right now if we don't do this, the renderer inverts all normals
// Really no clue why this happens
if(isTheDogFlying)
for(int i = 0; i < 10; i++)
for(auto dog : dogList)
{
// If we bark the red dogs, they'll turn upside down
// Woofing is good enough for now
if(dog.IsRed())
dog.Woof();
}
}