-
Notifications
You must be signed in to change notification settings - Fork 9
CONTRIBUTING
http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es-expressions-and-statements
Space between code sections indicates that you are doing a multi-section function. Time to factor?
Do we want functions to always go into a namespace?
You don't need to specify input type as part of function name-- the function signature tells us that
Use something_count
rather than n_something
or num_something
.
This corresponds to something_vector
.
Abbreviations should be used sparingly, and they should be documented in the following list.
_idx
_str
px_
Should we do _params
?
Make everything consistent. If you have plain_yogurt
, then use plain_yogurt_count
, not plainyogurt_count
.
Clarity is first priority.
Make everything explicit.
- Use braces everywhere.
- Explicit casts vs type conversions.
No code duplication.
No out arguments.
No uninitialized variables. That's why we use the ternary operator. http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-always
Working on the stack preserves memory locality.
Comments are for documenting intent.
Avoid if statements.
No sentinel values.
Structured programming. Early return is not structured programming, but we use } // else
Make sure you can break your tests. Tweak something and make sure they fail.
Use operation-assignment operators such as += where appropriate.
Understand rules for RVO.
Use raw strings.
Note that you can <<
any standard container to std::cout
or whatever through the magic of cxx-prettyprint.
unsigned types are generally considered to be a bad thing https://channel9.msdn.com/Events/GoingNative/2013/Interactive-Panel-Ask-Us-Anything 9:50, 42:40, 1:02:50 but they are "correct" for indexing and are all over the STL. Note that Eigen uses https://en.cppreference.com/w/cpp/types/ptrdiff_t .