Skip to content

Genesis Style Guide

Ian Pike edited this page Aug 24, 2023 · 2 revisions

THIS ARTICLE IS A WORK IN PROGRESS

Genesis follows an open style of formatting that is focused towards providing a fast and easy manner of reading over source code in exchange for much larger vertical code expansion. This guide here will aim to dictate further what the general style of the project is past what the clang-format and editorconfig tools enforce.

NOTE: These are not hard rules. Just suggestions and the user is free to choose if they wish to follow these rules or not. Though the user is highly encouraged to consider this guide and style as it is written with a purpose of making our code far easier to work with.

How to format in genesis


variables:

Variables inside of genesis always use camelCase and generally only modify a few things depending on the context of the variable itself. The key principles listed below better dictates also how you should handle variables as a whole, but at the end of the day the user is left the discretion to decide how they wish to implement these suggestion.

how to format variables:

type style
local variable int localVariable { 10 };
member variable int m_memberVariable { 10 };
global variable int g_globalVariable { 10 };

KEY PRINCIPLES OF VARIABLES:

  • Always use camelCase when creating a variable.
  • Prefer explicit declaration of variables instead of explicit unless the type is obvious or is only meant to exist temporarily. e.g. loops
  • Always prefer brace initialization when viable.
  • Avoid global variables at all cost unless it is unavoidable.
  • Use descriptive names and avoid acronyms. Ideally your variables should be verbose and aid any reader to immediately understand its purpose.
Clone this wiki locally