close Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Version 25 (modified by malte.appeltauer, 11 years ago) (diff)



This website hosts context-oriented programming language extensions that have been developed in research activities at the Software Architecture Group, which is led by Prof. Dr. Robert Hirschfeld at the Hasso Plattner Insitute (University of Potsdam).

Representing Context-dependent Behavioral Variations

Software systems must adapt to changing contexts over time, even while they are running. Unfortunately mainstream programming languages and development environments do not support this kind of dynamic change very well, leading developers to implement complex designs to anticipate various dimensions of variability.

The notion of Context-oriented Programming (COP) directly supports variability depending on a large range of dynamic attributes. In effect, it should be possible to dispatch runtime behavior on any properties of the execution context. First prototypes have illustrated how multi-dimensional dispatch can indeed be supported effectively to achieve expressive runtime variation in behavior.

Different COP languages or systems may provide different interpretations of the following mechanisms, but should at least address the following requirements:

  • Behavioral variations. Variations typically consist of new or modified behavior, but may also comprise removed behavior. They can be expressed as partial definitions of modules in the underlying programming model such as procedures or classes, with complete definitions representing just a special case.
  • Layers. Layers group related context-dependent behavioral variations. Layers are first-class entities, so that they can be explicitly referred to in the underlying programming model.
  • Activation. Layers aggregating context-dependent behavioral variations can be activated and deactivated dynamically at runtime. Code can decide to enable or disable layers of aggregate behavioral variations based on the current context.
  • Context. Any information which is computationally accessible may form part of the context upon which behavioral variations depend.
  • Scoping. The scope within which layers are activated or deactivated can be controlled explicitly. The same variations may be simultaneously active or not within different scopes of the same running application.

More research and experimentation is clearly needed into different ways to compose and trigger variations. For example, variations may be expressed not only as differences in code, but as extensions, wrappers, advice, refactorings, or general transformations. Variations may not only be triggered explicitly and programmatically, but also implicitly by means of rules or constraints. Important questions include how existing development approaches can be adapted and extended to support COP, starting from analysis over design up to implementation.

One compelling application domain for COP is to control software evolution. COP can enable runtime deployment of software changes while strictly delimiting the visibility of changes to specific clients and leaving others untouched. Radical changes can slowly percolate through a running system, without breaking clients who are not ready for them. Backwards-compatibility need no longer be a critical concern if the client context is taken into account when deploying changes. Global consistency is neither assumed nor desirable.

COP signals a move away from application-specific solutions to runtime variability (such as those offered by many design patterns), and instead focuses on developing a new programming paradigm and corresponding language constructs and underlying software infrastructure to support context-dependent behavior. We believe that these steps are essential to achieving the high degree of maintainability, robustness and adaptability that is needed for the emerging breed of dynamic, mobile and pervasive applications.

Most of the existing approaches for handling context-dependent software behavior have been embedded in other research domains, such as object-oriented programming, aspect-oriented programming, feature-oriented programming, productline architectures, ambient intelligence, unanticipated and/or dynamic software evolution, dynamic languages, and so on. However, it is about time to recognize and appreciate a focus on context orientation as a common thread.

Language Implementations


JCop is a context-oriented language extension to Java that provides explicit and declarative layer activation.

Malte Appeltauer (malte.appeltauer@…)
Robert Hirschfeld (robert.hirschfeld@…)
Michael Haupt (michael.haupt@…)
Software Architecture Group, Hasso-Plattner-Institut Potsdam

Hidehiko Masuhara (masuhara@…)
東京大学 The University of Tokyo


ContextJS is ....

Jens Lincke (jens.linke@…)
Robert Hirschfeld (robert.hirschfeld@…)


Robert Hirschfeld (robert.hirschfeld@…)


ContextJ is JCop's predecessor that offers explicit layer activation and layer-in-class modularization.

Malte Appeltauer (malte.appeltauer@…) Robert Hirschfeld (robert.hirschfeld@…) Software Architecture Group, Hasso-Plattner-Institut Potsdam

Attachments (9)

Download all attachments as: .zip