Communication Dans Un Congrès Année : 2003

Traits: Composable Units of Behaviour

Résumé

Despite the undisputed prominence of inheritance as the fundamental reuse mechanism in object-oriented programming languages, the main variantssingle inheritance, multiple inheritance, and mixin inheritance -all suffer from conceptual and practical problems. In the first part of this paper, we identify and illustrate these problems. We then present traits, a simple compositional model for structuring object-oriented programs. A trait is essentially a group of pure methods that serves as a building block for classes and is a primitive unit of code reuse. In this model, classes are composed from a set of traits by specifying glue code that connects the traits together and accesses the necessary state. We demonstrate how traits overcome the problems arising from the different variants of inheritance, we discuss how traits can be implemented effectively, and we summarize our experience applying traits to refactor an existing class hierarchy.

Fichier principal
Vignette du fichier
Scha03a-ECOOP-Traits.pdf (190.47 Ko) Télécharger le fichier
Origine Fichiers produits par l'(les) auteur(s)
Licence

Dates et versions

hal-05074042 , version 1 (19-05-2025)

Licence

Identifiants

  • HAL Id : hal-05074042 , version 1

Citer

Nathanael Schärli, Stéphane Ducasse, Oscar Nierstrasz, Andrew P Black. Traits: Composable Units of Behaviour. ECOOP 2003 - European Conference on Object-Oriented Programming, Jul 2003, Darmstadt, Germany. ⟨hal-05074042⟩
34 Consultations
68 Téléchargements

Partager

  • More