Scippy

UG

Ubiquity Generator framework

coding-style-guidelines.md
Go to the documentation of this file.
1 Coding style guidelines for UG
2 ------------------------------
3 
4 1. Source file directories and source file names
5  Source files are located in organized directories in the “src” directory as follows.
6  - ug: Source files of top abstracted base classes of UG
7  - ug_*: There are two cases:
8  1) Source files of abstracted base classes for a parallel framework developed on top of UG, for example, ug_bb, ug_cmaplap,
9  2) Source files for interface classes for a specific branch-and-bound based “base solvers”,
10  since UG was originally developed for parallel branch-and-bound, for example, ug_scip, ug_xpress.
11  Source files in the directory ug_* are named as follows by using ug_bb as an example:
12  - File names start with a lowercase letter with the second part of the directory name separated by ‘_’ and
13  the name followed by "Para" plus some meaningful name connected by an uppercase letter. For example, bbParaSolverPool.h and bbParaSolverPool.cpp.
14  - File names of the communicator objects are bbParaComm plus some meaningful name for the communicator. For example, bbParaCommMpi.h and bbParaCommMpi.cpp.
15  - File names for transferred objects, which are transferred between the LoadCorrdinator object and the Solver object, are ended with “Th” if it is for shared memory version,
16  or, are ended with “Mpi” if it is for distributed memory. For example, bbParaNodeTh.h, bbParaNodeTh.cpp, bbParaNodeMpi.h, bbParaNodeMpi.cpp.
17 
18 2. Source file structure
19  A source file consists of, in order:
20  1) License and copyright information
21  2) include statement
22  3) program codes for classes and functions
23  Exactly one blank line separating each section that is present.
24  Ordering of class contents is as follows:
25  1) private members
26  2) protected members
27  3) public members
28 
29 3. Formating
30  1) Spacing
31  - Indentation is 3 spaces. No tabs anywhere in the code.
32  - Every opening parenthesis requires an additional indentation of 3 spaces.
33  - Spaces around all operators.
34  - Spaces around the arguments inside an if/for/while-statement, as well as inside macros.
35  - No spaces between control structure keywords like "if", "for", "while", "switch" and the corresponding brackets.
36  - No spaces between a function name and the parenthesis in both the definition and function calls.
37  - Braces are on a new line and not indented.
38  - In function declarations, every parameter is on a new line.
39  - Always only one declaration in a line.
40  - Blank lines are inserted where it improves readability.
41  - Multiple blank lines are used to structure the code where single blank lines are insufficient, e.g., between differrent sections of the code.
42  2) Naming
43  - Class names start with an uppercase letter (Heading starts with sencond part of directory name)
44  - Variable names start with a lowercase letter
45  - Use assert() to show preconditions for the parameters, invariants, and postconditions.
46  - For each structure there is a typedef with the name in all upper case.
47  - Defines should be named all upper case.
48  3) Documentation
49  - Document functions, parameters, and variables in a doxygen conformed way.
50