<?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 'declarative'</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/declarative/" />

    <updated>2009-12-11T08:22:00Z</updated>


    <entry>
        <id>http://duncan-cragg.org/blog/post/introducing-fjord/</id>
        <title>Introducing Fjord</title>
        <published>2009-12-11T08:22:00Z</published>
        
        <updated>2009-12-11T08:22:00Z</updated>
        
        <link rel="alternate" type="text/html" href="http://duncan-cragg.org/blog/post/introducing-fjord/" title="Introducing Fjord" />
        
        <category term="declarative" />
        
        <category term="json" />
        
        <category term="forest" />
        
        <category term="fjord" />
        
        <summary type="xhtml">
            <div xmlns="http://www.w3.org/1999/xhtml">

<p>

Following on from my recent article where I
<a href="http://duncan-cragg.org/blog/post/deriving-forest/">derived FOREST</a>,
this article offers the beginnings of a JSON unification and rewriting language that
can be used in a FOREST architecture.
</p><p>
Why JSON, not XHTML, now? Well, I recently discovered that
<a href="http://www.google.com/trends?q=json%2C+xhtml">JSON is overtaking XHTML</a>
in interest, and I was further inspired by Kris Zyp&#39;s recent announcement of his
<a href="http://www.ietf.org/id/draft-zyp-json-schema-01.txt">JSON Schema</a>
Internet-Draft.
</p><p>
Fjord is a language for describing how the state of a JSON resource at any time depends
on both its current state and on the state of other JSON resources that it links to via
hyperlinks.  
</p><p>
Fjord is a Norwegian word, probably pronounced &#39;fiyourd&#39;, and might stand for some
combination of the words: &#39;Functional JSON Object/Observer Resource/Rule/Rewrite
Dependencies/Declarations&#39;. Or maybe it&#39;s just because they&#39;re
<a href="http://images.google.co.uk/images?q=fjord">truly awesome</a>, an&#39; I wanna go.
</p><p>
Fjord also gives me an opportunity to show some examples of the &quot;end-user&quot; view of a FOREST
interaction; starting with a simple finance example.
 &#160; ...
</p>

            </div>
        </summary>
        <content type="xhtml" xml:space="preserve">
            <div xmlns="http://www.w3.org/1999/xhtml">

