Understanding the Impact of Collection Contracts on Design
Java provides a specification for a user-defined general purpose equivalence operator for objects, but collections such as Set have more stringent requirements. This inconsistency breaks polymorphism: programmers must take care to follow Set's contract rather than the more general Object contract if their object could enter a Set. The authors have dynamically profiled 30 Java applications to better understand the way programmers design their objects, to determine whether they program with collections in mind. Their results indicate that objects which enter collections behave very differently to objects which do not. Their findings should help developers understand the impact of design choices they make, and guide future language designers when adding support for collections and/or equality.