Open martinstolz opened 10 years ago
:thumbsup: the private pragma never really made sense to me, as you say they separate logical pieces of code irrespective if they are private or public.
using the p_
prefix may be better as it isn't tied to an application prefix so allows for re-use.
How about a simple _
-prefix? That's how it's usually approached in JS.
@KATT This is occupied by Apple and should not be used. See their docs.
Ah yeah, I thought that was the case, but didn't bother to google it. :)
:smiley:
How about __
?
Otherwise, +1 on p_
.
Same with double underscore. I use it personally! But might clash with Apple's stuff as well.
Well, we've already been through this discussion when we set up the guidelines document and the outcome of that (very long) discussion was that we should not use prefixes of the private methods in general. So the format is not wrong in the guideline.
I believe we also agreed on using the us2_ prefix when releasing e.g. open source software components to decrease the risk of accidental method overrides by the users of that component.
And regarding the pragma marks, this is also what we agreed on. We're sorting methods based on functionality, but within that group of methods we'll sort public methods first, and then have a "private" pragma mark delimiter. So that section of the style guide isn't incorrect either.
The style of private methods is incorrect. Pragma marks should not be used to separate public and private methods but separating logical pieces of code.
Also it makes sense to mark your private methods in order to see immediately the purpose and membership of the method.
I have seen a proposal in Matt Galloway's book
- (void)p_didLogin
Another proposal of me is using the app's prefix
- (void)us2_didLogin