Guys@Bern: About Traits Was: Morph cleaning proposal
hannes.hirzel.squeaklist at bluewin.ch
Wed Feb 12 21:16:46 UTC 2003
Stephane Ducasse <ducasse at iam.unibe.ch> wrote:
> > - Guys at Bern: What about the stability of the current traits
> > implementation?
> > Do you expect too much changes?
> What I suggest to you is to use the image nathanael provided. And tell
> us! Design
> a small system and check because I can tell you that this is great (it
> is ;)) but
> we need your and other point of view. I think that in two days you can
> access it.
> If this is stable, it is now if hundred of squeakers play with it, we
> will find certainly
> some bugs.
> Read what nathanael said on the web page. I think that traits are
> stable, but we cannot
> save them (no file out support but one guy can define that in now time).
Thank you for pointing at this. The three papers are very interesting
to read and the screen shots of a Squeak implemenation of traits
give a good impression how it works.
The links to the three papers about traits are
The traits implementation in Squeak
I give a *very* short and informal summary:
A. Attributes of traits
- A trait provides a set of methods that implement behaviour
- A trait requires a set of methods that parameterize the provided
- Traits do not specify any state variables, and the methods provided by
traits never directly access state variables
- Traits can be composed: trait composition is symmetric and confilcting
methods are excluded from the composition.
B. Classes under the traits model
Class = State + Traits + Glue
C. Compatibilty to existing Smalltalk language
Traits are completely downwards compatible and do not require modifiying
or extending the method syntax of the underlying language.
D. Traits and Refactoring
Another surprise was that the refactoring process turned out to be quite
enjoyable and very straightforward. Trait-based refactoring seems to be
compatible with an extreme programming style of develoopment, because it
does not require one to do all of the design "up front".
E. Very informal analogy
Traits are like Java interfaces but instead of just method headers you
have code in the "interface" methods, but no instance variables. You can
use the same trait in different classes as a building block.
I hope this motivates some members of the list to look at the papers
I really would like to see this persued further within Squeak and
applied to Morphic.
More information about the Squeak-dev