yaru
yaru

Reputation: 1320

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;
}

Upvotes: -1

Views: 87

Answers (2)

QuentinUK
QuentinUK

Reputation: 3077

Describe what is being done:-

getNumberOfLines

The other could be ambiguous

getLineNumbers

Sound more like a plural, ie an array of numbers.

Upvotes: 0

Anoop Vaidya
Anoop Vaidya

Reputation: 46563

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

Upvotes: 2

Related Questions