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.

One of our senior developers has stated that we should be using a naming convention for stored procedures with an "objectVerb" style of naming such as ("MemberGetById") instead of a "verbObject" type of naming ("GetMemberByID"). The reasoning for this standard is that all related stored procedures would be grouped together by object rather than by the action.

While I see the logic for this way of naming things, this is the first time that I have seen stored procedures named this way. My opinion of the naming convention is that the name can not be read naturally and takes some time to determine what the words are saying and what the procedure might do.

What are your takes on this? Which way is the more common way of naming a stored proc, and does a what types of stored proc naming conventions have you used or go by?

share|improve this question
1  
"the name can not be read naturally"? By whom? What is your first natural language? English? Or something else? –  S.Lott Jan 26 '11 at 15:52
9  
@S.Lott - to me it does look like something you'd hear in a swamp in Degobah. –  TZHX Jan 26 '11 at 15:54
1  
Great question! Having some standards are better than having no standards, but some able people took this concept even further and came up with a good standard. For instance, Dijkstra has written about why it makes so much more sense to index arrays with a 0 as the first element rather than 1. developeronline.blogspot.com/2008/04/… It is a seemingly trivial topic, and yet I bet it took him some tinkering to come up with it. Similarly, Spolsky has a nice system: joelonsoftware.com/articles/Wrong.html Some thinking upfront avoids pain –  Job Jan 26 '11 at 16:07
3  
I'd say get rid of stored procedures alltogether ;) –  Mike Brown Jan 26 '11 at 16:45

4 Answers 4

up vote 10 down vote accepted

Look at it like this. How are your methods organized in code? By object, with the methods hanging off.

MyObject.GetById(int)
MyObject.Save()

By having your stored procs mimic that naming, it will be much easier to see how they relate to your source code.

MyObjectGetById
MyObjectSave
share|improve this answer
    
Good point, but SQL is not inherently OO. In fact, it is VERY different from Java/C#/etc. code that interfaces with it. It is only natural to let SQL do its thing and let Java do its thing. If code must be generated, it can be accomplished with little effort. –  Job Jan 26 '11 at 16:01
4  
I don't think OO is a consideration here. The above is just an example of how it's not as unnatural as it may first appear to use such a naming convention. –  Mark Freedman Jan 26 '11 at 16:10
1  
If by having a method in the code be "MyObject.GetById(int)" why could a stored proc not also be called "MyObject.GetById" ? The grouping would still occur, and a dot would give separation between the object/table and the action that is wanted. –  Chris Jan 26 '11 at 16:32
1  
@Chris, I'm not sure you can use a '.' in a proc name, but certainly using objectVerb groups thing in the same manner as one thinks about them. I don't think of get first, I think of what I want, then how to retrieve it. –  CaffGeek Jan 26 '11 at 17:04
1  
@Mark Freedman, not that it's necessarily OO, you group things in procedural languages the same way, only they aren't in actual objects. But usually prefixed with what would naturally become an object if the code were converted. strCompare, strLen, etc, etc, objectAction –  CaffGeek Jan 26 '11 at 17:06

I too can see the logic; it groups actions together by entity. However, if your actions are always GET, PUT, and DELETE the change in naming might not matter that much. I see the best benefit from the new naming standard occurring when you have unique action names e.g. "AccountTransferMoney," that kind of thing.

The most important thing is that there is a single standard, and that it is followed by everyone.

share|improve this answer
1  
Coming from a company that had no official naming standards (other than "prefix with sp"), having a standard is the only thing that matters. –  Glen Solsberry Jan 26 '11 at 15:54
1  
+1 - having one standard is the important thing. –  TZHX Jan 26 '11 at 15:55

You have to decide what's the bigger issuer, finding the procs you're looking for or quickly deciphering their meaning?

If you see:

memberGetID memberGetName memberGetThis memberListSomething memberDelete

At some point, once you've already found 'member' you just ignore that and go from there.

Look in a phonebook. If you want to find John Smith, is Smith, Dave Smith, John Smith, Robert

really that hard? I don't call people by their last name and then first name unless it's James Bond.

share|improve this answer
1  
+1 I love this question and the responses! It deals with usability, and that can get pretty tricky and interesting. –  Job Jan 26 '11 at 16:09

Instead of "objectVerb", you could use "namespace_verbObject", like Member_GetById.
It will group procedures by namespace, and still use traditional "verbSomething" naming.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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