Do you hate HATEOAS?



  • I wish to ask for your opinions about HATEOAS. It seems to have its pros and cons, as usual. I've seen one project where it's the perfect thing not to use. What do you think about it?


  • BINNED

    TIL hypermedia is a thing undefined

    I honestly never heard that term before. Given how stupid it sounds, I hope I never will again.



  • As with all things RESTful, the terminology is gibberish. In essence, it's a notion of not using predefined REST interfaces, but building them dynamically for each resource. You have some single entry endpoint which leads you to resource A, which tells you what actions can be taken on it with possible link to resource B etc. I'm not going to say what I think about it to not infect any potential discussion, but I hope some other people came across it and have some opinions.


  • BINNED

    Yeah, I kinda got that bit, though I half stopped reading after getting hit by the "hypermedia" thing.

    Sounds very... Enterprise-y. I never had to wrangle with it, but at the first glance it looks like looking for trouble to me.



  • undefined is this?!


  • Discourse touched me in a no-no place

    There's a metric buttload of crap written about it, but the basic idea is actually reasonable. The principle is that you should make the responses that you serve back to REST requests (especially to GETs) be self-describing; if there are sub-resources, there should be links to those sub-resources so that nothing needs to guess the URLs or what they mean (at some level). Like that, you can just use a browser and follow links to at least get a reasonable read-only view of what's going on. (You can also use content negotiation to do better, but you don't have to.)

    Which isn't to stop you from also describing how to use the REST application in other ways too. (My REST apps both follow HATEOAS and publish a WADL description; which is the most convenient form for a client depends on the client.)



  • If it was a good idea, it wouldn't have such a shitty name.



  • It doesn't bode well when something has "HATE" in the name, does it?



  • It's nice, but nothing you'll ever see correctly implemented. I can't count the amount of crappy APIs (crAPIs?) I have to struggle with every day. For example, right now I'm working with an API which has only one endpoint and all requests are like:

    POST: /getPage
    post-data: {"page":"dashboard"}
    

    And another one which contains some URLs that aren't really pointing to anything and usually end up in a 400.



  • I think the approach should be directly tied to use cases. The one service I mentioned is such crap that it takes more time to actually work around its crappyness, than to get things done.



  • I'm picturing you with a big chart up on the wall, showing all of the states you've explored to, annotated with special cases, danger zones, and shortest routes between common states and important resources.

    No idea how far off that is; I just read the wiki article and let my imagination run wild.



  • Ok, let me tell you my thoughts and let's see what you think about it.
    IMHO, if you know upfront what you want to do and the subject you want to work on, HATEOAS is absolutely not the way to go. You need a simple IDL of some sorts, which you can use to call the service directly and live happily ever after.
    But if you have no knowledge of the resources to work on, or the actions available on them, HATEOAS seems to be a good way to expose the system interface.
    That in turn leads to a problem - if you take the HATEOAS approach, you have no need of any backwards compatibility, but if you use a WADL approach, you need to maintain previous versions of the interface (for some deprecation time at least). This in turn implies the whole HATEOAS approach has no sense, since you already need to maintain a versioned interface. And this implies I need a drink.



  • Having had to deal with Oracle's OAS I find the name endlessly amusing.



  • @NeighborhoodButcher said:

    I wish to ask for your opinions about HATEOAS.

    Sounds like a racist breakfast cereal.



  • I seem to be a magnet for WTF technologies.


  • Discourse touched me in a no-no place

    @NeighborhoodButcher said:

    if you use a WADL approach, you need to maintain previous versions of the interface (for some deprecation time at least).

    Only if you're making breaking changes (i.e., changes that don't extend the API, such as removing a resource) instead of extensive changes. It's just like when you're making changes to an API to a library; adding another method or class doesn't really have to cause many problems for anyone, but deleting a public class is going to be trouble.

    It all ultimately comes down to what happens with the messages on the wire. If you continue to accept the messages you used to accept and to generate compatible responses, you don't need to worry about evolving the interface description itself.



  • @dkf said:

    adding another method or class doesn't really have to cause many problems for anyone

    Pedantic comment: except for ABI and all that stuff.

    @dkf said:

    If you continue to accept the messages you used to accept and to generate compatible responses, you don't need to worry about evolving the interface description itself.

    Yeah, that's what I meant be keeping it backwards compatible. That's where HATEOAS shines, but if you want to do a simple "do X on Y", you really don't want to go through the complete tree of resources just to get a URL. Let me give the example of the horrible service I originally mentioned. Someone computed it's necessary to do over 9200 requests just to GET one specific resource. That really swings the pendulum in favor of WADL (or a hybrid).


  • Discourse touched me in a no-no place

    @NeighborhoodButcher said:

    Pedantic comment: except for ABI and all that stuff.

    Pedant pendant: evolving the ABI is possible too, just tricky. (Also highly irrelevant to this topic.)

    @NeighborhoodButcher said:

    Someone computed it's necessary to do over 9200 requests just to GET one specific resource.

    undefined



  • @dkf said:

    @NeighborhoodButcher said:
    Someone computed it's necessary to do over 9200 requests just to GET one specific resource.

    undefined

    Have I said I'm a WTF magnet?


  • Discourse touched me in a no-no place

    @NeighborhoodButcher said:

    Have I said I'm a WTF magnet?

    In that case… have you tried using WS-SecureConversation yet? 😈


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.