News for hackers. Stuff that matters.
Re:RESTful thinking considered harmful by webjunkie on Friday March 30, 2012 @09:50AM (#3775895)
"The RESTful thinker may design both the payment of an order and the shipping of an order both as updates"

Maybe this thinker got it wrong. How about POST /orders/42/payment to create a payment object?

Re:RESTful thinking considered harmful by hsuresh on Friday March 30, 2012 @09:58AM (#3775928)
Yup. The author is wrong in his assumption. You can always model the "process" parts using a resource(payment resource as against pay, transaction as against credit/debit etc).
Re:RESTful thinking considered harmful by wvanbergen on Friday March 30, 2012 @10:14AM (#3775999)
My point is not so much that REST is wrong, but that RESTful thinking can be harmful if it comes before thinking about the process you're supporting.
Re:RESTful thinking considered harmful by hsuresh on Friday March 30, 2012 @11:22AM (#3776356)
Ok, but what is RESTful thinking?

The way i think about REST is this: here is my stateful application, how can i make it available over HTTP/REST. So i start identifying resources. Most of them are easy - they map to your domains models. But some of the operations on some of the resources are quite important to my application (eg: ordering products, making a payment etc), so i consider creating separate resources for them.

It looks like you are referring to modeling your stateful application when you talk about RESTful thinking.

Re:RESTful thinking considered harmful by richardlblair on Friday March 30, 2012 @01:47PM (#3777178)
That's a very good question, what is RESTful thinking?

I personally think so many of us are misguided in our think when it comes to RESTful APIs. In order to make good design decisions for your API you must understand how the users of your API perceive RESTful APIs. In order for you to understand how the users of your API perceive RESTfuls APIs you must consider how the masses (within your target audience) understand RESTful APIs.

Whether your interpretation of RESTful APIs is right or wrong does not matter. What matters is that people can use it. In order for people to use your API it must be easy to understand. In order for it to be easy understand it must be well documented and consistant.

Therefore RESTful API design must be approached on a case by case basis. You must understand your users, their knowledge base, and how capable they are.

wvanbergen: Interesting article. It was thought provoking at the very least.

Re:RESTful thinking considered harmful by jaylevitt on Friday March 30, 2012 @08:51PM (#3778875)
I think by "RESTful thinking" he means "cargo-culting the Rails RESTful scaffolding".
Re:RESTful thinking considered harmful by chrisdinn on Friday March 30, 2012 @11:17AM (#3776324)
I think this is a fair point. REST is all about resources and representations, which makes modeling simple CRUD actions on domain objects very easy. However, modeling application processes effectively is harder and requires deeper thought and a more thorough understanding of REST.

I've always thought the key to understanding REST is understanding idempotence. Is HTTP request to mark an order as paid idempotent? If so, a PUT/PATCH should be fine. If not (say, you're actually transferring funds) then a POST should be used. This key principle will help make your URL design choices much easier. In your example, the PATCH API appears idempotent, making the suggested POST replacement sort of confusing to me.

When it comes to modeling application processes using HTTP, understanding which requests are repeatable without consequence and which aren't is very important. It's hard to talk about modeling processes RESTfully without talking about idempotence. It's at the heart of the protocol's design.

RESTful thinking needn't be harmful for application processes as long as you do it effectively.

Re:RESTful thinking considered harmful by masklinn on Friday March 30, 2012 @09:55AM (#3775919)
> to create a payment object?

resource.

Also, not sure what's up with TFA's strawmanning,

    PATCH /orders/42 # with { order: { paid: true  } }
    PATCH /orders/42 # with { order: { shipped: true } }
looks like RPC update calls (hey let's map our Ruby attribute updates to HTTP calls, yay!) more than RESTful calls.

Also, not sure why a payment resource would be conceptually "within" an order (although that's got little to do with RESTfullness): why not POST to /payments?order=42? Which would return a link to e.g. /payments/2345 for your actual payment resource?

Something similar to http://blog.steveklabnik.com/posts/2011-07-03-nobody-underst... transaction resources.

Re:RESTful thinking considered harmful by beza1e1 on Friday March 30, 2012 @10:01AM (#3775941)
Nearly correct. POST does not specify the name of the resource. So you do

  /orders/42 # with { order: { paid: true  } }
And it returns the /orders/42/payment transaction resource.
Re:RESTful thinking considered harmful by drsim on Friday March 30, 2012 @10:25AM (#3776057)
I disagree. Surely an Order HAS Payments, therefore /orders/42/payment POST is more correct. Likewise orders/42/shipment.

Nicely leading on to /orders/42/payments/1.