REST is neither CRUD nor CRAP

In the wake of my praise for CRUD is CRAP, David Ingasked “how do you reconcile something like REST (astoria etc) with being CRUD-adverse? Is there a happy place where the two can go for coffee?” Sure there is: I hear Tim Ewald’s XML Nation serves great coffee and the scones are pretty good. ^[Actually, I have no idea if Tim even likes coffee or scones. FYI, DevHawk Nation would not feature great coffee or pretty good scones. We would, however, have Arrogant Bastard Ale on tap.]

Seriously, the key observation that Tim recently made is that REST != CRUD. Sure, it can be used that way and for simple scenarios it works fine. (I’ll define “simple scenarios” in a second.) But I don’t believe CRUD style REST works in the large. Tim said you can’t build with just CRUD because it’s “to simplistic to be useful”. I’ll go even more fundamental, using REST for CRUD means having giving up transactions entirely. I’ve already accepted that building loosely coupled services means giving up distributed transactions. But the idea of giving up transactions entirely is just crazy talk.

So when I said “simple scenarios” above, I meant “scenarios that don’t need transactions”. (I take it as a given that RESTifarians aren’t hot for WS-AtomicTransaction.) ATOM Publishing is a simple scenario because the web resource authoring scenario doesn’t need transactions to protect updates to multiple resources at a time. If it did, I don’t believe the REST as CRUD approach they use would work.

As you might guess then, I’m not a fan of Astoria. I believe the sweet spot for so called “data services” will be read only (because they don’t need transactions, natch). I’m sure there are some read/write scenarios Astoria will be useful for, but I think they will be limited – at least within the enterprise.

If REST != CRUD, then what is it? Let’s go back to Tim’s post:

Every communication protocol has a state machine. For some protocols they are very simple, for others they are more complex. When you implement a protocol via RPC, you build methods that modify the state of the communication. That state is maintained as a black box at the endpoint. Because the protocol state is hidden, it is easy to get things wrong. For instance, you might call Process before calling Init. People have been looking for ways to avoid these problems by annotating interface type information for a long time, but I’m not aware of any mainstream solutions. The fact that the state of the protocol is encapsulated behind method invocations that modify that state in non-obvious ways also makes versioning interesting.

The essence of REST is to make the states of the protocol explicit and addressable by URIs. The current state of the protocol state machine is represented by the URI you just operated on and the state representation you retrieved. You change state by operating on the URI of the state you’re moving to, making that your new state. A state’s representation includes the links (arcs in the graph) to the other states that you can move to from the current state. This is exactly how browser based apps work, and there is no reason that your app’s protocol can’t work that way too. (The ATOM Publishing protocol is the canonical example, though its easy to think that its about entities, not a state machine.)

While I disagree with Tim’s disagreement of ATOM (i.e. I believe APP is about entities, but it works because it doesn’t need transactions), I agree 100% that REST is about protocol state. Tim lays this very clear in his airline reservation sample. Thus, I can spurn CRUD and still embrace REST if I want to.

Further, Tim’s points on the opaque nature of RPC style interactions (which web services appear to have fallen into despite the best of intentions) are spot on. If you’re doing simple request/response services, the protocol state is trivial, so that works fine. However, in the scenarios I face, long running services are the norm and managing the protocol state is critical. I’ve got some ideas on how to do that, but that’s a future blog post.

Early Afternoon Coffee 81

These morning meetings are really cramping the “morning” style of these posts. But better late than never, I guess.

  • Politics 2.0 Watch: Democrats pwn Republicans online. (via Balloon Juice)
  • Roger Wolter writes about integrating SSB with WF, something I’ve experimented with myself. I didn’t find the integration quite as natural as Roger did – transactions are a real PITA, and Roger apparently he hasn’t looked into that yet - but I agree 100% with the idea that “most SSB programs end up looking a lot like a workflow.” Looking forward to seeing your code, Roger.
  • Pat explains his Newton vs. Einstein view of distributed systems and then rants about Consistency, Availability and Partition-tolerance. In particular, he discusses the evolution of what consistency (and to less extent availability) means in the face of loose coupling. Do yourself a favor and give up on distributed transactions now. Also, Pat points to another paper from CIDR dealing with isolation in services. Haven’t read it yet, but I’ve added it to “the pile”.
  • David Chappell writes about Service Component Architecture vs. Service Oriented Architecture. Since I don’t “do” evangelism anymore, I don’t spend much time watching what our competitors are doing. According to the SCA website, SCA is supposedly a “a model for building applications and systems using a Service-Oriented Architecture.” But according to David, SCA 1.0 focuses on “portability, not interoperability, and so they don’t fully define the interactions between components necessary to create composites that cross vendor boundaries.” I realize that we don’t industry agreement on all the details of what SOA means, but I think we all agree that it’s cross platform and cross vendor. Or maybe we can’t even agree on that much.

Morning Coffee 79

  • Soma announces PopFly, the “fun, easy way to build and share mashups, gadgets, Web pages, and applications” from the Non-Professional tools team. The PopFly team blog has some videos. Sounds vaguely like Yahoo! Pipes, but cooler. While most of the focus is on their browser-based mashup creator, they also have VS support for the non-non-professionals among us.
  • Eric Nelson suggests that the new Dynamics CRM systems is actually a LOB application platform in it’s own right. More details in Ben Riga’s MIX session. (via Gianpaolo)
  • Sam Gentile is worried that C# is becoming to complex, especially when you also consider how fast the platform is moving underneath. When you get your head out of the debugger for a second and look at the Big Picture, it certainly seems overwhelming. Is it just a question of getting used to it? The first time I fired up the VS.net 2002 alpha and looked at all the classes in the BCL, I had the same overwhelmed feeling, but eventually I got over it. Or have things just gotten too big and move to fast now? If so, it’s time for some new layers of abstraction…
  • Udi Dahan writes about building testable services. Testability has to be a core consideration when building anything, but especially a reusable framework. I’ve had similar thoughts about language design. How do you unit test a DSL?
  • Roberto Medrano of SOA Software thinks “maybe 20 percent of IT folks understand SOA and half of the rest think they do”. Personally, I think most IT folks don’t agree on what SOA is or should be. Furthermore, we don’t even have a common lexicon to discuss it, so we end up talking past each other and arguing about topics we agree on. I think Roberto is really saying is “most people are wrong because they don’t agree with what I think SOA is”. (via Jack van Hoof)
  • Jeffrey Snover talks about the virtuous cycle of .NET language support. His point is that time spent learning .NET pays off as you transition between system programming (C#, VB.NET), shell programming (PowerShell) and script programming (IronPython, DLR). I’m not sure I would break them down that way, but his point spot on.
  • Clemens Vasters experiments with the new BizTalk Services with a sample called TweetieBot. I agree 100% with his point about the assumption of centralization will be challenged by the federation of personal services.

Morning Coffee 78

  • Ian Griffiths posts a much longer version of “Even though the runtime supports multiple languages, most programmers are only fluent in one.” (via Larkware)
  • I wrote yesterday that Pat Helland’s first post back was light on the tech talk. Luckily (for us) he takes the bus to work so he has plenty of time to write blog entries. Today’s post is his “personal opinion about how computers suck”. Money Quote: “We try too hard as an industry.  Frequently, we build big and expensive datacenters and deploy big and expensive computers. In many cases, comparable behavior can be achieved with a lot of crappy machines which cost less than the big expensive one.”
  • Steve Jones wrote that CRUD is CRAP. I agree 100%, but for additional reasons. Not only is it boooooring to write, it also delegates control outside of the service which I think is a mistake. Check out this post from Maarten Mullender who advised to do CRUD only when you can afford it.
  • MIT Media Lab has created Scratch “a new programming language that makes it easy to create your own interactive stories, animations, games, music, and art — and share your creations on the web” targeted at kids 8 and up. It’s a dynamic visual programming language that looks like Lego. Between Scratch, Boku and Phrogram I think my kids will have lots of fun learning to program like daddy does. (via GeekDad)
  • Halo 3 is coming September 25th! I foresee lots of people calling in sick that day. And the next. And the rest of the week, etc. etc. etc.

Making My Mark at TechEd

One of the things that’s different about being in MSIT is that it’s cut my travel dramatically. Basically, the only travel I’ve done since taking this job was Thomas Erl’s SOA Workshop last September. So it came as a bit of a surprise when I got tapped to present at TechEd (at fairly close to the last minute).

The last year I ran the architecture track, all track owners were asked to include either a globalization or MSIT session in our track. Since then, MSIT has expanded it’s role at TechEd dramatically, with 14 breakouts, 20 chalk talks and our own Technical Learning Center.

I’m doing a two chalk talks on my MSIT project, Rome. I mentioned the project back when I switched jobs, but we’ve never talked about the project by name before. We haven’t accomplished quite as much as I’d hoped since then, but we’ve progressed to the point that we can talk publicly about what we’re doing. Now that we’ve begun to open the kimono a bit, you should see more on Rome, Not only from me but also my teammates who blog: Dale, Rick and Dottie.

So if you’re going to TechEd, make sure you stop by the MSIT Technical Learning Center and say hi. Unlike my last two trips to TechEd, I have very limited responsibilities this time – basically just show up on time and talk about what I do all day, twice – so that leaves plenty of time to attend sessions, chat up attendees and ride roller coasters. Hope to see you there.

ROME: Service Oriented Infrastructure for the Enterprise
Like most enterprises, Microsoft IT is adopting a service oriented approach for the development of their internal systems. However, in order to avoid projects building similar service infrastructures on a per application basis, MSIT realizes the need for a common service oriented infrastructure to build these systems upon. Inside MSIT, the Rome project is tasked with designing, building and maintaining the infrastructure for these services. Come chat with Harry Pierson, lead architect of the Rome project, and discuss the challenges of building a large-scale service infrastructure inside a large enterprise like Microsoft.

  • MST02-TLC Monday (June 4th) 1:15-2:30pm
  • MST14-TLC Thursday (June 7th) 1-2:15pm