Jump to content

Assertion Code

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 219.88.61.103 (talk) at 09:14, 23 May 2005. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

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 reduce the possibility of an unforseen situation causing an undetected error, a programmer may insert a separate redundant check on the recall of treatments to make sure that they do match the correct patient. This situation 'cannot happen' as the database handles the internal links and will (should) not allow it mislinking, but no system is infallible and a double check reassuring. The technique can be used to achieve very high reliability in critical situations.