Traits: A mechanism for fine-grained reuse

  • Authors:
  • Stéphane Ducasse;Oscar Nierstrasz;Nathanael Schärli;Roel Wuyts;Andrew P. Black

  • Affiliations:
  • University of Berne and LISTIC, University of Savoie, Annecy Cedex, France;University of Berne, Berne, Switzerland;University of Berne, Zürich, Switzerland;Université Libre de Bruxelles, Belgium;Portland State University, Portland, Oregon

  • Venue:
  • ACM Transactions on Programming Languages and Systems (TOPLAS)
  • Year:
  • 2006

Quantified Score

Hi-index 0.00

Visualization

Abstract

Inheritance is well-known and accepted as a mechanism for reuse in object-oriented languages. Unfortunately, due to the coarse granularity of inheritance, it may be difficult to decompose an application into an optimal class hierarchy that maximizes software reuse. Existing schemes based on single inheritance, multiple inheritance, or mixins, all pose numerous problems for reuse. To overcome these problems we propose traits, pure units of reuse consisting only of methods. We develop a formal model of traits that establishes how traits can be composed, either to form other traits, or to form classes. We also outline an experimental validation in which we apply traits to refactor a nontrivial application into composable units.