Reputation: 8540
We are thinking about using ServiceStack in our next project; and while looking at examples, I've noticed, that there's no common naming convention. For example:
entity: Movie
request: Movie
response: MovieResponse
The same goes for all operations. Now this example:
entity: Answer
request: Answers
response: AnswerResult
entity: User?
request: GetUsers
response: GetUsersResponse
(it is kind of weird to see class names staring with verb)
So, may be you have come up with some clever naming convention and would like to share. Also, are there any larger open source projects on service stack, where I could look how they organize their service model?
Upvotes: 8
Views: 2565
Reputation:
I use BREAD1 and Verb-Entity with the following styles:
Namespace is "Entities", then:
Note the form is really [Verb][Entity][Role].
Verbs: Browse, Read, Edit, Add, Delete (BREAD), Validate, Extract (e.g. other operations)
Entity: This is plural or singular, depending upon the normal number of affected / retrieved entities. (I'm not entirely discounting that a service like DeleteEntity might delete multiple entities at a time, but careful consideration should be given if put into a "singular"-name DTO/service. It could always follow the plural DeleteEntities.)
Role: (Nothing) = Request DTO, Reponse = Response DTO, Service = Service.
Namespace: Always plural. This avoids conflicts with DAL classes like Entity (singular).
For the BREAD bindings (endpoint is always plural, it represents a collection):
Misc. binding guidelines:
1 Unfortunately, BREAD appears to be a fringe term. From the CRUD wikipedia article:
Another variation of CRUD is BREAD, an acronym for "Browse, Read, Edit, Add, Delete".
I prefer how it sounds and that it has a separate Browse action.
Upvotes: 14
Reputation: 148
I currently use the third option where the request starts with the verb. Reason being my implementation is not entirely based on typical REST style urls and I use the c# clients extensively. In this scenario the verbs just helps to clearly identify the purpose of the service.
Apart from my particular scenario I would go with
entity: Movie request: Movie response: MovieResponse
Upvotes: 4