[squeak-dev] Re: My view on Traits

itsme213 itsme213 at hotmail.com
Fri May 16 14:14:00 UTC 2008


"Ryan Mitchley" <ryan.mitchley at gmail.com> wrote in message

> As I see it, this confuses
> Y Is-A X (i.e. Y subclasses X)
> with
> Y Has-A-Part X (i.e. Y has a member variable / subpart / trait X)

What about
  Y plays role R1, and role R2

e.g. a Car plays the role of TransportationVehicle and CollateralAsset.

The "state" related to these two roles are not independent: as you rack up 
miles on the transportation vehicle, the asset collateral value drops; when 
the asset is hauled away for non-payment, the transportation vehicle is not 
available.

Doing this with "has-A" becomes quite intricate, unless you systematically 
set up a notification channel between the parts and the whole. Perhaps 
traits are cleaner for these (within their limitations e.g. static, not 
dynamic;  cannot rename callback methods, only alias).

Sophie 






More information about the Squeak-dev mailing list