<p>
</p><div class="summary"><p>
Following on from my recent article where I
<a href="http://duncan-cragg.org/blog/post/deriving-forest/">derived FOREST</a>,
this article offers the beginnings of a JSON unification and rewriting language that
can be used in a FOREST architecture.
</p><p>
Why JSON, not XHTML, now? Well, I recently discovered that
<a href="http://www.google.com/trends?q=json%2C+xhtml">JSON is overtaking XHTML</a>
in interest, and I was further inspired by Kris Zyp&#39;s recent announcement of his
<a href="http://www.ietf.org/id/draft-zyp-json-schema-01.txt">JSON Schema</a>
Internet-Draft.
</p><p>
Fjord is a language for describing how the state of a JSON resource at any time depends
on both its current state and on the state of other JSON resources that it links to via
hyperlinks.  
</p><p>
Fjord is a Norwegian word, probably pronounced &#39;fiyourd&#39;, and might stand for some
combination of the words: &#39;Functional JSON Object/Observer Resource/Rule/Rewrite
Dependencies/Declarations&#39;. Or maybe it&#39;s just because they&#39;re
<a href="http://images.google.co.uk/images?q=fjord">truly awesome</a>, an&#39; I wanna go.
</p><p>
Fjord also gives me an opportunity to show some examples of the &quot;end-user&quot; view of a FOREST
interaction; starting with a simple finance example.
</p></div><p>
<b>Instrument, Bids, Asks</b>
</p><p>
Let&#39;s take the simplest possible view of a
<a href="http://www.livemint.com/2009/04/05215410/Ask-Mint--Bidask-spread-all.html">financial market</a>.
</p><p>
There&#39;s an Instrument, and there are Bids and Asks on that Instrument. The Instrument
summarises all the Bids and Asks into the &#39;bid-ask spread&#39;, taking the highest bid price
and the lowest ask price.  Forget volumes, trades and any other detail. 
</p><p>
The Instruments, Bids and Asks are on various servers across various organisations.
That&#39;s the &#39;symmetric REST&#39; part.
</p><p>
Here&#39;s a JSON Instrument resource at the URL shown. It holds three Bid or Ask objects:
</p><pre>
http://the-bank.com/fjord/equity-instrument-23ab33-2319f.json
{
    &quot;tags&quot;: [ &quot;equity&quot;, &quot;instrument&quot; ],
    &quot;long-name&quot;: &quot;Acme Co., Inc&quot;,
    &quot;buyers&quot;: [ 
        &quot;@http://a-bank.com/fjord/equity-bid-9ac0d1-88ce1.json&quot;
    ],
    &quot;sellers&quot;: [ 
        &quot;@http://c-bank.com/fjord/equity-ask-510efb-cca62.json&quot;,
        &quot;@http://d-bank.com/fjord/equity-ask-8560ae-33eff.json&quot;
    ],
    &quot;bid-ask-spread&quot;: {
        &quot;high-bid&quot;: &quot;10.00&quot;,
        &quot;low-ask&quot;:  &quot;14.00&quot;
    }
}
</pre><p>
The &#39;@&#39; character is the flag that this string is a link or a URL.  The meaningful names
in those links are really just for humans and the layers below us - Fjord itself won&#39;t
let you see inside them.
</p><p>
</p><blockquote class="others-content"><div><p>
So now that we&#39;ve introduced a JSON extension making it a hypermedia or hyperdata
type, perhaps we should announce this convention in a media type string. How about 
&quot;<code>application/fjord+json</code>&quot;?  This media type will also serve to set expectations on
everything else about Fjord JSON objects, once the notation is stable.
</p></div></blockquote><p>
</p><p>
Notice that, instead of &#39;class&#39; or &#39;type&#39; or a top-level tag, we have a list of tags.
In Fjord, class is in the eye of the beholder - but, of course, must be a stable grammar
in the eye of the generator!
</p><p>
Right, so here is a new Bid object held at &#39;B&#39; Bank, that the Instrument hasn&#39;t seen yet:
</p><pre>
http://b-bank.com/fjord/equity-bid-0043ee-419ac.json
{
    &quot;tags&quot;: [ &quot;equity&quot;, &quot;bid&quot; ],
    &quot;on&quot;: &quot;@http://the-bank.com/fjord/equity-instrument-23ab33-2319f.json&quot;,
    &quot;price&quot;: &quot;&quot;,
    &quot;by&quot;: &quot;@http://b-bank.com/fjord/hcard-b-bank-4990cd-232b0.json&quot;
}
</pre><p>
It has a pointer to the Instrument it is a bid on, a bid price that isn&#39;t yet set, and a
link to the hCard object of the bank offering the bid and serving this Bid object.
</p><p>
So Bids and Asks can see Instruments and vice-versa, and each can set their own state
accordingly, as part of a FOREST interaction.
</p><p>
The &#39;animation&#39; of Bid, Ask and Instrument JSON object resources is driven by three
simple Fjord rules...
</p><p>&#160;</p><p>
<b>Rule One: Bid Sets Price From Instrument</b>
</p><p>
Here is a rule setting the price of a new Bid to be 10% more than the highest current
Bid on the instrument, hopefully ensuring this Bid is now the high bid:
</p><pre>
{
    &quot;tags&quot;: [ &quot;equity&quot;, &quot;bid&quot; ],
    &quot;on&quot;: { &quot;tags&quot;: [ &quot;equity&quot;, &quot;instrument&quot; ],
            &quot;bid-ask-spread&quot;: { &quot;high-bid&quot;: &quot;/$hibid;decimal/&quot; }
          },
    &quot;price&quot;: &quot;/null/( $hibid * 1.10 )/&quot;
}
</pre><p>
This is a template that matches the Bid object and its dependencies and rewrites part of
the Bid.
</p><p>
<i>Notice how the Bid object&#39;s link to the Instrument object is jumped transparently: the
Bid can &#39;see&#39; right into the Instrument in order to do its matching.  However, it cannot
itself rewrite the Instrument - only Instrument rules can do that.</i>
</p><p>
In Fjord, matching is written with the &#39;/ ; /&#39; notation: each part of this
semicolon-separated list must match. In this case, the high bid has to bind to the
identifier &#39;$hibid&#39; and has to be a decimal. The price must not be set yet. 
</p><p>
The keys &#39;decimal&#39; and &#39;null&#39; are, of course, special reserved words for matching in
patterns.  The &#39;null&#39; matches empty strings, lists and hashes.
</p><p>
The rewrite part follows at the end of a match and is also wrapped in slashes. Here, the
price is being set to the high-bid plus 10%.  The parentheses introduce an expression.
</p><p>
This rule only matches if the price is empty - once set, the rule will not refire.
</p><p>
For more complex rewrites, the following forms can also be used: 
</p><pre>
    &quot;price&quot;: { &quot;/null//&quot;: &quot;( $hibid * 1.10 )&quot; }
    &quot;price&quot;: { &quot;when&quot;: &quot;/null/&quot;, &quot;then&quot;: &quot;( $hibid * 1.10 )&quot; }
</pre><p>
which allow full hashes and lists to be both matched and set.
</p><p>&#160;</p><p>
<b>Rule Two: Instrument Puts New Bid into its Buyers List</b>
</p><p>
The Instrument adds the new Bid to its buyers list with this rule:
</p><pre>
{   &quot;#url&quot;: &quot;/$bid/&quot;,
    &quot;tags&quot;: [ &quot;equity&quot;, &quot;bid&quot; ],
    &quot;on&quot;: { &quot;#url&quot;: &quot;/this/&quot;,
            &quot;tags&quot;: [ &quot;equity&quot;, &quot;instrument&quot; ],
            &quot;buyers&quot;: &quot;/list/has($bid)/&quot;,
    }
}
</pre><p>
This is a rule on the Instrument, that &#39;looks up to&#39; and matches the enclosing Bid.
</p><p>
The &#39;#url&#39; is an optional, reserved-word entry that can only appear at the top of a JSON
resource and holds that resource&#39;s URL. Here, it is bound to &#39;$bid&#39;, picking up the URL
of the Bid object that refers to and encloses this Instrument.
</p><p>
Further down, the &quot;#url&quot; reserved-word value of &quot;this&quot; indicates the start of the
object that this rule applies to. If &quot;this&quot; is absent, then, of course, this is a rule
on the top-level object, as in the first rule above.
</p><p>
The rewrite part matches the buyers list of the Instrument and applies the &#39;has()&#39;
operator which ensures the list now contains the wrapping Bid; it rewrites the list to
include its argument if it doesn&#39;t already. 
</p><p>
If this rule matches two wrapping Bids simultaneously, then &#39;$bid&#39; is set to a &#39;match
set&#39; - a simultaneous binding to the URLs of all of those Bids, and &#39;has()&#39; must ensure
that all of these Bids are now in the list at once.
</p><p>
If there is no change after a rule is applied, the resource&#39;s Etag isn&#39;t incremented, and
dependent rules won&#39;t fire. <i>Fjord may re-apply any rule at any time, usually on an
incoming state change indicated by Etag, so matches have to be designed accordingly.</i>
</p><p>
That&#39;s why we say &#39;has&#39;, not &#39;add&#39;, which would add the Bid again and again each time
the rule is applied. We could say <code>&quot;/list;hasNo($bid)/add($bid)/&quot;</code>, but that&#39;s
uglier and more imperative than declarative.
</p><p>&#160;</p><p>
<b>Rule Three: Instrument Sets Bid-Ask Spread from Bids and Asks</b>
</p><p>
This is what the instrument looks like, now, with the new link to our Bid:
</p><pre>
{
    &quot;tags&quot;: [ &quot;equity&quot;, &quot;instrument&quot; ],
    &quot;long-name&quot;: &quot;Acme Co., Inc&quot;,
    &quot;buyers&quot;: [ 
        &quot;@http://a-bank.com/fjord/equity-bid-9ac0d1-88ce1.json&quot;,
        &quot;@http://b-bank.com/fjord/equity-bid-0043ee-419ac.json&quot;
    ],
    &quot;sellers&quot;: [ 
        &quot;@http://c-bank.com/fjord/equity-ask-510efb-cca62.json&quot;,
        &quot;@http://d-bank.com/fjord/equity-ask-8560ae-33eff.json&quot;
    ],
    &quot;bid-ask-spread&quot;: {
        &quot;high-bid&quot;: &quot;10.00&quot;,
        &quot;low-ask&quot;:  &quot;14.00&quot;
    }
}
</pre><p>
And here is what the new B-Bank Bid looks like with its competitive price:
</p><pre>
{
    &quot;tags&quot;: [ &quot;equity&quot;, &quot;bid&quot; ],
    &quot;on&quot;: &quot;@http://the-bank.com/fjord/equity-instrument-23ab33-2319f.json&quot;,
    &quot;price&quot;: &quot;11.00&quot;,
    &quot;by&quot;: &quot;@http://b-bank.com/fjord/hcard-b-bank-4990cd-232b0.json&quot;
}
</pre><p>
So now the Instrument has to adjust its bid-ask spread to accomodate the new Bid. This
happens when the following rule matches, which it always does - but only fires when a
change is detected:
</p><pre>
{
    &quot;tags&quot;: [ &quot;equity&quot;, &quot;instrument&quot; ],
    &quot;buyers&quot;:  { &quot;price&quot;: &quot;/$bids;decimal/&quot; },
    &quot;sellers&quot;: { &quot;price&quot;: &quot;/$asks;decimal/&quot; },
    &quot;bid-ask-spread&quot;: {
        &quot;high-bid&quot;: &quot;/decimal/max($bids)/&quot;,
        &quot;low-ask&quot;:  &quot;/decimal/min($asks)/&quot;
    }
}
</pre><p>
This rule matches as many times as there are Bids and Asks, meaning that the local
identifiers $bids and $asks are each bound to match sets. 
</p><p>
Notice how the &#39;{ price .. }&#39; patterns match elements of a list, in the same way an
XPath can match either one or several elements in a sequence of XML elements.
</p><p>
The &#39;max()&#39; and &#39;min()&#39; operators take the highest and lowest values in a match set
(or in a physical list, come to that). Once again, this rewrite means &#39;set this value
and increment the Etag, but only if there&#39;s a change&#39;. 
</p><p>
Here, the high-bid becomes our new Bid&#39;s &#39;11.00&#39;.
</p><p>&#160;</p><p>
<b>Fjord</b>
</p><p>
So that&#39;s a quick intro to some of my ideas for JSON matching and rewriting in a FOREST
architecture.
</p><p>
Fjord is a declarative, JSON-encoded language for expressing how the state of a JSON
resource is a function of both its own state and the state of peer JSON resources that
it can see via links in a hyperdata Web.
</p><p>
Fjord objects are &#39;masters of their own destiny&#39;, not allowing other objects to tell
them what to do except via declarative intention.
</p><p>
Further articles will give more proposals for the syntax and semantics of Fjord,
including true unification, and put it into the set of languages that are ideal for
programming parallel and distributed systems, as well as for integration.
</p><p>
Since Fjord is very young and I&#39;m still implementing it (in Java), I would certainly
welcome comments about it, or about the 
<a href="http://duncan-cragg.org/blog/post/deriving-forest/">FOREST</a>
style that it supports. You can chat with me on 
<a href="http://twitter.com/duncancragg">Twitter</a>, too!

</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/mobile-widgets-arent-mobile-web/</id>
        <title>Mobile Widgets aren&#39;t the Mobile Web</title>
        <published>2009-02-11T16:20:00Z</published>
        
        <updated>2009-02-11T16:20:00Z</updated>
        
        <link rel="alternate" type="text/html" href="http://duncan-cragg.org/blog/post/mobile-widgets-arent-mobile-web/" title="Mobile Widgets aren&#39;t the Mobile Web" />
        
        <category term="architecture" />
        
        <category term="declarative" />
        
        <category term="web2.0" />
        
        <category term="strest" />
        
        <category term="ajax" />
        
        <category term="rest" />
        
        <category term="scalability" />
        
        <category term="momo" />
        
        <category term="microweb" />
        
        <category term="mobile2.0" />
        
        <category term="u-web" />
        
        <summary type="xhtml">
            <div xmlns="http://www.w3.org/1999/xhtml">

<p>

<a href="http://mobilemonday.org.uk/2009/01/february-2nd-event-changing-landscape.html">Mobile Monday London</a>
met last night to discuss the Mobile Web and Widgets. It was an engaging and 
thought-provoking evening.
</p><p>
Your intrepid reporter was there and, in spite of the crashing of his sad, clunky old
Windows Mobile Xperia X1, losing all his notes, he brings you this hot report from
right out of his memory (somewhat steamed up by subsequent socialising, but reclarified by
Google).
</p><p>
After that, I give an explanation of why I believe that Widgets are not the solution
to what Mobile 2.0 needs...
 &#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://mobilemonday.org.uk/2009/01/february-2nd-event-changing-landscape.html">Mobile Monday London</a>
met last night to discuss the Mobile Web and Widgets. It was an engaging and 
thought-provoking evening.
</p><p>
Your intrepid reporter was there and, in spite of the crashing of his sad, clunky old
Windows Mobile Xperia X1, losing all his notes, he brings you this hot report from
right out of his memory (somewhat steamed up by subsequent socialising, but reclarified by
Google).
</p><p>
After that, I give an explanation of why I believe that Widgets are not the solution
to what Mobile 2.0 needs...
</p></div><p>
<b>GSMA ONE</b>
</p><p>
First up was Kevin Smith from Vodafone to tell us about the 
<a href="https://gsma.securespsite.com/access/entry/default.aspx">GSMA ONE Web API</a>
(also <a href="http://oneapi.aepona.com/">via here</a>).
ONE means &#39;Open Network Enablers&#39;. It seems quite similar to the
<a href="http://web21c.bt.com/">Web21C</a>
initiative by BT, led by my good friend
<a href="http://blog.whatfettle.com/">Paul Downey</a>,
but which was unfortunately set aside in favour of
<a href="http://www.ribbit.com">Ribbit</a>.
</p><p>
You can send an SMS, get a user&#39;s location and access billing and connection info. All
through a scary 
<a href="http://duncan-cragg.org/blog/post/strest-service-trampled-rest-will-break-web-20/">STREST</a>
interface. 
</p><p>
Scary because it looks like you can 
<a href="http://www.betavine.net/bvportal/web/guest/projects/resources/api/gsma_api">send a text using a GET</a>... 
The documentation
<a href="http://oneapi.aepona.com/content/gsma/tutorials/GSMA_Access_API_Messaging_REST_Tutorial.pdf">here</a> [PDF]
does suggest using POST, but even so, the design fundamentally wants Resource-Orientation 
in place of Service Orientation:
</p><p>
The message appears to be tacked on to the URL as an argument.  There are references to
&#39;soapUI&#39;, endpoints, etc. An SMS message doesn&#39;t appear to have its own URL, just an
internal message ID. There are &#39;exceptions thrown&#39;, all with a 400 code, even for
internal platform and integration faults.  And so-on - in classic
<a href="http://duncan-cragg.org/blog/post/strest-service-trampled-rest-will-break-web-20/">STREST</a>
style! 
</p><p>
Still, nothing that can&#39;t be fixed with a little help from a REST dude, or a read of 
<a href="http://oreilly.com/catalog/9780596529260/">&quot;RESTful Web Services&quot;</a>.
</p><p>&#160;</p><p>
<b>OMTP BONDI and Ikivo</b>
</p><p>
Next, Nick Allot told us all about
<a href="http://bondi.omtp.org/">OMTP BONDI</a>,
which is an attempt to ameliorate fragmentation in the mobile Web and widget space - the
one which allows access to parts of the phone not normally reached in a browser: PIM,
SMS, camera, GPS, etc.
</p><p>
Their big thing is security: take widgets out of the safety of the browser and give them
access to the phone via APIs, and you have a potential security nightmare. 
</p><p>
Seems BONDI will let you do most Mobile 2.0 native-like 
<a href="http://bondi.omtp.org/widget-gallery/">applets</a>, such as LBS, photo-sharing, etc.
There&#39;s a reference implementation for sad, clunky old Windows Mobile, and both 
<a href="http://www.gomonews.com/bondi-initiative-from-omtp-to-defragment-mobile-internet/">Opera and LiMo are jumping aboard</a>,
too.
</p><p>
BONDI aims to be W3C compatible where possible. Not HTML5, mind, but rather a works-now,
fit-for-purpose solution to the fragmentation problem, that includes widgets and may
later converge with HTML5. There&#39;s an 
<a href="http://wapreview.com/blog/?p=1184">excellent discussion</a>
about this on WAP Review.
</p><p>
This was followed by a talk by Samuel Sweet from 
<a href="http://www.ikivo.com/">Ikivo</a>.
It seems that, starting with their successful
<a href="http://www.gsmarena.com/samsung_release_the_t*omnia_in_korea__omnia_but_on_steroids_-news-656.php">Samsung T*Omnia</a>
widget interface, Ikivo have been overcome with standards love, and are going BONDI as
well as W3C compliant, especially with SVG as a rendering technology.
</p><p>&#160;</p><p>
<b>Firefox for Mobile</b>
</p><p>
Christian Sejersen of Mozilla gave a good intro to what is currently called
<a href="http://images.google.com/images?q=fennec">Fennec</a> - Alpha 2,
but will soon be renamed the more grown-up &#39;Firefox&#39;. It&#39;s got the same code in it after
all: and APIs such as camera and location that get added to the common codebase
will be accessible via both mobile and desktop.
</p><p>
<a href="http://vimeo.com/2577978">Looks very swishy</a>
and touchy and in sync with the times. Available now on Maemo (and 
<a href="http://moblin.org/category/tags/fennec">Moblin</a>)
and soon on sad, clunky old Windows Mobile. Then later this year on Symbian.  Codebase
is C, so no Java or Javascript phones supported, of course. Or closed walled-garden
proprietary locked-down phones like, um, the iPhone. It seems that the add-on community
is already fixing up their plugins for this mobile version without even being prompted.
No news on the <a href="http://labs.mozilla.com/2007/10/prism/">Prism</a>
widget-alike system, to compete with BONDI or Opera. It&#39;s &quot;still in the labs&quot;...
</p><p>&#160;</p><p>
<b>Panel</b>
</p><p>
Then the panel session started, with the best questions from the excellent host,
<a href="http://www.torgo.com/blog/">Dan Appelquist</a> of Vodafone,
and some good ones from the audience.
</p><p>
There was much elaboration and clarification on the presentations (thus included above
instead), and an interesting conversation around monetisation: how do widgets make
money? Three suggestions: adverts, selling widgets on an app(let) store and
micro-payments. Graham Thomas of T-Mobile appeared to be happy just to get more Internet
traffic for now..
</p><p>
There was also confirmation from Graham that Web&#39;n&#39;Walk 4.0 will major on widgets, but
he didn&#39;t say what flavour. More hot journalism uncovers
<a href="http://www.smartphoneshow.com/files/_15.30_jon_tetzchner_innovate_collaborate_accelerate.pdf">this confirmation</a>
[PDF] (page 29) that it&#39;s still going to be tied in with Opera.
</p><p>
The outstanding revelation of the evening (sorry Ikivo!) came when someone told us that
the Palm Pre&#39;s widget system is not only proprietary, but <i>uses tables for layout</i>!
The horror! Lots of tutting and W3C-like smugness around the room.
</p><p>&#160;</p><p>
<b>Following Open W3C Standards can still break the Web</b>
</p><p>
The goal of all this standard widget aspiration, apart from the obvious motivation of
being able to compete with the iPhone, is to allow everyone to write widgets, and for
those widgets to work on all our phones.
</p><p>
However, <i>just because everyone does what the W3C thinks they should do doesn&#39;t mean you
automatically get interoperability</i>.  Most importantly, doing what the W3C wants
doesn&#39;t mean you won&#39;t break the Web!
</p><p>
The W3C, don&#39;t forget, also brings you &#39;Web&#39; Services - those mis-named standards
responsible for much Web-breaking, including inspiring a whole generation of
Web-breakers with their 
<a href="http://duncan-cragg.org/blog/post/strest-service-trampled-rest-will-break-web-20/">STREST</a>
interfaces.
</p><p>
Interoperability on the Web is about state transfer, content types, URLs, hypertext. No
amount of API and widget standardisation will give classic Web interoperability as long
as they ignore these Web basics.
</p><p>
A widget is an applet is an application. It&#39;s a closed structure whose data interoperability
has to be hard coded each time, and whose imperative Javascript naturally wants to
make function calls back on the server - probably through HTTP.
</p><p>
And you run either this application or that, each having its own way of pushing or
pulling data around, or even the same data presented in much the same way all over again.
</p><p>
In the Web you run one browser application and everything is mashed within - data interoperability.
</p><p>&#160;</p><p>
<b>The U-Web gives us the best of both worlds</b>
</p><p>
Admittedly, the basic Web isn&#39;t good enough by itself when seeking an architecture for
Mobile 2.0&#39;s essential personalisation, interactivity and usability.
</p><p>
But that doesn&#39;t mean that we should throw away the Web&#39;s hard-won advantages of
interoperability and scalability, that we perhaps take too much for granted.
</p><p>
Enter the <a href="http://the-u-web.org">U-Web</a>!  The U-Web &quot;puts the Web back into Web 2.0 and
Mobile 2.0&quot;. 
</p><p>
It takes the best of the Web&#39;s one-way static document publishing model, and extends it
to a two-way dynamic data exchange model, while keeping the interoperability and scalability
of the Web.
</p><p>
Instead of working on widget standards that break the Web, let&#39;s standardise a fully
Web-compatible Mobile 2.0 architecture that delivers the same rich, personal
functionality, but adds back the seamless mashability of ever-changing people and their
ever-changing stuff. Oh, and promises scalability and rapid, easy development.
</p><p>
I&#39;ve kicked off the project with the <a href="http://the-u-web.org">U-Web</a> proposal - perhaps
you&#39;d like to jump in and help? Email me (see left bar) or leave a comment.
</p><p>

</p>

            </div>
        </content>
    </entry>
    
    <entry>
        <id>http://duncan-cragg.org/blog/post/mobile-20-killer-app-app-killer/</id>
        <title>The Mobile 2.0 Killer App is the App Killer</title>
        <published>2008-12-19T17:05:00Z</published>
        
        <updated>2008-12-19T17:05:00Z</updated>
        
        <link rel="alternate" type="text/html" href="http://duncan-cragg.org/blog/post/mobile-20-killer-app-app-killer/" title="The Mobile 2.0 Killer App is the App Killer" />
        
        <category term="architecture" />
        
        <category term="declarative" />
        
        <category term="web2.0" />
        
        <category term="yaml" />
        
        <category term="socialsoftware" />
        
        <category term="identity" />
        
        <category term="publishsubscribe" />
        
        <category term="p2p" />
        
        <category term="multimedia" />
        
        <category term="event-driven" />
        
        <category term="mobile2.0" />
        
        <summary type="xhtml">
            <div xmlns="http://www.w3.org/1999/xhtml">

<p>

Mobiles are unique - if you want to miss out on the opportunity they represent, you
could choose to see them as just slow computers with tiny interfaces and dodgy Internet
connections. Then try to squeeze in your traditional applications; try squeezing the
office desktop metaphor with its sedentary documents into a device the size of a mouse!
</p><p>
Alternatively, see them as the most personal, social and dynamic of devices that are
becoming connected to the Internet. Now a multi-billion-scale global opportunity opens
up to you.  That&#39;s customers <i>and</i> dollars! In trying to grasp this, some are calling
it &#39;Mobile 2.0&#39;, by analogy with its sibling, Web 2.0.
</p><p>
In that light, <i>the Killer App for Mobile 2.0 is the sharer, masher and updater of
People, Things, Times and Places</i>...  The key to getting Mobile 2.0 right is for it to
merge seamlessly into our lives. That means the handling of dynamic and shared data
becomes the top priority, even above the handling of applications.
</p><p>
This article describes a Mobile 2.0 platform that makes people and their stuff first
class - not applications.
 &#160; ...
</p>

            </div>
        </summary>
        <content type="xhtml" xml:space="preserve">
            <div xmlns="http://www.w3.org/1999/xhtml">

<p>
</p><div class="summary"><p>
Mobiles are unique - if you want to miss out on the opportunity they represent, you
could choose to see them as just slow computers with tiny interfaces and dodgy Internet
connections. Then try to squeeze in your traditional applications; try squeezing the
office desktop metaphor with its sedentary documents into a device the size of a mouse!
</p><p>
Alternatively, see them as the most personal, social and dynamic of devices that are
becoming connected to the Internet. Now a multi-billion-scale global opportunity opens
up to you.  That&#39;s customers <i>and</i> dollars! In trying to grasp this, some are calling
it &#39;Mobile 2.0&#39;, by analogy with its sibling, Web 2.0.
</p><p>
In that light, <i>the Killer App for Mobile 2.0 is the sharer, masher and updater of
People, Things, Times and Places</i>...  The key to getting Mobile 2.0 right is for it to
merge seamlessly into our lives. That means the handling of dynamic and shared data
becomes the top priority, even above the handling of applications.
</p><p>
This article describes a Mobile 2.0 platform that makes people and their stuff first
class - not applications.
</p></div><p>
Mobile 2.0 should be about effortless delivery of dynamic data such as local weather,
personalised news feeds, timelines off Facebook and feeds off Twitter, messages, notes,
videos, photos, calendar entries, map locations and meetup plans.
</p><p>
Mobile 2.0 should easily allow us to two-way-share this dynamic data with family,
friends, contacts, third parties and the world.
</p><p>&#160;</p><p>
<b>People don&#39;t actually want applications on their mobiles!</b>
</p><p>
What Mobile 2.0 does <i>not</i> need is traditional applications, because applications just
get in the way of this sharing, mashing and updating of live and personal data.  What
most people want on their mobiles is not the applications, but the stuff they animate.
</p><p>
People only accept the concept of applications (whether a native app or a Web app)
because that&#39;s all they&#39;ve been offered, and it&#39;s largely good enough.  But no-one
actually <i>wants</i> to download and launch and register and log in to a local
find-your-friends application - they just want to find their friends in the area - now!
And they shouldn&#39;t then have to flip between the find-your-friends map owned by that
application and the restaurant review map owned by another.
</p><p>
They don&#39;t want Facebook videos and YouTube videos and phone videos. They just want to
share videos. They shouldn&#39;t have to think about whether to send a picture by MMS or to
use an upload app, after remembering the login. They don&#39;t want multiple ways of sending
messages: IM, SMS, Twitter, Facebook, etc. They shouldn&#39;t have to think about how to
tell their friends about some news item - whether to post a TinyURL link on Twitter or
copy the text manually into Facebook.
</p><p>
They only want one shared calendar, not the phone calendar and a Google calendar and
events on Upcoming.org, that need two more logins.  They shouldn&#39;t have to think about
how to synchronise music or contacts lists on the phone, the iPod, the PC, some memory
card and online.
</p><p>
Applications - both native and Web, and including Applets and Widgets - just get in the
way of life!  They try to own or control our People, Things, Times and Places, breaking
them up with arbitrary application boundaries and making things unnecessarily hard to do.
</p><p>&#160;</p><p>
<b>People just want to share new stuff through their mobiles</b>
</p><p>
What most people would prefer is for their friends and messages from their phonebook,
their Facebook, their Twitter, their IM, plus their Flickr photos, their Facebook
photos, their restaurant and film reviews and their meeting places <i>all</i> to appear on
the <i>same</i> map or in the <i>same</i> calendar... along with the local weather forecast
for now and for any dates being planned.
</p><p>
And for that map or calendar, those photos, messages, interesting news, etc., to be
actively shared amongst those friends, or even the entire world, simply by flicking the
&#39;share with friends&#39; or the &#39;make public&#39; switch. Any member of a group should be able
to post photos into a shared gallery, or scribble onto a shared whiteboard.
</p><p>
The Killer App for Mobile 2.0 is the sharer, masher and updater of People, Things, Times
and Places.  This Mobile 2.0 platform would seamlessly merge, update, synchronise,
upload, download and save your latest life stuff, including that of your friends and
family, so that you no longer have to think about doing it yourself.
</p><p>
Your identity and your stuff would be owned and controlled by you through your personal
handset. They would not be merely transferr<i>able</i> - they&#39;d simply <i>be</i> transferred,
to where they&#39;re needed, when they&#39;re needed, using an open Internet protocol and
standard formats.
</p><p>&#160;</p><p>
<b>What this Mobile 2.0 platform must do</b>
</p><p>
This platform will have a tactile 3D interface, with touchable, draggable areas for
People (friends, family, organisations), Things (photos, videos, messages, feeds, news,
notes), Times (appointments, plans, weather) and Places (maps, galleries).  It will
seamlessly access and present this interactive content from the phone itself -
representing you - from friends, and from third parties.
</p><p>
This interactive content will be findable by tags, geo-tags and timestamps - it&#39;s
semantic data, not document text. You&#39;ll be able to pick a Person, then see their
related Things, Times and Places; or pick a Thing, to see it&#39;s associated People, Times
and Places.  Stuff will also be findable by recommendation and trust, or at worst
by well-targetted advertising.
</p><p>
Loss of Internet will be handled gracefully - stuff from others will still be visible,
but simply not updated. There are no central servers, so loss of a server only affects
the particular content it sources and &#39;animates&#39; for you.
</p><p>
Third parties will easily be able to add functionality and interactive content such as
map overlays, media, news feeds, etc.. They just expose them using the open protocol and
notation - they won&#39;t have to ask anyone in order to do so. Some contributors can adapt
the Facebook, Flickr, Twitter and various IM APIs in the same way. This will require a
system for reconciling the multiple identities of users and their contacts.
</p><p>
There will need to be a virtual property system backed up by crypto keys and supporting
payment - just because we don&#39;t have an App Store, doesn&#39;t mean we can&#39;t charge for
interactive content! It will also be possible to charge for premium services, such as
remote storage space for over-enthusiastic photo-snappers.
</p><p>&#160;</p><p>
<b>Blueprint for the Mobile 2.0 Killer Application</b>
</p><p>
Right, we need to describe some more important things with capital letters, because
we&#39;re going to talk about the best open notation and Internet protocol for sharing,
mashing and updating...
</p><p>
We&#39;ve already introduced People, Things, Times and Places. Call these Entities. Entities
are open data - they have a current State.  We&#39;ll use a text-based notation to describe
their public State, because it&#39;s easy to read and write. Each Entity will conform to an
open standard public schema or syntax.
</p><p>
Entities can Link up because they will each have a UID (unique identifier). Some
friends-People met at the last-week-Time and the Tower-of-London-Place and took these
photo-Things. I have a collection Thing of People and both personal and public
collection Things of photo-Things. You get the idea. That&#39;s a form of mashing. Oh -
photos on the Web can be wrapped in Entities that pull out their metadata, and Web URLs
are valid Links.
</p><p>
Any Entity can Observe another. Well, it&#39;s mostly People Entities doing the Observing
and being Observed, via the mobile device: my Person Observes your Person to see what
you&#39;re up to, then Observes your collection Thing of latest photos and may watch you on
the map Place as you head towards me snapping more. Sharing and updating.
</p><p>
But some Things can be Observers, too; the more interactive ones that are affected by
Entities around them. A simple example may be a restaurant review summarising Thing,
that Observes and averages the scores off several reviewers&#39; submission Things. Each
time a score is added or changed, the final score adjusts accordingly. That&#39;s sharing
and updating, too, and Entities that depend on other Entities is another form of mashing.
</p><p>
Entities have read permissions, which control which People and other Entities can see
their State. Crypto tech may be needed to support this in some cases.  Entities don&#39;t
have write permissions as such, because they control their own State as a result of what
they Observe.
</p><p>
Of course, these Observations occur over the Internet. This will use an open standard
publish-subscribe, peer-to-peer protocol. An Internet packet will subscribe to an
Entity&#39;s Link, another packet will return current Entity State, subsequent packets will
broadcast State updates to current subscribers. State is transferred into servers and
handsets as required, by a combination of pull and push - sharing and updating. The
protocol will ultimately also have to support things like streaming and real-time media;
over Wifi at least, so as not to scare off the carriers...
</p><p>&#160;</p><p>
<b>The U-Web Mobile 2.0 platform</b>
</p><p>
This Mobile 2.0 Killer Application for sharing, mashing and updating People, Things,
Times and Places ... will have a shorter name! I&#39;m calling it the &#39;U-Web&#39; Mobile 2.0
platform at the moment, reflecting its affinity to the
<a href="http://duncan-cragg.org/blog/post/universe-web/">Universe Web</a>
I described before. The U-Web platform application will be free and the protocols
and formats outlined above will be open.
</p><p>
The typical handset specification and APIs we&#39;re aiming for are: at least 320x320
touch screen with Embedded 3D; GPS, Wifi and good 3G; front- and back-facing cameras.
</p><p>
There&#39;s a large number of Windows Mobile devices that match this, including phones from
HTC, Sony-Ericsson, Samsung, etc.  There&#39;s currently one Symbian (the Nokia 5800/Tube
with the N97 to come next year). One iPhone. One Android.  One Blackberry without Wifi
(the Storm).
</p><p>
Although Nokia&#39;s plans are somewhat unclear, their S60v5/Qt/Ovi offering looks like it
may preclude the U-Web, especially since the U-Web wants to be the top app... The U-Web
certainly wouldn&#39;t be allowed onto the Apple App Store - the clue is in the name!
Writing it in C also rules out Java phones, such as Android - which in any case is
another app-oriented platform - and any Blackberry handsets.
</p><p>
The U-Web should thus be written for Windows Mobile 6+ Professional handsets. At least
their users will have a ready appetite for anything integrated and easy to use, that
keeps them clear of the .. clumsy .. operating system. It will also be worth keeping an
eye on the various Linux MID (Mobile Internet Device) platforms, including OpenMoko,
Maemo and Moblin, and maybe LiMo.  Similarly, we should write for Windows and Linux on
the server side - the code will be essentially the same. It&#39;ll need to be written in C
as the lowest common denominator, most efficient language.
</p><p>
The U-Web will be the top or idle application: on Windows Mobile it would replace the
Today screen, or more likely TouchFLO 3D or Spb Mobile Shell. Else it could be an
Xperia X1 Panel. Like these, it will give access to phone functions such as calls,
texts, camera, speaker mute, Bluetooth and Wifi enable, lock screen, brightness, etc.
</p><p>
Of course, it won&#39;t actually be the <i>only</i> application while it is in its beta phase -
people may still want to access a browser, email and various settings and utilities. The
need for browser and email should reduce significantly when functions such as Web 2.0,
messaging and file sharing are drawn up into the mobile-native U-Web, leaving just
actual documents fitting awkwardly.
</p><p>&#160;</p><p>
<b>Opportunity</b>
</p><p>
It is a mistake to see Mobile as just a second-class computing platform or as a
miniature office desktop onto which you must squeeze applications and documents.
</p><p>
Mobile represents a whole different world of personal interaction and almost 100%
presence - especially now that mobiles are becoming Internet-connected and location-aware
and are being furnished with top-quality cameras and touch screens.  The mobile device
represents you, here, now; what you&#39;re seeing and doing, to your social network.
</p><p>
A Mobile 2.0 platform needs to drop closed applications and go instead with the flow of
People, Things, Times and Places. It needs to transparently share, mash and update people
and their stuff.
</p><p>
The U-Web Mobile 2.0 platform described here is designed to seamlessly merge your real
and virtual lives, starting with intuitive, 3D touch interfaces that give an almost
tangible feel to virtual property, then expanding out to touch the 3D lives of others.
</p><p>
If you take a photo, your friends can instantly &#39;join you on the map&#39; where you stand
and chat about it - and the weather conditions you&#39;re experiencing.  No need to upload
to photo sharing sites with logins, or to launch isolated chat, map and weather apps.
</p><p>
The opportunity is billion-scale - increasingly capable mobile devices will become the
world&#39;s primary connected computing device, outstripping PCs and making current Internet
and Web usage look like just a warm-up.
</p><p>
We should be in there with appropriate software when that happens. We can stumble into
this step-by-painful-step via applications and browsers, or we can just let go and
meet the actual requirements - with a platform for mashing dynamic, shared data.
</p><p>
I&#39;d be delighted to hear from you if you&#39;re interested in helping or getting involved in
any way with building this platform! Email me - link&#39;s on the left - or leave a comment.
</p><p>&#160;</p><p>

