Safely creating correct subclasses without seeing superclass code
Authors:
Open Access
- 1 October 2000
- journal article
- Published by Association for Computing Machinery (ACM) in ACM SIGPLAN Notices
- Vol. 35 (10) , 208-228
Abstract
A major problem for object-oriented frameworks and class libraries is how to provide enough information about a superclass, so programmers can safely create new subclasses without giving away the superclass's code. Code inherited from the superclass can call down to methods of the subclass, which may cause nontermination or unexpected behavior. We describe a reasoning technique that allows programmers, who have no access to the code of the superclass, to determine both how to safely override the superclass's methods and when it is safe to call them. The technique consists of a set of rules and some new forms of specification. Part of the specification would be generated automatically by a tool, a prototype of which is planned for the formal specification language JML. We give an example to show the kinds of problems caused by method overrides and how our technique can be used to avoid them. We also argue why the technique is sound and give guidelines for library providers and programmers that greatly simplify reasoning about how to avoid problems caused by method overrides.Keywords
This publication has 13 references indexed in Scilit:
- Data groups1998
- A study of the fragile base class problem1998
- Reuse contracts1996
- Modular reasoning in the presence of subclassingACM SIGPLAN Notices, 1995
- Specification and verification of object-oriented programs using supertype abstractionActa Informatica, 1995
- A behavioral notion of subtypingACM Transactions on Programming Languages and Systems, 1994
- Typing the specialization interface1993
- Issues in the design and specification of class libraries1992
- Designing an object-oriented programming language with behavioural subtyping1991
- Proof of correctness of data representationsActa Informatica, 1972