Contract Soundness for object-oriented languages
Authors:
Open Access
- 1 October 2001
- conference paper
- Published by Association for Computing Machinery (ACM)
- Vol. 36 (11) , 1-15
Abstract
Checking pre- and post-conditions of procedures and methods at runtime helps improve software reliability. In the procedural world, pre- and post-conditions have a straightforward interpretation. If a procedure's pre-condition doesn't hold, the caller failed to establish the proper context. If a post-condition doesn't hold, the caller failed to establish the proper context. If a post-condition doesn't hold, the procedure failed to compute the expected result. In the object-oriented world, checking pre- and post-conditions for methods, often called contracts in this context, poses complex problems. Because methods may be overridden, it is not sufficient to check only pre- and post-conditions. In addition, the contract hierarchy must be checked to ensure that the contracts on overridden methods are properly related to the contracts on overriding methods. Otherwise, a class hierarchy may violate the substitution principle, that is, it may no longer be true that an instance of a class is substitutable for objects of the super-class. In this paper, we study the problem of contract enforcement in an object-oriented world from a foundational perspective. More specifically, we study contracts as refinements of types. Pushing the analogy further, we state and prove a contract soundness theorem that captures the essential properties of contract enforcement. We use the theorem to illustrate how most existing tools suffer from a fundamental flaw and how they can be improved.Keywords
This publication has 9 references indexed in Scilit:
- Behavioral contracts and behavioral subtyping2001
- JML (poster session)2000
- Classes and mixins1998
- A practical approach to programming with assertionsIEEE Transactions on Software Engineering, 1995
- A behavioral notion of subtypingACM Transactions on Programming Languages and Systems, 1994
- Applying 'design by contract'Computer, 1992
- Designing an object-oriented programming language with behavioural subtyping1991
- An Overview of Anna, a Specification Language for AdaIEEE Software, 1985
- A theory of type polymorphism in programmingJournal of Computer and System Sciences, 1978