Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

which is more restful ?

 
Lmn Opq
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 :

/myapplication/Persons

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

/myapplication/Persons/{id}/teacher
/myapplication/Persons/{id}/doctor
/myapplication/Persons/{id}/programmer

or should I post all the information to the url :

/myapplication/Persons
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic