Re: passing a method name?
Re: passing a method name?
- Subject: Re: passing a method name?
- From: Matt Neuburg <email@hidden>
- Date: Mon, 21 Dec 2009 09:48:12 -0800
- Thread-topic: passing a method name?
On Sun, 20 Dec 2009 15:39:08 -0800, Dave Carrigan <email@hidden> said:
>
>On Dec 20, 2009, at 3:29 PM, Graham Cox wrote:
>
>> I think what the OP was talking about was making a called method sensitive to
its caller, which is a no-no.
>
>
>That's what I thought the OP was saying, and I agree. It would mean that doing
a refactor and changing a method's name, or even adding a new parameter to a
method, would break the code in some unrelated method. That's a huge maintenance
problem.
Well, I took the OP to mean just the opposite. Procedures often have to be
broken into two parts, esp. because of sheets; so, you might start out in
doMyThing:, but then you show a sheet and after the delegate callback you
want to proceed to doMyThingPart2:. Since the latter name is derivable from
the former, passing _cmd is a sensible way to generalize this situation, and
it's the exact opposite of a huge maintenance problem; provided the naming
convention is obeyed (a common enough pattern in Cocoa), pairs of methods
can be introduced or removed at will as development proceeds. m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden