Abstract Data Types

Post Conditions

Suppose you have a class that has a method
public void delete()

A post condition is given
Post: delete the object

So I write code that

  1. looks for the object in an array and deletes all as it looks
  2. simply deletes all objects - nice, easy, clean
  3. adds some variable that indicates that I have looked at each object as I go through, and then when I find the one I am looking for, delete it and the rest of the items
  4. etc. etc
I could do any of these things (and worse) and I have met your specs of "delete the object"

Others:


MethodPost ConditionProblems
Draw()Draw itemWhat happens to other existing items?
Remove()Remove itemWhat happens to other existing items?
Move()Move itemWhat happens to other existing items?
ChangeColor()Change the color of the itemWhat happens to other existing items?

ADTs are design by contract. I can implement the job any way I want as long as I meet your specs.
Be careful of what you say your specs are.

Discuss:
Pre: Not Applicable
as opposed to "none"