0

When writing API methods that count something I always lose a tremendous amount of time thinking about how to write the thing that is being counted.

Singular or plural?

For instance, how would you name a function that counts results?

getResultsCount or getResultCount ?

This might sound silly, plural sounds more logical, but since both forms are found in the wild (google gives ~4800 results for "getResultCount" and ~4600 for "getResultsCount"), I'm hesitating and it bothers me.

Disclaimer: I'm not a native English speaker :)

Is there only one grammatically correct form or is it a matter of taste?

djfm
  • 2,317
  • 1
  • 18
  • 34

1 Answers1

0

You should naming it basically for what it will do, if getResultsCount make mores sense than getResultCount, name it getResultsCount, else, name it getResultCount.

Its not that hard, Ill you have to do is give name that sweets better accordinling to the what it will do.

I suggest you read the book Clean Code written by Robert C. Martin, it really give good tips about naming.

Rodrigo Valente
  • 319
  • 3
  • 17