In Search of REST
Since the Ruby on Rails world is all gaga over REST right now, I figured that I’d jump on that wagon. I’ve often prided myself on being part of the latest fads no matter how silly they are. :)
As a developer that has worked in the MS world for a long time, I’m far more familiar with SOAP than I am with REST. For the most part, I’ve kind of seen REST as a lesser form of SOAP. But that couldn’t be farther from the truth.
In the same way that RoR is a better fit than ASP.Net for most web application development, REST is a better fit than SOAP for most web API development. Of course, these are my own opinions and are certainly open to criticism. Feel free to leave a comment if you disagree.
The hardest thing with REST is to change the way your mind has been taught to think with SOAP. It’s not just a matter of writing code to expose your business objects as services. REST isn’t really an afterthought that you add on to an existing application. It’s a way to rethink the way you approach your entire application. For more on this, check out the following links:
- REST 101: Part 1 – Understanding Resources
- REST 101: Part 2 – A Million APIs
- Build an app with Ruby on Rails resources
- Discovering a world of resources
These articles will talk about the beauty of CRUD and how well it maps over to the HTTP verbs of GET, POST, PUT and DELETE. Beautiful stuff.
But I don’t think that I truly got it until I read the following quote from “A false REST understanding” that talks about a REST-enabled web application that has a shopping cart for buying books:
The book entry in the cart then has its own URL, that can be used to delete it or modify the quantity.
Pretty simple quote, eh? Not exactly earth shattering, is it?
But that idea was enough to make things start to sink into my head. REST is not about exposing methods over the web, which was the default way that I looked at it after being exposed to SOAP. It’s about exposing a URL for every resource so that you can perform CRUD actions on those resources. That’s why it’s important that you normalize your application in the same way that you normalize your database tables.
If that just seems like a bunch of crap, then consider it this way. You know all of those OOP articles that talk about how separation of concerns is a great thing? Think about what normalization is in a database. It’s the same thing.
It’s all starting to make sense now.
P.S. One last link – you’ve just got to watch the David Heinemeier Hansson screencast from RailsConf 2006 where he introduces REST support in Rails. Be sure to follow along with his slides while you watch the presentation.
Comments are closed.
Maybe these pages on my site may be of interest to you too:
http://ariejan.net/2007/01/23/new-in-rails-resource-scaffold-generator/ http://ariejan.net/2007/01/23/rails-nested-resource-scaffold/
Hope you enjoy it!
Thanks for the links. I’ll be sure to check them out.