Content deleted Content added
Added information about preconditions and postconditions of a method |
m dab C |
||
Line 3:
A method should preserve [[invariant]]s associated with the class, and should be able to assume that every invariant is valid on entry to the method. A method can have [[parameter]]s, which are associated with [[precondition]]s. A method may produce output, which are constrained by [[postcondition]]s of the method. If the [[argument]]s to a method do not satisfy their preconditions, a method can raise an [[exception]]. However, if the object's state doesn't satisfy its invariants on entry to the method, or when the method returns, the program is considered to have a [[Software bug|bug]].
Whereas a [[C programming language|C]] [[programmer]] might push a value onto a [[stack_(software)|Stack]] data-structure by calling:
stackPush(&myStack, value);
a [[C Plus Plus|C++]] programmer would write:
|