[Newbies] Determining the sender in a method
Rob Rothwell
r.j.rothwell at gmail.com
Sun May 25 12:51:14 UTC 2008
On Sun, May 25, 2008 at 12:59 AM, Randal L. Schwartz <merlyn at stonehenge.com>
wrote:
> Rob> Or would doing this just be bad form?
>
> Yes. While you *can* do a lot of magic like this, it's probably
> best if you avoid it for now. A typical pattern is to pass self:
>
>
> MyObject>>doSomething
> ^self otherClass makeSomethingOn: self.
Thanks...this is almost what I did, lacking the "bad form" MethodContext
introspecting methods you described. Although I admit I hardwired it as
below, but will rectify that soon enough!
Also note: don't hardwire a helper class name in your methods. Use
> a method call to get it, so you'd say:
>
> MyObject>>otherClass
> ^TheOtherClass
>
> If you hardwire it, it'll make your class much harder to subclass.
Which is what I am doing (subclassing). This "trivial" example shows I am
making progress but still somewhat bound by the laws of non-object
programming!
Thanks again,
Rob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/beginners/attachments/20080525/e6787d64/attachment.htm
More information about the Beginners
mailing list