Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

What is the name of book that offers guidance on when to use each verb for a method call? For example, I might use GetApples() to return a list of Apple instances; or I might use BindApples(IControl control) if I want to bind these apples to a dropdown list. What book would suggest when you use Get or Bind as part of a method name?

share|improve this question
    
While we do allow certain questions asking for the canonical book on specialized topics, asking for a book on how to name your methods is a roundabout "What do I name my stuff?" question that is not on-topic here. –  user8 Feb 4 '12 at 11:28
add comment

closed as not constructive by Mark Trapp Feb 4 '12 at 11:25

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

2 Answers

up vote 3 down vote accepted

Sounds like "Code Complete", though I haven't read it. Many books will give similar advice.

The basic idea is meant to be simple and intuitive - don't expect a huge dictionary of "use x for y". The general rule is simply that you use "Get" when getting something, "Bind" when binding something, and "XXX" when XXXing something. The principle is that when naming a method, you use the verb that most clearly describes the behaviour of that method. An exhaustive table of verbs and when to use them would be a waste of a lot of paper.

share|improve this answer
    
+1 - yes, that's the book I was thinking of. –  Carnotaurus May 18 '11 at 11:18
    
In theory, I like your comment but in reality there is a massive repository of verbs that a developer could use, even to perfom the "same" function. –  Carnotaurus May 18 '11 at 11:20
1  
Yes, but look in a dictionary and you'll find that many of the most common verbs have lots of different meanings. And "synonyms" usually aren't completely synonymous - there can be subtleties of meaning in choosing a less-used verb for a particular meaning which could cause confusion. My personal theory - the terminator was originally designed for delivery work, but there was confusion over the crucial Let_Them_Have_It method. –  Steve314 May 18 '11 at 23:14
    
Please explain this a bit more –  Carnotaurus Feb 4 '12 at 11:09
    
@Carnotaurus - (1) that was 9 months ago, and (2) I don't see how I could explain it more clearly. –  Steve314 Feb 4 '12 at 11:32
show 1 more comment

I don't believe books on this subject are currently in print, mostly because these problems haven't received much attention yet. The concept of always using the same word for a single concept is called a controlled vocabulary.

There is active research though, for example by Einar W. Høst. He wrote a couple of papers on the subject including The Java Programmer's Phrase Book and The Programmer's Lexicon, Volume I: The Verbs. They don't contain exhaustive lists, but mostly theory about the relationships between names and their semantics (which are the foundations for such a list).

As opposed to some, I do think it makes sense to make such a list. Not just to prevent errors, but to make APIs look more uniform and increase their usability (once you know the words, you always guess right about a method's name you know should exist).

As an additional rant, it's a little weird that lots of organisations use code conventions but not actual naming conventions. It's as if the policy is: "We don't care if you name your method abcxyz123, as long as you make sure it's AbcXyz123!"

share|improve this answer
1  
+1 - good point about "controlled vocabulary". I suspect it could cause problems where awkward verbs must be used to avoid cases where the most natural verb is also the most natural choice for other cases too, but that's just the usual good-rule-applied-obsessively issue. –  Steve314 May 18 '11 at 6:59
1  
+1 - interesting but not exactly what I was looking for. –  Carnotaurus May 18 '11 at 11:18
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.