Assertion Code
Assertion Code is code that tests for situations that cannot happen, or really should not happen. Such code is usually inserted by a programmer in order to report if there is a fault in the logic or coding and a theoretically impossible happening does occur.
This can prevent unforseen situations causing problems. For example; in a medical application a database must never link a treatment to the wrong patient as this could cause serious harm to the patient. To be certain that an unforseen situation will never produce an undetected error, a programmer may separately record the Patient ID on every treatment and on recalling it check that the treatment has the correct Patient ID. This situation 'cannot happen' as the database handles the internal links and will (should) not allow it, but no system is infallible and a double check is reassuring. The technique can be used to achieve very high reliability in critical situations.