- Precondition
In
logic a precondition is a condition that has to be met before a main argument can have any value.----
In
computer programming , a precondition is a condition or predicate that must always be true just prior to the execution of some section ofcode or before an operation in aformal specification .If a precondition is violated, the effect of the section of
code becomes undefined and thus may or may not carry out its intended work. Security problems can arise due to incorrect preconditions.Often, preconditions are simply included in the documentation of the affected section of code. Preconditions are sometimes tested using assertions within the code itself, and some languages have specific syntactic constructions for doing so.
For example: the
factorial is only defined for integers greater than or equal to zero. So a program that calculates the factorial of an input number would have preconditions that the number be an integer and that it be greater than or equal to zero.ee also
*
Design by contract
*Postcondition
*Hoare logic
*Invariants maintained by conditions
*Database trigger
Wikimedia Foundation. 2010.