Respectful Type Converters For Mutable Types

Author: Jeannette M. Wing and John Ockerbloom

Click here for the PostScript version.


In converting an object of one type to another, we expect some of the original object's behavior to remain the same, and some to change. How can we state the relationship between the original object and converted object to characterize what information is preserved and what is lost after the conversion takes place? We answer this question by introducing the new relation, respects, and say that a type converter function K: A -> B respects a type T. We formally define respects in terms of the Liskov and Wing behavioral notion of subtyping; types A and B are subtypes of T.

In previous work we defined respects for immutable types A, B, and T; in this paper we extend our notion to handle conversions between mutable types. This extension is non-trivial since we need to consider an object's behavior as it varies over time. We present in detail two examples to illustrate our ideas: one for converting between PNG images and GIF images and another for converting between different kinds of bounded event queues. We also discuss in less detail other real-world applications, namely those inspired by our Typed Object Model (TOM) conversion service built at Carnegie Mellon and by the infamous Year 2000 (Y2K) problem.