Precondition

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 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.

ee also

*Design by contract
*Postcondition
*Hoare logic
*Invariants maintained by conditions
*Database trigger


Wikimedia Foundation. 2010.

Игры ⚽ Нужно сделать НИР?

Look at other dictionaries:

  • precondition — UK US /ˌpriːkənˈdɪʃən/ noun [C] ► something which must happen before something else can happen: »Innovation is an essential precondition for growth. a precondition of sth »The agreement to move to new premises was made a precondition of the… …   Financial and business terms

  • Precondition — Pre con*di tion, n. A previous or antecedent condition; a preliminary condition. [1913 Webster] …   The Collaborative International Dictionary of English

  • precondition — index necessity, need (requirement), prerequisite, requirement, sine qua non Burton s Legal Thesaurus. William C. Burton. 2006 …   Law dictionary

  • precondition — (n.) 1825, from PRE (Cf. pre ) + CONDITION (Cf. condition) (n.) …   Etymology dictionary

  • precondition — ► NOUN ▪ a condition that must be fulfilled before other things can happen or be done. ► VERB ▪ bring into a desired or necessary state beforehand …   English terms dictionary

  • precondition — [prē΄kən dish′ən] vt. to prepare (someone or something) to behave, react, etc. in a certain way under certain conditions n. a condition required beforehand if something else is to occur, be done, etc …   English World dictionary

  • Précondition — Principe d une précondition Il s agit d une condition appliquée au début d un calcul ou d une fonction informatique, et permettant d en valider le résultat. Expression B de précondition Si P est un prédicat et S une substitution, P | S, qui se… …   Wikipédia en Français

  • precondition — UK [ˌpriːkənˈdɪʃ(ə)n] / US [ˌprɪkənˈdɪʃ(ə)n] noun [countable] Word forms precondition : singular precondition plural preconditions something that must happen or be done before something else can happen An army withdrawal is a precondition for… …   English dictionary

  • precondition — /pree keuhn dish euhn/, n. 1. something that must come before or is necessary to a subsequent result; condition: a precondition for a promotion. v.t. 2. to subject (a person or thing) to a special treatment in preparation for a subsequent… …   Universalium

  • precondition — pre|con|di|tion [ˌpri:kənˈdıʃən] n something that must happen or exist before something else can happen precondition of/for ▪ A ceasefire is a precondition for talks …   Dictionary of contemporary English

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”