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

    <updated>2009-08-13T11:43:00Z</updated>


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

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

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

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

            </div>
        </content>
    </entry>
    
    <entry>
        <id>http://duncan-cragg.org/blog/post/inter-enterprise-rest-integration-rest-dialogues/</id>
        <title>Inter-Enterprise REST Integration | The REST Dialogues</title>
        <published>2007-04-08T13:38:00Z</published>
        
        <updated>2007-04-08T13:38:00Z</updated>
        
        <link rel="alternate" type="text/html" href="http://duncan-cragg.org/blog/post/inter-enterprise-rest-integration-rest-dialogues/" title="Inter-Enterprise REST Integration | The REST Dialogues" />
        
        <category term="architecture" />
        
        <category term="declarative" />
        
        <category term="strest" />
        
        <category term="p2p" />
        
        <category term="app" />
        
        <category term="dialogue" />
        
        <category term="event-driven" />
        
        <category term="rest" />
        
        <category term="atom" />
        
        <category term="scalability" />
        
        <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 (GetSearchResults, GetItem,
GetCategoryListings, etc).
</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 4: Inter-Enterprise REST Integration</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 (GetSearchResults, GetItem,
GetCategoryListings, etc).
</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 4: Inter-Enterprise REST Integration</b>
</p></div><p>
</p><p>
<b>Duncan Cragg:</b> OK - I&#39;ve demonstrated how you can replace
imperative, function-call API-driving with a clean, declarative,
RESTful interaction, driven by simple business rules. 
</p><p>
We had servers run by eBay and clients run by the public, in the
same way your SOAP API is used.
</p><p>
<b>eBay Architect:</b> Ah: that&#39;s something SOA has that REST doesn&#39;t!
</p><p>
<b>DC:</b> What? What&#39;s that?
</p><p>
<b>eA:</b> Services are all about Enterprise Integration: about
servers talking to servers. In REST you&#39;re all about clients
talking to servers. The Web is essentially only browser clients
talking to Web servers. With Web Services, you can do more serious
Enterprise Integration.
</p><p>
<b>DC:</b> You never give up do you? So you want &#39;serious&#39; integration.
Is that within or between enterprises?
</p><p>
<b>eA:</b> Let&#39;s say between.
</p><p>
<b>DC:</b> Fine. We&#39;ll use the same example as before: it&#39;s just a
variation on the Patterns used.  
</p><p>
We can standardise a more general version of the eBay schemas for
Items, Offers, ResponseToBestOffers and so on. Anyone can put their
own Items, Offers, etc. up on their own servers, or on some public
auction service site.  Everyone can do auctions with eBay and with
anyone else who decides to set up. 
</p><p>
Even, say, a new Google auction site: let&#39;s call it &#39;gBay&#39;!
</p><p>
<b>eA:</b> Ha! OK, let&#39;s go through this slowly: you have eBay and
&#39;gBay&#39; sites, with sets of users on each. Now Ernie wants to sell
his old laptop on eBay, so creates a new Item for it.  Gordon is
registered to gBay and needs a cheap laptop.
</p><p>
<b>DC:</b> Great - well the first thing is search. As an interoperable
site, gBay offers a broad search across both gBay sale Items and
eBay ones - cached and indexed internally. The gBay search database
would be filled by crawling eBay URIs and even by running queries on
eBay.
</p><p>
<b>eA:</b> Mm. Have to check the T&#39;s &amp; C&#39;s...
</p><p>
<b>DC:</b> So Gordon on gBay finds Ernie&#39;s laptop on eBay. The
presentation of this eBay sale item will be given the gBay
style, but calling out directly to the eBay data and images.
</p><p>
<b>eA:</b> OK, now let&#39;s say Gordon decides to make an offer.
</p><p>
<b>DC:</b> So an Offer resource is created on <i>gBay</i> referring to the
laptop on eBay. Then through a notification, the Item on eBay is
alerted to this Offer.
</p><p>
<b>eA:</b> What&#39;s notified, to where?
</p><p>
<b>DC:</b> There&#39;s a number of possible patterns.  Before, we had the
pattern of POSTing a resource to a server that then creates the
GETable version.
</p><p>
However, now gBay is hosting the Offer, so the internal mechanisms
for notification are no longer available. 
</p><p>
So gBay could suggest an update through APP or a simpler POST to a
collection of Offer entries within the eBay Item to point to this,
now remote, Offer.
</p><p>
Perhaps the gBay Offer can simply be POSTed wholesale to the eBay
Item. 
</p><p>
Or just a link to it.
</p><p>
Or eBay may poll, read a feed or search gBay for new Offer URIs,
putting them into Offer lists as they come up. 
</p><p>
An unusual approach (thanks to 
<a href="http://wellformedweb.org/story/1">Joe Gregorio</a>)
would be for gBay to GET the eBay Item, with the Offer marked in a
Referer: header.
</p><p>
<b>eA:</b> Plenty of patterns to choose from. So there are some Offers
on eBay, some on gBay. The Item lists its Offers in a rank as before,
as they appear through this notification.
</p><p>
Now, let&#39;s say Ernie wants to accept Gordon&#39;s Offer on gBay. 
</p><p>
<b>DC:</b> OK, assuming he can see the Offers the same regardless of
host, he just chooses Gordon&#39;s Offer on the offer listing for his
Item and accepts it.
</p><p>
<b>eA:</b> So we need to create a ResponseToBestOffer on eBay.
</p><p>
<b>DC:</b> Yes. Now the patterns are reversed, because eBay needs to
notify gBay this time - of its ResponseToBestOffer. 
</p><p>&#160;</p><p>
</p><p>
<b>Pub-Sub and Observer Pattern</b>
</p><p>
<b>DC:</b> Again, it can do this by POSTing the ResponseToBestOffer to
each Offer on gBay in turn, or can POST the actual Item itself to
each Offer, where the Item has a link to the ResponseToBestOffer.
</p><p>
That would implement a logical subscription to the Item from each of
the Offers on it.
</p><p>
<b>eA:</b> It sounds to me like POSTing several times to implement this
pub-sub pattern is physically inefficient, even if it&#39;s logically
correct.  Especially when it&#39;s the same information repeated from
eBay to gBay servers.
</p><p>
<b>DC:</b> Yes, indeed: a single notification to gBay would be better,
letting gBay handle the propagation of subscription responses. This
would in effect treat gBay as a proxy cache, and the notification as
a cache invalidation event on gBay&#39;s copy of the eBay Item.
</p><p>
<b>eA:</b> What URI on gBay would you POST this eBay Item to?
</p><p>
<b>DC:</b> Something like <code> http://gbay.com/ebay.com/item/4243</code> - to a
copy of itself. You could also GET this cached copy if you wanted.
</p><p>
<b>eA:</b> OK, what next?
</p><p>
<b>DC:</b> In gBay the losing Offers get updated on receipt of this
ResponseToBestOffer state. Gordon&#39;s Offer gets set to &#39;won&#39;. In
eBay, all the losing Offers are updated to &#39;lost&#39;. The laptop Item
gets marked &#39;sold&#39;, with a link to the ResponseToBestOffer, which
links to the Offer that won.
</p><p>
It is possible to implement this internally in eBay (and that
pub-sub cache invalidation propagation in gBay) using the
<a href="http://en.wikipedia.org/wiki/Observer_pattern">Observer Pattern</a>.
and an event-driven server. 
</p><p>
<b>eA:</b> Makes sense - you mean something like 
<a href="http://www.eecs.harvard.edu/~mdw/proj/seda/">SEDA</a>?
</p><p>
<b>DC:</b> Yep.
</p><p>
So the Offers all subscribe to the Item to watch for its status
switching to &#39;sold&#39; and to see if they won.  Conversely, the Item
can subscribe to the Offers: maybe the Offers could change or be
withdrawn, and the Item needs to keep itself updated accordingly.
</p><p>
<b>eA:</b> Wow - symmetric subscription - the two-way Observer Pattern!
</p><p>
OK, what next?
</p><p>
<b>DC:</b> The eBay laptop Item resource will be further updated by its
owner with paid, shipped, refunded, etc., as it currently is within
eBay.
</p><p>
<b>eA:</b> Hold on, you&#39;re mixing patterns: you had the Observer
Pattern on the Item just now: the Item observes the Offers. 
The Offers&#39; state can be POSTed to the Item, whose own state may
then change according to its rules.
</p><p>
But you then mix patterns by allowing a POST directly to the Item
from the Item&#39;s owner, to update a couple of fields.
</p><p>
In one, the Item chooses what its state will be according to the
state of its peers, and in the other, it&#39;s told, not according to
a peer state, but some POST content type. 
</p><p>
That doesn&#39;t seem neat or symmetric.
</p><p>
<b>DC:</b> It&#39;s true that these interaction styles differ: the Observer
Pattern or pub-sub approach is peer-to-peer (resource-to-resource as
equals watching each other); and in this scenario it&#39;s also
server-to-server. 
</p><p>
The direct edit request is more a client-server pattern, where the
server resource - the Item - is considered under the control of a
client.
</p><p>
However, the Item is always in control of its own state, and can
even ignore a request by its owner if that request doesn&#39;t match its
internal integrity rules. 
</p><p>
The Item supporting both styles at the same time is absolutely fine.
</p><p>
Actually, you could see these two styles as aspects of the same
peer-to-peer pattern: introduce a resource in the client that
holds edit requests, to which the Item subscribes. It all ends up
being much the same.
</p><p>&#160;</p><p>
</p><p>
<b>Transactions, Trust</b>
</p><p>
<b>eA:</b> Right, now what if you have a race, where the
ResponseToBestOffer is created at the same time as an Offer is
changed or withdrawn?
</p><p>
Don&#39;t you need some kind of two-phase commit or distributed
transaction logic?
</p><p>
<b>DC:</b> Of course not. It&#39;s the same as in the real world: as long
as it all settles in the end and the rules are followed. The
ResponseToBestOffer cites what state of the Offer it is accepting.
If that changes for any reason, the ResponseToBestOffer is void.
</p><p>
It&#39;s about state and state consistency in REST, as opposed to the
SOA style of maintaining total control at all times.
</p><p>
There will be temporary states that trigger the rules and that need
to be resolved. That&#39;s the programming and distribution model.
Tolerance of transient states is what makes this model so robust.
</p><p>
<b>eA:</b> Surely there are some legal and contract issues?  How is
this exchange legally binding?
</p><p>
<b>DC:</b> You can digitally sign the Item, Offer and ResponseToBestOffer
resources, and each side needs to keep records of the history.  Then
it&#39;s down to agreements between eBay and gBay and the local laws in
force.
</p><p>
<b>eA:</b> What about buyer and seller ratings and feedback?
</p><p>
<b>DC:</b> Ernie in eBay and Gordon in gBay can happily publish
feedback about each other, and Ernie will be able to see Gordon&#39;s
rating via eBay&#39;s interface, or directly on gBay.  
</p><p>
As for aggregated ratings from several buyer/seller interactions: a
person&#39;s rating is a function of the ratings of all those they have
dealt with. These ratings can be fetched by GET from remote sites,
and combined with internally-held ratings, depending on the trust of
one site over another site&#39;s ratings.
</p><p>
<b>eA:</b> So how do we trust these ratings across sites?
</p><p>
<b>DC:</b> We have to trust eBay that it trusts gBay. This is one
of the basics of distributed systems. In a monolithic system
you have a single trust domain: all parts can trust each other.
</p><p>
Split the application up across multiple trust domains and you need
authentication and crypto.  You can&#39;t get way from needing peer trust
structures built up explicitly through crypto, agreement and
contract and/or implicitly through past successful experience.
</p><p>
<b>eA:</b> Can you be more specific?
</p><p>
<b>DC:</b> Normally, a GET for a resource or a POST of some data comes
with a header identifying the GETer or POSTer. The resource can also
be signed by a user on a site or by the site itself as a proxy. 
</p><p>
Or, if you have an agreement with the site, you just need to use
https to ensure you&#39;ve got a secure connection with that site, 
then needn&#39;t have individual signatures.
</p><p>
<b>eA:</b> Where&#39;s the Single Sign On and Identity in all this?
We&#39;ve got users working across multiple sites.
</p><p>
<b>DC:</b> Well, gBay is the holder of the Gordon identity or persona -
and it manages his world view. Gordon on gBay needs his identity to
mean something on eBay, but we don&#39;t want him to have to create an
account on eBay or to have to tell gBay his eBay login details to
work on both sites. So he expects gBay and eBay to have come to
some agreements about technology and policy.
</p><p>
In REST, we don&#39;t have sessions and logins - we have identity,
which implies asymmetric (private/public key) crypto for signatures
and security. We have a number of tools available to us, including
OpenID and https, as well as resource signing.
</p><p>
<b>eA:</b> Here&#39;s a question for you: how would you manage a single
shopping trolley for Gordon on gBay, containing and allowing payment
for eBay goods?
</p><p>
<b>DC:</b> ShoppingTrolley resource, links to eBay and gBay items.  At
checkout, smaller eBay-Items-only ShoppingTrolley resource POSTed to
eBay along with CreditCard resource (again, you can sign the
ShoppingTrolley and encrypt the data).
</p><p>
<b>eA:</b> So, as eBay, why should we integrate the seller ratings of
someone on gBay? Or get gBay&#39;s for-sale items coming up in our
searches? Or accept Offers and ShoppingTrolleys from gBay? We don&#39;t
control or trust them, and don&#39;t want to send traffic or business
over to them.
</p><p>
<b>DC:</b> Fair enough, for now. I&#39;m only describing what&#39;s technically
possible. Like I said before, you may revisit your stance on
interoperability and mutual agreements one day soon. 
</p><p>
Also, what if your business decides this year to set up a commercial
partnership with another similar business and the managers come to
you asking how it&#39;s all going to work together internally?
</p><p>
You&#39;ll find having good REST interoperability already in place a
huge asset for internal integration! You&#39;ll also find that an
interop-friendly approach makes developing internal &#39;mashups&#39; much
easier.
</p><p>&#160;</p><p>
</p><p>
<b>Better Than SOA</b>
</p><p>
<b>eA:</b> I still can&#39;t see why all this is better than our SOAP
approach, though: it just seems like the same things are
happening at the end of the day - that it&#39;s only a change of 
perspective.
</p><p>
<b>DC:</b> Well, a minute ago, you were challenging using REST for
anything other than simple data manipulation. Now I&#39;ve shown 
you the power of a REST approach can be easily extended to a
clean, simple, scalable, interoperable, general, declarative
programming model. And you&#39;re still not satisfied!
</p><p>
<b>eA:</b> Ha! OK. So tell me why this programming model is so
scalable and interoperable compared with the SOAP API and 
normal function calls.
</p><p>
<b>DC:</b> It&#39;s scalable because of all the reasons I mentioned
before: the cacheability of the basic data operations and their
parallelisability through URI partitioning.  <i>updated - I meant 
data partitions not operation partitions!</i>
</p><p>
Plus now we have parallelisability of the application of the
business rules. There&#39;s nothing more parallelisable than a
declarative system.
</p><p>
<b>eA:</b> If you say so! OK, perhaps you could elaborate on that;
it sounds like a new point.
</p><p>
<b>DC:</b> It is: when you&#39;re leading the computer step-by-step
through a process, you have to handle concurrency yourself.
That&#39;s the &#39;How&#39; of &#39;What not How&#39;. 
</p><p>
Conversely, when you simply declare &#39;What&#39; the rules are, the
computer is free to go off and do things as concurrently as the
rules and the data separation allow.
</p><p>
<b>eA:</b> Mm. OK. Interoperability?
</p><p>
<b>DC:</b> It&#39;s interoperable again for the reasons I mentioned
before. Firstly, the power of the URI; this scenario is a full
player in the Web: you can share links to Items around and go
fetch your Offers and Feedbacks with a simple HTTP GET. You can
make things happen by POSTing to the relevant URI, given its
content type.
</p><p>
There&#39;s also the expectation of standard Content-Types,
sub-types and schemas in GET and POST, rather than custom
eBay WSDLs and schemas, that I mentioned before. 
</p><p>
<b>eA:</b> Like you said, you already mentioned these things.
Anything to add now that we&#39;re doing business rules?
</p><p>
<b>DC:</b> Yes; when data is your interface and resource
transformation your basic programming model, resource data
types become part of your &#39;programming language&#39;.  As such,
there is great benefit in sharing data types to <i>allow such
programming across multiple domain boundaries</i>. 
</p><p>
SOA, on the other hand, encourages inventing your own
&#39;programming language&#39; every time. It&#39;s a much more brittle
model and mind-set.
</p><p>
You can&#39;t GET your RespondToBestOffer function call, but I
can GET the ResponseToBestOffer!  It&#39;s basically a more
mashable approach to distributed programming.
</p><p>
<i>(c) 2006-2007 Duncan Cragg</i>
</p><p>&#160;</p><p>
In Part 5: <a href="http://duncan-cragg.org/blog/post/distributed-observer-pattern-rest-dialogues/">The Distributed Observer Pattern</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><p>

