I have this method in my NDVector
class which finds the angle between two vectors along two axes (for 3D vectors this means you can find the angle between them just in terms of their X and Y components, X and Z components, or Y and Z components):
- (float) angleBetweenThisAnd: (NDVector *) vector2 byAxis: (NSUInteger) axis1 and: (NSUInteger) axis2;
I don't think I'm utilizing the descriptive naming you can do with methods which take multiple parameters in Objective-C. I find myself doing this a lot, really. I think of the method, say it as a sentence which doesn't state the relationship between its subject and its verb in plain English (i.e. [someVector angleBetweenThisAnd: otherVec ...]
instead of [someVector findsAngleBetweenItselfAnd: otherVec ...]
) and then write it as the method name, but it seems so redundant to say "and" in the name of a method. I mean of course it's and!
In Java, naming methods was a lot simpler, but in Objective-C, I'm confused by the close relationship between plain English and code in method names. Most importantly, is there a common way to avoid using "and" in the name of a method?
Look at some of the NSDate comparison methods for inspiration.
For example, following a pattern like timeIntervalSinceDate:
or descriptionWithCalendarFormat:timeZone:locale:
, how about [NDVector angleWhenIntersectingWithVector:axis1:axis2]
?
This could look like:
- (float) angleWhenIntersectingWithVector:(NDVector *)vector2
axis1:(NSUInteger)axis1
axis2:(NSUInteger)axis2;
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments