SWE/CS 332 In Class Exercise # 9
September 27, 2017


Name(s):

Consider Liskov's IntSet example (implemented in LiskovSet.java)
    // Overview:  IntSets are mutable, unbounded sets of integers
    List<Integer> els;   // the representation
  1. What is the abstraction function?


  2. What is an appropriate rep-invariant?


  3. How do generics help?


  4. How do AF/RI change for a specialized rep:
    public class IntSet {
        // IntSets are mutable, unbounded sets of integers
        boolean[] specialEls = new boolean[10];   // frequent items
        List<Integer> otherEls;                   // infrequent items
    
  5. Consider the mutable GrowList example (implemented in GrowList.java) from the homework. This code uses a map to represent a list.


    What is the abstraction function?


    What is a suitable representation invariant?


    What happens if you add a
        public void nasty() {
    
    
    
        }
    
    method to the interface that breaks the representation invariant?