Difference between revisions of "Cpp Coding Standards/DESIGN"
From Apache OpenOffice Wiki
m |
|||
Line 2: | Line 2: | ||
General design rules. | General design rules. | ||
---- | ---- | ||
− | === | + | === Summary === |
− | + | ||
==== NoCyclicDependencies ==== | ==== NoCyclicDependencies ==== | ||
Avoid cyclic dependencies. | Avoid cyclic dependencies. | ||
Line 18: | Line 17: | ||
==== AvoidGlobalData ==== | ==== AvoidGlobalData ==== | ||
Minimize the use of global data. For objects in global scope that are meant to be local to a class' implementation use an anonymous namespace. | Minimize the use of global data. For objects in global scope that are meant to be local to a class' implementation use an anonymous namespace. | ||
+ | ---- | ||
+ | === Explanations === | ||
+ | |||
---- | ---- | ||
[[Category:Coding Standards]] | [[Category:Coding Standards]] |
Revision as of 18:10, 27 November 2006
Contents
Design
General design rules.
Summary
NoCyclicDependencies
Avoid cyclic dependencies.
DependencyInversionPrinciple
Use the dependency inversion principle. Prefer to define functionality in abstract interfaces and to inherit from them. Avoid state in abstract classes.
NoPrematureGeneralization
As a rule of thumb, don't generalize before the second occurrence and no later than the third.
GlobalDataInit
Avoid cross module dependencies when initializing global data. Never let a global object's initialization depend on another global object in a different compilation unit.
AvoidGlobalData
Minimize the use of global data. For objects in global scope that are meant to be local to a class' implementation use an anonymous namespace.