Stateful traits

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Stateful traits

Balázs Kósi
Hi Stephane!

The presentation has a slide titled Traits limits:
1) Trait users should define missing traits state
2) Important required methods and required state are mixed
3) Boilerplate glue code
4) Propagation of required accessors

With stateful traits instead of 1) and 3) now they have to call the
proper initialization methods, or setters of the traits. Is this any better?

2) is bad. Maybe categorisation of methods can help?
1) and 3) maybe also can be solved by tools, generating the proper
inst vars, and accessors.
What do you think?

Another question: Can Traits define class side behaviour?

thanks, balázs

Reply | Threaded
Open this post in threaded view
|

Re: Stateful traits

Philippe Marschall
> Another question: Can Traits define class side behaviour?
For stateless Traits (shouldn't be different with stateful Traits):
Yes they can. There are two ways.
- Either implement the behavior on the class side of the trait (iirc
this is called classtrait)
- Or include (right term?) the trait in the class side. The instance
side behavior of the trait then becomes class side behavior of the
class. What happens with classtrait bevahior in this case I don't
know.

Philippe

Reply | Threaded
Open this post in threaded view
|

Re: Stateful traits

Alexandre Bergel-2
In reply to this post by Balázs Kósi
Hi Balázs

> The presentation has a slide titled Traits limits:
> 1) Trait users should define missing traits state
> 2) Important required methods and required state are mixed
> 3) Boilerplate glue code
> 4) Propagation of required accessors

With stateful traits:
1) a trait user (i.e., another trait or a class) does not need to  
define the state required by the used trait.
2) if a trait needs some variables, then it can define it. Whereas  
with stateless traits the needed state had to be specified as  
required methods.
3) less glue code is needed
4) state and accessors are not duplicated across users of a trait.

A working version of our paper should be available on the esug  
website I think.


> With stateful traits instead of 1) and 3) now they have to call the
> proper initialization methods, or setters of the traits. Is this  
> any better?

cf above. Else have a look at what we wrote :-)

> 2) is bad. Maybe categorisation of methods can help?
> 1) and 3) maybe also can be solved by tools, generating the proper
> inst vars, and accessors.
> What do you think?
>
> Another question: Can Traits define class side behaviour?

yes.

Cheers,
Alexandre

--
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.cs.tcd.ie/Alexandre.Bergel
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.