The defaults of our coding style will be here. Anything not mentioned within will defer to what is specified in the link.
Variables are to be named using snake_case, like bruh_moment or jesus_mcphricking_christ. Acronyms are to be treated as their own word and will be written in all lowercase, like pratyay_istg.
Classes and structs are to be named using PascalCase, like CursedObject or BessiesOnlyFans.
Files are to be named using snake_case like variables and functions. Directories, on the other hand, will be named using all lowercase letters with no spaces, like frickjava.
Lines are heavily encouraged to be kept under 120 characters. Below are some examples of how to format different long lines.
// long class constructor
CursedObject(const vector<vector<pair<long long, long long>>>>& cursed_thing, const unordered_map<long long, vector<pair<int, string>>> other_cursed, int num) : num(num), arr(cursed_thing.size()), other_arr(num) { }
// formatted class constructor
CursedObject(const vector<vector<pair<long long, long long>>>>& cursed_thing,
const unordered_map<long long, vector<pair<int, string>>> other_cursed,
int num)
: num(num), arr(cursed_thing.size()), // multiple variables on a line OK
other_arr(num) { }
// long function call
int result_status = min(assassinate_fj(CursedObject(cursed_thing, 420696969), bessie), assassinate_fj(CursedObject(cursed_thing, -8), bessie));
// formatted function call
int result_status = min(
assassinate_fj(CursedObject(cursed_thing, 420696969), bessie),
assassinate_fj(CursedObject(cursed_thing, -8), bessie)
);
// (not that) long ternary expression
int includeTop = top + 1 < ysBetween.size() ? ysBetween[top + 1] - width : numeric_limits<int>::max();
// formatted ternary expression
int includeTop = top + 1 < ysBetween.size()
? ysBetween[top + 1] - width
: numeric_limits<int>::max();
Comment lines that go over the line limit are to be formatted using the \* and */ multiline comment tokens, like so:
/*
* there are no strangers to love, you know the rules,
* and so do i, a full committment's what i've been thinking of
* you wouldn't get this from any other guy
*/The methods of a class are to be ordered as follows:
class BessieOnlyFans {
private:
const int MOD = 1e9 + 7; // constants in their own section
int some_var;
long long another_var;
vector<int> defaulted_thing(1234);
vector<int> another_defaulted_thing(1234);
void private_spaghet_method() {
// i, just wanna tell you how i'm feeling
}
public:
// don't think public variables are supposed to be best practice anyways
int public_var;
BessieOnlyFans(int x, int size) : some_var(x) {
// gotta make you, understand
}
int getter_setter_whatever() {
// never gonna give you up, never gonna let you down
}
}