When contributing to Hexed, please adhere to these guidelines. Some are standard practice in software development, which I feel the need to specify since people contributing to Hexed may not be software engineers by training. Others are meant to standardize what is otherwise a matter of personal preference.
Please do not commit or push to the main
branch. The standard workflow should be the following:
After reviewing the pull request, the maintainer will merge it and delete the branch. You are encouraged to create as many new branches as you like, for any reason, even if they are just experiments you don't intend to merge. However, if you are completely done with a branch, please delete it. You are also encouraged to push frequently (at least once per work day)—productivity is maximized when everyone can see the latest version of everything. Finally, development should be test-driven as much as possible, granted the inherent difficulty of testing a computational physics solver.
A pull request will not be merged until it meets the following requirements:
Release
and in Debug
mode with sanitizers.Please adhere to the following style conventions whenever possible.
_
) to hyphens (-
) or camel case as word separators in file names.(of variables, functions, namespaces, classes, macros, etc. Anything in the code.)
x
to refer to horizontal position. Acceptable alternatives might be coord0
, or position
.Some examples of names I do not approve of:
eye
to refer to the identity matrix. References the pronunciation of the mathematical symbol, two levels removed from any descriptive meaning. I prefer the name identity
.str2num
to mean "string to number". Just call it str_to_num
. Distinguishing between "2" and "to" is worth 3 extra characters.If the code encounters a fatal problem, it should throw an exception (using the constructs of whatever language it is currently in) with a helpful error message. The message should identify what exactly was found to be wrong so that someone capable of understanding the problem has a clue where to start trying to figure out why. In the interest of performance, some functions in the C++ API may produce segmentation faults, memory leaks, or undefined behavior upon incorrect usage. However, the executable should catch incorrect usage and throw a useful exception. If an end user makes a mistake and obtains a segfault instead of an exception, I consider that a bug. Some common things I would like to avoid in this code are:
Hexed provides the HEXED_ASSERT macro to facilitate generating exceptions with detailed information about where the error occurred in the code.
using namespace
. The code is clearer when namespaces are referenced explicitly.HEXED_
or #undef
'd after they are no longer needed.constexpr
form of std::pow
, which are non-conforming features of GCC (for constexpr
math functions, see hexed::math
).int
. For example, don't use unsigned
for loop indices and array sizes unless there is a specific reason to.