[Q] perform:orSendTo:

Bob Arning arning at charm.net
Sun Jun 23 13:46:23 UTC 2002


German,

I'm not troubled by the comment, although that may reflect a different preference in comments as well as a difference in first language. The comment reads:

	"If I wish to intercept and handle selector myself, do it; else send it to otherTarget"

which, to me, is a suitable comment for all implementations of this method, especially the one at the top if the hierarchy. It speaks not about implementation, but intention. It says that implementors of this method get to choose who will handle this request. It doesn't say how the decision should be made or list a lot of exceptions. And, importantly, it will still be correct even if the implementation were to change someday.

As to
>And why it's implemented:
>   otherObject perform: selector
>and not:
>   self perform: selector
>???

I suspect (I can't find an old image that actually has the relevant change set in it) that the Object implementation was added when the implementation in Model was discovered to be too low in the hierarchy. This method was added AFAICT to support something that MVC had been doing for some time. It's proabably better not to tinker lightly here.

Cheers,
Bob

On Sun, 23 Jun 2002 03:37:03 -0700 <germanmorales at delta-sys.com> wrote:
>It seems that on Sat, 22 Jun 2002 17:33:53 -0400 (EDT) you
>wrote:
>> On Sat, 22 Jun 2002 14:11:26 -0700
>> German wrote:
>> >The problem seems to be that Object>>perform:orSendTo:
>> >doesn't do what its selector says, but just sends the
>> >message to the other possible target.
>> ><snip>
>> >Mi questions are:
>> >Why this is not the current implementation?
>> >It's just a bug or there's something else behind?
>> >Should I send a change set with such a fix? ;-)
>> 
>> German,
>> 
>> There are other classes implementing this method in a
>> manner similar to the one you suggest. My guess that
>> Object was left as simple as possible (#respondsTo: is
>> not cheap, nor does it win a lot of points for style) in
>> the hopes that the programmer would spot the problem
>> quickly and fix it somewhere else (whatever you do in
>> Object for this will not satisfy everyone).
>> 
>> Cheers,
>> Bob
>
>Thanks for your answer. But it didn't make me happy.
>
>I think that a method should do what it says will do.
>Or at least should be a comment saying that I must fix it.
>
>When I read "perform:orSendTo:", I understand:
>"perform this on you, but if you cant, then send it to this
>other Object". And this is clearly not what it does.
>
>Should I read it as "perform this on you or this other
>Object, I don't care on which" ???
>
>And why it's implemented:
>   otherObject perform: selector
>and not:
>   self perform: selector
>???
>
>Thanks in advance




More information about the Squeak-dev mailing list