C++ Software Design Tips Guidelines Checklist
Programming ....
|
|
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

Prashant Mhatre
Make Money, Programming, Bollywood, Marathi
^_*
March 8th, 2008 at 8:37 pm
[…] AhTim wrote an interesting post today onHere’s a quick excerptC++ 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 … […]