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

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 non-trivial application into composable units.

"... Abstract. Despite the undisputed prominence of inheritance as the fundamental reuse mechanism in object-oriented programming languages, the main variants — single inheritance, multiple inheritance, and mixin inheritance — all suffer from conceptual and practical problems. In the first part of this p ..."

Abstract. Despite the undisputed prominence of inheritance as the fundamental reuse mechanism in object-oriented programming languages, the main variants — single 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.

... an extension of the programming tools, i.e., the Smalltalk browser. In the following, we give a brief overview of this extended browser; a more detailed description can be found in a companion paper =-=[36]-=-. For each class (and each trait), the browser shows the various traits from which it is composed. The flattening property allows the browser to flatten this hierarchical structure at any level. In ad...

by
Andrew P. Black
- In Proceedings of the 26th International Conference on Software Engineering, 2004

"... Traits are an object-oriented programming language construct that allow groups of methods to be named and reused in arbitrary places in an inheritance hierarchy. Classes can use methods from traits as well as defining their own methods and instance variables. Traits thus enable a new style of progra ..."

Traits are an object-oriented programming language construct that allow groups of methods to be named and reused in arbitrary places in an inheritance hierarchy. Classes can use methods from traits as well as defining their own methods and instance variables. Traits thus enable a new style of programming, in which traits rather than classes are the primary unit of reuse. However, the additional sub-structure provided by traits is always optional: a class written using traits can also be viewed as a flat collection of methods, with no change in its semantics. This paper describes the tool that supports these two alternate views of a class, called the traits browser, and the programming methodology that we are starting to develop around the use of traits. 1.

...sed where it is relevant; previous papers contain a detailed discussion of the relationship of traits to mixins and multiple inheritance [10], and a comparison of the traits browser to other browsers =-=[9]-=-. 2. What is the Problem? Edsger Dijkstra has written eloquently of “our inability to do much” [5]. One of the ways in which object-oriented programming helps us to do more, to cope with the everincre...

"... For the last 15 years, implementors of multiple view programming environments have sought a single code model that would form a suitable basis for all of the program analyses and tools that might be applied to the code. They have been unsuccessful. The consequences are a tendency to build monolithic ..."

For the last 15 years, implementors of multiple view programming environments have sought a single code model that would form a suitable basis for all of the program analyses and tools that might be applied to the code. They have been unsuccessful. The consequences are a tendency to build monolithic, single-purpose tools, each of which implements its own specialized analyses and optimized representation. This restricts the availability of the analyses, and also limits the reusability of the representation by other tools. Unintegrated tools also produce inconsistent views, which reduce the value of multiple views. This paper describes an architecture that allows a single, minimal representation of program code to be extended as required to support new tools and program analyses, while still maintaining a simple and uniform interface to program properties. We present architectural patterns that address efficiency, correctness and the integration of multiple analyses and tools in a modular fashion.

...t sufficient to report missing “required” methods at release time, our desire to show this information interactively requires a much more sophisticated implementation, but supports new styles of work =-=[33]-=-. Thus, the frequency of use of an analysis can change from once every few minutes to multiple times per second. The literature contains quite a few performance-related patterns relevant to implementi...

...fiable) in a window below the browser. An example of the system browser for Squeak [4], a version of Smalltalk with multimedia support, is shown in Figure 6.2. Schärli and Black’s incremental browser =-=[89]-=- augments the traditional Smalltalk browser with virtual categories that convey the completeness (of implementation) and relationships of classes in an inheritance hierarchy. Virtual categories are co...

...here exists also some research related to the model of intensional views. Most closely related are probably the models of conceptual modules [1], law-governed architecture [13] and virtual categories =-=[19]-=-. Conceptual modules are sets of lines of source code (from multiple parts of the system) that are defined intensionally by means of a regular expression and that are treated as a logic unit. Our appr...

Despite the undisputed prominence of inheritance as the fundamental reuse mechanism in object-oriented programming languages, the variants – single inheritance, multiple inheritance, and mixin inheritance – all suffer from conceptual and practical problems. Traits overcome the problems arising with the different variants of inheritance. Traits are essentially groups of methods that serve as building blocks for classes and are primitive units 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. This thesis discusses the implementation of traits. The result it presents is a new Smalltalk kernel bootstrapped with traits. The implementation is fully done in Squeak [INGA 97], an open-source dialect of Smalltalk. It is planned that the next generation of Squeak will include traits. Because traits are simple and completely backward compatible with single

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

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 non-trivial application into composable units.