</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/universe-web/</id>
        <title>The Universe Web</title>
        <published>2008-07-18T19:49:00Z</published>
        
        <updated>2008-07-18T19:49:00Z</updated>
        
        <link rel="alternate" type="text/html" href="http://duncan-cragg.org/blog/post/universe-web/" title="The Universe Web" />
        
        <category term="cyberspace" />
        
        <category term="architecture" />
        
        <category term="declarative" />
        
        <category term="socialsoftware" />
        
        <category term="publishsubscribe" />
        
        <category term="p2p" />
        
        <category term="rest" />
        
        <category term="scalability" />
        
        <category term="json" />
        
        <category term="metaverse" />
        
        <summary type="xhtml">
            <div xmlns="http://www.w3.org/1999/xhtml">

<p>

Since the 
<a href="http://www.virtualworldsnews.com/2008/07/ibm-and-linden.html">announcement</a>
by 
<a href="http://www.ibm.com/virtualworlds/index.shtml">IBM</a>
and
<a href="http://lindenlab.com/">Linden Lab</a>
that
<a href="http://opensimulator.org/wiki/Main_Page">OpenSim</a>
can talk to 
<a href="http://secondlifegrid.net/">Second Life</a>,
I&#39;ve been thinking again about RESTful Virtual Reality.
</p><p>
I&#39;m not the first, of course. Others have been motivated by the same
goal: To bring the Web&#39;s scalability, linkability and interoperability
into Virtual World platforms.
</p><p>
Ultimately, how to use the same techniques as the Web to link
Virtual Worlds together into a single, massive &#39;Virtual Universe&#39;.
</p><p>
Here&#39;s how I would architect the Universe Web...
 &#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 
