Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
research-article
Open access

Contracts for First-Class Classes

Published: 01 November 2013 Publication History
  • Get Citation Alerts
  • Abstract

    First-class classes enable programmers to abstract over patterns in the class hierarchy and to experiment with new forms of object-oriented programming such as mixins and traits. This increase in expressive power calls for tools to control the complexity of the software architecture. A contract system is one possible tool that has seen much use in object-oriented programming languages, but existing contract systems cannot cope with first-class classes. On the one hand, the typical contract language deals only with plain values such as numbers, while classes are higher-order values. On the other hand, contract specifications are usually contained within class definitions, while classes as values call for a separate contract language.
    This article presents the design and implementation of a contract system for first-class classes as well as a two-pronged evaluation. The first one states and proves a “blame correctness” theorem for a model of our language. The theorem shows that when the contract system assigns blame to a component for a contract violation, the component is indeed responsible for providing the nonconforming value. The second part, consisting of benchmarks and case studies, demonstrates the need for the rich contract language and validates that our implementation approach is performant with respect to time.

    References

    [1]
    Eric Allen, Jonathan Bannet, and Robert Cartwright. 2003. A first-class approach to genericity. In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA’03). 96--114.
    [2]
    Eric Allen, David Chase, Joe Hallett, Victor Luchangco, Jan-Willem Maessen, Sukyoung Ryu, Guy L. Steele Jr., and Sam Tobin-Hochstadt. 2008. The Fortress Language Specification Version 1.0. Sun Microsystems.
    [3]
    Davide Ancona, Giovanni Lagorio, and Elena Zucca. 2003. Jam---Designing a Java extension with mixins. ACM Trans. Program. Lang. Syst. 25, 5, 641--712.
    [4]
    Thomas H. Austin, Tim Disney, and Cormac Flanagan. 2010. Virtual values for language extension. Tech. rep. UCSC-SOE-10-25. University of California, Santa Cruz.
    [5]
    Mike Barnett, K. Rustan M. Leino, and Wolfram Schulte. 2004. The spec# programming system: An overview. In Proceedings of the International Conference on Construction and Analysis of Safe, Secure and Interoperable Smart Devices (CASSIS’04). Lecture Notes in Computer Science, vol. 3362, Springer, 49--69.
    [6]
    Detlef Bartetzko, Clemens Fischer, Michael Moller, and Heikewehrheim. 2001. Jass---Java with assertions. Electron. Not. Theor. Comput. Sci. 55, 2, 103--117.
    [7]
    Gilad Bracha. 1992. The programming language jigsaw: Mixins, modularity, and multiple inheritance. Ph.D. dissertation. University of Utah. http://www.cs.utah.edu/dept/techreports/docs/ncstrl.utah_cs/UUCS-92-007/UUCS-92-007.pdf.
    [8]
    Gilad Bracha and William Cook. 1990. Mixin-based inheritance. In Proceedings of the European Conference on Object-Oriented Programming and the Conference on Object-Oriented Programming Systems, Languages, and Applications (OOPSLA/ECOOP’90). 303--311.
    [9]
    Gilad Bracha and David Ungar. 2004. Mirrors: Design principles for meta-level facilities of object-oriented programming languages. In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA’04). 331--344.
    [10]
    Luca Cardelli and John C. Mitchell. 1991. Operations on records. Math. Struct. Comput. Sci. 1, 3--48.
    [11]
    Manuela Carrillo-Castellon, Jesus Garcia-Molina, Ernesto Pimentel, and Israel Repiso. 1996. Design by contract in smalltalk. J. Object-Oriented Program. 7, 9, 23--28.
    [12]
    Christos Dimoulas and Matthias Felleisen. 2011. On contract satisfaction in a higher-order world. ACM Trans. Program. Lang. Syst. 33, 5, 16:1--16:29.
    [13]
    Christos Dimoulas, Robert B. Findler, Cormac Flanagan, and Matthias Felleisen. 2011. Correct blame for contracts: No more scapegoating. In Proceedings of the Symposium on Principles of Programming Languages. 215--226.
    [14]
    Dominic Duggan and Ching-Ching Techaubol. 2001. Modular mixin-based inheritance for application frameworks. In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA’01). 223--240.
    [15]
    Erik Ernst. 1999. gbeta---A language with virtual attributes, block structure, and propagating, dynamic inheritance. Ph.D. dissertation. University of Aarhus, Arhus, Denmark. http://ojs.statsbiblioteket.dk/index.php/daimipb/article/download/7654/6510.
    [16]
    Matthias Felleisen. 1991. On the expressive power of programming languages. Sci. Comput. Program. 17, 1--3, 35--75.
    [17]
    Matthias Felleisen, Robert Bruce Findler, and Matthew Flatt. 2009. Semantics Engineering with PLT Redex. MIT Press.
    [18]
    Robert Bruce Findler and Matthias Blume. 2006. Contracts as pairs of projections. In Proceedings of the International Symposium on Functional and Logic Programming (FLOPS’06). Lecture Notes in Computer Science, vol. 3945, Springer, 226--241.
    [19]
    Robert Bruce Findler, John Clements, Cormac Flanagan, Matthew Flatt, Shriram Krishnamurthi, Paul Steckler, and Matthias Felleisen. 2002. DrScheme: A programming environment for scheme. J. Funct. Program. 12, 2, 159--182.
    [20]
    Robert Bruce Findler and Matthias Felleisen. 2001. Contract soundness for object-oriented languages. In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA’01). 1--15.
    [21]
    Robert Bruce Findler and Matthias Felleisen. 2002. Contracts for higher-order functions. In Proceedings of the International Conference on Functional Programming. 48--59.
    [22]
    Kathleen Fisher and John Reppy. 2004. A typed calculus of traits. In Proceedings of the Workshop on Foundations of Object-Oriented Languages.
    [23]
    David Flanagan and Yukihiro Matsumoto. 2008. The Ruby Programming Language. O’Reilly.
    [24]
    Matthew Flatt and PLT. 2010. Reference: Racket. Tech. rep. PLT-TR-2010-1. PLT Inc. http://racket-lang.org/tr1/.
    [25]
    Matthew Flatt, Shriram Krishnamurthi, and Matthias Felleisen. 1998. Classes and mixins. In Proceedings of the Symposium on Principles of Programming Languages. 171--183.
    [26]
    Matthew Flatt, Robert Bruce Findler, and Matthias Felleisen. 2006. Scheme with classes, mixins, and traits. In Proceedings of the Asian Symposium on Programming Languages and Systems. Lecture Notes in Computer Science, vol. 4279, Springer, 270--289.
    [27]
    Benedict R. Gaster and Mark P. Jones. 1996. A polymorphic type system for extensible records and variants. Tech. rep. NOTTCS-TR-96-3. University of Nottingham.
    [28]
    Adele Goldberg and David Robinson. 1983. Smalltalk-80: The Language and its Implementation. Addison-Wesley.
    [29]
    David S. Goldberg, Robert Bruce Findler, and Matthew Flatt. 2004. Super and inner---Together at last! In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA’04). 116--129.
    [30]
    Benedict Gomes, David Stoutamire, Boris Vaysman, and Holger Klawitter. 1996. A language manual for sather 1.1. http://www1.icsi.berkeley.edu/_sather/Documentation/LanguageDescription/Descript.pdf.gz.
    [31]
    Kathryn E. Gray. 2008. Safe cross-language inheritance. In Proceedings of the European Conference on Object-Oriented Programming (ECOOP’08). Lecture Notes in Computer Science, vol. 5142, Springer, 52--75.
    [32]
    Kathryn E. Gray. 2010. Interoperability in a scripted world: Putting inheritance and prototypes together. In Proceedings of the Workshop on Foundations of Object-Oriented Languages.
    [33]
    Kathryn E. Gray, Robert Bruce Findler, and Matthew Flatt. 2005. Fine-grained interoperability through contracts and mirrors. In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA’04). 231--245.
    [34]
    Robert Harper and Benjamin Pierce. 1991. A records calculus based on symmetric concatenation. In Proceedings of the Symposium on Principles of Programming Languages. 131--142.
    [35]
    Murat Karaorman, Urs Holzle, and John Bruno. 1999. jContractor: A reflective java library to support design by contract. In Proceedings of the International Conference on Meta-Level Architectures and Reflection (Reflection’99). Lecture Notes in Computer Science, vol. 1616, Springer, 175--196.
    [36]
    Michael Kolling and John Rosenberg. 1997. Blue: Language specification, version 0.94. http://www.sd.monash.edu.au/blue/.
    [37]
    Reto Kramer. 1998. iContract: The java design by contract tool. In Proceedings of the Conference on Technology of Object-Oriented Languages and Systems. 295.
    [38]
    John Lamping. 1993. Typing the specialization interface. In Proceedings of the Annual Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA’93). 201--214.
    [39]
    Butler W. Lampson, James J. Horning, Ralph L. London, James G. Mitchell, and Gerald J. Popek. 1977. Report on the programming language euclid. SIGPLAN Not. 12, 2, 1--79.
    [40]
    Gary T. Leavens. 2006. JML’s rich, inherited specifications for behavioral subtypes. In Proceedings of the International Conference on Formal Engineering Methods (ICFEM’06). Lecture Notes in Computer Science, vol. 4260, Springer, 2--34.
    [41]
    Gary T. Leavens, Yoonsik Cheon, Curtis Clifton, Clyde Ruby, and David R. Cok. 2005. How the design of jml accommodates both runtime assertion checking and formal verification. Sci. Comput. Program. 55, 1--3, 185--208.
    [42]
    Ole Lehrmann Madsen, Birger Møller-Pedersen, and Kristen Nygaard. 1993. Object-Oriented Programming in the BETA Programming Language. Addison-Wesley Publishing, New York.
    [43]
    Barbara H. Liskov and Jeannette M. Wing. 1994. A behavioral notion of subtyping. ACM Trans. Program. Lang. Syst. 16, 6, 1811--1841.
    [44]
    David C. Luckham and Friedrich W. Von Henke. 1985. An overview of anna, a specification language for ada. IEEE Softw. 2, 9--23.
    [45]
    Sean Mcdirmid, Matthew Flatt, and Wilson Hsieh. 2001. Jiazzi: New-age components for old-fashioned java. In Proceedings of the Annual Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA’01). 211--222.
    [46]
    Bertrand Meyer. 1992a. Applying design by contract. IEEE Comput. 25, 10, 0--51.
    [47]
    Bertrand Meyer. 1992b. Eiffel: The Language. Prentice Hall.
    [48]
    David A. Moon. 1986. Object-oriented programming with flavors. In Proceedings of the Annual Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA’86). 1--8.
    [49]
    David L. Parnas. 1972. On the criteria to be used in decomposing systems into modules. Comm. ACM 15, 12, 1053--1058.
    [50]
    Reinhold Plosch. 1997. Design by contract for python. In Proceedings of the IEEE Joint Asia Pacific Software Engineering Conference. 213--219.
    [51]
    Gordon D. Plotkin. 1977. LCF considered as a programming language. Theor. Comput. Sci. 5, 223--255.
    [52]
    Nathanael Scharli, Stephane Ducasse, Oscar Nierstrasz, and Andrew Black. 2003. Traits: Composable units of behavior. In Proceedings of the European Conference on Object-Oriented Programming (ECOOP’03). Lecture Notes in Computer Science, vol. 2743, Springer, 248--274.
    [53]
    Marco Servetto and Elena Zucca. 2010. MetaFJig: A meta-circular composition language for java-like classes. In Proceedings of the Annual Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA’10). 464--483.
    [54]
    T. Stephen Strickland and Matthias Felleisen. 2010a. Contracts for first-class classes. In Proceedings of the Dynamic Languages Symposium. 97--111.
    [55]
    T. Stephen Strickland and Matthias Felleisen. 2010b. Nested and dynamic contract boundaries. In Proceedings of the International Conference on Implementation and Application of Functional Languages (IFL’10). Lecture Notes in Computer Science, vol. 6041, Springer, 141--158.
    [56]
    T. Stephen Strickland, Sam Tobin-Hochstadt, Robert Bruce Findler, and Matthew Flatt. 2012. Chaperones and impersonators: Run-time support for reasonable interposition. In Proceedings of the Annual Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA’12). 943--962.
    [57]
    Clemens Szyperski. 1997. Component Software. Addison-Wesley.
    [58]
    Tom Van Cutsem and Mark Miller. 2010. Proxies: Design principles for robust object-oriented intercession apis. In Proceedings of the Dynamic Languages Symposium. 59--72.
    [59]
    Mitchell Wand. 1994. Type inference for objects with instance variables and inheritance. In Theoretical Aspects of Object-Oriented Programming. MIT Press, 97--120.

    Cited By

    View all
    • (2021)Modeling-framework for model-based software engineering of complex Internet of things systemsMathematical Biosciences and Engineering10.3934/mbe.202145818:6(9312-9335)Online publication date: 2021
    • (2019)Hierarchical Modeling of Complex Internet of Things Systems Using Conceptual Modeling ApproachesIEEE Access10.1109/ACCESS.2019.29309337(102772-102791)Online publication date: 2019
    • (2019)Feature-oriented contract compositionJournal of Systems and Software10.1016/j.jss.2019.01.044152:C(83-107)Online publication date: 1-Jun-2019
    • Show More Cited By

    Recommendations

    Reviews

    Nathan Carlson

    Contracts are formal and verifiable specifications that extend traditional type definitions by including preconditions, postconditions, invariants, acceptable inputs and outputs, and other behavioral specifications [1]. These class-level specifications can be used to verify both usage and behavior of software components at runtime. This paper details the concept of blame, which is implemented in the Racket language. When a contract violation occurs, blame enables the system to accurately indicate the guilty party in the failed transaction. First-class classes, or classes that are in themselves objects, enable new ways of composing class types without resorting to multiple inheritance. Some mainstream languages such as Java and C# do not support first-class classes, while Ruby and Python do. Contract systems are intended to specify conditions about values, and not about classes themselves, and their relationships. Contracts are specified at a class level. Contract systems do not normally support meta-definition of contracts or the sharing of contracts between different classes without duplication of code. The authors present details of an innovative contract-based approach for working with first-class classes. The proposed approach includes both the design and implementation of a contract system for first-class classes, including some theoretical foundations and a formal proof of a new "blame correctness" theorem. The paper includes a practical evaluation and validation of the approach. It is well-researched and thorough, but its value is limited by a focus on both design by contract and languages that support first-class classes. However, the paper should prove valuable to those with interests in these areas. Online Computing Reviews Service

    Access critical reviews of Computing literature here

    Become a reviewer for Computing Reviews.

    Comments

    Information & Contributors

    Information

    Published In

    cover image ACM Transactions on Programming Languages and Systems
    ACM Transactions on Programming Languages and Systems  Volume 35, Issue 3
    November 2013
    156 pages
    ISSN:0164-0925
    EISSN:1558-4593
    DOI:10.1145/2542180
    Issue’s Table of Contents
    Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected].

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 01 November 2013
    Accepted: 01 May 2013
    Revised: 01 November 2012
    Received: 01 March 2012
    Published in TOPLAS Volume 35, Issue 3

    Permissions

    Request permissions for this article.

    Check for updates

    Author Tags

    1. Contracts
    2. first-class class systems

    Qualifiers

    • Research-article
    • Research
    • Refereed

    Funding Sources

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)56
    • Downloads (Last 6 weeks)11

    Other Metrics

    Citations

    Cited By

    View all
    • (2021)Modeling-framework for model-based software engineering of complex Internet of things systemsMathematical Biosciences and Engineering10.3934/mbe.202145818:6(9312-9335)Online publication date: 2021
    • (2019)Hierarchical Modeling of Complex Internet of Things Systems Using Conceptual Modeling ApproachesIEEE Access10.1109/ACCESS.2019.29309337(102772-102791)Online publication date: 2019
    • (2019)Feature-oriented contract compositionJournal of Systems and Software10.1016/j.jss.2019.01.044152:C(83-107)Online publication date: 1-Jun-2019
    • (2017)LMS-Verify: abstraction without regret for verified systems programmingACM SIGPLAN Notices10.1145/3093333.300986752:1(859-873)Online publication date: 1-Jan-2017
    • (2017)LMS-Verify: abstraction without regret for verified systems programmingProceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages10.1145/3009837.3009867(859-873)Online publication date: 1-Jan-2017
    • (2017)Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming LanguagesundefinedOnline publication date: 1-Jan-2017
    • (2016)Oh Lord, please don't let contracts be misunderstood (functional pearl)ACM SIGPLAN Notices10.1145/3022670.295193051:9(117-131)Online publication date: 4-Sep-2016
    • (2016)Oh Lord, please don't let contracts be misunderstood (functional pearl)Proceedings of the 21st ACM SIGPLAN International Conference on Functional Programming10.1145/2951913.2951930(117-131)Online publication date: 4-Sep-2016
    • (2016)Proceedings of the 21st ACM SIGPLAN International Conference on Functional ProgrammingundefinedOnline publication date: 4-Sep-2016
    • (2014)Behavioral software contractsACM SIGPLAN Notices10.1145/2692915.263285549:9(137-138)Online publication date: 19-Aug-2014
    • Show More Cited By

    View Options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Get Access

    Login options

    Full Access

    Media

    Figures

    Other

    Tables

    Share

    Share

    Share this Publication link

    Share on social media