</p>

            </div>
        </content>
    </entry>
    
    <entry>
        <id>http://duncan-cragg.org/blog/post/business-functions-rest-dialogues/</id>
        <title>Business Functions | The REST Dialogues</title>
        <published>2007-01-10T14:21:00Z</published>
        
        <updated>2007-01-10T14:21:00Z</updated>
        
        <link rel="alternate" type="text/html" href="http://duncan-cragg.org/blog/post/business-functions-rest-dialogues/" title="Business Functions | 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" />
        
        <category term="atom" />
        
        <category term="scalability" />
        
        <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 (GetSearchResults, GetItem,
GetCategoryListings, etc).
</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 3: Business Functions</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 (GetSearchResults, GetItem,
GetCategoryListings, etc).
</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 3: Business Functions</b>
</p></div><p>
</p><p>
<b>Duncan Cragg:</b> So, where did we get to?  Oh yes: the REST
recipe for scalable and interoperable distributed systems!
</p><p>
We can read data at a URI with GET. We will usually understand
that data when we get it, because it has a standard content type
at a number of layers - perhaps from character set up to
Microformat via XML and XHTML.
</p><p>
We can cache the data if the response allows it.
</p><p>
Then we can POST back our own content to the same URI - if we
believe that this resource is interested and that it will do
something we want.
</p><p>
Finally, the content we GET has more URIs that we can use in
the same way.
</p><p>
<b>eBay Architect:</b> Simple enough.
</p><p>
<b>DC:</b> In fact, these are essentially the 
<a href="http://roy.gbiv.com/pubs/dissertation/rest_arch_style.htm">constraints of REST</a>
as formulated by Roy Fielding.  Note that Fielding hardly
mentions actual verbs in his thesis: he, in fact, gives special
mention to GET and PUT, which is consistent with the basic
&#39;state transfer&#39; concept - one verb for each direction. The 
Web (and I) prefer POST to PUT!
</p><p>
Although we expect the resource to change in some way - perhaps
change, create more resources or delete resources, the resource
can actually do what it likes when POSTed to, as long as it
conforms to its declared standard.
</p><p>
Don&#39;t forget that REST doesn&#39;t <i>require</i> direct resource
editing as either a necessary or sufficient mode of
interaction, and that in general a resource can do what it
likes on receipt of incoming content, as long as both sides
have agreed in advance.
</p><p>
<b>eA:</b> How do you know what a resource will do, then?
</p><p>
<b>DC:</b> The standard to which the POST target conforms will
declare the type of the POSTed content and set the POSTer&#39;s
expectations of the consequence of such a POST.
</p><p>
HTML, of course, is a bit vague and low-level about what you
can POST - it&#39;s either name/value pairs or files, with no
promise about what will happen afterwards. This is because a
human is directly involved in the interaction. In contrast,
we&#39;re discussing the general REST integration case here, where
higher-level, more complex, machine-generated POST types are
expected.
</p><p>
<b>eA:</b> This all sounds fine to me. But, like I said, our API
has more complex business functions in it that go beyond simple
data read and write.
</p><p>
<b>DC:</b> What sort of functions were you referring to?
</p><p>
<b>eA:</b> There&#39;s many of them. Functions like PlaceOffer,
RespondToBestOffer, CompleteSale, SendInvoice.
</p><p>
These are real functions, not getting, setting or adding
data.
</p><p>
<b>DC:</b> Indeed, and as such form an excellent exercise to
demonstrate the general power of REST!
</p><p>
<b>eA:</b> Show me how. What&#39;s the trick?
</p><p>
<b>DC:</b> The trick is simply to identify your resources, then
to discover or define how their state depends on related
resources and POSTed content, using transformation rules, or
&#39;animation&#39; code.
</p><p>
Indeed, if the state of a resource depends on the state
of other resources - or POSTed data - via a transformation,
then you have a complete, general programming model.
</p><p>
<b>eA:</b> You mean my &#39;real functions&#39;?
</p><p>
<b>DC:</b> Yes - a resource can do any &#39;real functions&#39; just by
watching resource changes via GET or receiving resource data
via POST on its URI and then mechanically transforming itself
according to its internal rules - as defined by standard,
convention or agreement.
</p><p>
Data operations are enough to enable much more than just data
operations, as long as you have the internal transformation
rules in place that animate the data in the face of current state.
</p><p>
<b>eA:</b> What does this mean to an eBay Architect? How does that
help with placing offers and responding to offers?  How do I
send an invoice?
</p><p>&#160;</p><p>
</p><p>
<b>A REST eBay Transaction</b>
</p><p>
<b>DC:</b> OK, first identify your resources: let&#39;s look at what
resources are implied by your list. You mentioned PlaceOffer,
RespondToBestOffer, CompleteSale, SendInvoice. 
</p><p>
So, it looks like we have this list of resource types: User,
Item, Offer, ResponseToBestOffer, Feedback, Invoice.
</p><p>
Notice how, when we go from function (RespondToBestOffer!) to
resource (ResponseToBestOffer), we change the names from an
imperative instruction style to a declarative state style. This
is a crucial change in mind-set.
</p><p>
<b>eA:</b> Um - the CompleteSale function isn&#39;t just for adding
feedback, it allows paid and shipped to be set on an Item.
</p><p>
<b>DC:</b> Exactly: paid and shipped status are attributes of
the actual Item being sold; the Item would be updated directly
to complete a sale.  However, it makes sense to put Feedback in
its own separate resource.
</p><p>
Admittedly, this is just my initial analysis. I&#39;m sure it could
get more complex on closer inspection; I&#39;m just trying to be
illustrative. And I don&#39;t necessarily understand the whole eBay
auction process, so please forgive any slip-ups there!
</p><p>
<b>eA:</b> OK. Now you said that we should define how these
resources depend on each other and on POSTed content, using
transformation rules.  Take me through that.
</p><p>
<b>DC:</b> Sure. There are two API Users: Sam the Seller and Bill
the Buyer.
</p><p>
Sam POSTs his Item resource, and eBay&#39;s servers create a
linkable copy server-side, returning the URI in the &#39;Location:&#39;
header of the POST response.
</p><p>
Note that a server doesn&#39;t always need to create a linkable
copy of what&#39;s POSTed to it, but that&#39;s the pattern I&#39;ll use in
these examples.
</p><p>
Let&#39;s say Sam the Seller is posting a Fixed Price Item with
Best Offers switched on - since you&#39;ve mentioned
RespondToBestOffer. Here, people can suggest a near, lower
offer and a bit of negotiating can take place. Not the usual
eBay auction but a simpler interaction that is perhaps more
generally-applicable in e-commerce.
</p><p>
<b>eA:</b> Let Bill do a PlaceOffer, then: any transformations now?
</p><p>
<b>DC:</b> Yes. A number of people, including Bill, POST Offers
linking to the Item and see these Offers created on the server.
</p><p>
<b>eA:</b> So how does Sam get to know about the Offers on his
Item?
</p><p>
<b>DC:</b> Ah - that&#39;s your first transformation! Each time an
Offer is POSTed referring to an Item, the target Item itself is
updated. In particular, the Item has a sub-container with a
list of current Offers on it, ordered by value.
</p><p>
At any time, anyone can fetch their own resources, and some
owned by others, with a GET. Sam can GET his Item and its
list of current Offers; Bill can also see the Item, and GET his
Offer.  Items and Offers thus refer to one another by internal
links that everyone can understand because they understand URIs.
</p><p>
<b>eA:</b> Is this transformation really that big a deal?
</p><p>
<b>DC:</b> Not hugely. This transformation rule encapsulates the
commonly-occurring concept in commerce of a range of values of
multiple bids on some sale item - such as found in real estate
and in financial markets.
</p><p>
A further business transformation rule may perhaps have Offers
running a &#39;best-offer&#39; status flag that is kept consistent with
that Offer&#39;s relative state.
</p><p>
As you can see, and as is often the case in REST and declarative
programming generally, these business rules are very simple.
</p><p>
<b>eA:</b> So, Sam sees a number of Offers. Let&#39;s say Bill has the
highest and Sam wants to take it.
</p><p>
<b>DC:</b> Sam then POSTs a ResponseToBestOffer, accepting, and
linking to, Bill&#39;s Offer. Again, Sam gets the server-side URI
of his ResponseToBestOffer for future reference. 
</p><p>
<b>eA:</b> This is where I&#39;d call the RespondToBestOffer function.
</p><p>
<b>DC:</b> Yep. Now, you have this state: an Item from Sam and a
list of Offers on that Item, with a Best Offer from Bill. Onto
that overall state arrives Sam&#39;s ResponseToBestOffer referring
to and accepting Bill&#39;s Offer.
</p><p>
This new state is &#39;in tension&#39;: it&#39;s not yet mutually
self-consistent with the business rules - which say that we have
a sale.
</p><p>
To resolve the tension, something&#39;s got to change.  So all the
losing Offers get updated to &#39;lost&#39;, and Bill&#39;s to &#39;won&#39;. The
Item gets updated to &#39;sold&#39;, with a link to Bill&#39;s Offer.
</p><p>
Now we&#39;re back in harmony again after some simple
transformations on our resources.
</p><p>
<b>eA:</b> Mm. That&#39;s an interesting perspective.
</p><p>
<b>DC:</b> Yes, instead of calling functions, we&#39;re asserting
state and then applying rules to bring the state into a
configuration consistent with those rules.
</p><p>
<b>eA:</b> OK. So let&#39;s go back to my SOAP function list:
CompleteSale. You said paid and shipped from CompleteSale are
on the Item - but they still need to be actioned. And we still
need to add Feedback.
</p><p>
<b>DC:</b> Clearly, you can set the paid and shipped status of an
Item using POST to the Item&#39;s URI, just like in the simpler
data setting examples before.
</p><p>
Always remember, though, that an Item is responsible for its
own integrity - it may change spontaneously according to its
internal transformation rules, or may change directly via User
POSTs - but only if it will be consistent with its internal
integrity rules.
</p><p>
<b>eA:</b> Feedback?
</p><p>
<b>DC:</b> Adding Feedback happens by the seller POSTing a Feedback
resource to the URI of the buyer User&#39;s Feedback collection,
which then returns a URI for the server-created copy.
</p><p>
A number of Feedback resources can be aggregated into a rating
on a User resource; another simple transformation, where the
rating is dependent on the state of the collection of Feedback
resources.
</p><p>
<b>eA:</b> That&#39;s a point - what URI did you POST your Items and
Offers to before, to get them created on the server?
</p><p>
<b>DC:</b> A seller User can keep a collection of current Items to
POST to; a buyer User can keep a collection of current Offers.
</p><p>
It&#39;s just like in the Atom Publishing Protocol: new Items are
POSTed to the seller&#39;s Item collection, new Offers either to a
buyer&#39;s Offer collection or directly to the relevant Item -
either way should cause the Offer to be added to the other
Offer list.
</p><p>
<b>eA:</b> OK. SendInvoice? This has the side-effect of sending an
email - now <i>there&#39;s</i> an imperative!
</p><p>
<b>DC:</b> Not when you think declarative!
</p><p>
To send an Invoice, just POST it to the buyer User&#39;s Invoice
collection to get it created on the server with its URI.
</p><p>
Creation of the Invoice resource then triggers notification to
the recipient by email. This email can either include an entire
copy of the Invoice, or have a nice RESTful link back to the
actual Invoice resource. 
</p><p>
Email notification in a REST perspective falls into the same
category as Web Feeds and POST - it&#39;s a proactive way to get
resource state or state change out to an interested party.
</p><p>
Note that, like all interactions in this approach, it&#39;s not
event-driven - it&#39;s state-driven. If you keep re-POSTing the
same Invoice, or Item or Offer, it only gets created once, and
the email only needs to be sent once!
</p><p>
<b>eA:</b> All these resources floating around - how do you manage
them? You mentioned the Item and Offer collections.
</p><p>
<b>DC:</b> A seller&#39;s User resource would collect resources
together like Items and ResponseToBestOffers. A buyer&#39;s User
resource would have links to their collections of Offers,
Invoices and Feedbacks.  Buyers can also be sellers, of course.
</p><p>
These collections all form good candidates for viewing through
a feed reader, or feed reading widget. For example, you could
subscribe to your Item&#39;s collection of Offers to see new offers
come in. You might subscribe to the Item collection of a seller
whose goods often interest you. You would almost certainly have
a subscription to the collection of Feedbacks about you...
</p><p>
This kind of thing falls naturally out of the REST approach, as
long as collections have their own URI. Note that, unlike Web
Feeds, such collections should contain <i>links</i> to their
contents, perhaps alongside some summary information, not
entire copies of their contents&#39; text!
</p><p>
<i>(c) 2006-2007 Duncan Cragg</i>
</p><p>&#160;</p><p>
In Part 4: <a href="http://duncan-cragg.org/blog/post/inter-enterprise-rest-integration-rest-dialogues/">Inter-Enterprise REST Integration</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><p>

</p>

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

