-
Notifications
You must be signed in to change notification settings - Fork 20
Coding Style
Here are some points that should be followed if possible when contributing to Ant. Read the existing source and try to infer the spirit of this project. Have a look at software development books, such as "Effective Modern C++" by Scott Meyers and "Clean Code" by Robert Martin.
- In any case, use Github, open issues, provide pull requests, make your wishes, thoughts, code changes public as early as possible. Don't promise to publish something some day later, and then never do it.
- Prefer general solutions and avoid hardcoding things, such as number of channels of detectors, they might change and novices don't know that 720 or 672 might have something to do with the CB.
- If you're aware that you're doing something "not quite right", label it with
/// \bug ...
doxygen-aware comment blocks and describe the problem.
See C++ FAQ.
Do not manually handle error conditions, but throw
things derived from std::exception
. RAII makes your code naturally exception-safe with respect to memory leaks.
- Do not use
char*
. usestd::string
- Do not use C-style arrays, use
std::vector
- Do not use
printf
, use thestd::ostream& operator<<
technique
C++ has zero-overhead for data types if done right. But usually, even performance drawbacks are acceptable if the solution looks easier to understand and/or is more general.
But use std::unique_ptr
and std::shared_ptr
, although ROOT makes this hard as it has its own weird understanding of object ownership. There are wrappers in Ant, such as src/base/WrapTFile.h
and src/base/WrapTTree.h
.