Any software system, whether object-oriented or not, relies on the state of
the system being "correct" at certain stages of its execution. To take a very
simple example, when a numerical division operation is performed, the divisor
must be non-zero. If this is not the case, the system may crash in an
unpredictable and uncontrolled manner.
One way of indicating such requirements is to state that the system must be
in some state either before or after an operation. Such a statement about the
state of a software system is called an assertion.
Assertions often form the basis for software specification. In some systems,
the assertions are embedded in the software as annotations or formal
comments. However, it can be useful to make the assertions executable so that
the correc... (more)