-
Notifications
You must be signed in to change notification settings - Fork 0
/
Coding Guidelines.txt
21 lines (11 loc) · 2.09 KB
/
Coding Guidelines.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Coding Guidelines for Metternich
1. Namespace, class, variable and function names are in snake_case.
2. Function names generally begin with a verb in the imperative, for example: DoSomething().
3. Prefer defining functions in headers if they don't require any external includes (which aren't already in the precompiled headers), so that the compiler is able to inline the functions if it deems optimal to do so, thus providing performance improvements.
4. Braces are always used for "if" statements.
5. Header files are included in the following order: first the header which corresponds to the current source file, then the other Metternich headers, then headers for third-party libraries, then Qt headers, and finally standard library headers.
6. Documentation headers for functions are located where the function definition is, regardless of whether that is in a header or source file.
7. Class definitions should be ordered in the following fashion: first, any macros which define a portion of the class (e.g. the Q_OBJECT macro). Then, typedefs, followed by enumerations, constant expressions, static methods, static variables, instance methods and finally instance variables. Within each of these, public ones are to be followed by protected members, and finally private ones.
8. The precompiled headers should include all library/third party headers used by the engine, but no headers belonging to Metternich itself. This way, compile times are reduced substantially, without
9. Using classes from the standard C++ library is to be preferred to Qt-specific ones.
10. Include Metternich headers in other Metternich headers only in the following circumstances: 1. if a class defined in the header derives from a class defined in the other header, 2. if a template class defined in the header requires the inclusion of the other header or 3. if the header pertains to a small derived class of e.g. a scripted condition, and is itself only included in a source file with a factory function (in such a case the header of the small derived class should have no source file, so that compilation and linking times are kept in check).