jQuery in Action, 3rd edition
The moose likes Web Services and the fly likes which is more restful ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "which is more restful ?" Watch "which is more restful ?" New topic

which is more restful ?

Lmn Opq

Joined: Jun 19, 2011
Posts: 5
I am using the restlet framework. I have a resource called Person. This person has the following fields :

- name
- age
- job

a person could be either a teacher, a programmer, or a doctor.
According to the job type, the person will have a set of properties. For example, if a person is a teacher, he will have the following properties :

- teaching hours
- subjects
- classes

if a person is a programmer, he would have the following properties :

- skills
- experience

the question is, when I want to post a new person, should I post the person(name,age,job) to the following url :


and then post the properties to one of the following ( according to his job )


or should I post all the information to the url :

Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
Personally, I would choose the latter approach since a teacher, a doctor and a programmer are all persons and should be treated in the same manner as such.
I would consider adding a "role" property to the base Person resource. Depending on what the clients accessing the service want for kind of data, I would also consider adding a Teachers, a Doctors and a Programmers resources. Adding these resources would also make it possible to create a Person by POSTING to, for instance, the Teachers resource.
Best wishes!

My free books and tutorials: http://www.slideshare.net/krizsan
I agree. Here's the link: http://aspose.com/file-tools
subject: which is more restful ?
It's not a secret anymore!