Concepts in Programming Flashcards
Name the three key elements to Design by Contract?
1 Preconditions: What must be true in order for the routine to be called.
2 Postconditions: What the routine is guaranteed to do.
3 Class invariants: The conditions that that ensures the instances of a class stay invariant when applying the methods to them. A routine my break an invariant during the execution of the routine, but by the time the routine exits the invariant must be restored.
What are the first steps to take in implementing Design by Contract?
Enumerate:
1 The input domain range.
2 Boundary conditions.
3 What the routine promises to deliver (and what it doesn’t promises to deliver).
BEFORE writing any code!
Explain the crash early principle.
It is easier to identify the source of a problem if code crashes early.
Invariant (about an object)
When an object do not change when a given transformation is applied to it.