users@jersey.java.net

Re: [Jersey] RESTful Documents

From: Jochen Schalanda <jochen_at_schalanda.name>
Date: Wed, 20 May 2009 14:57:35 +0200

Hi Markus,

first I'd also like to recommend the "RESTful Web Services" book[1] to
you, as it does a terrific job in explaining the key principles of REST
and the steps which are necessary to design a RESTful application.


> If I want to do simple CRUD, what is the most "typical" design pattern
> in the RESTful world:

The answer to this question heavily depends on your actual application.
I'm neither an expert nor do I have years of experience in this field,
but I would take the following approach:

If your parts only contain a manageable number of characteristics, I'd
go with your first variant and publish each part as a resource and put
the characteristics into their representation. The characteristics do
not need to be published as independent resources in this case.

If the characteristics themselves are largely more complex than simple
key-value data (you mentioned the attributes diameter and length), I'd
go with your second variant and also publish each characteristic as a
self-contained resource and link to their respective URI in the
representation of the individual parts. This also is conform to
HATEOAS[2] and connectedness respectively.


This said, I really do not see any advantage of your third variant over
your first or second version and would even consider it not to be
RESTful at all, since it undermines the connectedness of your
resources/application.


Maybe you should resend your questions to the already mentioned
rest-discuss list[3], since they do not really relate to Jersey/JAX-RS
but are more general design questions.


[1]: http://oreilly.com/catalog/9780596529260/
[2]: http://roy.gbiv.com/untangled/2008/rest-apis-must-be-hypertext-driven
[3]: http://tech.groups.yahoo.com/group/rest-discuss/


Regards,
Jochen

>
>
>
> (1) GET / PUT of the part uses an XML body which contains also the
> embedded XML of all characteristics?
>
>
>
> (2) GET / PUT of the part uses an XML body which contains a list of URLs
> pointing to the characteristics and the client does a lot of subsequent
> GETs / PUTs for their XML body?
>
>
>
> (3) GET / PUT of the parts uses an XML body which contains just the IDs
> of the characteristics and the client must inherently know how to obtain
> their XML bodies?
>
>
>
> I am pretty sure that the REST experts have some patterns which they
> will use every day. But how do they look like?
>
>
>
> Any comments welcome!
>
>
>
> Regards
>
> Markus
>