Skip to content
Licensed Unlicensed Requires Authentication Published by De Gruyter Oldenbourg September 25, 2009

Classboxes – Controlling Visibility of Class Extensions (Classboxes – Kontrollierte Sichtbarkeit von Klassenerweiterungen)

  • Alexandre Bergel

Summary

Unanticipated changes to complex software systems can introduce anomalies such as duplicated code, suboptimal inheritance relationships and a proliferation of run-time downcasts. Refactoring to eliminate these anomalies may not be an option, at least in certain stages of software evolution. A class extension is a method that is defined in a module, but whose class is defined elsewhere. Class extensions offer a convenient way to incrementally modify existing classes when subclassing is inappropriate. Unfortunately existing approaches suffer from various limitations. Either class extensions have a global impact, with possibly negative effects for unexpected clients, or they have a purely local impact, with negative results for collaborating clients. Furthermore, conflicting class extensions are either disallowed, or resolved by linearization, with subsequent negative effects. To solve these problems we present classboxes, a module system for object-oriented languages that provides for behavior refinement (i. e. method addition and replacement). Moreover, the changes made by a classbox are only visible to that classbox (or classboxes that import it), a feature we call local rebinding. We present an experimental validation in which we apply the classbox model to both dynamically and statically typed programming languages. We used classboxes to refactor part of the Java Swing library, and we show two extensions built on top of classboxes which are (i) runtime adaptation with dynamically classboxes and (ii) expressing crosscutting changes.

Zusammenfassung

Unerwartete Veränderungen in komplexen Systemen führen zu Anomalien wie z. B. dupliziertem Code, suboptimalen Vererbungsbeziehungen und die Zunahme von Runtime Downcasts. Refactoring bietet nicht immer eine Lösung, zumindest nicht in allen Stufen der Software Evolution. Eine Klassenerweiterung ist eine Methode, die in einem Modul deklariert, aber deren Klasse an anderer Stelle definiert ist. Klassenerweiterungen sind eine elegante Möglichkeit, um bestehende Klassen inkrementell zu verändern, wenn Vererbung nicht anwendbar ist. Existierende Ansätze zeigen einige Nachteile auf. So können z. B. Klassenerweiterungen globale Einflüsse mit negativen Folgen für die Benutzer dieser Klasse haben. Als Lösungsansatz stellen wir “classboxes” vor, ein Modulsystem für Objekt-orientierte Sprachen, das Verhaltensverfeinerungen anbietet, d. h. Redefinition und Zusatz von Methoden. Die Veränderungen einer Classbox sind nur für diese oder andere Classboxes, die diese importieren, sichtbar. Dieses bezeichnen wir als so genanntes Local Rebinding. Wir präsentieren eine experimentelle Bewertung, in der wir das Classbox Prinzip auf statisch und dynamisch typisierte Programmiersprachen anwenden. Teile der Java Swing Bibliothek wurden mit diesem Prinzip refaktorisiert. Zusätzlich stellen wir zwei Erweiterungen vor, die auf dem Classbox Prinzip aufbauen, die Adaption einer Anwendung mit dynamischen Classboxen und die Definition von Crosscutting Ausdrücken.

Published Online: 2009-9-25
Published in Print: 2007-7-1

© Oldenbourg Wissenschaftsverlag

Downloaded on 27.4.2024 from https://www.degruyter.com/document/doi/10.1524/itit.2007.49.4.260/html
Scroll to top button