views:

103

answers:

3

What do you call your functions when names that contain a saxon genitive like "Verify Task's Priority" and "Change Argument's Priority" or "Increase Action's Delay"?

Do you drop the apostrophe? verifyTasksPriority(), changeArgumentsPriority(), increaseActionsDelay()

Do you drop both the apostrophe and the "s"? verifyTaskPriority(), changeArgumentPriority(), increaseActionDelay()

Do you replace the saxon genitive with "of"? verifyPriorityOfTask(), changePriorityOfArgument(), increaseDelayOfAction()?

I don't like the first option because it sounds like the function works on multiple things rather than just one thing. I don't like the second option because it doesn't sound natural. I don't like the third option because the word, of, in a function name just doesn't sound right.

What option do you use?

+7  A: 

I use the second. It sounds good to me. Think of "Task Priority" as a compound word like "vacuum cleaner".

David Thornley
This is exactly my view too. Compound nouns are usually the most succinct way to name functions.
Noldorin
+1  A: 

I find that numbers two and three sound fine to me, and are descriptive. I use the second option. The first option could possibly be confusing since it seems to indicate that it operates on a collection rather than a single item (Tasks instead of Task, for instance).

I was not, however, aware that I was doing Saxon genitive programming; I'll add that to my resume immediately.

Larry Lustig
A: 

I can't remember ever feeling the need to use any of them off hand.

I write OO code, mainly in OO languages, so to verify the priority of a task you'd have task.verifyPriority(), though usually just have task.verify() as the public method.

Verifying the priority may involve other logic - say the priority can only be 7 if the task's owner is Bob. Setting the owner of one of Bob's priority 7 tasks to Anna would make it inconsistent, but would you have verifyOwner() to be called when you change the owner as well as verifyPriority() for when you change the priority, even if they had the same logic?

I've found that making APIs less specific to the detail of the implementation leads to more malleable code.

In non-OO languages I usually use <library>_<Noun>_<Verb> so tman_task_verify ( task_t* self ) to verify the task object in the task manager library to verify itself.

Pete Kirkham