There are some lightweight ways of
handling this using roles. Person instanceVariables:
roles aPerson roles add: Human new; add: Ninja
new. There are a number of roles
implementations. One based on doesNotUnderstand which runs through the
roles collection and passes the called but not understandable message to each
instance. Some implementations will return a collection of responses if
multiple roles answer the same message, and this can get kinda tricky if you
don’t know how to watch for it. You can also define a specific
interface to your methods by specifically implementing your methods on Person to
look for a role before forwarding the method and handling the call if it does
not. For Example: Person >> killSilently aPerson
hasNinjaRole ifTrue: [^self ninjaRole killSilently]. aPerson
hasHumanRole ifTrue: [^self humanRole killSilently]. aPerson
handleKillingRequestWithMoreSleepAndExercise. Ninja >> killSilently “walk
on rice paper leaving no trace then you will be ready” self
doSilentKilling Human >> killSilently “humanity
wins” self
tryToKill. self
goToPoliceStation. self
confess. I’m not saying I like roles. I
just thought I’d mention more options. Ron Teitelbaum President / Principal Software Engineer US Medical Record Specialists From:
[EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Michael Gorsuch Here's an idea: On 11/13/06, Michael
Haupt <[EMAIL PROTECTED]>
wrote: Hi Warakom, |
_______________________________________________ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners