Recent years saw the development of a composition mechanism called Traits. Traits are pure units of behavior that can be composed to form classes or other traits. The trait composition mechanism is an alternative to multiple or mixin inheritance in which the composer has full control over the trait composition.
To evaluate the expressiveness of traits, some hierarchies were refactored, showing Code Reuse. However, such large refactorings, while valuable, may not exhibit all possible composition problems, since the hierarchies were previously expressed using single inheritance and following certain patterns.
This paper presents our work on designing and implementing a new trait-based stream library named Nile. It evaluates how far traits enable reuse, what problems can be encountered when building a library using traits from scratch and compares the traits solution to alternative composition mechanisms. Nile’s core allows the definition of compact collection and file streaming libraries as well as the implementation of a backward-compatible new stream library. Nile method size shows a reduction of 40% compared to the Squeak equivalent. The possibility to reuse the same set of traits to implement two distinct libraries is a concrete illustration of trait reuse capability.
~
CASSOU, Damien, DUCASSE, Stéphane and WUYTS, Roel, 2009. Traits at work: The design of a new trait-based stream library. Computer Languages, Systems & Structures. 1 April 2009. Vol. 35, no. 1, p. 2–20. DOI 10.1016/j.cl.2008.05.004.
Note: We're not so much interested in Code Reuse as we are in modeling Concepts.
~
The third property results in spontaneous generalization. Knowledge about an item is automatically generalized to all other items, to the Degree that they are similar to that item. As long as the input situations consist of familiar elements, the system can perform reasonably well in new situations.
We summarize research demonstrating that variables of urban morphology, taken together, play a significant, possibly very large (and still poorly understood) role in the generation of greenhouse gas (GHG) emissions.
Kay, looking at Smalltalk-80, said, “It’s terrible that it can’t be used by children, since that’s who Smalltalk was intended for. It fell back into data-structure-type programming instead of simulation-type programming.”
Multiple inheritance has been the focus of a large amount of work and research efforts. Recently, traits proposed a solution in which the composite entity has the control and which can be flattened away, i.e., traits do not affect the runtime semantics [1,2]. Traits are fine-grained units that can be used to compose classes. Like any solution to multiple inheritance, the design of traits is the result of a set of trade-offs. Traits favor simplicity and fine-grained composition. Traits are meant for single inheritance languages. Trait composition conflicts are automatically detected and the composer is empowered to resolve these conflicts explicitly. Traits claim to avoid many of the problems of multiple inheritance and mixin-based approaches that mainly favor linearization where conflicts never arise explicitly and are solved implicitly by ordering.