How to avoid using "and" in Objective-C method name

michaelsnowden

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?

Aaron Brager

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to copy the objective-c method name more effecively in XCode?

From Dev

When to avoid using accessor methods in Objective C

From Dev

When to avoid using accessor methods in Objective C

From Dev

Objective-C @autoreleasepool and method with "alloc" in the name

From Dev

Objective-C method name alias

From Dev

Objective C substite method trigger name with string

From Dev

Using "?" in variable name for Objective-C development

From Dev

using delegates in class method, objective-c

From Dev

Using self inside objective c method

From Dev

Objective C - Implement a method using an out id*

From Dev

How to validate first name Objective-C?

From Dev

How to Get operating system name in objective c

From Dev

How to access self in class method objective C

From Dev

Objective C : loadNibNamed method: how does it work?

From Dev

How to call an Objective C class method in Swift

From Dev

how to override objective-c method in swift

From Dev

How To Use self On A Class Method In Objective C

From Dev

How to call swift method from objective c

From Dev

How to instantiate class by name in Swift without using the objective-c runtime

From Dev

How to call objective c method from c method iOS

From Dev

How do I expose a private class method of an Objective-C object using protocols in Swift?

From Dev

How to create custom rectangles as shown below programatically in objective-C using UIBezierPath or any other method?

From Dev

Objective C - Avoid Import Loop

From Dev

How to get method name from inside that method without using reflection in C#

From Dev

specifying an array by name, using a string. Objective C

From Dev

Method overloading in objective c

From Dev

Make A Call In Objective-C To A Method Using Swift String

From Dev

What is the purpose of using a factory method in objective-c context?

From Dev

Accessing class method in objective c. Using self or classname?

Related Related

  1. 1

    How to copy the objective-c method name more effecively in XCode?

  2. 2

    When to avoid using accessor methods in Objective C

  3. 3

    When to avoid using accessor methods in Objective C

  4. 4

    Objective-C @autoreleasepool and method with "alloc" in the name

  5. 5

    Objective-C method name alias

  6. 6

    Objective C substite method trigger name with string

  7. 7

    Using "?" in variable name for Objective-C development

  8. 8

    using delegates in class method, objective-c

  9. 9

    Using self inside objective c method

  10. 10

    Objective C - Implement a method using an out id*

  11. 11

    How to validate first name Objective-C?

  12. 12

    How to Get operating system name in objective c

  13. 13

    How to access self in class method objective C

  14. 14

    Objective C : loadNibNamed method: how does it work?

  15. 15

    How to call an Objective C class method in Swift

  16. 16

    how to override objective-c method in swift

  17. 17

    How To Use self On A Class Method In Objective C

  18. 18

    How to call swift method from objective c

  19. 19

    How to instantiate class by name in Swift without using the objective-c runtime

  20. 20

    How to call objective c method from c method iOS

  21. 21

    How do I expose a private class method of an Objective-C object using protocols in Swift?

  22. 22

    How to create custom rectangles as shown below programatically in objective-C using UIBezierPath or any other method?

  23. 23

    Objective C - Avoid Import Loop

  24. 24

    How to get method name from inside that method without using reflection in C#

  25. 25

    specifying an array by name, using a string. Objective C

  26. 26

    Method overloading in objective c

  27. 27

    Make A Call In Objective-C To A Method Using Swift String

  28. 28

    What is the purpose of using a factory method in objective-c context?

  29. 29

    Accessing class method in objective c. Using self or classname?

HotTag

Archive