Equality and Hashing for (almost) Free: Generating Implementations from Abstraction Functions

In an object-oriented language such as Java, every class requires implementations of two special methods, one for determining equality and one for computing hash codes. Although the specification of these methods is usually straightforward, they can be hard to code (due to subclassing, delegation, c...

Full description

Bibliographic Details
Main Authors: Rayside, Derek (Contributor), Benjamin, Zev (Contributor), Singh, Rishabh (Contributor), Near, Joseph Paul (Contributor), Milicevic, Aleksandar (Contributor), Jackson, Daniel (Contributor)
Other Authors: Massachusetts Institute of Technology. Computer Science and Artificial Intelligence Laboratory (Contributor), Massachusetts Institute of Technology. Department of Electrical Engineering and Computer Science (Contributor)
Format: Article
Language:English
Published: Institute of Electrical and Electronics Engineers, 2010-02-11T13:29:09Z.
Subjects:
Online Access:Get fulltext
LEADER 02293 am a22003253u 4500
001 51695
042 |a dc 
100 1 0 |a Rayside, Derek  |e author 
100 1 0 |a Massachusetts Institute of Technology. Computer Science and Artificial Intelligence Laboratory  |e contributor 
100 1 0 |a Massachusetts Institute of Technology. Department of Electrical Engineering and Computer Science  |e contributor 
100 1 0 |a Jackson, Daniel  |e contributor 
100 1 0 |a Rayside, Derek  |e contributor 
100 1 0 |a Benjamin, Zev  |e contributor 
100 1 0 |a Singh, Rishabh  |e contributor 
100 1 0 |a Near, Joseph Paul  |e contributor 
100 1 0 |a Milicevic, Aleksandar  |e contributor 
100 1 0 |a Jackson, Daniel  |e contributor 
700 1 0 |a Benjamin, Zev  |e author 
700 1 0 |a Singh, Rishabh  |e author 
700 1 0 |a Near, Joseph Paul  |e author 
700 1 0 |a Milicevic, Aleksandar  |e author 
700 1 0 |a Jackson, Daniel  |e author 
245 0 0 |a Equality and Hashing for (almost) Free: Generating Implementations from Abstraction Functions 
260 |b Institute of Electrical and Electronics Engineers,   |c 2010-02-11T13:29:09Z. 
856 |z Get fulltext  |u http://hdl.handle.net/1721.1/51695 
520 |a In an object-oriented language such as Java, every class requires implementations of two special methods, one for determining equality and one for computing hash codes. Although the specification of these methods is usually straightforward, they can be hard to code (due to subclassing, delegation, cyclic references, and other factors) and often harbor subtle faults. A technique is presented that simplifies this task. Instead of writing code for the methods, the programmer gives, as a brief annotation, an abstraction function that defines an abstract view of an object's representation, and sometimes an additional observer in the form of an iterator method. Equality and hash codes are then computed in library code that uses reflection to read the annotations. Experiments on a variety of programs suggest that, in comparison to writing the methods by hand, our technique requires less text from the programmer and results in methods that are more often correct. 
520 |a National Science Foundation 
546 |a en_US 
655 7 |a Article 
773 |t IEEE 31st International Conference on Software Engineering