Now, what exactly does that mean? How should you implement it?
Does changeTire() mean
The behaviour for these two situations are completely different, and
the name of the method alone does not supply enough information.
You, the implementor, need more information on which of these to
implement, and you, the user, would like to be sure that the
method you use is doing the action you are expecting and that you
are calling the right one at the right time.
Writing PRE and POST conditions when designing the Tire class
and the changeTire() method, will ensure that the
programmer implements the correct behaviour.
Reading and considering PRE and POST conditions when using the Tire class
and the changeTire() method, will ensure that the
user calls the action expected and uses the right one at the right time.
A designer, implementor, or user of a system should never expect a particular
unstated interpretation
of a method. PRE and POST conditions provide the contract under
which agreements for the content are made.
Someone did not pay attention to PRE and POST conditions.
JPL contracted out for a specific task that
required measurements. The contractors did the job, but returned the
value of the measurements in english units rather than metric.
This simple error caused the failure in the mission!
If the PRE and POST were set and agreed upon,
the product specs would have been clearly established and the taxpayers
would not have paid millions/billions of dollars in vain.
P.S.
My son Matthew was a TUL (tactical uplink lead) in the successful (2004/05) mission. I am so proud!
For example, for the second example of changeTire(), a
PRE condition may be something like the tire is off the rim and
a new tire is available to put on the rim. A PRE condition for the
first may be something like the tools available to remove the
tire from the body are available, etc.
Do you know why JPLs first Mars mission was not successful?