next up previous
Next: Introduction

Evolution of Object Behavior using Context Relations

Linda M. Seitergif , Jens Palsberggif , and Karl J. Lieberherrgif



A collection of design patterns was described by Gamma, Helm, Johnson, and Vlissides in 1994. Each pattern ensures that a certain system aspect can vary over time, for example the operations that can be applied to an object or the algorithm of a method. The patterns are described by constructs such as the inheritance and reference relations, attempting to emulate more dynamic relationships. As a result, the design patterns demonstrate how awkward it is to program natural concepts of behavioral evolution when using a traditional object-oriented language.

In this paper we present a new relation between classes: the context relation. It directly supports behavioral evolution, and it is meaningful at both the design and implementation level. At the design level we picture a context relation as a new form of arrow between classes. At the implementation level we use a small extension of C++. The basic idea is that if class C is context-related to a base class B, then B-objects can get their functionality dynamically altered by C-objects. Our language construct for doing this is a generalization of the method update in Abadi and Cardelli's imperative object calculus. A C-object may be explicitly attached to a B-object, or it may be implicitly attached to a group of B-objects for the duration of a method invocation. We demonstrate how the context relation can be used to easily model and program the Adapter, Bridge, Chain of Responsibility, Decorator, Iterator, Observer, State, Strategy, and Visitor patterns.

Keywords: Reusable design, a new class relation, behavior composition.

Karl Lieberherr
Tue Jan 21 09:24:10 EST 1997