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 fact that must always be true just prior to the execution of some section of code. Preconditions are sometimes tested using assertions within the code itself. Often, preconditions are simply included in the documentation of the affected section of code. If a precondition is violated, the section of code is free to do whatever it wants - format the hard disk, blow up the monitor, attempt to take over the world, etc. Security problems can arise due to incorrect preconditions - e.g. a section of code that has the precondition that the input is correct, when it may not be.
A precondition would be a requirement you must meet even before you meet the conditions, and thats not the sort of thing intended at all.
But in fact, although they are synonymous above, there are two differences between condition and precondition in some uses: (1) the pre- prefix adds emphasis and stresses more heavily the necessity that these requirements be satisfied first, and (2) the two words cannot always combine with the same prepositions for the same meanings.
Precondition combines with of, for, and to: A precondition to [of, for] the purchase of a new house is finding a willing lender.
Many preconditions, such as the calling convention or correct data type for input parameters, may be enforced via a software development best practice such as coding to interfaces.
However, other types of preconditions exist - often, software components are brittle because some simple candidates for preconditions (such as "the password cannot be an empty string") remain implicit, and the behavior of the component following a violation of that precondition is unspecified.
Preconditions can be used to specify which inputs should be considered as valid, and fail fast when violated.
Share your thoughts, questions and commentary here
Want to know more? Search encyclopedia, statistics and forums:
Press Releases |
The Wikipedia article included on this page is licensed under the
Images may be subject to relevant owners' copyright.
All other elements are (c) copyright NationMaster.com 2003-5. All Rights Reserved.
Usage implies agreement with terms, 1022, m