Method redefinition: ensuring alternative behaviors

  • Authors:
  • I. Nunes

  • Affiliations:
  • Lisbon University, Bloco C6, Piso 3, Campo Grande, 1749-016 Lisboa, Portugal

  • Venue:
  • Information Processing Letters
  • Year:
  • 2004

Quantified Score

Hi-index 0.89

Visualization

Abstract

The redefinition of a method in subclasses can completely change the semantics of the superclass method unless there are effective mechanisms that enforce the preservation of behavioral properties. Several approaches to behavioral subtyping-- exact pre-post match, plug-in match, relaxed plug-in match among others--exist that enforce the preservation of behavioral properties.To maintain or weaken pre-conditions and to maintain or enforce post-conditions when redefining methods in extended classes--plug-in match--is the solution that is adopted, by construction, in the Eiffel language, among other assertion languages. This approach forbids the specification of a class of legitimate programs from which we present an example. We claim that relaxed plug-in match should be enforced instead, in order to accommodate these examples. Other approaches exist, as is the case of case analysis in JML and OCL, that allow the specification of those programs, but they do it at the cost of decreasing software extension.We propose a new way of building contracts that identify and express, in a natural and elegant way, the several contributions that method redefinition can bring, and that are expressive enough to specify extensible contracts for the above mentioned class of programs. These contracts ensure, by construction, that redefinition preserves behavioral properties.