Search the web
Sign In
New User? Sign Up
rest-discuss · REST Discussion Mailing List
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want to share photos of your group with the world? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.

Messages

  Messages Help
Advanced
Why HATEOAS?   Message List  
Reply Message #12362 of 14748 |
Re: [rest-discuss] Why HATEOAS?

The last point really hits home for me. If I understand it correctly, as a client consuming an API that adheres to what Craig is saying, I can, for example rely on the fact that a given URI might be changed by the server, say due to a bug fix or a new version deployed, but mean while my client still works without breaking. I would guess the server implementation would document this fact, especially in the case of a newer version deployed that may change the URI, but I particularly find this beneficial to clients for exactly the reason Craig gives, less worry about my client breaking due to a server URI change. As long as the expected functionality and response remains the same we're good.

I never considered the 2nd point. Very interesting indeed. Craig did help me with something like this... pagination. In a search engine app for example, a consumer could get a 1 - 100, 101 - 200, etc back. By returning the proper URI to get the next series, and/or previous series of results, I myself do not need to figure out the values to send in the request.. I can simply pluck the URI the server returns for the next/previous, and use it with assurance.



From: Craig McClanahan <craigmcc@...>
To: Solomon Duskis <sduskis@...>
Cc: Rest List <rest-discuss@yahoogroups.com>
Sent: Tuesday, March 31, 2009 5:59:03 PM
Subject: Re: [rest-discuss] Why HATEOAS?

On Tue, Mar 31, 2009 at 5:01 PM, Solomon Duskis <sduskis@gmail. com> wrote:

> [snip]
> Assuming that the practical barriers of entry are removed, what practical
> benefits will we see?
>

I know exactly where you are coming from with these questions ... I
felt the same way until recently. I've designed several REST APIs
over the last couple of years, but up until the most recent one, I
designed and documented them in the "typical" way, describing the URI
structure of the application and letting the client figure out what to
send when. My most recent effort is contributing to the design of the
REST architecture for the Sun Cloud API[1] to control virtual
machines and so on. In addition, I'm very focused on writing client
language bindings for this API in multiple languages (Ruby, Python,
Java) ... so I get a first hand feel for programming to this API at a
very low level.

We started from the presumption that the service would publish only
*one* well-known URI (returning a "cloud" representation containing
representations for, and/or URI links to representations for, all the
cloud resources that are accessible to the calling user). Every other
URI in the entire system (including all those that do state changes)
are discovered by examining these representations. Even in the early
days, I can see some significant, practical, short term benefits we
have gained from taking this approach:

* REDUCED CLIENT CODING ERRORS. Looking back at all the REST client
side interfaces
that I, or people I work with, have built, about 90% of the bugs
have been in the construction
of the right URIs for the server. Typical mistakes are leaving out
path segments, getting them
in the wrong order, or forgetting to URL encode things. All this
goes away when the server
hands you exactly the right URI to use for every circumstance.

* REDUCED INVALID STATE TRANSITION CALLS. When the client decides
which URI to call and
when, they run the risk of attempting to request state transitions
that are not valid for the current
state of the server side resource. An example from my problem
domain ... it's not allowed to
"start" a virtual machine (VM) until you have "deployed" it. The
server knows about URIs to
initiate each of the state changes (via a POST), but the
representation of the VM lists only the
URIs for state transitions that are valid from the current state.
This makes it extremely easy
for the client to understand that trying to start a VM that hasn't
been deployed yet is not legal,
because there will be no corresponding URI in the VM representation.

* FINE GRAINED EVOLUTION WITHOUT (NECESSARILY) BREAKING OLD CLIENTS.
At any given time, the client of any REST API is going to be
programmed with *some* assumptions
about what the system can do. But, if you document a restriction to
"pay attention to only those
aspects of the representation that you know about", plus a server
side discipline to add things later
that don't disrupt previous behavior, you can evolve APIs fairly
quickly without breaking all clients,
or having to support multiple versions of the API simultaneously on
your server. You don't have to
wait years for serendipity benefits :-). Especially compared to
something like SOAP where the
syntax of your representations is versioned (in the WSDL), so you
have to mess with the clients
on every single change.

Having drunk the HATEOAS koolaid now, I would have a really hard time
going back :-).

Craig McClanahan

[1] http://kenai. com/projects/ suncloudapis/ pages/Home




Wed Apr 1, 2009 6:32 am

andjarnic
Offline Offline
Send Email Send Email

Message #12362 of 14748 |
Expand Messages Author Sort by Date

There seems to be a pretty big conceptual and practical barrier of entry to HATEOAS in machine-to-machine interaction. We simply don't have examples of ...
Solomon Duskis
sduskis
Offline Send Email
Apr 1, 2009
12:04 am

... I know exactly where you are coming from with these questions ... I felt the same way until recently. I've designed several REST APIs over the last couple...
Craig McClanahan
craig_mcclan...
Offline Send Email
Apr 1, 2009
1:00 am

Hi Craig, That is a great summary. The key point leakage of business rules. In the absence of hyperlinks, the server will have to explain the clients the rules...
Subbu Allamaraju
sallamar
Online Now Send Email
Apr 1, 2009
3:00 am

