Frogman Engine C++ Programming Standard

This document can be further revised.

Preface

The Necessity of Programming Standards.

Code base increases significantly as a project develops, depending on the project goal and type. Inconsistent code base jeopardizes readability and maintainability, interfering personal or team productivity.

Programming standards might not be necessary for 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);
    }
}

Creating the Programming Style Guide

(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, learning the reasons behind the rules is invaluable.

Reference

C++ Coding Standards | Pope's Dev Docs

Major Rules

1. Do Not Religiously Practice Clean Code. Try Not to Write Redundant, Over-Engineered, or Complicated Code so Co-workers Can Easily Read and Understand them.