How Being Stateful Would Improve Starbucks
As a followup to the REST rant the other day, here’s a digression that occurred to me:
Imagine that instead of buying a Coke at 7-Eleven (simple object acquisition with no preparation required), picture buying a coffee at Starbucks.
Now, I don’t actually hate Starbucks qua Starbucks, but I do hate two things about Starbucks. One of them is the coffee itself (over-roasted, excessively astringent), and the other is the order delivery process. (If you’re asking what that leaves, it leaves the ubiquity — bully for them! — and the cafe environment outside all the shouting, which generally involves non-awful music, comfortable chairs, and available power and wifi, all good things in my book).
There’s an interesting article about Starbucks that says their process is actually a good thing. The experience described in that article, however, is not the experience I have on those occasions when Starbucks is my only option. The article refers specifically to a correlation identifier. In my (admittedly small) sample of Starbucks experiences, the number of times my name has been written on my cup (or even asked for) is exactly zero. Without any correlation identifier, how do customers know whose (ugh) Venti® nonfat latte is whose?
In software terms, what Starbucks is doing is really just a half-assed version of asynchronous processing. When you do this in software, you (the client) register a callback. A software callback is the equivalent of giving the barista not your name, but your phone number. Many restaurants have those pagers for tables, which are essentially the same thing — when you register your callback, you’re given a handle, which is unique to you. You get the actual call (or the pager vibrates) when your coffee (or table) is ready.
The brute force software alternative to this is scheduled polling. You’ve probably had this experience at a poorly run Starbucks, actually, when the shouty person is inadequately shouty, and you have to keep returning to the counter to find out if your drink is done yet. The canonical example of polling in real life is “are we there yet?” But I digress even more.
The Starbucks problem is that they don’t have a proper callback, they just shout “Venti® nonfat latte!” In practice there’s no queue management. Everybody who ordered a Venti® nonfat latte (and I’ve never seen the number be less than two) has to figure out who’s where in the queue, with somebody invariably feeling like they’ve gotten their drink stolen. I’m not sure there even is a term for what sort of queue “management” that is. It’s just a mess.
But (and this is where this ties in to the previous rant) not only is the Starbucks model a callback done wrong, it’s a broken hybrid of REST and stateful services. They treat the part where they take your money like a REST transaction, queue the process of making your beverage, and then forget who you are. In a true stateful model, each cup would have a serial number (not a name), and they’d have to record the completion of the process to get the name that associates with that serial number. That way they’d have not only a 1:1 correlation of processes to customers, they’d actually know how long each process took in the real world and be able to see where processes could be improved and beverages could be repriced or eliminated from the menu based on actual data.
They could do this without writing anything or wasting paper, too. They could just have a hundred plastic coasters (forty would probably do it, actually) with numbers on them, so that a number (handle) could be reused endlessly. Put a cup on the numbered coaster and put the number into the POS terminal, along with the customer’s name (or hand the customer a pager tied to that same number). When the order is done, the shouty person keys the number in, the system records completion, and the shouty person can then thank the customer by name. Add the pager and they don’t even have to shout, making the environment for everybody else that much more pleasant.
Then they just have to start making better coffee.
