prefix 'm' written in camelCase.
Examples:
const int mFoo;
float mBar;
static std::string mHeaderText;Always use const when a variable shouldn't change value.
No prefix but a good name using camelCase that describes the object is required.
Examples:
void Foo(const Vector2ui& windowSize) -> Good!
void Bar(const int& int / number / bla) -> Bad!Accessibility operators should always be in the following order
-
public
-
protected
-
private
Structs should be used as pure POD (piece of data) objects. No constructors, functions or operators should be defined in the struct, in that case it should be a class. Defining helper functions outside the struct is allowed but should be in a namespace.
A POD struct:
struct Foo {
int counter = 0;
std::string name = "";
}A bad struct:
struct Foo {
void DoSomethingCool(const std::string& newName);
int counter = 0;
private:
std::string name = "";
}New folders should use PascalCase:
Source/Core/Engine/ECS
New files should use camelCase:
testClass.h
Classes inside of Core (Engine) should be put inside the namespace RF (RuneForge)
Classes inside of Editor should be put inside the namespace RE (RuneEditor)
Classes outside these should be put in a namespace in a categorizing way:
Math::Vector3 Utils::GenericHelperFunction
It is important to keep the namespace as short as you can while still keeping a good description of the category, this is to not bloat the code more than is needed.
Global variables in source files should be put in an empty namespace.
Uses the prefix 'g' written in camelCase
constexpr int gSuperImportantInt = 42;
Globals should always be in a namespace.