The last point really hits home for me. If I understand it correctly, as a client consuming an API that adheres to what Craig is saying, I can, for example...
Kevin Duffey
andjarnic
Offline Send Email
Apr 1, 2009
6:33 am

Excellent explanation, you should publish that somewhere for easy reference. I think this will give me the final argument to convince my boss to give me the...
amsmota@...
amsmota
Offline Send Email
Apr 1, 2009
9:11 am

... Good idea ... should have done that last night: http://blogs.sun.com/craigmcc/entry/why_hateoas Craig...
Craig McClanahan
craig_mcclan...
Offline Send Email
Apr 1, 2009
5:29 pm

... [snip] ... Hi Chris, This was a great post. I'm looking at doing something similar for an application as well, but, having looked at the API for the Sun...
Andrew S. Townley
adz1092
Offline Send Email
Apr 1, 2009
9:52 am

Snipping and interspersing a few comments: ... In the specification, this is described on the various pages like ...
Craig McClanahan
craig_mcclan...
Offline Send Email
Apr 1, 2009
6:13 pm

Apologies for the delayed reply. Was away from email for a bit. ... That's cool. However, that's not exactly what I meant by "verbs" in the above. To me,...
Andrew S. Townley
adz1092
Offline Send Email
Apr 4, 2009
11:06 am

... Sorry to pick out one tiny piece of your excellent post...But... IMO, there are very very few applications/clients that can approach integration in this...
Bill Burke
patriot1burke
Offline Send Email
Apr 6, 2009
2:30 pm

... I certainly agree with you that there are very, very few apps that *do* approach integration in this manner, but I don't agree that you can't have apps...
Andrew S. Townley
adz1092
Offline Send Email
Apr 8, 2009
8:50 am

... Its true because stable systems are well tested. You can't test variability. ... FYI, I wasn't bashing HATEOAS. I think it is extremely useful to have ...
Bill Burke
patriot1burke
Offline Send Email
Apr 8, 2009
7:45 pm

Excellent points. I'd like to add that following links instead of constructing URIs also enables an evolutionary change of distribution of resources across...
Stefan Tilkov
stilkov
Offline Send Email
Apr 1, 2009
9:56 am

... How would you initially define and then evolve your XML schema in such an environment? I know Atom allows arbitrary attributes and elements in its schema...
Bill Burke
patriot1burke
Offline Send Email
Apr 1, 2009
1:40 pm

... The snarky answer would be "what schema? we don't need no stinkin' schema" :-). If you are using XML message formats, though, schemas are pretty useful...
Craig McClanahan
craig_mcclan...
Offline Send Email
Apr 1, 2009
5:47 pm

... Not talking about verbs, but links/relationships. Define/require your atom links in your schema so that the client is assured that the links will be there...
Bill Burke
patriot1burke
Offline Send Email
Apr 1, 2009
6:27 pm

Good summary. A perspective helped me understand HATEOAS is to think a system as a combination of multiple state machines. These state machines are distributed...
Dong Liu
edonliu
Offline Send Email
Apr 1, 2009
3:48 pm

... SOAP is stateless, but many services are not, so the WS-* architecture has to deal with some of the same problems REST deals with. You have WS-Addressing...
Assaf Arkin
assafarkin
Offline Send Email
Apr 1, 2009
2:26 am

... Actually, I'd like to turn this question around. I've always been confused by what folks who design systems that comply with all of REST except HATEOAS...
wahbedahbe
Offline Send Email
Apr 1, 2009
3:01 pm

... Wouldn't this have to be compared with a totally non-REST solution like SOAP-bad web services? If yes, then quick benefits that come to mind are a (1)a...
Ebenezer Ikonne
amaeze77
Online Now Send Email
Apr 1, 2009
4:18 pm

... A message based rather than RPC-based architecture. HTTP content-negotiation. All the HTTP caching semantics that come as a result of constrained...
Bill Burke
patriot1burke
Offline Send Email
Apr 1, 2009
4:53 pm

I think there are multiple levels of HATEOAS: One is simple linking of information - easy to do, very obvious benefits (of course one could use a different...
Stefan Tilkov
stilkov
Offline Send Email
Apr 1, 2009
5:20 pm

... To turn this round again - I would not agree that all REST benefits are derived from links in content. ... Each principle and constraint adopted gets you...
Bill de hOra
bdehora
Offline Send Email
Apr 4, 2009
7:07 pm

Ok, but I'm more wondering about the specific gains folks are seeing in practice in the systems they are building. The reason I'm curious is because there are...
wahbedahbe
Offline Send Email
Apr 6, 2009
3:26 pm

... Let's say you're writing a new database server based on a new theory for massively scaling megadata to the cloud. To get taken seriously you'll need ...
Assaf Arkin
assafarkin
Offline Send Email
Apr 6, 2009
4:00 pm

... So for me, some partical things come to mind. - the methods give you high level support for potential operations/scaling pain. Just knowing a system could...
Bill de hOra
bdehora
Offline Send Email
Apr 6, 2009
10:11 pm

... Just curious. Why not a big conneg fan? Is it that you prefer existing, well defined formats? To me, conneg seems to be one of the most powerful...
Bill Burke
patriot1burke
Offline Send Email
Apr 7, 2009
11:48 pm
Advanced

Copyright © 2010 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help