InfoQ

InfoQ

News

My Bookmarks

Login or Register to enable bookmarks for unlimited time.

The content has been bookmarked!

There was an error bookmarking this content! Please retry.

REST – The Good, the Bad and the Ugly

Posted by Boris Lublinsky on May 20, 2009

Sections
Architecture & Design,
Enterprise Architecture
Topics
Web Services ,
SOA ,
Architecture ,
REST ,
Design
Tags
WSDL

 

In his new post, Arnon Rotem-Gal-Oz gives his opinion on REST (a more detailed REST discussion from Arnon can be found here)

According to Arnon, the top three advantages of using REST are:

 

  • Relative ease of integration:
    ...a good RESTful API is discoverable from the initial URI onward. This doesn’t suggest that a any application calling on your service will auto magically know what to do. It does mean however that the developer reading your API trying to integrate it has an easier life. Especially if since hypermedia provides you the roadmap of what to do next
  • Use of ubiquitous standards - HTTP is the most common implementation of REST:
    Speaking HTTP which is the protocol of the web, emitting JSON or ATOMPub means it is much easier to find a library that can connect to you on any language and platform.
  • Scalability:
    ...stateless communication, replicated repository make for a good scalability potential.

Arnon also discusses some of the drawbacks of REST. In his view, the two main REST drawbacks are:

 

  • "Lo-rest" (using just GET and POST) implementations, which are specific to REST over HTTP:
    While technically it might still be RESTful, to me a uniform interface with 2 verbs is too small to be really helpful (which indeed makes a lot of the implementation unRESTful)
  • Limitations of today’s programming languages:
    ... programming languages are not resource oriented so the handling code that maps URIs to tends to get messy. On the other hand it is relatively hard to make the REST API hyper-text driven (Which is a constraint of REST)

Finally, Arnon points to the ugly cases of REST, which, for the most part, are driven by misuse of REST:

 

  • Zealous followers (term used by Arnon - proves again that REST arguments are often religious)
    That isn’t something unique to REST any good technology/idea (Agile, TDD etc. ) gets its share of followers who think that [insert favorite idea] is the best thing since sliced bread and that everybody should do as they do or else.
  • Misunderstanding of REST:
    ... building an implementation that is GETsful (ie. does everything with http GET) or doing plain RPC where the URI is the command, doing CRUD with HTTP verbs etc. etc.

Arnon concludes his post by stating, that:

REST seems simple but it isn’t - it requires a shift in thinking (e.g. identifying resources, externalizing the state transitions etc.). ... done right it can be an important and useful tool in your toolset. [but] ... as with any architecture/technology - a bad implementation can negate all the benefits

There seems to be an endless SOA debate on WS* vs. REST. In reality neither one is the "answer to everything" (be wary of the "Hammer" syndrome)

... when you take a holistic view of a complete business you are bound to see places where different architectural principles are a good fit. Architecture styles (and architectural patterns) are tools you can use to solve the challenges. There are places where a hammer is a great fit, but it is also wise to make sure the toolset has more than just a hammer.

For example, most REST implementations do not support asynchronous invocations and events. As a result, event-driven architectural style is probably a bad fit for REST. Another example, the separation of business and infrastructure concerns provided by the SOAP envelope is left to the implementer in the case of REST. Consequently, the implementation requires a significant number of potentially changing infrastructure concerns which might be not a good fit for REST.

REST has gained additional popularity lately with advances in Web 2.0, specifically Mashups and AJAX . In this case, REST services are often accessed from Javascript and use JSON as a marshalling mechanism. Based on this, many of the REST proponents claim that REST is easier to consume compared to the slew of WS* standards. Well, this is true if you are implementing consumer "by hands". On another hand, tools generating service consumer from WSDL and available in many programming languages make this job trivial.

 

The list of examples of REST vs. [anything] is endless and heavily depends on the list’s author. In his post, Arnon presents a good straw man for picking the appropriate architecture for an implementation.

  • This article is part of a featured topic series on SOA

11 comments

Watch Thread Reply

