Tuesday, August 14, 2007

What Can a RESTaurant Teach You About REST? (part 1)

I'm buying a house soon. That's the sort of transaction you have to get right. No matter what the cool kids are saying about transactions being dead, I'll fight Brewer's conjecture all the way the bank. I want my house, and the seller wants his money. It's definitely not okay for one of us to end up with both. Why? Because it's too hard to correct the error[*]. Therefore we pay the not inconsiderable overhead of title companies, escrow agents, loan officers, wire transfer fees, etc. to get it right. It's way cheaper than going to court.

But in the rarefied world of blogosphere REST pundits, we evangelize the webby way for lots of things. Fire and forget. Assume your communication channel is going to fail a lot. Assume statelessness. This would totally suck for buying a house. Imagine having to bring all 300 pages of documentation required to every meeting you attended—tax returns, site surveys, credit reports. And how could anyone be sure you were being consistent? Boy I would love to have brought a different set of papers to the loan officer as I did to the IRS. (Hello, sub-prime mortgage crisis! But I digress.)

But aren't we talking about RESTaurants? I thought it was a clever pun.

Sorry, yes we were. But the point was to introduce the cost of getting it right. And besides, it's hard to concentrate on anything else when you're buying a house, so indulge me.

What, honestly, is the cost to you if a restaurant fails to get your order right? Mistakes are made all the time by waiters, customers, busboys, managers, and cooks. Yet, unlike closing on a house, you do not sign contracts or involve lawyers when you order food at a restaurant. In fact, you don't even do a credit check; centuries of social convention have blessed us with a system where it is assumed you can pay for dinner and only have to prove it at the end.

Or has it? I once booked an anniversary party for my company at a tony restaurant in Las Vegas. I had to put down a credit card to hold the table. Why there and not at, say, my neighborhood pizza joint? The answer is fairly obvious: if I flake on my big party at said tony restaurant, they're out a private room and four figures. If I flake on dinner with my wife at said pizza joint, they'll fill the table anyway most nights, and if they don't, they're out 20 bucks, tops.

Okay, now you're bugging me. REST pundits are supposed to wax poetically about URL design and resource representations. You know, eBay transactions are really resources, what is the URL of a pixel[**]?—that sort of thing. This is a rambling diatribe about transactions, not REST. You can't fool me! Though you are at last talking about restaurants.

Well, REpresentations are only half of REST. (As measured by the letters they get in the acronym.) State Transfer is pretty damn important in a stateless protocol. Transactions are only one kind of state transfer. And what I'm warming up to talk about (warming up, get it? restaurants? anyone? is this thing on?) is state transfer. How does that latte get to you at Starbucks? My jalapeño sausage at the local barbecue joint? My #1 Meal, cheese, no pickles, onion rings and a Diet Coke at Whataburger? My Kansas City Strip at Delmonico? Getting there involves many state transfers, and each of these restaurants has chosen a different system.

But now you've gone and spent all your time on silly jokes.

So I have. See you tomorrow.

[*] Oh yes, funny story. When I bought my first house, the combination of my naiveté and an under-trained clerk at the title office led to me bringing a personal check for the down payment on my house. It was an average house, but a 20% down payment still made the check five figures. The title company protested that they couldn't be expected to float that kind of money waiting for my check to clear. And besides, we had already signed so much paperwork and gotten everyone in the same room, that it seemed unlikely we would want to do this again in 5 days. I said, "The check won't bounce, and if it does, what's the problem? You know where I live, right?" Cursory examination of the 300 pages of paper signed that afternoon indicated more than a few copies of my old and new addresses. Some uneasy laughter ensued, and that was the end of that. I got lucky. That actually would have been a very expensive error on the title company's part.

[**] Turns out, whole pictures can have URLs. That's an approach I'm pretty sure wouldn't work for satellite imagery. But again, I digress.

3 Comments:

At August 15, 2007 2:48 AM, Anonymous Anonymous said...

Who said that REST can't be stateful?
A REST call could easily change the resources on the server, thus not making it stateless.

 
At August 15, 2007 10:15 AM, Blogger Sebastian Good said...

REST uses HTTP, a stateless protocol. Of course the resources at either end can be stateful and transfer state, that's the whole point! But the key observation is that the statefulness must be explicit: HTTP doesn't carry any for you. (Well, with the exception of cookies, but let's not get ahead of ourselves.)

 
At August 15, 2007 2:47 PM, Anonymous Frank said...

I wonder what this restaurant will be able to teach you about REST :)

Nice reservation number btw!

 

Post a Comment

Links to this post:

Create a Link

<< Home