I am wondering which methods are "helper methods". Where should we draw the border of the tag to say that a particular method is a "helper method"? In fact, I consider any method as a "helper method", if it is not an initialization method, a method implemented to match the protocol response or delegation method. Any other method that I implement to accomplish something is a “helper method” in my perspective, but I feel that there are more categories to think about.
Why do I want to know this? Because I want to use the use of the #pragma HEADLINE icon in Xcode. I find it nice to organize the code in some way.
Please help me get my photo of the "helper method". Examples are appreciated!
I see this as methods that are not required for the library to function properly, but make things more convenient or readable to the end user.
Hmmm ... did not give an example. Let's say you have a function to get users from a database, and it took the form
User GetUsers(UserRole) { //Do Something }
And an example of a helper method might be
User GetAdmins() { return GetUsers("Admins"); }
His example is crude pseudo-codes, but gives you the gist. GetAdmins functionality is completed in GetUsers (), but the GetAdmins helper function helps readability (and nothing more).
Make sense?
, , , , . .
, . , , , .
, . , , . , , .
, , , , , .
:
+[NSObject new]
[[NSObject alloc] init];
NSClassFromString(str)
objc_getClass([str UTF8String]);
+[NSURL URLWithString:str]
[[[NSURL alloc] initWithString:str] autorelease];
-[NSURLRequest initWithRequest:request delegate:delegate]
[request initWithRequest:request delegate:delegate startImmediately:NO]
-[NSString substringFromIndex:]
-[NSString substringWithRange:]
-, , -, . , - NSString, NSDate, , NSDateFormatters .
-, DRY- , -, , API (, , , ).
, , Extensions , , " " Objective-C. : +(NSError *)errorWithCFStreamError:(CFStreamError)streamError, " " CFStreamError NSError/CFErrorRef , OS X 10.5 ( iPhone).
+(NSError *)errorWithCFStreamError:(CFStreamError)streamError
In Objective-C, I think you could call any private method a "helper method", where in particular I mean that the signature of the method does not appear in the .h file. That is, these are the methods that you probably declare in the continuation of the class in the .m file:
@interface MyClass () - (void)somePrivateMethod; @end
Some other answers call helper methods — optional, but generally available methods that are not critical to the API — I would rather call convenience methods.
Source: https://habr.com/ru/post/1708292/More articles:What is the standard method for a website to link to the win32 executable? - web-applicationsкак создать поле, похожее на stackoverflow, нажмите, чтобы отклонить - jqueryHow to access a selection of a subset of UITableView? - objective-cHow can I keep track of who contributed a comment to a TFS work item - tfsTwo dates during the year from each other - c #Does FormsAuthenticationModule, ...? - authenticationИспользование точек с запятой в выражениях Oracle SQL - performanceGet a list of selected items in javascript - javascriptBacklight J2ME - mobileHow long does it take to become proficient in Oracle given SQL Server - oracleAll Articles