Naming Standards – Is It Good Practice to End a Function’s Name with a Preposition?

functionsmethodsnamingnaming-standards

I have seen examples of methods whose name ended with a preposition applying to the first (and most often only) parameters.
But other examples don't use this kind of naming convention.
Which do you think is more readable?
For example, should I make a method like this:

getColorFor(Player player)

or like this?

getColor(Player player)

In this scenario, the method would return a color that represents the player supplied as parameter.

Best Answer

If it adds meaningful clarification or fits the "ethos" ... Yes.

.NET's OrderBy() and ElementAt() might be good examples.

Personally, I like code that reads pretty much like English. It takes a ton of guesswork, hovering and digging, and arcane knowledge out of reading someone's code when it tells me unambiguously what it does.

And as far as I can tell, I'm not the only one who feels this way.