Previous article

next article

Flattening Traits

Oscar Nierstrasz, Stéphane Ducasse and Nathanael Schärli
Software Composition Group, University Of Bern


PDF Version


Traits are fine-grained components that can be used to compose classes, while avoiding many of the problems of multiple inheritance and mixin-based approaches. Since most implementations of traits have focused on dynamically-typed languages, the question naturally arises, how can one best introduce traits to statically-typed languages, like Java and C#? In this paper we argue that the flattening property of traits should be used as a guiding principle for any attempt to add traits to statically-typed languages. This property essentially states that, semantically, traits can be compiled away. We demonstrate how this principle applies to Featherweight-Trait Java, a conservative extension to Featherweight Java.

Note: Due to the typographical sophistication of this article, no HTML version is available. Please use the PDF version.


About the authors

Oscar Nierstrasz is a Full Professor of Computer Science at the University of Bern, Switzerland, where he has led the Software Composition Group since its founding in 1994. See also

Stéphane Ducasse is a Swiss National Science Foundation Professor at theUniversity of Bern since 2002, and a Full Professor of Computer Science at the University of Savoie in Annecy since 2005.

Nathanael Schärli was a PhD student in the Software Composition Group from 2001 to 2005, when he completed his dissertation entitled “Traits–Composing Classes from Behavioral Building Blocks”.

Cite this article as follows: Oscar Nierstrasz, Stéphane Ducasse, Nathanael Schärli, “Flattening Traits”, in Journal of Object Technology, vol. 5, no. 4, Mai-June 2006, pp. 129-148

Previous article

next article