SWE/CS 332 In Class Exercise # 8
Name(s):
Consider Liskov's
IntSet.java
class.
-
Derive the abstraction function and the rep-invariant for this class.
If you need a hint, Liskov has done exactly this on a closely
related implementation.
-
Weaken the rep-invariant by removing the prohibition on duplicates
in the rep.
Important: whether there are duplicates in the rep has nothing to
do with whether there are duplicates in the abstract state
- which there most definitely aren't since the abstract state is a set.
Students often struggle with this - probably because
they don't yet understand that the client state and the implementation
state are truly distinct things. It's important to get it straight.
-
The abstraction function does not change, but the
the abstraction function must nonetheless be re-implemented.
Explain this, and make it happen.
-
Rewrite methods as needed for the new rep-invariant.