<a href="http://www.virtualworldsnews.com/2008/07/ibm-and-linden.html">announcement</a>
by 
<a href="http://www.ibm.com/virtualworlds/index.shtml">IBM</a>
and
<a href="http://lindenlab.com/">Linden Lab</a>
that
<a href="http://opensimulator.org/wiki/Main_Page">OpenSim</a>
can talk to 
<a href="http://secondlifegrid.net/">Second Life</a>,
I&#39;ve been thinking again about RESTful Virtual Reality.
</p><p>
I&#39;m not the first, of course. Others have been motivated by the same
goal: To bring the Web&#39;s scalability, linkability and interoperability
into Virtual World platforms.
</p><p>
Ultimately, how to use the same techniques as the Web to link
Virtual Worlds together into a single, massive &#39;Virtual Universe&#39;.
</p><p>
Here&#39;s how I would architect the Universe Web...
</p></div><p>
<b>Entities</b>
</p><p>
The Universe Web needs Entities. (I&#39;m going to be capitalising
Significant Things a lot here to help the Web comparison - hope you
don&#39;t mind). There&#39;s no need to make the Entity list too complicated
since we&#39;re not doing online games yet - just a world like Second Life.
</p><p>
Here&#39;s a list of different kinds of Entity:
</p><ul>
<li>   Places: buildings, streets, hills, lakes</li>
<li>   Things: trees, books, birds, clocks</li>
<li>   People</li>
</ul><p>
</p><p>&#160;</p><p>
<b>State, Links and animation</b>
</p><p>
Entities aren&#39;t exactly the Objects of Object-Oriented programming:
they have lots of public State. In a Virtual World, you can directly
experience their colour, position, orientation, physical relation to
each other, etc., thanks to the local render engine.
</p><p>
The basic structure of the Universe Web is made up of Linked
Entities. A tree is Linked to its ground which is Linked to a
building which is Linked to its occupants which are Linked to their
clothing. Kneebones may even be Linked to thighbones.
</p><p>
Entities are often animated. Actually, Places are generally static,
and People generally animate themselves. So, when talking in general,
we should look at the animation of Things, like trees, books, birds
and clocks.
</p><p>
There are two ways an Entity&#39;s animation can be guided: by Laws and
by Rules.
</p><p>&#160;</p><p>
<b>Laws</b>
</p><p>
Springiness is a handy Law. For example, tree branches, pages in a
book and birds&#39; wings and legs can all have springiness. We can
declare a mid-air location in a bird&#39;s State and a springiness in
its legs, then if the bird lands on a branch, the springiness can
trigger the bird and branch waving gently to a halt.
</p><p>
We could even allow a single bird to become part of a flock Entity,
where the flock only knows how many birds it has and the coordinates
of its centre. Each bird will then be animated by global flock Laws.
</p><p>
The book can have a State of open or closed. If bookness was
elevated to a global Law, then a book deciding that its State was
now simply closed could trigger the elaborate, springy closing of
its pages with a nice &#39;shlump&#39; sound at the end.
</p><p>
The clock&#39;s current time may be set by the clock Entity itself, then
the Law of time take over in between the clock updating its own time
directly.
</p><p>
A Law can be invoked over an Entity&#39;s animation by simply adding the
Law&#39;s name and parameters to its State. Such Laws can be handled by
the physics engine in the same way surface texture is handled by the
render engine: States such as &#39;red&#39; need global meaning, Law
applications such as &#39;springy&#39; need global meaning.
</p><p>&#160;</p><p>
<b>Rules</b>
</p><p>
When a clock reaches its alarm time, it rings.  When its wizard
master approaches, a magic book may glow and open.  Birds fly away
from danger (if a fox is too close, fly away from it). In between
danger, birds and foxes look for food (if a bird is close, run
towards it). 
</p><p>
These are Rules.  Rules are driven by the Observation of one Entity
by another. The fox Observes the bird, the book Observes the wizard.
Rules apply to Entity types: fox Rules, bird Rules, book Rules, etc. 
Rules can guide the animation of an Entity by evolving its State.
</p><p>
State evolution depends on the current State plus the States of the
Observed Entities: Rules make an Entity change from one State to the
next by taking the Entity&#39;s own State, Observing the States of the
Entities around that it cares about, then deciding what the next,
new State should be.  If an Entity changes State, those Entities
Observing it may themselves change State according to their own
Rules, and so-on.
</p><p>
Links are part of an Entity&#39;s State, and Links may therefore change
on the application of Rules. In other words, the virtual world may
restructure when a Rule is run.
</p><p>
An Entity may either Observe another Entity, or Link to it, or both.
An Entity that Links to another needn&#39;t Observe it. Trees don&#39;t
bother to Observe the ground they grow from. Conversely, an Entity
that Observes another needn&#39;t Link to it. A fox would only Link to a
bird if she was lucky enough to catch it. Meanwhile, it is true that
there&#39;s probably a <i>chain</i> of Links to everything that&#39;s Observed.
</p><p>
Unlike Laws, Rules can&#39;t or shouldn&#39;t be second-guessed, so have to
be run &#39;at source&#39; or &#39;inside the Entity&#39;, then the new State
distributed to both the Observing Entities and to all the render
engines.
</p><p>
But render engines are actually Observing People Entities..
</p><p>&#160;</p><p>
<b>People are First Class</b>
</p><p>
In Virtual Worlds, we have People avatars: People are first class
Entities.  People can Observe and can change State, but it&#39;s a real
user doing the animation, not a set of Rules. Observation and State
change by a Person is implemented through the render engine.
</p><p>
Although self-animated, People can still make use of Laws. For
example Laws can be invoked to allow gestures to be easier to make
and to look better, and to allow People to &#39;run forward&#39; rather than
putting their &#39;left foot forward, ..&#39;.  Avatar skills become global
Laws which can be triggered by an avatar&#39;s State animated by a user.
</p><p>&#160;</p><p>
<b>The Universe Wide Web</b>
</p><p>
The Universe Web I&#39;ve just described is a lot like the World Wide Web:
</p><ul>
<li>   An Entity is like a Web Resource</li>
<li>   The State of an Entity is like an HTML Web Representation of a Web Resource</li>
<li>   A Link in an Entity&#39;s State is like a Web URL inside an HTML Web Representation</li>
<li>   Laws are like Javascript, Flash, link hover, blink tags and animated GIFs</li>
<li>   Rule sets are like PHP scripts or Java servers</li>
<li>   A State Observation is like a Web Representation Transfer</li>
</ul><p>
A crucial difference between the Resource Web and the Entity Web is
that, here <i>it&#39;s another Entity doing the Observation</i>.  One
Entity transfers its State to another. 
</p><p>
It&#39;s as if the GET or POST has another Entity &#39;at the client end&#39;.
GET is like an Entity subscribing or Observing; POST is like an
Entity publishing or notifying its State to another (an HTML form
has a content type, too).
</p><p>
People are just examples of that Entity &#39;at the client end&#39;.
Instead of a user hidden behind a client browser, we have
first-class People Entities doing &#39;GET&#39;s and &#39;POST&#39;s: Observing
the Virtual World and acting (i.e., changing State) within it.
Other examples are foxes and clocks.
</p><p>&#160;</p><p>
<b>Notation and Protocol</b>
</p><p>
There are two open standards we need to have in progress while
implementing the Universe Web: the notation and the protocol (our
HTML/URI and HTTP).
</p><p>
Firstly, we have to define the notation for Entities and their
Rules. Both the State of Entities and the Rules that animate them
will be written in the same notation: a Rule talks directly about
State. To me, basing that on JSON (rather than XML) is a clear
choice. Add inter-JSON Entity Links (essentially UUIDs), then work
out a simple JSON Rule language. We will then need to define JSON
&#39;schemas&#39; for the kinds of Entity we would model. These can be
written in the Rule language itself.
</p><p>
Secondly, to define the protocol for Entities to Observe or
subscribe to one another. It will be a &#39;symmetric, asynchronous
HTTP&#39; - a Peer-to-Peer, Publish-Subscribe protocol. UDP and
Multicast stand out for this kind of interaction. A packet will
subscribe, a packet will return current State, a subsequent packet
will multicast State updates. We can re-use all the HTTP cache
headers, only now we can push updates into caches and into render
programs. Packets will inevitably end up tunnelled through TCP and
HTTP, mind...
</p><p>
This lighter notation, which also breaks the data up into smaller
pieces, and this multicast pushing of State change into caches, along
with P2P-style operation, will mean the Universe Web scales even
better than its parent. 
</p><p>
Also, programming declaratively using Rules is both highly
productive and further cleanly scalable through parallel processing. 
</p><p>
Of course, it will be pretty trivial to allow inter-Web cross-over
such as referring to PNG texture images via URL and pulling Universe
Web Entities into a Javascript application that subscribes to them
via Comet.
</p><p>&#160;</p><p>
</p><p>
<b>Building the Universe Web</b>
</p><p>
So that&#39;s my Universe Web. It&#39;s basically the same as the World Wide
Web and thus as scalable, linkable and interoperable. It comes with
added symmetry: Entities, including People as avatars, exchange
State in each direction.
</p><p>
It&#39;s a two-way data Web, not a one-way document Web.
</p><p>
I&#39;ve started work on the Universe Web: the notation, the protocol
and the implementation (in C, for portability across platforms,
including mobile).  Contact me if you want to help!
</p><p>

</p>

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

