Traits, r?les and other repurposed terms

Adrian Howard adrianh at quietstars.com
Tue Feb 12 17:24:03 GMT 2008


On 8 Feb 2008, at 14:15, Ovid wrote:

> --- Adrian Howard <adrianh at quietstars.com> wrote:
>
>>> --- Abigail <abigail at abigail.be> wrote:
>>>
>>>> (Of course, "roles" is just "multiple inheritance" with a
>> different
>>>> name.
>>>
>>> With all due respect, this is not even remotely true.
>> [snip]
>>
>> I think that depends on how you define MI and roles :-)
>>
>> For example Eiffel's OO model (ignoring the switching roles/traits
>> in/
>> out at runtime - which it doesn't handle)
>
> Oops.  OK, so for C++, Java, C#, Ruby, Python, Perl, etc., they're not
> the same thing :)

It does depend :-) I guess that, to some extent roles/traits embody  
"good" use of mixins/MI. I know that's not the whole story, but it is  
a moderately large chunk of it.

That's a *good* thing of course - I'm just not 100% certain that  
naming these things as the "new" concepts of "role" and "trait"  
rather than just as different kinds of class makes it easier to grok  
for poor simple minds like mine.

... but I think it may explain why its a harder sell to folk who have  
internalised ways of using MI well. They see a chunk of stuff that  
they can do already, and miss the fact that it stops a whole bunch of  
dumb stuff with some additional side benefits along the way.

That's the way it seems to me at the moment. I could be talking horse  
shit of course - since I've not used roles/traits in anger on a real  
project, just tried to get my poor head around S12 ;)

> I really do like the idea Eiffel has of being explicit about the
> redefinition/renaming of inherited methods, but as noted, you don't  
> get
> the runtime benefits (very similar to prototype-based classes) or the
> introspective separation of 'does-a' versus 'is-a', though in the case
> of Eiffel, I'm not sure how that would play out.  Since I'm  
> comfortable
> with traits but not with Eiffel, I can't say much more than that.

Y'know. I'd not thought of that aspect of it before. Not seeing uses  
for it at the moment mind - but I'm sure they're there!

> Though for smaller-scale systems, this can be arguing about how many
> angels can dance on the head of a pin :)

Indeed.

The fact that the tone of some of the folk complaining about roles/ 
traits matches my recollection of the tone of some of the folk  
complaining about objects/classes in the late eighties means there's  
probably something useful there :-)

Cheers,

Adrian



More information about the london.pm mailing list