This document can be further revised based on the feedback and later gains from personal experience.
The code base increases significantly as the project develops, depending on the project goal and type. Inconsistent code base jeopardizes readability and maintainability, interfering with personal or team productivity.
Programming standards might not be necessary for coding one-time-use code bases. Following a programming style guide is required to avoid code base inconsistencies and entering the debugging hell.
Clean code does not exist, and it is a fairy tale because the perception of clean code is subjective to individuals or teams. The goal of this document is to avoid writing unreadable code and to avoid religiously following the Clean code.
A simplified example of obfuscated, deeply nested code)
#include <iostream>
#include <cstdlib>
void mergeSort(int *arr, int l, int r) {
if (l < r) {
int m = l + (r - l) / 2;
mergeSort(arr, l, m);
mergeSort(arr, m + 1, r);
int n1 = m - l + 1;
int n2 = r - m;
int *L = (int*) malloc(n1 * sizeof(int));
int *R = (int*) malloc(n2 * sizeof(int));
for (int i = 0; i < n1; i++) L[i] = arr[l + i];
for (int j = 0; j < n2; j++) R[j] = arr[m + 1 + j];
int i = 0, j = 0, k = l;
while (i < n1) {
if (j < n2) {
if (L[i] <= R[j]) {
arr[k] = L[i];
i++;
} else {
arr[k] = R[j];
j++;
}
} else {
arr[k] = L[i];
i++;
}
k++;
}
while (j < n2) {
arr[k] = R[j];
j++;
k++;
}
free(L);
free(R);
}
}
(rather than adopting others).
Many well-documented C++ programming style guides and conventions, such as the Google style guide and the Unreal coding standard, are available online. Despite their availability, pioneering firsthand is time-consuming, but learning the reasons behind the rules is invaluable.
C++ Coding Standards | Pope's Dev Docs