Precondition aus Wikipedia. Zum Beitrag
Precondition - Wikipedia, the free encyclopedia
/* cache key: enwiki:resourceloader:filter:minify-css:4:c88e2bcd56513749bec09a7e29cb3ffa */
From Wikipedia, the free encyclopedia
Jump to: ,
For other uses, see Preconditioning (disambiguation)
This article relies largely or entirely upon a single source
. Please help improve this article
by introducing citations
to additional sources. Discussion about the problems with the sole source used may be found on the talk page
. (September 2010)
In computer programming
, a precondition is a condition or predicate
that must always be true just prior to the execution of some section of code
or before an operation in a formal 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.