I know this sounds like a subjective answer, but I will try to make the question as objective as possible, because an objective answer to the question would be the most helpful.
I recently had a code reviewer point out that I have a habit of including prepositions at the end of my methods. Here's a recent method I wrote as an extension method to the Point
class:
var rectangle = new Rectangle(0, 0, 2, 2);
var point = new Point(3, 1);
var result = point.DistanceTo(rectangle);
My code reviewer mentioned that the method should be point.Distance(rectangle)
. I've always considered this subjective and a matter of style. However, I have noticed more .NET API design going in this direction. For example, with NUnit's Fluent Interface, you have:
Assert.That(result, Is.EqualTo(1.0));
I have also seen this with Linq:
list.CopyTo(anotherList);
list.IndexOf(item);
list.RemoveAt(0);
Is there any settled or consistent way that .NET and/or Third Party API designers use prepositions at the end of methods? Or is it just a matter of style, and subjective? Has the API design in the .NET framework itself evolved with this policy, or has it always been in place?