Requires is a prerequisite, meaning that the specified condition must be true before for the called method. Ensures is a postcondition, meaning that the method guarantees that the specified condition is true after the method call completes.
Prerequisites and / or postconditions may be violated during the execution of the method: tests are performed upon entry and exit of the method, respectively. An invariant condition is a contract that states that the specified condition is always fulfilled.
Read Bertrand Meyer Object Oriented Software for more details [more details] more. This Mayer article is shorter [much shorter].
Nicholas carey
source share