Search code examples
objective-cmethod-names

How to name a method properly?


It's more a question about English grammar, but nevertheless, can you tell me which one is a correct method name? This ambiguity drives me crazy.

Method linesNumber returns number of "rows" in some sort of table. I personally like "numberOfLines" variant, but linesNumber is shorter...

#pragma mark - RCGroupDataSource methods

- (NSUInteger)linesNumber { // ???: or numberOfLines or lineNumbers
    return 2;
}

Solution

  • Always give full name as you can.

    Method linesNumber returns number of "rows" in some sort of table.

    why not use numberOfRowsInTable

    You can refer AppleDocumentation and CocoaDevCentral