hibiscus/CODINGSTYLE.md

55 lines
2 KiB
Markdown

# Hibis Coding Standards
## CXX Language
Use C++17 as the C++ standard. Hibis should compile under all major compilers.
## Structure
Each module of the game engine should be kept within their specific folders. E.g.:
- Core
- Renderer/(renderer name)
If statically linking third party libraries are *absolutely* required, they must be placed in a folder called `external` in the repository root.
## Formatting
Files need to end with a new line.<br>
Indenting should be done using hard tabs (the tab character) rather than spaces.<br>
New lines should be after `{` with the exception of class/struct construction which has no newlines at all.<br>
There should be one class per file.
## Includes
`#include` uses must go in the following order (with each section seperated by an extra newline):
```cpp
#include <system-header>
// From Hibis
#include <hibis-header>
// Use header in current dir
#include "relative-header"
```
`..` should be avoided within "relative" headers in the event it causes issues for packagers.<br>
Include guards should be handled via `#pragma once`.
## Variables
Variables should be camelCase and be named to make it obvious what their purpose is.<br>
Variables should be prefixed with specific chars depending on where the variable is.
- Member Variable - Prefix with `m`
- Global Variable - Prefix with `g`
- Static Variable - Prefix with `s`
Example:
```cpp
const int gAmountOfTimesISuccessfullyWriteGoodVariableNames = 0;
class ExampleClass final {
public:
ExampleClass() {}
~ExampleClass() {}
// dont ask
void hmmmTimeToScream() {
std::cout << "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAa" << std::endl;
}
private:
std::string mMyName = "Example Class";
}
```
## Classes
If a class is not going to be used/intended to be used for polymorphism, mark it as a `final` class.<br>
Base classes should make all functions `virtual` to allow for functions to be overriden.<br>
Simple set/get functions should be inside of the header file on a single line.<br>
Class names should be in PascalCase and be obvious what their purpose is.