Technology of Object-Oriented Languages and Systems (TOOLS 33) Another Mediocre Assertion Mechanism for C++ St. Malo, France June 05-June 08 ISBN: 0-7695-0731-X
Assertions are a basic programming ingredient. If the language you use does not support them in a proper way, at least you must use some kind of standardized comments, to express things like preconditions for functions. The comments can be turned into executable functions by a preprocessor, but we could write the function calls directly, with the advantage of having the compiler check their syntax. This technique can be used with C++, to emulate the full set of assertions used in Eiffel to implement Design by Contract. The assertion functions are grouped in a class; class Assertions, which is inherited by the classes whose functions we want to assert. The assertions can be turned on and off object by object, during the execution of the program. The system works well under inheritance, although some guidelines must be followed when writing postconditions on the base class. The simplicity of this mechanism makes it possible to comment out all or some of the assertions automatically, through the programming environment.
Citation:
Pedro Guerreiro, "Another Mediocre Assertion Mechanism for C++," tools, pp.226, Technology of Object-Oriented Languages and Systems (TOOLS 33), 2000 Usage of this product signifies your acceptance of the Terms of Use. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||