|
Traits (Was Design best practice : put state-independent methodsonclass sid: msg#00168lang.smalltalk.squeak.beginners
On Tue, Mar 25, 2008 at 8:02 PM, Matthew Fulmer <tapplek@xxxxxxxxx> wrote:
_______________________________________________
So...if in a general sense a trait has no knowledge of the object it will be attached to, is it common practice to create traits to be used only by a specific group of objects so that some common behaviour can be assumed?
Or at that point are you just creating a subclass and should just go ahead and duplicate the methods? As a trivial example, say you have Dog and Rock, and you want to make a Pet out of both of them even though they both have different base classes (like Animal or Mineral). Furthermore, Pet>>careInstructions needs to use "self foodRequirements," which you may provide for a Dog or a Rock, but not for all objects.
In other words, would you expect to see PetTraits that are meant to be used with Dog or Rock subclasses only?
Thanks! Rob Beginners mailing list Beginners@xxxxxxxxxxxxxxxxxxxxxxxxxx http://lists.squeakfoundation.org/mailman/listinfo/beginners
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Design best practice : put state-independent methodsonclass side?, Matthew Fulmer |
|---|---|
| Next by Date: | Re: Design best practice : put state-independent methodsonclass side?, David Mitchell |
| Previous by Thread: | Design best practice : put state-independent methods on class side?, itsme213 |
| Next by Thread: | Re: Traits (Was Design best practice : put state-independentmethodsonclass side?), itsme213 |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |