<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?xml-stylesheet href="http://duncan-cragg.org/css/atom.css" type="text/css" ?>
<!-- Copyright (c) 2006 Duncan Cragg -->

<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
    <id>http://duncan-cragg.org/blog/</id>
    <title>What Not How - Posts tagged 'app'</title>
    <subtitle>Duncan Cragg on Declarative Architectures</subtitle>
    <author><name>Duncan Cragg</name></author>
    <logo>/favicon.gif</logo>
    <icon>/favicon.ico</icon>
    <rights>All content including photos and images by Duncan Cragg. Copyright (c) Duncan Cragg, your rights preserved: see /CXL.html</rights>
    <generator uri="http://www.djangoproject.com">A Django Production.</generator>
    <link rel="alternate" type="text/html" href="http://duncan-cragg.org/blog/" title="What Not How" />
    <link rel="self" type="application/atom+xml" href="http://duncan-cragg.org/blog/atom/app/" />

    <updated>2009-11-25T21:29:00Z</updated>


    <entry>
        <id>http://duncan-cragg.org/blog/post/deriving-forest/</id>
        <title>Deriving FOREST</title>
        <published>2009-11-25T21:29:00Z</published>
        
        <updated>2009-11-25T21:29:00Z</updated>
        
        <link rel="alternate" type="text/html" href="http://duncan-cragg.org/blog/post/deriving-forest/" title="Deriving FOREST" />
        
        <category term="architecture" />
        
        <category term="app" />
        
        <category term="microformats" />
        
        <category term="rest" />
        
        <category term="atom" />
        
        <category term="forest" />
        
        <summary type="xhtml">
            <div xmlns="http://www.w3.org/1999/xhtml">

<p>

Say we want to integrate multiple applications which handle order processing. OK, that&#39;s
got to be one of the dullest starts to a blog post. Never mind, bear with me...
</p><p>
So, we have applications on separate servers for handling and driving data such as
orders, product descriptions and catalogues, stock lists, price lists, tracking, packing
notes and delivery notes, invoices, payments, etc.
</p><p>
We may choose an SOA approach, of course. But let&#39;s say our sponsors have heard of this
cheaper alternative: REST! Which to them means &#39;using Web technology to save money&#39;.
</p><p>
Now .. suppose we push the time slider right back to before Mark Baker and the SOA -vs-
REST Wars - or the &#39;SOAP -vs- REST Wars&#39; as people naively called it. To when REST was
simply (!) a description of the Web&#39;s architectural style...
</p><p>
What if we revisit the applicability of the Web, and its abstraction into REST, to the
architecture of machine-to-machine distributed systems - to something like our order
processing integration?
</p><p>
I think we&#39;d quickly arrive at something that looks more like
<a href="http://duncan-cragg.org/blog/post/forest-get-only-rest-integration-pattern/">FOREST</a>
than, say, AtomPub...
 &#160; ...
</p>

            </div>
        </summary>
        <content type="xhtml" xml:space="preserve">
            <div xmlns="http://www.w3.org/1999/xhtml">

<p>
</p><div class="summary"><p>
Say we want to integrate multiple applications which handle order processing. OK, that&#39;s
got to be one of the dullest starts to a blog post. Never mind, bear with me...
</p><p>
So, we have applications on separate servers for handling and driving data such as
orders, product descriptions and catalogues, stock lists, price lists, tracking, packing
notes and delivery notes, invoices, payments, etc.
</p><p>
We may choose an SOA approach, of course. But let&#39;s say our sponsors have heard of this
cheaper alternative: REST! Which to them means &#39;using Web technology to save money&#39;.
</p><p>
Now .. suppose we push the time slider right back to before Mark Baker and the SOA -vs-
REST Wars - or the &#39;SOAP -vs- REST Wars&#39; as people naively called it. To when REST was
simply (!) a description of the Web&#39;s architectural style...
</p><p>
What if we revisit the applicability of the Web, and its abstraction into REST, to the
architecture of machine-to-machine distributed systems - to something like our order
processing integration?
</p><p>
I think we&#39;d quickly arrive at something that looks more like
<a href="http://duncan-cragg.org/blog/post/forest-get-only-rest-integration-pattern/">FOREST</a>
than, say, AtomPub...
</p></div><p>
Some pretty obvious things to notice about the Web and, indeed, REST:
</p><ul>
<li>The Web is essentially data on URLs of standard content types containing more URLs;</li>
<li>The Web is the Web because of the massive proliferation of links in that data;</li>
<li>REST mostly concerns itself with the consequences of GET, including cacheing;</li>
<li>The Web uses, I don&#39;t know, let&#39;s say 98% GET, 2% POST, around 0% other methods.</li>
</ul><p>
In other words, the Web, and its good qualities, are mostly based on:
</p><pre>
GET URL -&gt; HTML -&gt; a.href=URL -&gt; GET URL ..
</pre><p>
</p><p>
When applying this Web/REST architectural style to our integration scenario, there are
things that we can say right now with certainty will be different, but will have
corresponding elements:
</p><ul>
<li>It&#39;s about data not documents, so HTML is probably going to be replaced by XML, although perhaps XHTML+Microformats or Atom would make a good compromise;</li>
<li>We have a choice of link specs: xhtml:a.href, atom:link.rel, xml:xlink; I don&#39;t think we&#39;ll be using XLink since no-one else seems to;</li>
<li>We&#39;ll probably use machine-generated URLs perhaps containing UUIDs, GUIDs or whatever.</li>
</ul><p>
In other words, we&#39;re not going to be spinning a hypermedia Web - it&#39;s more a
&#39;hyperdata&#39; Web.
</p><p>
So, in order to emulate the document Web in our hyperdata integration Web, we&#39;ll mostly
be doing something like:
</p><pre>
GET ID-URL -&gt; XHTML -&gt; a.href=ID-URL -&gt; GET ID-URL ..
</pre><p>
</p><p>&#160;</p><p>
Oh! I&#39;ve got some 
<a href="http://docs.google.com/present/view?id=0AUwWWDrZPVcFZGZtODR6YzZfMGhiM3MyMmR0&amp;hl=en">slides</a>
of all this on Google Docs: we&#39;re up to Slide 2! Maybe right-click, open in a new window...
</p><p>&#160;</p><p>
<b>Symmetry - Slide 3</b>
</p><p>
But by far the biggest difference between the Web and an integration scenario is that
the asymmetry on the network goes away; even for a cross-enterprise integration.
</p><p>
Where the Web&#39;s browser clients and site servers have always been asymmetric - clients
being hidden away and only able to establish outbound connections - machine-to-machine
integration is fundamentally symmetric - all servers can be made visible to each other.
</p><p>
Now, in order to keep the well-studied benefits described in REST, including separation
of concerns, we should aim to maintain the client-server, layered structure in the use
of the protocol.
</p><p>
But <i>clients can be servers and vice-versa</i>!
</p><p>
So, in machine-to-machine integration scenarios, we have:
</p><ul>
<li>Two-way GETs on machine-minted URLs pointing at XHTML+Microformats or Atom content containing more links.</li>
</ul><p>
In other words:
</p><ul>
<li>A hyperdata Web both created and consumed by the applications being integrated.</li>
</ul><p>
All of the dynamic data or hyperdata items in our order processing scenario will be
distributed across the many applications being integrated. Each application serves
its part of the hyperdata Web to the others. 
</p><p>
And, of course, the hyperdata joins all these applications up: a payment resource
in the accounting application will point to an order resource in the order processing
application, etc.
</p><p>&#160;</p><p>
<b>Interactions and Application State</b>
</p><p>
Now, each application has its own set of business rules and constraints over the
hyperdata parts that it governs. 
</p><p>
So how exactly should the applications publishing those bits of the hyperdata Web
interact? How do orders interact with packing notes and stock levels, with payments and
accounts?
</p><p>
In the Web, you go to a site and jump some links. Each page brings in CSS, Javascript,
images, maybe iframes: an eager assembly of pages from links to many resources, in
contrast to the lazy, on-demand fetching of links from a user jumping them.
</p><p>
The browser at any time has a state that depends on the page and images, etc, currently
being viewed, plus the history of previous pages, bookmarks, etc.
</p><p>
Search engines in the Web, without a user driving things, are eager to traverse links
in order to do their work indexing pages. Order processing applications will probably
have more in common with search engines than with browsers.
</p><p>
REST describes this in terms of hypermedia - links - driving &#39;application state&#39;. 
</p><p>
So we next need to decide what &#39;application state&#39; is, in our Web- and REST-driven
architecture for machine-to-machine distributed systems; where the user driving
hypermedia link traversals is replaced by business rules or logic driving hyperdata link
traversals.
</p><p>
Each integrated application has its own &#39;application state&#39;, so, to follow REST, this
application state should be driven by the surrounding hyperdata of peer applications,
according to those business rules.
</p><p>&#160;</p><p>
<b>Application State is Linked Resources - Slide 4</b>
</p><p>
In fact - and this is a consequence of the symmetry of integration - <i>&#39;application
state&#39; is those very resources that the application contributes to the hyperdata Web!</i>
</p><p>
A stock tracking application&#39;s state is pretty well described by a bunch of resources
describing the stock levels. A fulfilment application&#39;s state could be inferred by
inspecting the outstanding packing notes.
</p><p>
We&#39;re not limited to the asymmetric browser-server of the Web, where the browser&#39;s
&#39;application state&#39; is never visible except when it POSTs something back.
</p><p>
It&#39;s more like a search engine, where you can publically access an &#39;application state&#39;
that is entirely driven by the hypermedia crawled by the search bot.  A search engine&#39;s
application state is rendered into the results page resources you see when you do a search.
</p><p>
So the resources of each application in the order processing integration are driven by the
surrounding, linked resources of the other applications.
</p><p>
You could rephrase REST&#39;s &#39;hypermedia as the engine of application state&#39; when applying
it to symmetric machine-to-machine integration in this neat way:
</p><blockquote class="others-content"><div><p>
Hyperdata as the Engine of Hyperdata.
</p></div></blockquote><p>
</p><p>&#160;</p><p>
<b>The Functional Observer Programming Model - Slide 5</b>
</p><p>
So now, how do we program the hyperdata-driven-hyperdata of our integrated applications?
</p><p>
How do we animate the stock tracking hyperdata chunk over here in the face of today&#39;s
packing notes in their hyperdata chunk over there?
</p><p>
That&#39;s what 
<a href="http://duncan-cragg.org/blog/post/forest-get-only-rest-integration-pattern/">FOREST</a>
is all about!  
</p><p>
The name &#39;FOREST&#39; stands for 
&#39;<a href="http://duncan-cragg.org/blog/post/forest-functional-observer-rest/">Functional Observer REST</a>&#39;.
</p><p>
The words &#39;Functional Observer&#39; describe FOREST&#39;s hyperdata-driven-hyperdata programming
model. But it&#39;s much simpler than it sounds...
</p><p>
<i>A FOREST resource in the hyperdata Web sets its next state as a Function of its
current state plus the state of those other resources Observed by it via its links.</i>
</p><p>
The best way to encode such state evolution is in rewrite rules or functions which match
a resource and its linked resources on the left-hand side, then rewrite that resource&#39;s
state on the right-hand side.
</p><p>&#160;</p><p>
<b>Not Like AtomPub, then</b>
</p><p>
So, quite a different conclusion from what is now the &#39;conventional REST&#39; of the four
verbs - GET, POST, PUT and DELETE.
</p><p>
Quite different from asymmetric, one-way application protocols as modelled by AtomPub,
in which clients aren&#39;t considered worthy to hold their own resources, but are allowed
only an inscrutable &#39;application state&#39;.
</p><p>
By focusing on GET and the freedom in integration to be symmetric, we&#39;ve arrived at a
general distributed programming model, FOREST, that allows us to express business rules
that drive an application&#39;s hyperdata in the context of another application&#39;s hyperdata.
</p><p>
Watch this blog (and <a href="http://twitter.com/duncancragg">Twitter</a>), where I&#39;ll be talking
more about the benefits of FOREST, its implementation, and, above all, offering examples of how it would work (once the code is ready enough!).
</p><p>

</p>

            </div>
        </content>
    </entry>
    
    <entry>
        <id>http://duncan-cragg.org/blog/post/forest-get-only-rest-integration-pattern/</id>
        <title>FOREST: a GET-only REST Integration Pattern</title>
        <published>2009-10-09T17:14:00Z</published>
        
        <updated>2009-10-11T11:46:00Z</updated>
        
        <link rel="alternate" type="text/html" href="http://duncan-cragg.org/blog/post/forest-get-only-rest-integration-pattern/" title="FOREST: a GET-only REST Integration Pattern" />
        
        <category term="architecture" />
        
        <category term="app" />
        
        <category term="dialogue" />
        
        <category term="rest" />
        
        <category term="rest-observer" />
        
        <category term="forest" />
        
        <summary type="xhtml">
            <div xmlns="http://www.w3.org/1999/xhtml">

<p>

Since the day in 2006 that our
<a href="http://duncan-cragg.org/blog/post/getting-data-rest-dialogues/">dialogue</a>
took place with <i>an imaginary eBay Architect</i>, he has been promoted to <i>imaginary
Enterprise Architect</i> in an investment bank!  Convinced by the merits of REST, he took
his enthusiasm for it into his new job and embarked on architecting a trading system
using REST or ROA as an alternative to SOA.
</p><p>
Now, he hit upon a snag: he had a REST &quot;bank server&quot; generating bids on an instrument
and POSTing them into that instrument&#39;s REST &quot;market server&quot;. But then <i>he had two
copies of his bid</i>! One held by the bank server on one URI, and the other in a &quot;bid
collection&quot; held by the market server&#39;s instrument - on another URI.
</p><p>
He asked himself: &quot;Which URI is the real one? Which host &#39;owns&#39; the bid? Is the market&#39;s
copy just a cache? If so, why does it have a new URI? Why doesn&#39;t the market host know
the URI of the bank&#39;s original bid? <i>Why can&#39;t servers become clients and just GET the
data that their own data depends upon?</i>&quot; The server seemed to be dominating the 
conversation, not letting its &#39;client&#39; server have a say in things.
</p><p>
Our worried Enterprise Architect noticed that such Service-Orientation permeated REST
practice: there were &quot;REST APIs&quot; to Web sites, or &quot;Web services&quot; with a small &#39;s&#39;. Even
AtomPub had a &quot;service document&quot;!  Some patterns, like AtomPub, offered just simple
read/write data services through the full HTTP method set. Some simply used such a
read/write interface as a wrapper around more complex service functions.
</p><p>
He wondered: &quot;Where&#39;s the Web in REST integration? The Web works great without PUT and
DELETE: isn&#39;t using GET on its own RESTful enough?&quot;
</p><p>
So, remembering something I said about &quot;Symmetric REST&quot;, he contacted me again...
 &#160; ...
</p>

            </div>
        </summary>
        <content type="xhtml" xml:space="preserve">
            <div xmlns="http://www.w3.org/1999/xhtml">

<p>
</p><div class="summary"><p>
Since the day in 2006 that our
<a href="http://duncan-cragg.org/blog/post/getting-data-rest-dialogues/">dialogue</a>
took place with <i>an imaginary eBay Architect</i>, he has been promoted to <i>imaginary
Enterprise Architect</i> in an investment bank!  Convinced by the merits of REST, he took
his enthusiasm for it into his new job and embarked on architecting a trading system
using REST or ROA as an alternative to SOA.
</p><p>
Now, he hit upon a snag: he had a REST &quot;bank server&quot; generating bids on an instrument
and POSTing them into that instrument&#39;s REST &quot;market server&quot;. But then <i>he had two
copies of his bid</i>! One held by the bank server on one URI, and the other in a &quot;bid
collection&quot; held by the market server&#39;s instrument - on another URI.
</p><p>
He asked himself: &quot;Which URI is the real one? Which host &#39;owns&#39; the bid? Is the market&#39;s
copy just a cache? If so, why does it have a new URI? Why doesn&#39;t the market host know
the URI of the bank&#39;s original bid? <i>Why can&#39;t servers become clients and just GET the
data that their own data depends upon?</i>&quot; The server seemed to be dominating the 
conversation, not letting its &#39;client&#39; server have a say in things.
</p><p>
Our worried Enterprise Architect noticed that such Service-Orientation permeated REST
practice: there were &quot;REST APIs&quot; to Web sites, or &quot;Web services&quot; with a small &#39;s&#39;. Even
AtomPub had a &quot;service document&quot;!  Some patterns, like AtomPub, offered just simple
read/write data services through the full HTTP method set. Some simply used such a
read/write interface as a wrapper around more complex service functions.
</p><p>
He wondered: &quot;Where&#39;s the Web in REST integration? The Web works great without PUT and
DELETE: isn&#39;t using GET on its own RESTful enough?&quot;
</p><p>
So, remembering something I said about &quot;Symmetric REST&quot;, he contacted me again...
</p></div><p>
</p><p>
<b>Enterprise Architect:</b> I see we made it into Appendix A of
<a href="http://oreilly.com/catalog/9780596529260/">the REST book</a>
by Richardson and Ruby!
</p><p>
<b>Duncan Cragg:</b> Indeed - even though I hadn&#39;t finished writing up our chat when it was
published...
</p><p>
<b>EA:</b> So why <i>did</i> it take you so long to write it up?
</p><p>
<b>DC:</b> Well, I, er, got distracted by
<a href="http://www2007.org/prog-Developers.php#saturday">Web 2.0</a> and
<a href="http://the-u-web.org/">Mobile 2.0</a>!
</p><p>
But I&#39;m back now, intending to focus more on ROA&#39;s advantages over SOA.
</p><p>
<b>EA:</b> Great! Because I wanted to talk to you about that.
</p><p>
Where I now work, we are looking at REST or ROA as an alternative to SOA. However, all the
available REST patterns still seem to see the world through Service-Oriented eyes.
</p><p>
I want to do REST like the Web does: to have different servers just publishing stuff that&#39;s
all linked up. And &quot;mashed up&quot;: to have that stuff, that data, &quot;over here&quot; depend on
that data &quot;over there&quot;: meaning that servers can be clients and vice-versa.
</p><p>
<b>DC:</b> Hyperdata that depends on someone else&#39;s hyperdata!  Maybe rewrite rules over
interlinked XHTML. 
</p><p>
I called it &quot;REST Observer&quot; back then, but
<a href="http://tech.groups.yahoo.com/group/rest-discuss/message/13266">recent events</a>
on the rest-discuss mailing list have left me very wary of using the word &#39;REST&#39; so
openly in the name of something!
</p><p>
So I decided to hide it within a different word: 
&#39;<a href="http://duncan-cragg.org/blog/post/forest-functional-observer-rest/">FOREST</a>&#39;!
</p><p>
Here is a 
<a href="http://tech.groups.yahoo.com/group/rest-discuss/message/13765">posting</a>
about FOREST that I recently made to the rest-discuss mailing list:
</p><p>&#160;</p><p>
<b>FOREST</b>
</p><p>
FOREST is a GET-only REST Integration Pattern defined simply as:
</p><p>
</p><blockquote class="others-content"><div><p>
A resource&#39;s state depends on the state of other resources that it links to.
</p></div></blockquote><p>
</p><p>
This means that resource servers must also be clients in order to see those dependencies.
</p><p>&#160;</p><p>
<b>Common Web Pattern</b>
</p><p>
FOREST is a REST Pattern derived from GET-only or polling Web use-cases, including mashups:
</p><p>
</p><ul>
<li>feed aggregators or filters</li>
<li>search index results pages</li>
<li>pages that depend on a search</li>
<li>Google&#39;s mobile versions of pages</li>
<li>sites that create summaries of other Web pages</li>
<li>sites that create feeds from Web pages</li>
<li>creating pages or feeds from REST &#39;APIs&#39; (GET only)</li>
<li>Yahoo Pipes</li>
</ul><p>
</p><p>&#160;</p><p>
<b>Going Enterprisey</b>
</p><p>
FOREST is a REST Pattern for building &quot;Enterprise Mashups&quot; in an ROA / WOA / SOA.
</p><p>
OK - those of you without Dion Hinchcliffe in your feed reader may be feeling a little
queasy at this point, but I&#39;d encourage you to read on ... Actually, I quite like the
phrase &quot;Enterprise Mashup&quot; since it lightens the gravity of that &#39;Enterprise&#39; word.
</p><p>
<a href="http://www.openmashup.org/omadocs/v1.0/emml/createMashupScript.html">Enterprise Mashup Markup Language</a>
is the nearest thing to this that I know about, but FOREST is quite different: it is
much simpler and is /only/ a REST Pattern.
</p><p>&#160;</p><p>
<b>Patterns can be implemented in frameworks...</b>
</p><p>
A FOREST implementation would inevitably be over HTTP. It would initially be just XHTML
or Atom. I imagine fetching XHTML resources within which are expected to be links to
more such documents. Any XHTML could depend on any other, and they&#39;re all interlinked.
If you depend on another resource, you must have found it directly or indirectly through
links in your body. Alternative discovery: a resource could be told that it is being
watched using an HTTP header in the GET request listing the URIs of the resources that
depend on it - then it could watch and link back.  Etag would be used for an
automatically incremented version number.
</p><p>&#160;</p><p>
<b>Rough Consensus and Working Code</b>
</p><p>
I would ideally see this work towards a formal description via &quot;rough consensus and
working code&quot;. I intend to knock up a prototype of FOREST in a Jetty servlet and post it
to GitHub; if that code works, I may get rough consensus...
</p><p>
What a FOREST XHTML/HTTP formalisation would specify: <i>Updated</i>
</p><p>
</p><ul>
<li>use of HTTP headers (Etag, Cache-Control, Content-Location, Referer*)</li>
<li>API*: doc builder, XPath body set/get*, callbacks (observed, notified*)</li>
</ul><p>
Notes (*):
</p><ul>
<li>&#39;Referer&#39; is a possible header for the URIs of dependent resources</li>
<li>the API would be language-independent, but probably Java-like</li>
<li>the XPath &#39;get&#39; would be extended to jump links from doc to doc</li>
<li>every doc jumped to gets observed</li>
<li>&#39;notified&#39; means being told when the GET returns with the observed state</li>
</ul><p>
</p><p>&#160;</p><p>
What a FOREST Java servlet and client library would implement &#39;under&#39; these specs:
</p><p>
</p><ul>
<li>a driver module loader: drivers animate resources through the API</li>
<li>a document cache - in memory and maybe saved to disk or database</li>
</ul><p>
</p><p>
Resource animation would either be by the application of business rules driving the API,
or by adapting between external state and the API.
</p><p>&#160;</p><p>
<b>Amazing</b>
</p><p>
<b>EA:</b> Wow! That&#39;s amazing! Can I help build it?
</p><p>
<b>DC:</b> Of course you can. Know any Java?
</p><p>

</p>

            </div>
        </content>
    </entry>
    
    <entry>
        <id>http://duncan-cragg.org/blog/post/web-objects-ask-they-never-tell-rest-dialogues/</id>
        <title>Web Objects Ask, They Never Tell | The REST Dialogues</title>
        <published>2009-08-13T11:43:00Z</published>
        
        <updated>2009-08-13T11:43:00Z</updated>
        
        <link rel="alternate" type="text/html" href="http://duncan-cragg.org/blog/post/web-objects-ask-they-never-tell-rest-dialogues/" title="Web Objects Ask, They Never Tell | The REST Dialogues" />
        
        <category term="semanticweb" />
        
        <category term="architecture" />
        
        <category term="declarative" />
        
        <category term="publishsubscribe" />
        
        <category term="p2p" />
        
        <category term="app" />
        
        <category term="microformats" />
        
        <category term="dialogue" />
        
        <category term="event-driven" />
        
        <category term="rest" />
        
        <category term="scalability" />
        
        <category term="rest-observer" />
        
        <summary type="xhtml">
            <div xmlns="http://www.w3.org/1999/xhtml">

<p>

In an exclusive nine-part dialogue with <i>an imaginary eBay
Architect</i>, we present an accessible discussion of the 
REST vs. SOA issue.
</p><p>
Although eBay have what they call a &#39;REST&#39; interface, it is, in
fact, a 
<a href="http://duncan-cragg.org/blog/post/strest-service-trampled-rest-will-break-web-20/">STREST</a>
interface, and only works for a few of the many function calls
that they make available via SOAP.
</p><p>
In this <a href="http://duncan-cragg.org/blog/post/getting-data-rest-dialogues/">dialogue series</a>,
I argue the case for eBay to adopt a truly REST approach to
their integration API. 
</p><p>
<b>Part 9: Web Objects Ask, They Never Tell</b>
 &#160; ...
</p>

            </div>
        </summary>
        <content type="xhtml" xml:space="preserve">
            <div xmlns="http://www.w3.org/1999/xhtml">

<p>
</p><div class="summary"><p>
In an exclusive nine-part dialogue with <i>an imaginary eBay
Architect</i>, we present an accessible discussion of the 
REST vs. SOA issue.
</p><p>
Although eBay have what they call a &#39;REST&#39; interface, it is, in
fact, a 
<a href="http://duncan-cragg.org/blog/post/strest-service-trampled-rest-will-break-web-20/">STREST</a>
interface, and only works for a few of the many function calls
that they make available via SOAP.
</p><p>
In this <a href="http://duncan-cragg.org/blog/post/getting-data-rest-dialogues/">dialogue series</a>,
I argue the case for eBay to adopt a truly REST approach to
their integration API. 
</p><p>
<b>Part 9: Web Objects Ask, They Never Tell</b>
</p></div><p>
</p><p>
<b>eBay Architect:</b> You&#39;ve pushed a lot of responsibility up to the business logic and
away from the distribution technologies - away from the HTTP level.
</p><p>
As I understand it, you only want to use HTTP to implement a distributed Observer
Pattern, where clients can become servers?
</p><p>
<b>Duncan Cragg:</b> Indeed. REST can be symmetric when used in integration outside of the
Web. Further, these server-clients can have resources that do their <i>own</i> GET-ing,
with POST <i>callbacks</i>, in order to Observe other resources. I&#39;ve given many examples
of this style.
</p><p>
<b>eA:</b> So how do you program such a distributed system at the business logic level?
</p><p>
<b>DC:</b> Well you need to be able to easily express that the state of a resource depends
on the latest state - the intentions and declarations - of other resources it is Observing.
</p><p>
My vision is that you would express this business logic in a simple, powerful and
expressive declarative language.
</p><p>
<b>eA:</b> Hmmm.. Just try getting all declarative on someone who just wants his share prices
on time!  No-one in business understands such abstract concepts.
</p><p>
<b>DC:</b> Oh no? The favourite programming tool of business is the spreadsheet! 
</p><p>
And HTML is a form of declarative programming: imagine if you had to 
<a href="http://duncan-cragg.org/blog/post/right-way-to-do-ajax-is-declaratively/#comment-507">build your DOM</a>
from the top using Javascript! Or if you had to set all your styles in Javascript
instead of using declarative CSS!
</p><p>
<b>eA:</b> Well I&#39;ve seen some pretty ghastly examples of <i>those</i> two crafts! 
</p><p>
And many failed attempts to allow non-programmers or business analysts to program
directly.
</p><p>
<b>DC:</b> True, but that doesn&#39;t change the fact that most non-programmers can only 
think declaratively - they know What they want, but they haven&#39;t got much of a clue How
to get it.
</p><p>
Business people talk business rules and business data.
</p><p>
<b>eA:</b> We just can&#39;t program with them!
</p><p>
<b>DC:</b> Well, perhaps we just haven&#39;t found the best discipline of pragmatic formalisms
and methodology that will allow those rules to easily become programs.
</p><p>
It&#39;s a 
<a href="http://duncan-cragg.org/blog/post/right-way-to-do-ajax-is-declaratively/">well-supported claim</a>,
though, that declarative programming is simpler, clearer and more productive than imperative.
</p><p>
<b>eA:</b> OK - so how would you actually define these business rules?
</p><p>
<b>DC:</b> You could use a rules engine, or a DSL engine, or even XSLT - if that works for
you. There are 
<a href="http://en.wikipedia.org/wiki/XML_transformation_language">many ways to transform XML</a>.
</p><p>
<b>eA:</b> How would <i>you</i> do it?
</p><p>
<b>DC:</b> I would like to have an XML rewriting and templating system: &quot;if this XPath
or XML template matches Observed XML resource A, this one matches resource B and this
one matches myself, rewrite this and that bit of myself with these bits from A and B&quot;.
</p><p>&#160;</p><p>
<b>Web Objects Ask, They Never Tell</b>
</p><p>
<b>eA:</b> So you want to go around re-creating huge XML documents all the time?
</p><p>
<b>DC:</b> Who said anything about huge? This is another Web thing that doesn&#39;t necessarily
apply to us in REST integration: we don&#39;t need the equivalent of the giant, monolithic
HTML page. We can work in much smaller chunks.
</p><p>
I&#39;d even just call them &#39;objects&#39; rather than resources. Or &#39;Web objects&#39;, if you like. 
</p><p>
They could be little 
<a href="http://duncan-cragg.org/blog/post/content-types-and-uris-rest-dialogues/">XHTML carriers of Microformats</a>.
</p><p>
<b>eA:</b> I thought we&#39;d given up on distributing fine-grained objects back in the 
CORBA days?
</p><p>
<b>DC:</b> Ah, but this isn&#39;t trying to transparently distribute zillions of method 
calls in an RPC model. 
</p><p>
This is about optimising state transfer. Only send what you need, cache where you can,
push when something changes. Separate your data by rate of change, timeliness, cacheability.
</p><p>
<b>eA:</b> So these Web objects don&#39;t have any methods?  Because that would be RPC when
distributed?
</p><p>
<b>DC:</b> Exactly. In REST integration, the Web objects Ask, they never Tell! These Web
objects are reactive: Asking for public state, not Telling each other what to do.
</p><p>
<b>eA:</b> You mean the opposite of
<a href="http://www.pragprog.com/articles/tell-dont-ask">Tell Don&#39;t Ask</a>?
</p><p>
<b>DC:</b> Yes. As an object, you don&#39;t Tell another object How to do something, you Ask for
What you want by either simply Observing its public state or by it Observing yours, then
letting it decide How to evolve by itself. You then watch it and react or interact.
</p><p>
It&#39;s the &quot;imperative to declarative inversion&quot;: everything is turned upside-down or
inside-out when you distribute things this way!
</p><p>
<b>eA:</b> Oh yes, your &quot;inevitable inversion&quot; thing.
</p><p>
<b>DC:</b> Another indication of this inversion from the imperative object-oriented world
to the declarative ROA world is how the derided &#39;train wrecks&#39; of object-orientation now
become the essential XPaths of the object Web. 
</p><p>
You could say we have no methods, only &#39;getters&#39;, and XPath &#39;train wrecks&#39; are encouraged!
</p><p>
<b>eA:</b> Doesn&#39;t sound too safe to me - it breaks encapsulation, doesn&#39;t it?
</p><p>
<b>DC:</b> Well, it&#39;s actually safe to dig around, since the data is held in shape by a
stable, open, public schema.  You&#39;re expected to go traversing the tree.
</p><p>
And you get excellent encapsulation since Web objects are total masters of their own
destiny: they privately control the evolution of that public state. 
</p><p>
You very much retain the value of &#39;What not How&#39;; in fact, in a much better-defined way
since it&#39;s fundamentally baked in to the programming model.
</p><p>&#160;</p><p>
<b>Hyperdata as the Engine of Object State</b>
</p><p>
<b>eA:</b> But when you write &#39;train wrecks&#39; you often end up jumping from object to
object. How do your object Web XPaths do that, assuming they want to?
</p><p>
<b>DC:</b> <a href="http://en.wikipedia.org/wiki/Hyperdata">Hyperdata</a> of course! Links to links
around the Web. Objects can have their opaque UUIDs or GUID object handles encoded into
their URIs. Then objects can be wired up with XHTML links.
</p><p>
<b>eA:</b> So now your XPath transparently jumps these links?!
</p><p>
<b>DC:</b> Actually, yes! That would then allow us to dynamically break up data into more
manageable chunks without breaking the XPaths that traverse it.  
</p><p>
Also, with this approach, you still get to drill down to data like in transparent URI
paths, but you now use XPaths that are properly a part of the content layer, jumping
transparently <i>over</i> those opaque inter-object URIs.
</p><p>
<b>eA:</b> Would you use these &#39;jumping XPaths&#39; in the rewrite rules you said you wanted?
</p><p>
<b>DC:</b> Of course. Either linear XPaths, or XPath-like XML tree templates on the
left-hand side of a rewrite rule. 
</p><p>
You&#39;d start a template match on yourself, then continue on to match other objects by
jumping over links, then on and on from object to object.
</p><p>
<b>eA:</b> So I suppose any such jump to another object means you then need to start
Observing it, right?
</p><p>
<b>DC:</b> Exactly. And if hyperlinks are the only way you can find other objects to
Observe, it brings us to the following:
</p><p>
<i>Your object&#39;s next public state depends only on its current public state and the states
of those objects that are visible to it through hyperlinks.</i>
</p><p>
<b>eA:</b> Sounds a bit like the &quot;Hypertext As The Engine Of Application State&quot; constraint
of REST.
</p><p>
<b>DC:</b> Exactly! Except now that we&#39;re doing REST symmetrically - now that clients can
be servers, too - client Application State can have its own URIs!
</p><p>
<b>eA:</b> So you could re-phrase this as the even more intimidating: &quot;Hyper<i>data</i> As The
Engine Of Application <i>Resource</i> State&quot;!
</p><p>
<b>DC:</b> Well - how about just &quot;Hyperdata As The Engine Of Object State&quot;?!
</p><p>
<b>eA:</b> So do I have to wait for this link-jumping XML rewrite engine of yours to
express my business logic, in order to get &quot;Hyperdata As The Engine Of Object State&quot;?
</p><p>
<b>DC:</b> No, of course not! Use a nice, dynamic, XML-talking language, like Scala, and
follow the same principle, perhaps using a DSL.
</p><p>
<b>eA:</b> Can&#39;t you have objects that <i>aren&#39;t</i> entirely dependent on others? Like those
that represent external state?
</p><p>
<b>DC:</b> Of course. That&#39;s normal Web stuff. It&#39;s probably best to keep these &#39;pure&#39;: to
have either fully-interdependent objects driven by Hyperdata, or fully externally-driven
ones.
</p><p>&#160;</p><p>
<b>Class, Extension, Instance and Behaviour</b>
</p><p>
<b>eA:</b> Right, so we&#39;ve got these little Web-mapped XHTML Microformat objects all linked
up and watching each other in an Observer Pattern. This object&#39;s state depends on that
linked object&#39;s state according to rewrite rules or a DSL.
</p><p>
So taking this mapping to objects one last step, I presume object &#39;class&#39; maps onto an XML
schema, XHTML Microformat specification or other content type?
</p><p>
<b>DC:</b> Yes. A public grammar in some form. Domain or business classes only, of course,
not low-level classes.
</p><p>
<b>eA:</b> So, does each standard Web object class or type have a standard set of rules
guiding its evolution or behaviour?
</p><p>
<b>DC:</b> Yes. If you see something and recognise its type, you can attempt to interact
with it according to its public specification, and it should, but needn&#39;t, react.
</p><p>
The public specification can define the expected behaviour in the RFC language of MUST
and SHOULD, like AtomPub. Or it can define it in rewrite rules!
</p><p>
<b>eA:</b> So then, how do I add my own business rules to a content type or &#39;class&#39;, if its
behaviour is standardised and meant to be stable and predictable?
</p><p>
<b>DC:</b> There are two ways you can make use of a generic standard, and both are forms of
layering or abstraction: 
</p><p>
You can &#39;mash up&#39; standard component instances with declarative configuration - just
using them as they are for your domain.
</p><p>
Alternatively, you can extend or subclass their standard structures and behaviour to
become themselves more domain-specific.  For example, rules can be overridden or their
right-hand sides merged.
</p><p>
Again, think of how AtomPub can be <i>used</i> in any domain that looks like time-ordered lists
of content; and how you can <i>extend</i> AtomPub without breaking unextended clients or servers.
</p><p>&#160;</p><p>
<b>The REST Observer Pattern</b>
</p><p>
<b>eA:</b> I think you need a memorable name for your symmetric-REST, &quot;Hyperdata As The
Engine Of Object State&quot; architectural style!
</p><p>
<b>DC:</b> How about the &quot;REST Observer Pattern&quot;?
</p><p>
<b>eA:</b> But a Pattern has to be a retro-fit to existing behaviour, and &quot;REST Observer&quot;
is quite new.
</p><p>
<b>DC:</b> I mean REST .. [<i>DC does double bunnie ears</i>] &quot;Observer Pattern&quot;!
</p><p>
<b>eA:</b> Have you got any worked examples of the REST Observer Pattern?
</p><p>
<b>DC:</b> Will have soon...
</p><p>
<i>(c) 2006-2009 Duncan Cragg</i>
</p><p>&#160;</p><p>
Coming soon: Worked examples of the REST Observer Pattern.
</p><p>
<i>Note that the opinions of our imaginary eBay Architect don&#39;t
necessarily represent or reflect in any way the official
opinions of eBay or the opinions of anyone at eBay.</i>
</p><p>
<i>Indeed, I can&#39;t guarantee that the opinions of our real blogger
necessarily represent or reflect in any way the official
opinions of Roy Fielding...</i>

</p>

            </div>
        </content>
    </entry>
    
    <entry>
        <id>http://duncan-cragg.org/blog/post/ws-are-you-sure-rest-dialogues/</id>
        <title>WS-Are-You-Sure | The REST Dialogues</title>
        <published>2009-07-16T16:16:00Z</published>
        
        <updated>2009-07-16T16:16:00Z</updated>
        
        <link rel="alternate" type="text/html" href="http://duncan-cragg.org/blog/post/ws-are-you-sure-rest-dialogues/" title="WS-Are-You-Sure | The REST Dialogues" />
        
        <category term="architecture" />
        
        <category term="declarative" />
        
        <category term="publishsubscribe" />
        
        <category term="p2p" />
        
        <category term="app" />
        
        <category term="dialogue" />
        
        <category term="event-driven" />
        
        <category term="rest" />
        
        <category term="atom" />
        
        <summary type="xhtml">
            <div xmlns="http://www.w3.org/1999/xhtml">

<p>

In an exclusive nine-part dialogue with <i>an imaginary eBay
Architect</i>, we present an accessible discussion of the 
REST vs. SOA issue.
</p><p>
Although eBay have what they call a &#39;REST&#39; interface, it is, in
fact, a 
<a href="http://duncan-cragg.org/blog/post/strest-service-trampled-rest-will-break-web-20/">STREST</a>
interface, and only works for a few of the many function calls
that they make available via SOAP.
</p><p>
In this <a href="http://duncan-cragg.org/blog/post/getting-data-rest-dialogues/">dialogue series</a>,
I argue the case for eBay to adopt a truly REST approach to
their integration API. 
</p><p>
<b>Part 8: WS-Are-You-Sure (Security, Reliable Messaging and Transactions)</b>
 &#160; ...
</p>

            </div>
        </summary>
        <content type="xhtml" xml:space="preserve">
            <div xmlns="http://www.w3.org/1999/xhtml">

<p>
</p><div class="summary"><p>
In an exclusive nine-part dialogue with <i>an imaginary eBay
Architect</i>, we present an accessible discussion of the 
REST vs. SOA issue.
</p><p>
Although eBay have what they call a &#39;REST&#39; interface, it is, in
fact, a 
<a href="http://duncan-cragg.org/blog/post/strest-service-trampled-rest-will-break-web-20/">STREST</a>
interface, and only works for a few of the many function calls
that they make available via SOAP.
</p><p>
In this <a href="http://duncan-cragg.org/blog/post/getting-data-rest-dialogues/">dialogue series</a>,
I argue the case for eBay to adopt a truly REST approach to
their integration API. 
</p><p>
<b>Part 8: WS-Are-You-Sure (Security, Reliable Messaging and Transactions)</b>
</p></div><p>
</p><p>
<b>Duncan Cragg:</b> So, back to your list of Enterprise functions. We&#39;re on to what I&#39;m
going to call the &#39;WS-Are-You-Sure&#39;: Security, Reliable Messaging and Transactions.
</p><p>
Let&#39;s attack these <a href="http://www.coactus.com/blog/2007/01/starting-with-the-web/">Starting with the Web</a>!
</p><p>
<b>eBay Architect:</b> We could start with Security: authentication, authorisation and
encryption.  For example, you have to keep some information secret on eBay.  Like
Invoices, Offer details. Reserve price on an Item. And you have to ensure only the
owners of data can change it.
</p><p>
<b>DC:</b> The simplest pattern for read security is to use 
<a href="http://tools.ietf.org/html/rfc2617">HTTP Basic Authentication</a> over 
<a href="http://tools.ietf.org/html/rfc2246">TLS</a> - following 
<a href="http://tools.ietf.org/html/rfc2818">HTTPS</a>.  Simple, but well-supported
and usually good enough. 
</p><p>
But with HTTPS you lose some of the benefits of using intermediaries, such as cacheing.
If those intermediaries are untrustworthy, then you can use message-level rather than
transport-level security: encrypt the resource state being transferred.
</p><p>
<b>eA:</b> Can&#39;t I use WS-Security for this?
</p><p>
<b>DC:</b> <a href="http://www.isecpartners.com/files/iSEC_HILL_AttackingXMLSecurity_bh07.pdf">Possibly</a>(PDF)!
However, the benefits of cacheing may be lost in the time taken to package and unpackage
each resource in turn. You may prefer a
<a href="http://www.wanderingbarque.com/nonintersecting/?year=2007&amp;monthnum=05&amp;day=25&amp;name=message-level-security-and-rest">more lightweight approach</a>
as suggested in the <a href="http://tools.ietf.org/html/rfc4287">Atom</a>
and <a href="http://tools.ietf.org/html/rfc5023">AtomPub</a> specs.
</p><p>
<b>eA:</b> How does REST handle authorisation: such as read and write permissions?
</p><p>
<b>DC:</b> As I keep saying, REST is about much more than simple data read/write services.
In REST we don&#39;t have the generic concept of authorisation on a specific process
execution, such as a command that could cause state change. 
</p><p>
REST infrastructure is about state transfer, which is thus really only about &#39;read permissions&#39;.
</p><p>
Everything else is business logic: it&#39;s up to the target resource to manage its reaction
to incoming non-GETs and to decide if or how it should change in response, according to
internal integrity constraints and the identity of the source.  Resources are masters of
their own destiny and must be aware of the identity of interacting parties at that level.
</p><p>
<b>eA:</b> What <i>can</i> you do to secure the infrastructure level below the business logic?
</p><p>
<b>DC:</b> The department managing the infrastructure can see data going either out (GET)
or in (POST), and can see the target URIs. They can thus do both server- (URI) and
client- (request header) based security and partitioning.
</p><p>
For read permission, it&#39;s possible to implement a low-level lookup from the identity
in the request header to whatever URIs they can GET.  They can enforce simple rules at
that level like &#39;only GETs are allowed on these URIs unless the client is in this list&#39;.
They can groom more and less sensitive traffic to different servers.
</p><p>
<b>eA:</b> Any more Security advice?
</p><p>
<b>DC:</b>  Paul Prescod has written some
<a href="http://www.prescod.net/rest/security.html">notes on REST security</a>.
</p><p>
Finally, remember to keep sensitive data out of those highly-propagatable unencrypted
URIs by using POST instead of GET when submitting queries; another reason to use URIs
that are literally opaque, not just treated as opaque operationally.
</p><p>&#160;</p><p>
<b>Reliable Messaging</b>
</p><p>
<b>eA:</b> Another of the WS-* specifications deals with Reliable Messaging. How does REST
give me the assurances I need that an important message - such as a new Offer on an Item
or a ResponseToBestOffer, or an Invoice - will be delivered? In the right order? I can&#39;t
just rely on POST, as you suggested before, if I really care about this.
</p><p>
<b>DC:</b> In REST, there are no command messages that have to make it through. There&#39;s
only state that may or may not need to be reliably transferred - or that may or may not
need to be notified in a timely manner.
</p><p>
In the eBay example, as I 
<a href="http://duncan-cragg.org/blog/post/business-functions-rest-dialogues/">described it before</a>,
&quot;if you keep re-POSTing the same Invoice, or Item or Offer, it only gets created once&quot;.
</p><p>
<b>eA:</b> Ah! Define &#39;same&#39;!
</p><p>
<b>DC:</b> If, as in this eBay example, the successful POST creates a server-side copy with
its own new URI, then the Item, Invoice, etc, must have some uniquely identifying
information on it. It could perhaps have a
<a href="http://devhawk.net/2007/12/05/Durable+And+RESTful.aspx">Message-ID header</a> or
get <a href="http://www.prescod.net/reliable_http.html">cheap, unique URIs minted for it</a>
from the server in advance.  Alternatively, when the POSTed resource already has a URI
itself on the &#39;client&#39;, then it&#39;s obviously the same each time it&#39;s POSTed.
</p><p>
When used as state notification, POST must be idempotent; repeatable.
</p><p>
So if the initial POST fails, just keep POSTing until you can see the appropriate
response, whatever that may be in business terms. On the pull or poll side, keep GETing
until you see what you expect.
</p><p>
<b>eA:</b> So that&#39;s another issue you&#39;re side-stepping by dumping it into the business
logic?!
</p><p>
<b>DC:</b> Only the business logic knows the following things: what signifies receipt of
the notification; if it matters that the state didn&#39;t get through; how frequently to
push or poll; whether it matters that state is out of date and by how much; and when to
give up and tell someone.
</p><p>
Set the push or pull frequency and total number according to the business logic&#39;s view
of the importance of that state transfer.  Set cache control according to your domain&#39;s
tolerance of stale data.
</p><p>
It&#39;s just like in real life: if something I sent doesn&#39;t get a response - in a form that
is completely dependent on the type of recipient - then, after a time - which is also
completely dependent on the type of recipient - I&#39;ll chase it up.
</p><p>
<b>eA:</b> Can&#39;t REST give any support here at all?
</p><p>
<b>DC:</b> Well, it would be easy enough to write a REST support library that implemented a
simple API for specifying your constraints on a successful state transfer.
</p><p>&#160;</p><p>
<b>Transactions</b>
</p><p>
<b>eA:</b> Now, when you&#39;re a site like eBay, dealing with money all the time, you need the
assurance that transactions give you. You need to make sure accounts are always
consistent. But I suppose, like
<a href="http://duncan-cragg.org/blog/post/inter-enterprise-rest-integration-rest-dialogues/">before</a>,
you&#39;re going to tell me that it&#39;ll all be fine in the end, right?
</p><p>
<b>DC:</b> Hold on. Let&#39;s not mix up financial transactions and database transactions!
We&#39;ll first talk about the need for atomic units of work.  Then see how to support
financial transaction business logic. 
</p><p>
Also, we&#39;re talking about units of work in public view, not hidden behind resources.
Inside, it&#39;s up to a resource to ensure that its integrity and consistency are
maintained through its interactions with others, and it&#39;s free to use transactions to 
achieve that internally if it wants, without exposing that to its clients.
</p><p>
<b>eA:</b> OK - so now say that it&#39;ll all be fine in the end!
</p><p>
<b>DC:</b> In a distributed system, you have to decide on what to give up out of 
<a href="http://queue.acm.org/detail.cfm?id=1394128">Consistency, Availability and Partition Tolerance</a>.
</p><p>
I have to say that eBay are actually fully clued here: that was a paper about &#39;BASE&#39; by
<a href="http://www.addsimplicity.com/">Dan Pritchett</a>, Technical Fellow at eBay, in which he
discusses the benefits of
<a href="http://www.infoq.com/news/2008/01/consistency-vs-availability">Eventual Consistency</a> - 
i.e., knowing that it&#39;ll all be fine in the end! Especially if you
<a href="http://glinden.blogspot.com/2006/12/talk-on-ebay-architecture.html">tidy things up eventually</a>.
</p><p>
<b>eA:</b> Gah! Ya got me there!
</p><p>
<b>DC:</b> Essentially, the rule of thumb is, use ACID internally, use BASE externally.
</p><p>
We&#39;re back to the inevitable inversion from internal imperative thinking to external
declarative thinking.  
</p><p>
As an imperative programmer you&#39;re inclined to want to take your internal programming
style out into the distributed world - to think single-thread, central control: &#39;begin - do
work - commit&#39;.
</p><p>
But the importance of Availability and Partition Tolerance in distributed systems
usually outweighs the importance of Consistency, leading the wise architect to a more
relaxed, less imperative, more declarative approach.
</p><p>
<b>eA:</b> Such as REST.
</p><p>
<b>DC:</b> Indeed. REST without
<a href="http://www.jboss.org/community/wiki/TransactionalsupportforJAXRSbasedapplications">transaction support</a>.
</p><p>
REST isn&#39;t a database model: in the same way REST doesn&#39;t imply simple read/write
services, it also doesn&#39;t imply inert data that needs locking. And resources in REST
should model active domain data, not low-level, domain-independent 
<a href="http://www.rgoarchitects.com/nblog/2009/06/15/TransactionsAreBadForREST.aspx">transaction paraphenalia</a>.
</p><p>
<b>eA:</b> How does REST without transactions work, BASE-ically, then?
</p><p>
<b>DC:</b> A handy phrase that sums it up is <i>intention puts the system in tension</i>.
</p><p>
You start by declaring your intention that some state be true, which puts the system in
tension - a tension that can only be resolved by the application of business logic
constraints over each player in parallel, until the whole system settles or resolves
into a new, consistent state.
</p><p>
<b>eA:</b> Examples, please!
</p><p>
<b>DC:</b> Think about how you&#39;d do the classic transfer of funds between accounts, in the
real world of loosely interacting, self-determined parties. Say inside a big company 
before computers came along, between an office that handles one account and an office
that handles the other.  
</p><p>
Your key resource is a signed declaration (the intention) by the payer that they are
happy to have funds passed to the payee. As long as this fact doesn&#39;t appear in one
account or the other, you have work to do (there is tension in the business rules). 
</p><p>
<b>eA:</b> You&#39;ve got to run around real quick with a piece of paper.
</p><p>
<b>DC:</b> It doesn&#39;t even need to happen all at the same time: you can visit one office,
check the funds are available and deduct the amount, then wander over to the other
office and tell them to increase the payee&#39;s balance. If you get waylaid and the
auditors come, there is always the signed declaration and the account history available
to resolve the situation.
</p><p>
You can enforce the constraint that no money appears to be in two places with the
business rule that the payee account is only increased if the payer&#39;s account has an
entry corresponding to the signed declaration.
</p><p>
<b>eA:</b> Mmm. Sounds a bit too loosely coupled to me.
</p><p>
<b>DC:</b> It&#39;s life outside of Central Control. 
</p><p>
Consider hotel and flight booking: you don&#39;t lock the hotel and the flight while telling
them all in a two-phase commit what your itinerary will be. You do &#39;optimistic locking&#39;
with compensation: if things don&#39;t work out, you cancel a booking. A system may tell you
something is available, but when it comes to booking it may have just been taken.
</p><p>
The real, distributed, reactive world doesn&#39;t work in a lock-step fashion, so our
distributed, reactive systems don&#39;t need to work that way to model it. Reality is much
more like optimistic locking with the possibility of compensation or merge on conflict
that, again, can only be defined at the business level.
</p><p>
<b>eA:</b> Why not do your optimistic locking below that? HTTP has support for it, right?
</p><p>
<b>DC:</b> In the same way that REST can support read permissions but is at the wrong level
for write permissions, which are a business level concern, there is an asymmetry in read
versioning versus write versioning.
</p><p>
While using Etags is great for optimising the reading and cacheing of data, I wouldn&#39;t
use them in the optimistic locking pattern for writes that is supported by HTTP.  The
proper place for handling a mismatch of versions in an interaction is not in the HTTP
headers.  
</p><p>
REST should be about state declaration and intention, not absolute write commands. Only
the business logic governing the evolution of a resource knows if, for example, it can
go ahead and respond anyway to an edit request, even though it&#39;s possible that the sender
has an out-of-date copy of it.
</p><p>
<i>(c) 2006-2009 Duncan Cragg</i>
</p><p>&#160;</p><p>
In Part 9: <a href="http://duncan-cragg.org/blog/post/web-objects-ask-they-never-tell-rest-dialogues/">Web Objects Ask, They Never Tell</a>
</p><p>
<i>Note that the opinions of our imaginary eBay Architect don&#39;t
necessarily represent or reflect in any way the official
opinions of eBay or the opinions of anyone at eBay.</i>
</p><p>
<i>Indeed, I can&#39;t guarantee that the opinions of our real blogger
necessarily represent or reflect in any way the official
opinions of Roy Fielding...</i>

</p>

            </div>
        </content>
    </entry>
    
    <entry>
        <id>http://duncan-cragg.org/blog/post/business-conversations-rest-dialogues/</id>
        <title>Business Conversations | The REST Dialogues</title>
        <published>2008-12-11T11:45:00Z</published>
        
        <updated>2008-12-11T11:45:00Z</updated>
        
        <link rel="alternate" type="text/html" href="http://duncan-cragg.org/blog/post/business-conversations-rest-dialogues/" title="Business Conversations | The REST Dialogues" />
        
        <category term="architecture" />
        
        <category term="declarative" />
        
        <category term="strest" />
        
        <category term="app" />
        
        <category term="dialogue" />
        
        <category term="event-driven" />
        
        <category term="rest" />
        
        <summary type="xhtml">
            <div xmlns="http://www.w3.org/1999/xhtml">

<p>

In an exclusive nine-part dialogue with <i>an imaginary eBay
Architect</i>, we present an accessible discussion of the 
REST vs. SOA issue.
</p><p>
Although eBay have what they call a &#39;REST&#39; interface, it is, in
fact, a 
<a href="http://duncan-cragg.org/blog/post/strest-service-trampled-rest-will-break-web-20/">STREST</a>
interface, and only works for a few of the many function calls
that they make available via SOAP.
</p><p>
In this <a href="http://duncan-cragg.org/blog/post/getting-data-rest-dialogues/">dialogue series</a>,
I argue the case for eBay to adopt a truly REST approach to
their integration API. 
</p><p>
<b>Part 7: Business Conversations</b>
 &#160; ...
</p>

            </div>
        </summary>
        <content type="xhtml" xml:space="preserve">
            <div xmlns="http://www.w3.org/1999/xhtml">

<p>
</p><div class="summary"><p>
In an exclusive nine-part dialogue with <i>an imaginary eBay
Architect</i>, we present an accessible discussion of the 
REST vs. SOA issue.
</p><p>
Although eBay have what they call a &#39;REST&#39; interface, it is, in
fact, a 
<a href="http://duncan-cragg.org/blog/post/strest-service-trampled-rest-will-break-web-20/">STREST</a>
interface, and only works for a few of the many function calls
that they make available via SOAP.
</p><p>
In this <a href="http://duncan-cragg.org/blog/post/getting-data-rest-dialogues/">dialogue series</a>,
I argue the case for eBay to adopt a truly REST approach to
their integration API. 
</p><p>
<b>Part 7: Business Conversations</b>
</p></div><p>
</p><p>
<b>eBay Architect:</b> Now, I have a few more questions about the areas where REST is
generally considered to be weaker than SOA.  I&#39;ll start with a big list, then we can go
through each one. 
</p><p>
<b>Duncan Cragg:</b> OK, go ahead!
</p><p>
<b>eA:</b> Right - it&#39;s basically the list of techniques you need to architect complex
distributed applications: Service Discovery, Service Description, Client/Server Session
State, Business Process Coordination, Workflow, Orchestration, Choreography; Security,
Reliable Messaging and Transactions.
</p><p>
<b>DC:</b> Phew! Well, some of these 
<a href="http://en.wikipedia.org/wiki/Begging_the_question">beg the question</a>;
by assuming you need them, you end up concluding that you need SOA!
</p><p>
Also, seeing WS-standards for these things, some people think that SOA has them covered
and that their work is done.  But you still have to design and architect your system on
top of these standards, to meet the business need.
</p><p>
In REST or ROA, we&#39;re talking about a different way of seeing distributed
systems that requires a break from Service- (and even Object-)
Oriented thinking and an embrace of Resource-Oriented thinking. 
</p><p>
<b>eA:</b> So what&#39;s the REST way of approaching my list?
</p><p>
<b>DC:</b> Do things the REST way and there are three possibilities: (a) that it&#39;s easy to
implement these functions in REST; (b) that you don&#39;t need these things anyway, or (c)
that it&#39;s already your job to do them as an application architect; it&#39;s part of your
business process, so you do work that you needed to do anyway in SOA, but do it in a
simpler and more powerful way.
</p><p>
<b>eA:</b> Already my job?
</p><p>
<b>DC:</b> It&#39;s your job while you&#39;re designing your resource interactions at the
application level: the resource-type or business level. Or maybe while you&#39;re making use
of some existing resource types and &#39;resource-animating&#39; code that does your business
logic for you.  Having WS-* only clouds and complicates this task.
</p><p>
<b>eA:</b> You&#39;ve just hand-waved away a billion-dollar standardisation and tooling
industry!
</p><p>
<b>DC:</b> Standards and tools are essential - we need them.  But simple standards and
tools are best. HTTP, URI, XML and standard schemas are perfectly good enough standards
to get started with, guided by the REST or ROA mind-set.
</p><p>
I&#39;ll grant that we do need some extra help to support RESTful resource interaction in
our domains and applications.  I would like a few more standards and tools, over and
above HTTP and XML, to help me build these complex distributed applications. Some help
configuring and programming the way an application&#39;s resources interact at a business level.
</p><p>
<b>eA:</b> What exact support would you like for REST integration?
</p><p>
<b>DC:</b> We would benefit from standards, tools and frameworks that help define resource
URIs, mapping to GETable and POSTable URIs, easy cache control, easy support for various
response codes, HTTP Auth-based and URI-based identity, inter-resource links,
collections, content types, Microformat support, useful schemas, structures, sets of
simple default behaviours, APP libraries, business rule engines, etc.
</p><p>
It is still early days for the adoption of REST - an adoption that&#39;s undoubtedly been
slowed by the industry&#39;s obsession with SOA. We do have Restlet and the 
<a href="https://jsr311.dev.java.net/nonav/releases/1.0/spec/index.html">JSR 311</a>
work, as well as some help from Microsoft in WCF and the ADO.NET Data 
Services Framework, but there is still much more that could be done.
</p><p>
<b>eA:</b> Indeed. There&#39;s lots of work to do to catch up with all the SOA standards, tools
and frameworks!
</p><p>
<b>DC:</b> I really don&#39;t want ROA to compete with SOA in bureaucracy and vendor
in-fighting! But REST needs much less than SOA. Some things are simply part of REST: you
discover stuff by following links; you know what something can do for you because of its
content type or schema - we went over this sort of thing before.
</p><p>&#160;</p><p>
<b>Service Discovery and Description</b>
</p><p>
<b>eA:</b> So, following links and seeing content types cover REST &#39;Service Discovery&#39; and
&#39;Service Description&#39;?
</p><p>
<b>DC:</b> Yes. When you start thinking in terms of resources not actions, it all becomes
much clearer:
</p><p>
In real life you might walk up the street, ask someone where the nearest shoe shop is or
consult a directory, then see a likely shop, decide it may have what you want, then go
in to investigate. Inside, you may consult more directories or just wander around. You
see the cues around you (shoes on offer, checkout desk), and act or react accordingly.  
</p><p>
You engage at a chosen level of understanding: there is a generic concept of street
layout, then generic shop and shop assistant understanding, then an understanding of how
to view and interact in shoe shops in particular.
</p><p>
<b>eA:</b> And in &#39;virtual life&#39;?
</p><p>
<b>DC:</b> The Web is exactly the same: you explore through links or by asking a search
engine, see what you want, enter the online shop, follow the cues, etc. It&#39;s no accident
that the cyberspace metaphor is often applied to the flat, 2D Web.
</p><p>
<b>eA:</b> And in REST integration?
</p><p>
<b>DC:</b> In REST integration, the metaphor can be extended for machine interaction: get a
list of items by direct reference or by query, go through them finding something that
matches, interact according to standard business types and follow links between business
resources. 
</p><p>
<b>eA:</b> So no service contracts for you, then, just exploring and hoping for the best.
Sounds a bit sloppy!
</p><p>
<b>DC:</b> You can do anything with anything in computing, it&#39;s just a matter of what
metaphor is the most powerful or expressive.
</p><p>
You <i>can</i> design your &#39;machine cyberspace&#39; to include contracts if that&#39;s what you need,
just like in real life, and just like we went over with the 
<a href="http://duncan-cragg.org/blog/post/inter-enterprise-rest-integration-rest-dialogues/">eBay/gBay example</a>.
</p><p>
But in general - especially when building distributed systems - it&#39;s best to start with
loose arrangements and established conventions; adding constraints, contracts and
Central Control only where absolutely necessary. Ensure central control only over
schemas.
</p><p>
Make your Enterprise &#39;mashable&#39; and everyone will thank you.  Expose the UUIDs and GUIDs
of your data in URLs. Transform and enrich your data within standard content types. Link
it all up with your own data and data from elsewhere. Allow two-way interaction. Then
publish it for future generations to discover and re-use!
</p><p>&#160;</p><p>
<b>Client State and Sessions</b>
</p><p>
<b>eA:</b> Right, now how do you model complex state transitions, state evolution and
conversations within a changing context, in a supposedly stateless architecture?
</p><p>
<b>DC:</b> There&#39;s a common misunderstanding about REST that its statelessness should
extend above the protocol (e.g., HTTP) into the application. On the contrary - once
above HTTP and into a Resource-Oriented application, it&#39;s <i>all</i> about state - as long
as that state has a URI!
</p><p>
All the stateless requirement is saying in practical terms is that each HTTP request and
response exchange is a one-off as far as HTTP is concerned. It means that you don&#39;t need
to tie successive exchanges together at the protocol level, which makes implementing
HTTP easier. HTTP just wants a URI to be a URI, and the content there to be manageable
via headers; and HTTP doesn&#39;t and shouldn&#39;t introspect either the URI or the content.
</p><p>
<b>eA:</b> So where do you keep the conversation state, then?
</p><p>
<b>DC:</b> Above HTTP in the world of URI-tagged state. You can have an ongoing
&#39;conversation&#39; between a client and a server resource - as long as those resources are
linkable and fetchable. 
</p><p>
You don&#39;t need sessions below the resource level; below the business level. If your
application truly demands the concept of a sequence of interactions with a start point
and an end point, then go ahead and implement it - at the application or domain level,
not at the framework level.
</p><p>
Most applications can use <i>ad hoc</i>, asynchronous interactions, where the client
identifies itself each time with Authorization headers.
</p><p>
<b>eA:</b> Can each client machine have assigned to it dedicated server resources as part
of this conversation, sort of like an explicit session state?
</p><p>
<b>DC:</b> Yes.  Cacheability and linkability are clearly affected, but if it truly makes
sense in your domain model to have client-specific resources, then just do it - by
definition their scalability and findability is limited to that client!  The client can
still cache its own view, as in a browser, and even intermediate proxies can, although
it&#39;s of benefit to only one client.
</p><p>
<b>eA:</b> Presumably it&#39;s a bad idea to put client state in a Cookie header?
</p><p>
<b>DC:</b> Yup: it&#39;s not got a URI, so its state is hidden. Put it on a URI in a server.
</p><p>
Hidden state is a red flag.
</p><p>
You know you&#39;re on the right track as long as you are exposing your statefulness
in URIs. It should always be obvious where things stand from inspecting public state
alone, to know what is possible and what will happen next.
</p><p>
If you find yourself hiding state in sessions and cookies, or returning different data
dedicated to that client from the same URI by setting no-cache, or if you tie up
successive interactions through sessions, you are going down the wrong track.
</p><p>
<b>eA:</b> Are cookies always bad?
</p><p>
<b>DC:</b> A Cookie header should be used only to identify the client, not a session. You&#39;d
probably use the Authorization header in REST integration anyway.  Just use Cookie
headers along with an auth scheme if you need a more elaborate, perhaps multi-layered
or proxied, authentication system.
</p><p>
<b>eA:</b> What about the Vary response header and its use with Authorization or Cookie
request headers?
</p><p>
<b>DC:</b> Mechanically, from the cache perspective, adding Vary on client-identifying headers
like these is the same as using per-client URIs; setting the Vary header to allow the URI to
be cached on a per-client basis is a hidden way of effectively adding the identifying
data from the Authorization or Cookie header to the URI itself.
</p><p>
Actual per-client resources are explicit; these Vary&#39;d resources are implicit. You
choose which to use at the application level based on the importance of the resources
being identified in your domain model. Either way, the identity of the requestor can be
used to determine read permissions.
</p><p>
The explicit way means you can pass links to your personal resources to others, modulo
read permissions. A client may or may not be able to or want to pass the link to its
dedicated resources to other players - it probably isn&#39;t a link they want anyway - 
but they can still pass around general jumping-off links, that make sense for other
recipients.
</p><p>
<b>eA:</b> To be honest, I just don&#39;t like the idea of the server saving and distributing a
ton of this client-specific resource data!
</p><p>
<b>DC:</b> There are two answers to this: firstly, now that we&#39;re using REST for business
data integration, not generating entire pages of HTML, the chunks of data can have much
finer grain. The actual amount of client-specific data can be much smaller! You can
cache and share links to all the generic chunks, and only transfer small amounts of less
cacheable and linkable per-client data.
</p><p>
Secondly, our clients in REST integration are also often servers, so can in fact expose
their <i>own</i> state. We may be better off just putting those client-specific resources on the
client itself, to get around this whole issue. The client isn&#39;t a browser any more! 
</p><p>
We&#39;re back to the symmetric
<a href="http://duncan-cragg.org/blog/post/distributed-observer-pattern-rest-dialogues/">Distributed Observer Pattern</a>.
</p><p>&#160;</p><p>
<b>Business Processes</b>
</p><p>
<b>eA:</b> OK, now what about Business Process Coordination, Workflow, Orchestration and
Choreography in that sloppy cyberspace of yours?
</p><p>
<b>DC:</b> We&#39;ve already discussed the auction business process, both
<a href="http://duncan-cragg.org/blog/post/business-functions-rest-dialogues/">single-site</a> and 
<a href="http://duncan-cragg.org/blog/post/inter-enterprise-rest-integration-rest-dialogues/">cross-site</a>,
which was quite a good example that covers a number of business activities.
</p><p>
Another good feature of REST is the way it naturally maps onto declarative business
rules. When you switch from process-thinking to resource-thinking, you also switch from
imperative thinking to declarative. This manifests as inter-resource dependency and
transformation.
</p><p>
<b>eA:</b> Eh?
</p><p>
<b>DC:</b> A spreadsheet is an example of this style, where you declare the way cells
depend on each other and then let the hidden magic take care of satisfying your
constraints. We&#39;ve discussed this style of programming before.
</p><p>
Again, tools will be essential to help with this.  Managing and testing event-driven
business rules over shared and distributed state is somewhat new territory, even to most
REST integrators!
</p><p>
<b>eA:</b> Business Processes and Business Rules seem like different things to me.
</p><p>
<b>DC:</b> Well, as we saw, the business process of an auction can emerge from the local
application of business rules. The thing is to let go of the myth that you benefit from
specifying and controlling some over-arching vision of your business processes - that it
makes sense to centralise control of what actually works best when delegated and
decentralised. 
</p><p>
Just write the local What, not the global How, and let the process emerge!
</p><p>
<b>eA:</b> Might be a hard sell to control freaks.
</p><p>
<b>DC:</b> Yeah, true enough. But it more closely maps onto the reality of the way
businesses operate and interoperate. It&#39;s more about the actual peer-to-peer business
interactions and visible state evolution, and less about central controllers that know
the intimate, inscrutable details of the Web Services involved.
</p><p>
Instead of coordinating the import and export of data from one hand-coded interface to
another, you can just link it all up and expect everyone to dereference and recognise
your data. Instead of coordinating sessions with implicit state, you can just react to
standard, public data types.
</p><p>
<i>(c) 2006-2009 Duncan Cragg</i>
</p><p>&#160;</p><p>
In Part 8: <a href="http://duncan-cragg.org/blog/post/ws-are-you-sure-rest-dialogues/">WS-Are-You-Sure</a> (Security, Reliable Messaging and Transactions).
</p><p>
<i>Note that the opinions of our imaginary eBay Architect don&#39;t
necessarily represent or reflect in any way the official
opinions of eBay or the opinions of anyone at eBay.</i>
</p><p>
<i>Indeed, I can&#39;t guarantee that the opinions of our real blogger
necessarily represent or reflect in any way the official
opinions of Roy Fielding...</i>

</p>

            </div>
        </content>
    </entry>
    
    <entry>
        <id>http://duncan-cragg.org/blog/post/google-micro-conference/</id>
        <title>Google Micro Conference</title>
        <published>2007-10-05T11:22:00Z</published>
        
        <updated>2007-10-05T11:22:00Z</updated>
        
        <link rel="alternate" type="text/html" href="http://duncan-cragg.org/blog/post/google-micro-conference/" title="Google Micro Conference" />
        
        <category term="web2.0" />
        
        <category term="atom" />
        
        <category term="ajax" />
        
        <category term="rest" />
        
        <category term="event-driven" />
        
        <category term="publishsubscribe" />
        
        <category term="p2p" />
        
        <category term="architecture" />
        
        <category term="declarative" />
        
        <category term="app" />
        
        <category term="microformats" />
        
        <category term="scalability" />
        
        <category term="json" />
        
        <category term="openid" />
        
        <category term="microweb" />
        
        <category term="google" />
        
        <summary type="xhtml">
            <div xmlns="http://www.w3.org/1999/xhtml">

<p>

Last night&#39;s 
<a href="http://osjam.truemesh.com/">Google London Open Source Jam</a>
(also <a href="http://www.red-bean.com/ospowiki/LondonOpenSourceJam05Talks">here</a>)
was on the subject of the &#39;Web&#39; (didn&#39;t they invent that? Oh no,
that was Microsoft).
</p><p>
This event has been getting better and better each time I&#39;ve
attended. There were some very interesting lightning talks held
together with a tight structure and plenty of chance to chat,
drink cold Leffe and eat cold pizza. And nick [<i>transatlantic
translation: &#39;steal&#39;</i>] the 
<a href="http://www.greenandblacks.com/uk/productdetails.php?pageid=27&amp;cid=6&amp;pid=11">Green &amp; Black&#39;s chocolate</a>.
</p><p>
An ideal Micro Conference...
 &#160; ...
</p>

            </div>
        </summary>
        <content type="xhtml" xml:space="preserve">
            <div xmlns="http://www.w3.org/1999/xhtml">

<p>
</p><div class="summary"><p>
Last night&#39;s 
<a href="http://osjam.truemesh.com/">Google London Open Source Jam</a>
(also <a href="http://www.red-bean.com/ospowiki/LondonOpenSourceJam05Talks">here</a>)
was on the subject of the &#39;Web&#39; (didn&#39;t they invent that? Oh no,
that was Microsoft).
</p><p>
This event has been getting better and better each time I&#39;ve
attended. There were some very interesting lightning talks held
together with a tight structure and plenty of chance to chat,
drink cold Leffe and eat cold pizza. And nick [<i>transatlantic
translation: &#39;steal&#39;</i>] the 
<a href="http://www.greenandblacks.com/uk/productdetails.php?pageid=27&amp;cid=6&amp;pid=11">Green &amp; Black&#39;s chocolate</a>.
</p><p>
An ideal Micro Conference...
</p></div><p>
I arrived late (it starts at 6pm) and spent some time catching up with
<a href="http://www.flickr.com/photos/92443667@N00/1488471991/in/set-72157602268864450/">ex-Thoughtworks colleagues</a>,
so I missed Dion &quot;Ajaxian&quot; Almaer&#39;s 
<a href="http://www.slideshare.net/dion/future-of-web-apps-google-gears">Google Gears slideset from FOWA</a>.  
Go there now and check it out.
</p><p>
Thus the first talk I saw
was a nifty piece of widgetry by Steven Goodwin called 
<a href="http://www.bluedust.com/minerva/">WARP</a>. In WARP, interacting with a page of
&#39;applets&#39; changed the URL to encode those applets&#39; current state. If
you link to the current page, it will always show that state.
Very long URLs, you can imagine. None of that fancy Ajax stuff.
RESTful, dare I say. Nice API server-side for unpacking your
applet params. 
</p><p>
A trip to the lavatories [<i>transatlantic translation:
&#39;restroom&#39;/&#39;bathroom&#39;</i>] revealed that they are, indeed, doing that
<a href="http://googletesting.blogspot.com/2007/01/introducing-testing-on-toilet.html">Testing in the Toilet</a>
project in Google. It works, too! I learned something. Other intelligence on
Google&#39;s Inner Workings include confirmation of the beanbags and of
the high quality, free grub to which I have already alluded.
</p><p>
A nice bloke from Yahoo! (<a href="http://kid666.com/blog">Tom Hughes-Croucher</a>:
another spy?) came along to sell his idea that, in the
collaborative world of open-minded hackers, we who run websites
could help each other with our 404s. If I get a 404, I use the
referrer link to tell you, via some RESTful POST, that your link to
me is bust (assuming I don&#39;t intend to fix it myself).
</p><p>
I think the world is a little more selfish, so you need to decide
who hurts more - the site who sends their visitors to a dead-end,
or the site delivering that dead-end to a new visitor. I suspect
the latter, by a small margin, as it&#39;s not exactly a nice welcome.
So it&#39;s up to them to let the new visitor down more gently, and to
notify the publisher of the broken link with little or no cost to
them. For example, a really sociable 404-ing site could just
redirect the hapless visitor back to the referring page, adding
&#39;?broken=links&#39; to the URL - hopefully to be picked up by log
scanning scripts at the referring site.
</p><p>
Next up, <a href="http://duncan-cragg.org/">yours truly</a> taking 
<a href="http://www2007.org/prog-Developers.php#saturday">yet another chance</a>
to promote his excellent 
<a href="http://the-u-web.org">Micro Web</a> thingy. 
Couple of people asked about it afterwards - including that nice
chap from Yahoo! Also, a smart - and nice - chap called Toby 
(<a href="http://www.thetobe.com/">this one?</a>) got me into a deep discussion
on imperative vs. event-driven vs. state-driven programming. He was
apparently an old-timer like me, as he was able to engage in
dewy-eyed Functional Programming recollections. I managed to give
out about four full colour printouts about the
<a href="http://the-u-web.org">Micro Web</a>, 
and to collect some good calling cards.
</p><p>
However, <a href="http://joe.truemesh.com">Joe Walnes</a>, even a pint down in
the pub afterwards, still refused to sign up for Micro Web duties.
This in spite of over three years of intensive lobbying, including
eight months of me working Trojan-horse-like in his kitchen, on The 2005
Implementation.
</p><p>
Another ex-Thoughtworks colleague, 
<a href="http://www.pubbitch.org/blog">Simon Stewart</a>
took yet another chance to promote his promising
<a href="http://code.google.com/p/webdriver/">Webdriver</a> thingy. And a very
interesting project it is becoming. Still needs more work - on IE
support, etc - but I&#39;ll probably be using it in my new job at the
<a href="http://www.ft.com">Financial Times</a>.
</p><p>
Another ex-Thoughtworks colleague, 
<a href="http://abc.truemesh.com/">Chris Matts</a> took a chance to promote
his and Andy Pols&#39; interesting new
<a href="http://demo.pols.co.uk/dream/">Dream Machine</a> thingy.
Perhaps a bit like <a href="http://www.cambrianhouse.com">Cambrian House</a> - you put 
your dreams and ideas into it and people expand on them.
Chris is a natural on-stage - and even used the age-old trick of
promising lots of money for no effort, to get our attention at the start.
</p><p>
All I could come up with for the <a href="http://the-u-web.org">Micro Web</a>
was &#39;Cheaper, Wider, Faster&#39;...
</p><p>&#160;</p><p>
<i>Updated: added reference to Dion Almaer, details about WARP, swapped in the 
picture of TWers that I was waiting for and fixed a minor blunder thanks to that 
ever-sharp ThoughtWorker,  
<a href="http://dan.bodar.com/">Dan Bodart</a>..</i>

</p>

            </div>
        </content>
    </entry>
    
    <entry>
        <id>http://duncan-cragg.org/blog/post/how-ruby-can-enable-web-20-platform/</id>
        <title>How Ruby can enable the Web 2.0 Platform</title>
        <published>2007-06-26T15:17:00Z</published>
        
        <updated>2007-06-26T15:17:00Z</updated>
        
        <link rel="alternate" type="text/html" href="http://duncan-cragg.org/blog/post/how-ruby-can-enable-web-20-platform/" title="How Ruby can enable the Web 2.0 Platform" />
        
        <category term="django" />
        
        <category term="web2.0" />
        
        <category term="atom" />
        
        <category term="ajax" />
        
        <category term="yaml" />
        
        <category term="rest" />
        
        <category term="event-driven" />
        
        <category term="publishsubscribe" />
        
        <category term="architecture" />
        
        <category term="declarative" />
        
        <category term="socialsoftware" />
        
        <category term="strest" />
        
        <category term="app" />
        
        <category term="microformats" />
        
        <category term="scalability" />
        
        <category term="json" />
        
        <category term="openid" />
        
        <category term="redux" />
        
        <category term="ruby" />
        
        <summary type="xhtml">
            <div xmlns="http://www.w3.org/1999/xhtml">

<p>

<a href="http://www.oreillynet.com/pub/a/oreilly/tim/news/2005/09/30/what-is-web-20.html">Web 2.0&#39;s definition</a>
includes seeing the Web as an application platform. Which means it
is in competition with Java and .Net, and with SOA, for both local
and widely distributed applications.
</p><p>
If the Web is going to be a platform, the skills you need to learn
to program it are the core Web 2.0 technologies such as Ajax, JSON,
Atom, Microformats and OpenID.
</p><p>
And Ruby. This language, that&#39;s capturing the hearts of many Web 2.0
programmers, is ideal for easing the transition from the Java
and .Net platforms to the Web platform, as I will show.
</p><p>
Even if you&#39;re part of a big company that is generally immune to the
latest trends, the marriage of Ruby and the Web-as-platform may be
something to prepare for. It could even displace your SOA agenda...
 &#160; ...
</p>

            </div>
        </summary>
        <content type="xhtml" xml:space="preserve">
            <div xmlns="http://www.w3.org/1999/xhtml">

<p>
</p><div class="summary"><p>
<a href="http://www.oreillynet.com/pub/a/oreilly/tim/news/2005/09/30/what-is-web-20.html">Web 2.0&#39;s definition</a>
includes seeing the Web as an application platform. Which means it
is in competition with Java and .Net, and with SOA, for both local
and widely distributed applications.
</p><p>
If the Web is going to be a platform, the skills you need to learn
to program it are the core Web 2.0 technologies such as Ajax, JSON,
Atom, Microformats and OpenID.
</p><p>
And Ruby. This language, that&#39;s capturing the hearts of many Web 2.0
programmers, is ideal for easing the transition from the Java
and .Net platforms to the Web platform, as I will show.
</p><p>
Even if you&#39;re part of a big company that is generally immune to the
latest trends, the marriage of Ruby and the Web-as-platform may be
something to prepare for. It could even displace your SOA agenda...
</p></div><p>
Few would disagree that the Ruby language is riding the wave generated
by Ruby-on-Rails. In turn, Rails is riding the Web 2.0 wave, coming
as it does from underpinning the very Web 2.0 
<a href="http://www.37signals.com">37signals</a> 
product suite.  
</p><p>
Rails and Ruby have tapped into the tech Zeitgeist of friendly,
simple and powerful. The speed with which the Ruby and Rails
communities have delivered the key components of Web 2.0 is matched
by the speed at which 
<a href="http://radar.oreilly.com/archives/2007/05/state_of_the_co_10.html">Ruby and Rails books are leaving the shelves</a>.
</p><p>
What is the ideal platform of Web 2.0? Will it be Rails and Ruby?
Will Ruby ride the Web 2.0 wave into the mainstream in the same way
Java rode the Web 1.0 wave?
</p><p>
Well, here&#39;s the problem with that question: Web 2.0 is supposed to
be primarily about the <i>Web</i> itself as the platform, as 
<a href="http://www.oreillynet.com/pub/a/oreilly/tim/news/2005/09/30/what-is-web-20.html">explained first</a>
by Tim O&#39;Reilly and then by a thousand Web 2.0 vendors and industry
watchers after him.
</p><p>
Web-as-platform is not just vendor hype or pundit hand-waving.
Let&#39;s think about what O&#39;Reilly meant by that.
</p><p>&#160;</p><p>
<b>Web as Platform</b>
</p><p>
Web 2.0 is about making the Web more interactive, and thus able to
support applications where Java and .Net would once have been
considered the sole delivery platforms.
</p><p>
The fact that the technologies of the Web can be turned to this
use is a shift with far-reaching implications.
</p><p>
Broadly, the shift we are seeing is from the one-way, static
document delivery of Web 1.0 towards the two-way, dynamic data
exchange of Web 2.0.
</p><p>
This fundamental repurposing is delivering more complex, interactive
applications that work inside our browsers and which fully leverage
the benefits of online operation. 
</p><p>
Web 2.0 is bringing the user and their stuff <i>into</i> the very Web
that they hitherto only passively consumed.  This network-enablement
of the user in turn enables their <i>social</i> networking and their
shared creativity and self-expression. 
</p><p>
Web 2.0 has tapped into a deep human need - a fact reflected in the
vast traffic volumes and correspondingly vast valuations of Web 2.0
startups that we&#39;re currently seeing.
</p><p>
But Web 2.0 is not just for the startups: Enterprise Web 2.0 is
coming! The bigco.com site is going to be looking a little, well,
static and lifeless when compared to the new sites that are
springing up everywhere, and that most of BigCo&#39;s employees are
using. Further, BigCo can gain huge benefits from Web 2.0 approaches
empowering and connecting those employees on the Intranet. And that
Intranet is an ideal platform for deploying company-wide, interactive
applications.
</p><p>
This shift in the Web to two-way dynamic data is being powered by a
set of technologies that a Web platform programmer is going to have
to learn.
</p><p>&#160;</p><p>
<b>Web 2.0 Platform Technologies</b>
</p><p>
Anything that claims to be an application platform must support
data. Web 2.0 is above all the data Web. Web 2.0 is about
semantics, not free text and font sizes. Hence, it inevitably starts
with data-oriented formats such as 
<a href="http://en.wikipedia.org/wiki/XHTML">XHTML</a>, 
<a href="http://www.yaml.org/">YAML</a> and 
<a href="http://json.org/">JSON</a>.  In Web 2.0
more than ever, we talk about data not documents and about
separating data from its presentation.  CSS is big in Web 2.0, for
good reason (not just for gradient fills). Inside the page of a
self-respecting Web 2.0 application, you&#39;ll often find 
<a href="http://microformats.org/">Microformats</a> - again, 
semantics in the page: publishing concise data of widely-understood
standard formats. Some of those Microformats may be 
<a href="http://support.technorati.com/support/siteguide/tags">tags</a>, and in
Web 2.0 the simplest and most powerful semantics are those little
pivot points in Webspace.
</p><p>
Again, if you&#39;re going to be a general purpose platform, you need to
be able to fetch, update, notify and display that data.  Web 2.0
integration usually happens via JSON data structures and 
<a href="http://en.wikipedia.org/wiki/Representational_State_Transfer">REST</a>
interfaces (some of which, especially those based on 
<a href="http://atompub.org/">AtomPub</a>,
are true REST).  Following on from the data-like pages we serve to
browsers, come the data-like feeds we publish to feed readers and to
other applications.  After feeds, the core technology that gives
Web 2.0 its dynamism and interactivity is 
<a href="http://en.wikipedia.org/wiki/Ajax_(programming)">Ajax</a> and 
<a href="http://en.wikipedia.org/wiki/DHTML">DHTML</a>, and
increasingly 
<a href="http://en.wikipedia.org/wiki/Comet_(programming)">Comet</a>
(server push to the browser). The core technology
that gives Web 2.0 its users is increasingly 
<a href="http://openid.net/">OpenID</a>.
</p><p>
All of the above are open technologies. You can do Web 2.0 without
proprietary technologies, just like Web 1.0. Indeed, keeping to the
principles that made the Web successful is also essential to the
success of Web 2.0. The Web platform is the first application
platform that has to consider scalability and interoperability, and
will ignore them at its cost.  I have written before about open
data, use of standard data formats and using REST properly to avoid
creating unscalable, walled-garden sites. You don&#39;t need Flash or
SilverLight, you don&#39;t need vast amounts of custom Javascript, you
don&#39;t need function calls tying you to your servers.
</p><p>&#160;</p><p>
<b>Programming the Web 2.0 Platform</b>
</p><p>
So, we&#39;ve got the dynamic data that you&#39;d expect of a would-be
platform. But how to drive changes in those data? How do we
program the Web platform to animate all this data?
</p><p>
All Rails programmers will know the above technology list; it comes
with the territory. The Web 2.0 Platform can be very succesfully
powered by Rails and Ruby. Ruby and Rails make Web 2.0
applications simple and quick to program, addressing many of the
needs of simple Web 2.0 applications out of the box. There&#39;s little
doubt that Ruby and Rails will have a secure future riding the
Web 2.0 wave.
</p><p>
However, for many Web 2.0 applications, programming may not even be
necessary, at least not in the procedural or imperative style
programmers expect. 
</p><p>
Look back to the early 90&#39;s: &#39;Web 1.0&#39; made a whole class of
applications easy to write without programming: applications for
navigating information. You just wrote in HTML, declaratively.
</p><p>
Now look back at the long path of evolution of Java, through J2EE,
Spring, AOP, IoC, Domain Driven Design, POJOs. All trying to
achieve the simple goal of &#39;remove all that MVC and persistence
stuff and let us concentrate on business or domain objects&#39;. But
they never quite seemed to get it right. 
</p><p>
But then Rails comes along, and has succeeded by simple virtue of
concentrating on easy manipulation of the 
&#39;<a href="http://www.oreillynet.com/pub/a/oreilly/tim/news/2005/09/30/what-is-web-20.html?page=3">Intel Inside</a>&#39;
of Web 2.0 - data. 
</p><p>
It&#39;s reminiscent of the 
&#39;<a href="http://nakedobjects.org/wiki/Main_Page">Naked Objects</a>&#39;
approach to application building with minimal programming (just
business or domain code in POJOs that expose state into the GUI and
are transparently persisted). The 
<a href="http://ajaxian.com/archives/streamlined-naked-objects-for-the-web">Streamlined</a>
project takes Rails even further down this path. Rails&#39; nearest
competitor, <a href="http://www.djangoproject.com/">Django</a>,
has an admin interface that works in a similar way, automatically
generating edit pages based on the data model.
</p><p>
Web 2.0 is about data, about semantics. Web 2.0 is inherently
declarative.  So Web 2.0 applications can be written declaratively -
Web 2.0 mashups can be just wired together and their data animated
by business rules. A bit like programming spreadsheets. 
</p><p>
<a href="http://www.techcrunch.com/2007/03/02/5-ways-to-mix-rip-and-mash-your-data/">Teqlo</a>, 
<a href="http://www.techcrunch.com/2007/04/16/coghead-announces-17000-developers-building-applications-visually/">Coghead</a>, 
<a href="http://www.techcrunch.com/2007/03/02/5-ways-to-mix-rip-and-mash-your-data/">Pipes</a>, 
<a href="http://www.techcrunch.com/2006/03/11/dabbledb-online-app-building-for-everyone/">DabbleDB</a>, 
<a href="http://www.techcrunch.com/2007/06/19/new-site-jumps-into-the-application-creation-space/">LongJump</a>, 
<a href="http://www.techcrunch.com/2007/05/18/microsoft-launches-popfly-mashup-app-creator-built-on-silverlight/">Popfly</a>, 
<a href="http://www.techcrunch.com/2006/08/21/salesforce-dives-deep-into-google-adwords/">AppExchange</a> and
<a href="http://www.techcrunch.com/2006/04/30/wyaworks-app-builder-for-non-coders/">Wyaworks</a> 
are all examples of the different ways to program the new Web 2.0
platform without imperative code.
</p><p>
That&#39;s what we mean by Web-as-platform - not only is the underlying
programming language irrelevant, it will often not even be needed,
certainly for simple data manipulation applications and for many
simple mashups. Being RESTful gives you a massive head start in
this, of course.
</p><p>
While Rails is already in the game with its innate understanding of
Web 2.0 techniques and philosophies, Ruby itself has a huge amount
to offer the would-be declarative programmer, who is making the
transition to this new Web platform from their traditional Java
or .Net platform.  In particular, it is easy to write your domain
logic in a declarative style in Ruby: they call them &#39;DSLs&#39; these
days, but the idea is the same in most examples I&#39;ve seen.
</p><p>&#160;</p><p>
<b>Web 2.0 - The Web Redux</b>
</p><p>
Now, if you&#39;ve been following this blog, you&#39;ll know I have a
few opinions on 
<a href="http://duncan-cragg.org/blog/post/right-way-to-do-ajax-is-declaratively/">Declarative Web 2.0</a> and on
<a href="http://duncan-cragg.org/blog/post/distributed-observer-pattern-rest-dialogues/">patterns for programming REST</a>.
Essentially I argue that, if you want to play in the Web 2.0
platform game, you don&#39;t want to be writing screeds of Javascript
functions that call more functions on your servers. 
</p><p>
I recently presented some ideas along these lines at
the WWW2007 conference, entitled 
&#39;<a href="http://www2007.org/prog-Developers.php#saturday">The Micro Web: putting the Web back into Web 2.0</a>&#39;,
where I also showed a demo written in Python.
</p><p>
This approach combines my 
<a href="http://duncan-cragg.org/blog/post/distributed-observer-pattern-rest-dialogues/">Distributed Observer Pattern</a>
with Comet push to enable highly dynamic Web 2.0 applications to be
coded RESTfully and declaratively, with zero Javascript.  The
Distributed Observer Pattern offers a clean programming model for
animating the Web 2.0 dynamic-data technology set I described above. 
</p><p>
I believe the Observer Pattern is core to the way we&#39;ll be
programming when the Web 2.0 Platform hits mainstream.  It enables
the kind of event- and rule-driven programming that matches the
characteristics of the Web 2.0 dynamic data platform. As a 
further killer benefit, it also directly addresses the optimal
utilisation of multicore processors.
</p><p>
I am currently porting my Python implementation of this approach to
Ruby, in the
<a href="http://rubyforge.org/projects/redux/">Redux</a> 
project on Rubyforge.  Redux stands for &#39;Ruby Event-Driven Update
Exchange&#39;.  It uses the highly scalable
<a href="http://rubyforge.org/projects/eventmachine">EventMachine</a>
epoll-based event loop to power its event-driven architecture.
This will be essential when Redux is asked to scale up a 
Comet-based application.
</p><p>
Like Rails, Redux will be a Web (2.0) application framework, but
unlike Rails, it puts the Observer Pattern and event- and
rule-driven programming at its core. 
</p><p>
Redux&#39;s headline is &#39;Web 2.0 in-a-box&#39; or &#39;Naked Objects on the Web&#39;.
</p><p>&#160;</p><p>
<b>Conclusion</b>
</p><p>
If you&#39;re in BigCo, and are responsible for setting BigCo&#39;s
technical strategy, then train your Java devs up on Web 2.0 core
technologies such as Ajax, JSON, Atom, Microformats and OpenID.  
</p><p>
And fire up their enthusiasm by tapping into Ruby (perhaps via
JRuby) on your way to the Web 2.0 platform. 
</p><p>
Learn patterns for mashing and integrating. Learn about REST and
event- and rule-driven programming, including declarative DSLs.
</p><p>
When this Web platform hits BigCo, you will probably find that its
REST or ROA style make your SOA integration strategy look rather
complex and unweildy.
</p><p>
Check out the
<a href="http://duncan-cragg.org/blog/post/distributed-observer-pattern-rest-dialogues/">Distributed Observer Pattern</a>,
and download
<a href="http://rubyforge.org/projects/redux/">Redux</a>
when it&#39;s done (I&#39;ll let you know if you subscribe here!).
</p><p>
In 2007 and beyond, its the Web itself that&#39;s the platform, not
Java or .Net. But if you want to get there via a language-based
platform, Ruby could be the best way to transition to it.
</p><p>
<i>Note: Everything I said about Ruby and Rails applies equally in
technical terms to Python and Django, but regardless of the
significant benefits of the latter, Ruby and Rails have the Web 2.0
market and mindshare. I&#39;ll probably switch this blog from Django to
Redux sometime this year..</i>
</p><p>
<i>(c) 2007 Duncan Cragg</i>
</p><p>

</p>

            </div>
        </content>
    </entry>
    
</feed>

