SWE 619 In Class Exercise Number 11
November 21, 2017


This is a JUnit theory exercise.

  1. Recall the equals() and hashCode() discussion in Bloch. Write a JUnit theory for the symmetry property for equals(). Focus on the contract perspective.


  2. Populate the theory with data points and choices for how equals() is implemented that:


  3. Repeat the exercise for the transitive property for equals().


  4. What happens to these theories/data points when favoring composition over inheritance?


  5. Repeat the exercise for the consistency relationship of hashCode() and equals().


  6. Consider the Comparable interface: what properties should be checked with theories?