I was reviewing an interface for a WCF web service today, and I began wondering about web service naming conventions.
It is understood that a service should be a logical grouping of a set of functionality. Therefore, if you have several pieces of functionality that center around a Project concept, then you should group them together under the name ProjectService.
So, the convention for service names is:
- Casing: Pascal case
- Format: [concept noun] + 'Service' to construct the name.)
- Examples: ProjectService, TaskService, PersonService, etc.
When creating methods for a data service, though, should you restate the concept in the title? In this case, you would use the following methods: CreateProject(), UpdateProject(), GetProjectByID(). Isn't this already understood by the title of the web service? So that you could say Create(), Update(), and GetByID() instead.
I propose no.
The latter might make more sense in an object-oriented world where you are operating on the object itself. However, a service is more like a manager class that operates on Project objects. Also, theoretically speaking, each one of these functions can live on their own apart from any other functionality. So, specifying the concept in the title of each method would make sense. And finally, there might be functionality in this service for sub-objects such as Task that would not be substantial/independent enough to live on its own in a TaskService.
In that case, it would be important to understand which type of object your Create(), Update(), and GetByID() are operating on.
So, my recommendation for a data web service methods is:
- Casing: Pascal case
- Format: [operation] + [concept noun] + [optional extensions]
- Examples: CreateProject(), UpdateProject(), GetProjectByID()
What are your thoughts?