Contracts
Reading
Important concepts
- breaking change
- contract
- signature
- precondition, postcondition, invariant
Some exercises (just to think about, not to hand in)
Consider the API and contract of each of the following classes:
-
Media
(from the Library activity; look atcheckIn()
,checkOut()
,isAvailable()
) -
CannonBall
(from Bubble Blitz, analyze whole class)
Start with method signatures. Which methods are part of the API? Which are not? Are any constants or instance variables part of the API?
Then think about behavioral contracts. What are preconditions and postconditions of the interesting methods? Can you identify any class invariants?
Your response
What was particularly interesting, confusing, or exciting to you in this reading?