Naming conventions for Root resource classes

879 views
Skip to first unread message

Mandy Warren

unread,
Mar 12, 2013, 5:09:30 PM3/12/13
to api-...@googlegroups.com
Hi,

I was looking for some guidance on naming conventions for the Java class which provides the implementation of the REST service (ie. the Root Resource Class).

In Spring examples it is named with the suffix Controller, in Apache CXF they seem to use the suffix Service and in Jersey they use the suffix Resource.

My gut feel is to use the suffix Resource as to my mind a REST Resource encompass the URI path plus the supported HTTP methods.  This does mean that I need to clearly distinguish between the Root Resource class and the class which holds the JSON/XML representation of the Resource data. I am considering this package/class naming convention:

package xxx.resources - contains classes which are Root Resources named with the suffix Resource, eg. AccountResource.java
package xxx.domain - contains classes which represent the Resource data named as per the Resource but without the Resource Suffix eg. Account.java

Any thoughts / recommendations would be much appreciated!

Thanks

Mandy



Ian Joyce

unread,
Mar 12, 2013, 5:12:30 PM3/12/13
to api-...@googlegroups.com
I use the suffix "Resource" as well.




Mandy



--
You received this message because you are subscribed to the Google Groups "API Craft" group.
To unsubscribe from this group and stop receiving emails from it, send an email to api-craft+...@googlegroups.com.
Visit this group at http://groups.google.com/group/api-craft?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Felipe Sere

unread,
Mar 12, 2013, 6:20:56 PM3/12/13
to api-...@googlegroups.com
We use the suffix -Representation for anything that can be serialized to either JSON or XML. 
Our -Resource classes contain paths and verbs ans the classes in the *.domain.* package represent the objects which are handled by the business logic...

Cheers,
Felipe


--
Gruß,
Felipe

Mandy Warren

unread,
Mar 13, 2013, 1:01:32 PM3/13/13
to api-...@googlegroups.com
Many thanks for your replies.
Reply all
Reply to author
Forward
0 new messages