IMP Manual
develop.5128fd965d,2024/12/03
|
Below are suggestions prompted by bugs found in code submitted to IMP.
using namespace
' outside of a function; instead explicitly provide the namespace. (This avoids namespace pollution, and removes any ambiguity.)const
variables instead. Preprocessor symbols don't have scope or type and so can have unexpected effects.const &
(if the object is large) and store copies of them.const
value or const
reference if you are not providing write access. Returning a const
copy means the compiler will report an error if the caller tries to modify the return value without creating a copy of it.#include <IMP/mymodule/mymodule_exports.h> #include <IMP/mymodule/MyRestraint.h> #include <IMP/Restraint.h> #include <vector>
double
variables for all computational intermediates.FloatKey get_my_float_key() { static FloatKey k("hello"); return k; }
double
parameters) it is easy for a user to mix up the order of arguments and the compiler will not complain. int
and double
count as equivalent types for this rule since the compiler will transparently convert an int
into a double.