In the newly released "Cocoa design patterns" (Buck and Yacktman), the chapter 
discussing Delegates includes an example, which in it's implementation file, 
has the following method, which is defined/declared like this:  ( I have 
removed the actual definition)


- (float)_myBarShouldChangeValue:(float)newValue
/*! Give the delegate a chance to change the new value */
{
   if(...something....)
   {
      ....more method definition.....
   }
   
   return newValue;
}


The method, as alluded to above, is not declared in the interface, and the 
compiler does not complain as it is called from a method later/after this.

The  Authors note:

".....The convention of naming so-called private methods with an underscore and 
a prefix reduces the chance that someone might inadvertently override or call 
the method."


I just wonder how this meshes with Apple's documentation:  (Private methods in 
"Coding guidelines for Cocoa")

"Names of most private methods in the Cocoa frameworks have an underscore 
prefix (for example, _fooData ) to mark them as private. From this fact follow 
two recommendations.

        • Don’t use the underscore character as a prefix for your private 
methods. Apple reserves this convention."


I have hunted around for a thread in cocoa, which I was looking at, ( and of 
course which I cannot find now)  that implied that "extensions" seemed to be 
the way that this should be addressed. 

I am not asking to start another huge thread, but, seeing that this has 
**just** been published, and in every other way is providing a really solid 
approach (for me)  to Cocoa, and trying to start out "right", is there an easy 
answer to the seemingly contradictory advice, or it is just possible/likely,  
that I have missed some very important issues.

Thanks in advance.








_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to