Programming Distributed Systems with YAMI4
4 JSF Coding Standard Exceptions
The YAMI4 C++ Core library was written with a strict coding standard that is to a large extent compatible with the JSF (Joint-Strike Fighter) document.
It should be noted, however, that some exceptions to the original set of rules were allowed in order to ensure better integration of code base with other components and to benefit from some of the assumptions that are commonly true in those contexts where the YAMI4 library will be most likely used.
This chapter documents exceptions from the JSF coding standard. The list of exceptions can be useful for those users who routinely use style checking and verification tools that have the JSF rules built in.
- Rule 1. There is no specific limit on the number of logical source lines in a function.
- Rule 22. The
stdio
library is used as documented in the chapter related to critical systems. The usage is limited to number formatting routines, which can be replaced with custom routines if necessary.
- Rule 33. The include form for local header files is used to clearly distinguish project-related files from standard and system libraries.
- Rules 49, 50. The identifiers are entirely composed of lower-case characters and digits, upper-case is not used.
- Rule 58. Line breaks for function declarations and calls with many parameters are used with no relation to the number of parameters.
- Rule 62. The tokens composing a type name are all separated by spaces and the type name in its entirety is separated by space from the given identifier.
- Rule 110. There is no restriction on the number of function parameters and there are several initialization functions that have more than 7 parameters (this is actually permitted by Rule 110 if initialization functions are treated in the same way as constructors).
- Rule 137. Unnamed namespaces are used instead of static declarations.
- Rule 147. Underlying bit representation of floating point numbers is used and relied upon in serialization routines (note: all serialization routines are grouped in a single file
serialization.cpp
).
- Rule 153. Unions are used for space optimization when it is clear that only one of several alternatives will be used (and there is a way to discriminate between them at run-time), for ensuring proper alignment of blocks in private allocator and in rare cases for reinterpret casts to avoid compiler warnings related to aliasing.
- Rule 163. Unsigned arithmetic on
std::size_t
is used for buffer size and offset management.
- Rule 169. Pointers to pointers are used in the implementation of internal lists and to describe buffer groups.
- Rule 175.
NULL
is used instead of 0
to clearly indicate the nature of expression.
- Rule 206. The free store is used via private allocator. Note that the private allocator can be redirected to use a dedicated and pre-allocated memory block, which makes the whole compatible with Rule 206.
- Rule 209. Basic integer types are used instead of specific-length typedefs for readability. It is assumed that the target platform uses 32-bit representation for
int
and 64-bit representation for long long
.
- Rule 215. Pointer arithmetic is used for buffer offset management.