forked from ducttape/ducttape-engine
-
Notifications
You must be signed in to change notification settings - Fork 1
Coding standards
svenstaro edited this page Jul 19, 2011
·
28 revisions
- Line limit: 100 characters
- Methods: LikeThis()
- Private methods: _LikeThis()
- Functions: like_this()
- Members: mLikeThis
- Macros and globals: LIKE_THIS
- Local objects, Parameters: like_this
- Pointers: Like* this
- References: Like& this
- Use 4 real spaces per level of indentation
- Comparisons: if("stuff" == "stuff")
Blocks:
while(true) {
DoStuff();
}
- The code needs to compile without warnings as they are treated as errors.
- Use the stack whenever possible. If a single dynamic allocation is required, use std::shared_ptr. For multiple dynamic allocations, be sure to put them into a boost::ptr_container.
- Do not use copy constructors unless required! Good: std::string blah("hi"), bad: std::string blah = "hi"
- Run valgrind on your stuff. Make sure it comes out clean.
- Document every bit of code using doxygen.
- Practice const-correctness.
- Never commit stuff that doesn't compile or that breaks tests.
- Don't use the
using
keyword. We like our code to be explicit since we are working with so many different libraries and otherwise the function origins wouldn't always be clear.