There’s been some discussion in web development circles recently about whether RESTful (a.k.a Client MVC, a.k.a. Single page) web applications are a good idea. Or, more accurately, whether they’re a better idea than just serving up HTML from the server.

Now, before I give my two cents on this, let’s define what we’re talking about here. Basic pattern behind RESTful web apps is this: the Server exposes a set of REST endpoints which emit XML or JSON (usually the latter), while the Client (which is typically built using some JavaScript MV* framework) consumes said endpoints.

I should note that both sides of the argument make some very valid points. In particular, the side against RESTful web apps points to non-trivial costs (in the form of increased complexity and performance issues) as reasons not to do it for every single app you build.

They make a great point. There is a cost associated with RESTful web apps, just like there is a cost associated with a lot of other things (Domain Driven design is one popular example). If the cost cannot be justified, it shouldn’t be incurred.

That said, I think that this architectural pattern is one of the most exciting trends in software development. Here’s why.

Forcing Function

If you’re building a RESTful web app, you’re forced to think about your domain in terms of resources and simple CRUD operations on those resources. Lots has been written on why resource orientation is a good thing, so I won’t rehash those reasons here. I’ll just say that to me, achieving modularity and loose coupling via resource orientation feels like the least labored way to do it.

In other words, I rarely feel like I’m straining the resource metaphor when I talk about what resources my app would consume/create. I also find it more natural and more straight forward to reason about, especially when compared to other layering or service oriented techniques.

Free API

Another benefit of building RESTful web apps is that you get a set of APIs for your domain for free. Want to build a mobile client? No problem, just use these APIs we already developed and tested. This stands in stark contrast to more “traditional” web applications where exposing your data to other consumers requires a whole new development effort.

Now, I should note that you’ll likely need to bullet-proof your APIs before exposing them to external consumers. After all, we tend to take shortcuts when we have complete control over both the consumer and the producer of the APIs. This is normal and reasonable because the extra level of rigor is simply not needed.

So, you will probably have to go back and add things like additional authentication mechanisms, more robust validations, better logging, more consistent response codes, clearer error messages, etc. That said, the effort to get these APIs prepped for external consumption is considerably lower than building them from scratch.

You may also like:

tagged with:

Did you love / hate / were unmoved by this post?
Then show your support / disgust / indifference by following me on Twitter!

This post got 4 comments so far. Care to add yours?

  1. Jigar Shah says:

    Hi,
    I had same thought. But i ran into few roadblocks. I used simple webapp with apache CXF for jax-rs service jsps for front end rendering.

    Access control and authentication propagation from web app to web service. I ended up using servlet context and some servletFilter. Not sure if thats ideal way.

    Localisation – I used Struts for long time. Ease with which it does localisation is really good. Is there a standard way of handling the same ?

    Controller – Since As i said controls are mostly transferred from js (since ajax call return decides which page – if any to be changed or refresh). Mostly works fine but in few cases where number of navigations are more its an issue.

    Too much js to manage. Everything is mostly ajax. using dom manipulation for updating ui is good but very dirty and difficult to manage. Thinking about using JavascriptMVC

    Would be grateful, if you can share your experience with respect to above observations.

  2. […] There’s been some discussion in web development circles recently about whether RESTful (a.k.a Client MVC, a.k.a. Single page) web applications are a good idea.  […]

  3. […] There’s been some discussion in web development circles recently about whether RESTful (a.k.a Client MVC, a.k.a. Single page) web applications are a good idea.  […]

  4. […] Artigo traduzido pela Redação iMasters, com autorização do autor. Publicado originalmente em http://tatiyants.com/restful-web-applications-are-good-for-you/ […]

Leave a Reply