In the book Clean Code the author recommends breaking large methods into small functions that do one specific thing. In languages like Java this translates to pretty, readable code.
public static String renderPage(PageData pageData)
{
includeHeader(pageData);
includeContent(pageData);
includeFooter(pageData);
return pageData.getHtml();
}
However in Objective-C as far as I know the only way to implement functions like this are to create private methods and call them by messaging self
- (NSString *)renderPageWithData:(PageData *)pageData {
[self includeHeader:pageData];
[self includeContent:pageData];
[self includeFooter:pageData];
return [pageData HTML];
}
I feel like messaging self
implies some sort of operation that the object is doing to itself. C functions aren't really an option because the don't fall under the scope of the class. Meaning I can't access any of the instance variables or the class object with out doing extra legwork, and adding complexity.
I'm looking for a good way to create clean code with regard to functions or methods in Objective-C