Go to the first, previous, next, last section, table of contents.


5 Programming Style

The central goal of module implementation is correctness. Performance is important, but secondary to correctness. By correctness, we mean that all specified functions are implemented strictly according to the module specification, without any memory leaks or segmentation faults. Aside from trivial cases, there will be no proof of correctness, only degrees of belief in correctness. And so the astute reader has already realized that "correctness" really means "belief in correctness".

Our belief in the correctness of an implementation is principally influenced by clarity of the implementation. It is much easier to develop confidence in code that is easy to understand than in code that is difficult to understand. Clarity is determined by degree of conformance to a style guide, appropriate use of abstractions, appropriate symbol names (that obey reasonable naming conventions), useful but sparing comments (when essential to understanding), and consistent formatting.

As we hope you will see, our software places an unusual premium on clarity, both directly and indirectly. Our belief in the correctness of an implementation is also affected by the rigor of the programmer's test suite and the abundance of assertions. Accordingly, our software always includes a comprehensive test suite as well as aggressive use of assertions.


Go to the first, previous, next, last section, table of contents.