Interfaces without implementation are like a day without sunshine

mob mob at mbedthis.com
Thu Aug 24 20:03:46 PDT 2006


We have implemented something very similar along the mixin design described 
below and have found them effective for cross-cutting concerns like logging.

Michael O'Brien
Mbedthis Software

> -----Original Message-----
> From: es4-discuss-admin at mozilla.org [mailto:es4-discuss-admin at mozilla.org]
> On Behalf Of P T Withington
> Sent: Thursday, August 24, 2006 1:21 PM
> To: Jeff Dyer
> Cc: es4-discuss at mozilla.org
> Subject: Re: Interfaces without implementation are like a day without
> sunshine
> 
> On 2006-08-24, at 14:19 EDT, Jeff Dyer wrote:
> 
> > The hard requirement for interfaces (when they were conceived in
> > AS3 at
> > Macromedia/Adobe) was to be able to relate a class to one or more
> > "abstract" types (as in Java). We discussed a richer idea of
> > interfaces
> > that would allow add implementation, etc, but were forced by design
> > and
> > practical concerns to choose a minimalist solution that would allow
> > for
> > future growth.
> 
> We have an implementation of 'traits' (composable units of behavior)
> that can be built on es3.  We have found them to be useful for
> structuring complex systems.  There are plenty of precedents for this
> pattern in O-O languages, although neither Java nor C# chose to adopt
> it -- perhaps for the same reasons.  I'm suggesting we move beyond
> the Java straight-jacket...
> 
> > But how do interfaces related to traits? To quote your reference
> > (http://www.iam.unibe.ch/~scg/Research/Traits/): "Unlike mixins and
> > multiple inheritance, Traits do not employ inheritance as the
> > composition operator. Instead, Trait composition is based on a set of
> > composition operators that are complementary to single inheritance and
> > result in better composition properties."
> 
> While we are using the term 'trait' for our system, our
> implementation is more along the lines of mix-ins (as described in
> their paper http://www.iam.unibe.ch/~scg/Archive/Papers/
> Scha03aTraits.pdf).  We allow a class to be composed of a base class
> and any number of traits.  The class is implemented by creating a
> prototype linked through its [[proto]] to instances of each of the
> traits and finally the base class.  So our traits are order-
> sensitive, they are composed by inheritance and you can override
> methods in traits (and access the overridden method using super).  We
> have not found it necessary to adopt the 'new composition method' of
> the referenced paper.  Although I understand from personal experience
> their concerns about mix-ins (ordering, integration, and fragility),
> I'm not convinced their solution is anything more than an enforced
> programming style.
> 
> We also allow state in our traits (as Nicholas requested).
> _______________________________________________
> Es4-discuss mailing list
> Es4-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es4-discuss




More information about the Es4-discuss mailing list