Recently, Sch{\"a}rli et al. pointed out that both single and multiple class-based inheritance are often inappropriate as a reuse mechanism, because classes play two competing roles, namely, a class is both a generator of instances and a unit of reuse. To overcome this problem, Sch{\"a}rli et al. proposed traits, which are composable pure units of behavior reuse consisting only of methods. However, both in the original proposal and (to the best of our knowledge) in all the trait-based approaches that can be found in the literature, traits live together with the traditional class-based inheritance. Therefore, besides their primary role of generators of instances, classes can still play a secondary role of units of (state and behavior) reuse, and a style of programming oriented to reuse is not enforced by the language, but left to the programmer's skills. When static typing is also taken into account, the role of unit of reuse and the role of type are competing, too. We argue that, in order to support the development of reusable program components, class-based statically typed programming languages should be designed according to the principle that each programming construct must have exactly one role. We present language constructs that separate completely the declarations of object type, behavior, state, and generator.

Separating Type, Behavior, and State to Achieve Very Fine-grained Reuse

BONO, Viviana;DAMIANI, Ferruccio;GIACHINO, Elena
2007-01-01

Abstract

Recently, Sch{\"a}rli et al. pointed out that both single and multiple class-based inheritance are often inappropriate as a reuse mechanism, because classes play two competing roles, namely, a class is both a generator of instances and a unit of reuse. To overcome this problem, Sch{\"a}rli et al. proposed traits, which are composable pure units of behavior reuse consisting only of methods. However, both in the original proposal and (to the best of our knowledge) in all the trait-based approaches that can be found in the literature, traits live together with the traditional class-based inheritance. Therefore, besides their primary role of generators of instances, classes can still play a secondary role of units of (state and behavior) reuse, and a style of programming oriented to reuse is not enforced by the language, but left to the programmer's skills. When static typing is also taken into account, the role of unit of reuse and the role of type are competing, too. We argue that, in order to support the development of reusable program components, class-based statically typed programming languages should be designed according to the principle that each programming construct must have exactly one role. We present language constructs that separate completely the declarations of object type, behavior, state, and generator.
2007
9th Workshop on Formal Techniques for Java-like Programs FTfJP 2007
Berlin, Germany
July 31, 2007
9th Workshop on Formal Techniques for Java-like Programs FTfJP 2007
John Boyland
-
-
-
http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.101.7482
http://cs.nju.edu.cn/boyland/ftjp/index.html
http://www.cs.ru.nl/ftfjp/
Inheritance; Trait; Subtyping; Flattening
V. BONO; F. DAMIANI; E. GIACHINO
File in questo prodotto:
File Dimensione Formato  
paper_7.pdf

Accesso aperto

Tipo di file: POSTPRINT (VERSIONE FINALE DELL’AUTORE)
Dimensione 159.73 kB
Formato Adobe PDF
159.73 kB Adobe PDF Visualizza/Apri

I documenti in IRIS sono protetti da copyright e tutti i diritti sono riservati, salvo diversa indicazione.

Utilizza questo identificativo per citare o creare un link a questo documento: https://hdl.handle.net/2318/29076
Citazioni
  • ???jsp.display-item.citation.pmc??? ND
  • Scopus ND
  • ???jsp.display-item.citation.isi??? ND
social impact