cocoa - What are your naming conventions for Objective-C "private" methods? -


inheriting code other developers has made me firm believer in keeping many messages possible out of class' public interface means of class extension. i'm firm believer in adopting special naming conventions private, implementation-specific members of class. being able tell @ glance messages being sent , members being referenced within implementation context not ever intended public use , vice versa. if nothing else, makes overall semantics of class easier me grasp more quickly, , that's worth it.

justification aside, i've written boatloads of classes boatloads2 of private methods, i've never come pattern naming love (like controversial ivar_ convention ivars). notable examples:

@interface myclass()  // this, know, apple has dibs on one,  // , method name collisions nasty. - (void)_myprivatemessage;  // suffix version promoted google ivars doesn't translate // method names in objective-c, because of way method // signature can broken several parts. - (void)dowork_; // that's okay... - (void)dowork_:(id)work with_:(id)something; // that's ugly , tedious... - (void)dowork_:(id)work with_:(id)something and_:(id)another; // eyes...  // version suggested apple, , has benefit of being officially  // recommended. alas, don't it: capital letter ugly. don't  // underscores in middle of name. worst of all, have type 3 characters  // before code-sense more useful inform me typing. - (void)bf_dowork;  @end 

at point, there kajillion different means mangle private method names, instead of making up, figured first take poll popular conventions may not aware of. so, have used?

i use 2 levels of private methods: private , private. private methods methods could become public, aren't. convenience methods use internally, , don't put in protection unless decide make public. private methods, ignore apple , use underscore prefix. since 99% of code in classes create , have prefixes on class names, chances of running naming problems small. when adding code classes didn't make, make private methods, add short prefix on rare occasion do.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -