Your Position: Join Wing -> How to: Write source code for wing -> Modules Design Principles
Modules Design Principles
1. Minimize header include and maximize compiling speed.
-
Define one class, or one structure, or one set of functions in one header file.
-
Implement inline functions in a *.inl file with the same name with corresponding *.h file. By doing so, only the file that is interested in those inline functions needs to include that *.inl.
-
The most frequently used inline functions, such as the default constructor of a class, should be placed in *.h file, not *.inl file.
-
Whenever possible, avoid inline functions. Doing so unless there is a great performance penalty that reported by performance analyzer.
-
Create a "Predeclaration.h" for each module. In that header put all pre-declarations of classes, structures and functions of that module, if necessary.
-
Avoid including header files in a header file, whenever possible. If you really need to include another header file in a header file, consider first if you can replace that include with pre-declaration.
-
Avoid declaring templates in a header file, whenever possible. If you really need to expose some template classes/structures/functions, consider put them in separate files to avoid add-on templates when you include one of them.
-
Minimize the connections between classes, whenever possible. Consider hiding details of the class in its implementation; consider common communication components such as a message pool.
2. Wrap classes in proper namespaces.
3. Minimize dependencies between modules.
-
Plugin based
-
Fast compilation
-
Minimize public header count
4. Minimize dependency on other projects.
5. Maintainability
-
Professional development environment and workflow.
-
Perfect development document.
-
Appropriate granularity and responsibility of modules.
6. Roubustness
-
Thorough automated test suites.
-
Priority-ranked defect management.
7. Extensibility
8. Ease of use
-
Simple but flexible UI.
-
Interactive tutorials.
-
Detailed reference document.
9. Performance
-
Thorough performance test and regression track suites.
10. Localizable
|