Largely based on Google C++ Style Guide: (https://sun.iwu.edu/~mliffito/cs_codex/posts/google-c++-style-guide/)
- Local and global variables will be named in lower_case_with_underscores.
- Structure member variables (attributes) will be named with_a_trailing_underscore_.
- Structure names will be named in upper CamelCase
- Functions will be named in upper CamelCase
- Enums, will be named in upper CamelCase
- Structure methods will be named in lower CamelCase
- All names should be descriptive, other than loop counter variables like i.
- Variable, class, and function comments come before the commented component.
- Doxygen comments: /// Inserts a molecule into the vector of atoms. /// /// Note: updates the numberOfMoleculesPerComponent, numberOfIntegerMoleculesPerComponent, /// numberOfPseudoAtoms, totalNumberOfPseudoAtoms. /// - Parameters: /// - selectedComponent: the index of the component /// - atoms: vector of atoms to be inserted /// - returns:
- Prefer // over /* and */.
- Terminal: 120 columns
- Braces: Allman style
- Horizontal whitespace: Use 1 space around (most) operators. E.g., x = y + z as opposed to x=y+z. Exceptions: ., ->, ++, and --.
- Do not put a space between a function name and its argument or parameter list. E.g., write Function(arg1, arg2), not Function (arg1, arg2).
- Vertical whitespace: Use 2 blank lines between functions/classes etc., as well as between related sections of code within a function (sort of like paragraph breaks in writing).
- Indentation: Indent each nested block 2 spaces at a time. Do not use tabs in your code. You should set your editor to emit spaces when you hit the tab key.
- Structures should be declared and implemented in their own files, which are named structure_name.ixx (declaration) and structure_name.cpp (implementation).
- Structures data members (attributes) are public
- All structures should have explicit constructors and destructors, even if they do nothing, for clarity.
- Use this-> to access an object’s attributes and methods from within its methods — this immediately differentiates them from normal variables and functions.
- avoid 'auto' to prioritize code clarity and safety over convenience.
upper camel case, or Pascal case: ThisIsUpperCamelCase or ThisIsPascalCase lower camel case: thisIsLowerCamelCase snake case: this_is_snake_case
Allman style: This style puts the brace associated with a control statement on the next line, indented to the same level as the control statement. Statements within the braces are indented to the next level. while (x == y) { foo(); bar(); }