Simplicity by Andrew Valderas Posted
Re: Simplicity by Arnon Rotem-Gal-Oz Posted
Re: Simplicity by Andrew Valderas Posted
Re: Simplicity by Jean-Jacques Dubray Posted
Re: Simplicity by Andrew Valderas Posted
Re: Simplicity by Jason Pearlman Posted
Question by Eli Konky Posted
What's bad and ugly, exactly? by Stefan Tilkov Posted
Re: What's bad and ugly, exactly? by Dilip Krishnan Posted
Re: What's bad and ugly, exactly? by Boris Lublinsky Posted
Programming languages and REST by Satadru Roy Posted
  1. Back to top

    Simplicity

    by Andrew Valderas

    "REST seems simple but it isn’t - it requires a shift in thinking."

    While this is very true to get the full benefits from the architecture... we've found that embracing REST lends itself very nicely to a natural evolutionary and incremental progression.

    First things first, simply exposing your resources with the Web Architecture simply to get things done is a fairly trivial task and provides consumers a very low barrier to entry to reuse your work. Subsequently, a couple of months in, we quickly discovered the power of the URI and linked data. Having a standard pointer for every resource in your heterogeneous collection of systems allows you to begin creating a system of systems with ease. A standard pointer, by the way, that's supported out of the box by nearly every language, platform, and framework in use today.

    Today, a year after writing our first RESTful services, we have begun making use of the more advanced properties of the Web Architecture. We are creating a vast interlinked web of resources. We are utilizing HATEOAS in our interface designs, which we believe will add flexibility as we evolution our interfaces. We have begun including RDFa in many of our representations, which will allow us to "ask questions" of the system we've been unable to in the past.

    So yes... it is a bit of a paradigm shift for developers to truly reap the more significant benefits from the Web Architecture, but you can have great productivity gains along the way as you move to embrace it as your default means to expose resources and services.

  2. Back to top

    Question

    by Eli Konky

    From the text I understand doing crud over http verbs is discouraged. Can someone explain?

  3. Back to top

    Re: Simplicity

    by Arnon Rotem-Gal-Oz

    @Andrew
    I never said REST isn't a good architecture style. I think it is more complicated than it seems at first.
    if you just sprinkle http GET and PUT on your otherwise RPC you have REST you might still see easier integration (by sticking to an ubiquitous standard like HTTP). But if your resources aren't really resources, you don't use hypermedia ("HATEOAS"), stateless communication etc. you can still have a mess of a system

  4. Back to top

    Re: Simplicity

    by Andrew Valderas

    @ Arnon
    Never meant to imply you were saying it isn't a solid architecture, just saying that we've experienced an evolutionary path developers can take allowing them to learn to gain advantage of the breath of the architecture along the way. But your right... there's no Magic here... just some nice standard, powerful patterns who's underpinnings are ubiquitously supported. Some assembly required. Your parents (i.e. Senior Software Engineers) put it together. You've still got to architect your software correctly.

  5. Back to top

    Re: Simplicity

    by Jean-Jacques Dubray

    @Andrew:

    >> will add flexibility as we evolution our interfaces...
    I don't understand I thought REST "interfaces" were uniform? Are you adding verbs?

  6. Back to top

    What's bad and ugly, exactly?

    by Stefan Tilkov

    I fail to see how the things listed under "bad" or "ugly" have anything to do with REST itself.

  7. Back to top

    Re: What's bad and ugly, exactly?

    by Dilip Krishnan

    @Stefan +1

    Also...

    >>For example, most REST implementations do not support asynchronous invocations and events. As a result, event-driven architectural style is probably a bad fit for REST

    ... In defense, (not to sound like a "hammer" head :)) I would argue that endpoints exposing Atom or RSS representations inherently lend itself to event driven architecture.

  8. Back to top

    Re: What's bad and ugly, exactly?

    by Boris Lublinsky

    Well,
    for me the worst and ugliest thing is misunderstanding what rest really is and say "REST everything" just because its fashionable. I have seen so many RPCs services, implemented as XML/JSON over HTTP and being cold REST, that I am starting to wonder

  9. Back to top

    Re: Simplicity

    by Andrew Valderas

    @ Jean-Jacques
    No... not evolving the actually HTTP methods... evolving the resources returned... allow new functionality (in the form of new URI's with well known relationships) to be exposed.

  10. Back to top

    Re: Simplicity

    by Jason Pearlman

    @Jean
    I believe he was referring to adding the richer web architecture concepts that are beyond the uniform HTTP REST interface. Things like using hypermedia as the engine of application state, allowing more dynamic discovery of actions on services. Or using RDFa to embed rich semantics in resources, allowing clients to interact by only understanding a vocabulary instead of a specific resource format.

    I've also experienced the evolutionary nature of utilizing the web architecture. Brian Sletten has a great slide on the conceptual stack to getting to a semantic web and it started with addressibility (resources at URIs). Nothing better than getting iterative benefits.

  11. Back to top

    Programming languages and REST

    by Satadru Roy

    "... programming languages are not resource oriented so the handling code that maps URIs to tends to get messy."

    This is the part I struggle with most. All the magic annotation sauce of APIs like JAX-RS notwithstanding, at the end of the day, I've to do a mental map from the handful of verbs and the URIs to method signatures like transferFunds(from, to, amt). It calls for a constant juggling between between two very different mindsets unless I reduce all my methods to doSomething(bagOfBytes) which throws out the window all of the nice object-orientation things we've been told are sacrosanct. IMHO, there's something missing that has to connect programming in the large (REST verbs, URIs) to the programming in the small(programming language APIs)...

Educational Content

10 tips on how to prevent business value risk

One category of risk that project teams need to ensure they address is business value failure – delivering a product that fails to provide value for the business investor.

Interview: Software Systems Architecture: Working With Stakeholders Using Viewpoints and Perspectives

InfoQ spoke to the authors of Software Systems Architecture on a couple of new topics, the System Context viewpoint and Agile, which have been added to the second edition.

Beauty Is in the Eye of the Beholder

Alex Papadimoulis discusses ugly code, where it comes from, how to avoid it, and how to get rid of it.

Architecting Visa for Massive Scale and Continuous Innovation

John Davies examines Visa’s architecture and shows how enterprises have architected complex integrations incorporating Hadoop, memcached, Ruby on Rails, and others to deliver innovative solutions.

Max Protect: Scalability and Caching at ESPN.com

Sean Comerford unveils ESPN.com’s architecture, what components are used and why, and the current changes the website goes through.

The Seven Deadly Sins of Enterprise Agile Adoption

Are there repeated patterns of failure on Enterprise Agile Enablement efforts? Sanjiv and Arlen discuss Seven Deadly Sins to avoid when adopting Agile in an enterprise.

Questions for an Enterprise Architect

Erik Dörnenburg answers: What is Enterprise and Evolutionary Architecture?, discussing 4 issues: Turning strategy into execution, Ensuring conformance, Where do the architects sit? Buying or building?

Wrap Your SQL Head Around Riak MapReduce

Sean Cribbs explains what Map-Reduce and Riak are, why and how to use Map-Reduce with Riak, and how to convert SQL queries into their Map-Reduce equivalents.