C++ Software Design Tips Guidelines Checklist
Posted on March 8th, 2008
-- Sponsored Links --
-- Sponsored Links --
C++ Software Design Tips Guidelines Checklist

* Open/close principle
* Prefer free to member functions
* Consider moving private members to the implementation file– pimpl idiom (handle/body, compilation firewall)
* Namespace names after content (not e.g. reverse domain names) and not too deep
“Early optimization is the root of all evil”
– optimize only if it makes sense (e.g. after profiling)
– consider the disadvantages in terms of maintainability/readability
* Consider the pimpl idiom for interface classes
* Code should be reentrant/thread safe
* Prefer code to comments
* Use third party libs if good, in particular the standard library and boost
Header files
– Appropriate include guards
– Be independently compilable
– Don’ t impose choices on including TUs
* Useless includes in place of forward declarations
* Using directives and declarations
* Namespace aliases
Exceptions
– “Do I want/can afford stack unwinding here”
– Don’ t use exception specifications, just document them
– Derive from std::exception
– constructor/copy constructor/operator= should be throw()
– Don’ t throw in destructors
– Code should be exception safe
at least basic guarantee possibly, if worth, strong guarantee or nothrow
Filed under Programming |
Comments are closed.