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.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.