MIT Libraries logoDSpace@MIT

MIT
View Item 
  • DSpace@MIT Home
  • MIT Open Access Articles
  • MIT Open Access Articles
  • View Item
  • DSpace@MIT Home
  • MIT Open Access Articles
  • MIT Open Access Articles
  • View Item
JavaScript is disabled for your browser. Some features of this site may not work without it.

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

Author(s)
Rayside, Derek; Benjamin, Zev; Singh, Rishabh; Near, Joseph Paul; Milicevic, Aleksandar; Jackson, Daniel; ... Show more Show less
Thumbnail
Downloadicse09-object-contract.pdf (220.1Kb)
OPEN_ACCESS_POLICY

Open Access Policy

Creative Commons Attribution-Noncommercial-Share Alike

Terms of use
Attribution-Noncommercial-Share Alike 3.0 Unported http://creativecommons.org/licenses/by-nc-sa/3.0/
Metadata
Show full item record
Abstract
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.
Date issued
2009-05
URI
http://hdl.handle.net/1721.1/51695
Department
Massachusetts Institute of Technology. Computer Science and Artificial Intelligence Laboratory; Massachusetts Institute of Technology. Department of Electrical Engineering and Computer Science
Journal
IEEE 31st International Conference on Software Engineering
Publisher
Institute of Electrical and Electronics Engineers
Citation
Equality and hashing for (almost) free: Generating implementations from abstraction functions Rayside, D.; Benjamin, Z.; Singh, R.; Near, J.P.; Milicevic, A.; Jackson, D.; Software Engineering, 2009. ICSE 2009. IEEE 31st International Conference on 16-24 May 2009 Page(s):342 - 352
Version: Author's final manuscript

Collections
  • MIT Open Access Articles

Browse

All of DSpaceCommunities & CollectionsBy Issue DateAuthorsTitlesSubjectsThis CollectionBy Issue DateAuthorsTitlesSubjects

My Account

Login

Statistics

OA StatisticsStatistics by CountryStatistics by Department
MIT Libraries
PrivacyPermissionsAccessibilityContact us
MIT
Content created by the MIT Libraries, CC BY-NC unless otherwise noted. Notify us about copyright concerns.