<?xml version="1.0" encoding="UTF-8"?>
<!--Generated by Squarespace V5 Site Server v5.13.156 (http://www.squarespace.com) on Mon, 20 May 2013 09:35:05 GMT--><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><title>Journal</title><link>http://www.simontylercousins.net/journal/</link><description></description><lastBuildDate>Thu, 04 Apr 2013 09:45:41 +0000</lastBuildDate><copyright></copyright><language>en-GB</language><generator>Squarespace V5 Site Server v5.13.156 (http://www.squarespace.com)</generator><item><title>JSON Converter for F# Map Type</title><category>FSharp.Enterprise</category><category>f#</category><category>json</category><dc:creator>Simon Tyler Cousins</dc:creator><pubDate>Thu, 21 Mar 2013 11:14:01 +0000</pubDate><link>http://www.simontylercousins.net/journal/2013/3/21/json-converter-for-f-map-type.html</link><guid isPermaLink="false">740536:8686775:33089890</guid><description><![CDATA[<p><a href="http://james.newtonking.com/pages/json-net.aspx">Newtonsoft</a>'s <a href="http://www.nuget.org/packages/NewtonSoft.Json">Json.NET</a>
library provides an extension mechanism to add support for the serialization of additional types not 
natively supported by the library. This is handy for the F# developer
wanting to work with <a href="http://www.json.org/">JSON</a>. Here I add support for F#'s <a href="https://github.com/fsharp/fsharp/blob/master/src/fsharp/FSharp.Core/map.fs">Map</a> type
by defining a MapTypeConverter. This code will be made available, along with other converters, in the <a href="https://github.com/colinbull/FSharp.Enterprise">FSharp.Enterprise library on github</a> in <a href="https://github.com/colinbull/FSharp.Enterprise/blob/develop/src/FSharp.Enterprise/Json.fs">Json.fs</a>.</p>

<pre><code>type MapTypeConverter() =
    inherit JsonConverter()

    let doRead (reader:JsonReader) = 
        reader.Read() |&gt; ignore

    let readKeyValuePair (serializer:JsonSerializer) (argTypes:Type []) (reader:JsonReader) =
        doRead reader // "key"
        doRead reader // value
        let key = serializer.Deserialize(reader, argTypes.[0])
        doRead reader // "value"
        doRead reader // value
        let value = serializer.Deserialize(reader, argTypes.[1])
        doRead reader // }
        FSharpValue.MakeTuple([|key;value|], FSharpType.MakeTupleType(argTypes))

    let readArray elementReaderF (reader:JsonReader) =
        doRead reader // [
        if reader.TokenType = JsonToken.StartArray then
            [|
                while reader.TokenType &lt;&gt; JsonToken.EndArray do
                    doRead reader // {
                    if reader.TokenType = JsonToken.StartObject then
                        let element = elementReaderF reader
                        yield element
            |]
        else
            Array.empty

    let writeKeyValuePair (serializer:JsonSerializer) (writer:JsonWriter) kv =
        let kvType = kv.GetType()
        let k = kvType.GetProperty("Key").GetValue(kv, null)
        let v = kvType.GetProperty("Value").GetValue(kv, null)
        writer.WriteStartObject()
        writer.WritePropertyName("key")
        serializer.Serialize(writer,k)
        writer.WritePropertyName("value")
        serializer.Serialize(writer,v)
        writer.WriteEndObject()

    let writeArray elementWriterF (writer:JsonWriter) (kvs:System.Collections.IEnumerable) =
        writer.WriteStartArray()
        for kv in kvs do
            elementWriterF writer kv
        writer.WriteEndArray()

    override x.CanConvert(typ:Type) =
        typ.IsGenericType &amp;&amp; typ.GetGenericTypeDefinition() = typedefof&lt;Map&lt;_,_&gt;&gt;

    override x.WriteJson(writer:JsonWriter, value:obj, serializer:JsonSerializer) =
        if value &lt;&gt; null then
            let valueType = value.GetType()
            if valueType.IsGenericType then
                let baseType = valueType.GetGenericTypeDefinition()
                if baseType = typedefof&lt;Map&lt;_,_&gt;&gt; then
                    let kvs = value :?&gt; System.Collections.IEnumerable
                    writer.WriteStartObject()
                    writer.WritePropertyName("pairs")
                    writeArray (writeKeyValuePair serializer) writer kvs
                    writer.WriteEndObject()   

    override x.ReadJson(reader:JsonReader, objectType:Type, existingValue:obj, serializer:JsonSerializer) =
        let argTypes = objectType.GetGenericArguments()
        let tupleType = FSharpType.MakeTupleType(argTypes)
        let constructedIEnumerableType = typedefof&lt;IEnumerable&lt;_&gt;&gt;.GetGenericTypeDefinition().MakeGenericType(tupleType)
        if reader.TokenType &lt;&gt; JsonToken.Null then
            doRead reader // "pairs"
            let kvs = readArray (readKeyValuePair serializer argTypes) reader
            doRead reader // }
            let kvs' = System.Array.CreateInstance(tupleType, kvs.Length)
            System.Array.Copy(kvs, kvs', kvs.Length)
            let methodInfo = objectType.GetMethod("Create", BindingFlags.Static ||| BindingFlags.NonPublic, null, [|constructedIEnumerableType|], null)
            methodInfo.Invoke(null, [|kvs'|])
        else
            box Map.empty
</code></pre>

<p>The MapTypeConverter can be added to the list of converters used by the Newtonsoft JSON library:</p>

<pre><code>let settings = 
    let jss = new JsonSerializerSettings()
    jss.Converters.Add(new MapTypeConverter())
    ...
    jss
</code></pre>

<p>Add a couple of helper functions:</p>

<pre><code>let ofObject payload = 
    JsonConvert.SerializeObject(payload,Formatting.None, settings)

let toObject&lt;'a&gt; js = 
    JsonConvert.DeserializeObject&lt;'a&gt;(js, settings)
</code></pre>

<p>Then F# Maps can be converted to and from JSON like so:</p>

<pre><code>let m = List.zip ["a";"b";"c"] [1..3] |&gt; Map.ofList
let j = Json.ofObject m
let o =Json.toObject&lt;Map&lt;string,int&gt;&gt; j
m = o
</code></pre>

<p>Resulting in the following:</p>

<pre><code>val m : Map&lt;string,int&gt; = map [("a", 1); ("b", 2); ("c", 3)]
val j : string =
  "{"pairs":[{"key":"a","value":1},{"key":"b","value":2},{"key":"+[16 chars]
val o : Map&lt;string,int&gt; = map [("a", 1); ("b", 2); ("c", 3)]
val it : bool = true
</code></pre>
]]></description><wfw:commentRss>http://www.simontylercousins.net/journal/rss-comments-entry-33089890.xml</wfw:commentRss></item><item><title>Why bugs don't like F#</title><category>f#</category><category>functional-programming</category><category>qcon</category><dc:creator>Simon Tyler Cousins</dc:creator><pubDate>Thu, 07 Mar 2013 09:30:31 +0000</pubDate><link>http://www.simontylercousins.net/journal/2013/3/7/why-bugs-dont-like-f.html</link><guid isPermaLink="false">740536:8686775:32929844</guid><description><![CDATA[<p>I have delivered a number of <a href="http://www.simontylercousins.net/journal/2013/2/22/does-the-language-you-choose-make-a-difference.html">projects in F#</a> that all share in common a very low defect rate (zero since go live as-of the publication date of this article). I was recently asked what I put this down to. Here is my list:</p>

<ol>
<li>I use the functional programming style as much as possible (<a href="http://notonlyoo.org">notonlyoo.org</a>)</li>
<li>In the few places I can't I am <em>very very very</em> careful.</li>
</ol>

<p>That's it. Everything else follows from these guiding principles. This is not specific to F# but F#, and other languages like it, strongly encourage and support this approach. </p>

<p>Whole classes of errors disappear because of the following:</p>

<ol>
<li>No nulls
<ul>
<li>there are no nulls, there are no null reference exceptions
<ul>
<li>F# has types that express absence more safely, Options, Choices ....</li>
</ul></li>
</ul></li>
<li>Immutable data
<ul>
<li>no complex state interaction errors
<ul>
<li>F# is immutable by default</li>
</ul></li>
</ul></li>
<li>Very strong type system
<ul>
<li>the compiler works hard to stop me writing nonsense
<ul>
<li>F# type inference and repl gives immediate feedback on nonsense</li>
</ul></li>
</ul></li>
<li><p>Composition of small functions </p>

<ul>
<li>a small function is easy to reason about, easy to test, and it will continue to work when composed with other small functions, if there is an error it will be in a single small function. Reuse is pervasive.
<ul>
<li>F# supports first class functions</li>
<li>F# has a syntax friendly to function definition and composition</li>
</ul></li>
</ul></li>
<li><p>Asynchronous programming abstractions</p>

<ul>
<li>no tedious error prone chaining, no asynchronous heisenbug errors <br />
<ul>
<li>F# asynchronous workflows make composing asynchronous computation easy and error free</li>
<li>F# agent abstraction makes dealing with state and concurrency easier to reason about</li>
</ul></li>
</ul></li>
<li><p>Higher-order functions over collections</p>

<ul>
<li>no indexing errors, boundary errors
<ul>
<li>F# has a rich library of functions over collections</li>
</ul></li>
</ul></li>
<li>Units of measure
<ul>
<li>no calculation errors caused by unit misunderstandings
<ul>
<li>F# supports typing of numeric types</li>
</ul></li>
</ul></li>
</ol>

<p>There is no magic to this. The functional programming style is a simple and safe paradigm in which to express solutions. F# provides excellent support for this style.</p>
]]></description><wfw:commentRss>http://www.simontylercousins.net/journal/rss-comments-entry-32929844.xml</wfw:commentRss></item><item><title>Does the language you choose make a difference?</title><category>c#</category><category>f#</category><dc:creator>Simon Tyler Cousins</dc:creator><pubDate>Fri, 22 Feb 2013 11:26:47 +0000</pubDate><link>http://www.simontylercousins.net/journal/2013/2/22/does-the-language-you-choose-make-a-difference.html</link><guid isPermaLink="false">740536:8686775:32860059</guid><description><![CDATA[<p>Let's compare the code from two projects using Kit Eason's code analyser on <a href="http://fssnip.net/h4" title="C# code noise">fssnip</a>. One project is written in C# and the other in F#. Both projects consume data feeds, perform some calculations and report the results to the users. The major difference between the projects is that the F# project consumes many more feeds and performs all the calculations in real-time.</p>

<h2>Comparison of Lines of Code</h2>
<br />
<p>
<img src="http://www.simontylercousins.net/storage/noise-proportional.png" alt="lines of code piecharts" title="Proportional Comparison of Lines of Code" />
</p>
    <h2>Summary</h2>

    <p>Here are the numbers:</p>

<p>
    <table class="gridtable">
        <tr>
            <th>Metric</th>
            <th>C# Project</th>
            <th>F# Project</th>
			<th>The F# Difference</th>
        </tr>
        <tr>
            <td>Useful lines</td>
            <td>183856</td>
            <td>7112</td>
            <td>26x</td>			
        </tr>
        <tr>
            <td>Comment lines</td>
            <td>57624</td>
            <td>182</td>
            <td>32x</td>			
        </tr>
        <tr>
            <td>Null check lines</td>
            <td>3036</td>
            <td>27</td>
            <td>112x</td>			
        </tr>
        <tr>
            <td>Blank lines</td>
            <td>33678</td>
            <td>1416</td>
            <td>24x</td>			
        </tr>
        <tr>
            <td>Brace lines</td>
            <td>62282</td>
            <td>265</td>
            <td>235x</td>			
        </tr>
        <tr>
            <td>Team Size</td>
            <td>7</td>
            <td>2</td>
            <td>3.5x</td>			
        </tr>
        <tr>
            <td>Project Duration</td>
            <td>5 years</td>
            <td>4 months</td>
            <td>15x</td>			
        </tr>
        <tr>
            <td>Defects since go live</td>
            <td>too many</td>
            <td>zero</td>
            <td>tending to infinity</td>			
        </tr>
    </table>
</p>

<h2>Conclusion</h2>

<p>WTF C#!!, OMG F#!!</p>

<p>... more seriously</p>

<p>
It is hard to draw any conclusions comparing different projects written by different teams using only various line counts as a metrics. 
</p>
<p>
I am both a C# dev and an F# dev. I can only offer subjective anecdotal evidence based on my experience of delivering projects in both languages (I am too busy delivering software to do anything else). I will leave rigour to others (btw let me know if you write a code analyser that can produce metrics for both C# and F#, I would love to run it on the projects I have and report the results). 
</p>
<p>
That said, the one stat in the summary that I find most compelling is the defect rate. I have now delivered three business critical projects written in F#. I am still waiting for the first bug to come in. This is not the case with the C# projects I have delivered. I will continue to monitor and report on this. It might be that I am just on a lucky streak, but I suspect that the clarity and concision of F# code contributes greatly to its correctness.
</p>
<h3>Updates:</h3>
<p>
More details on the F# project <a href="http://colinbul.wordpress.com/2013/02/23/f-end-to-end/">here</a>.
</p>
<p>
More details on the scarcity of bugs in F# code <a href="http://www.simontylercousins.net/journal/2013/3/7/why-bugs-dont-like-f.html">here</a>.
</p>
<p>
Saxon Matt performs another C#/F# code comparison <a href="http://saxonmatt.co.uk/2013/04/a-csharp-vs-fsharp-code-comparison.html">here</a>.
</p>]]></description><wfw:commentRss>http://www.simontylercousins.net/journal/rss-comments-entry-32860059.xml</wfw:commentRss></item><item><title>Function Composition in R</title><category>f#</category><category>r</category><dc:creator>Simon Tyler Cousins</dc:creator><pubDate>Tue, 15 Jan 2013 12:20:44 +0000</pubDate><link>http://www.simontylercousins.net/journal/2013/1/15/function-composition-in-r.html</link><guid isPermaLink="false">740536:8686775:32554982</guid><description><![CDATA[<p>I am learning to program in <a href="http://www.r-project.org/">R</a> with 40,000 other students by taking the excellent (and free!) <a href="http://class.coursera.org/compdata-002/class/index">Computing for Data Analysis</a> course run by Coursera.</p>

<p>R has many useful functions for slicing and dicing data, particularly if you work in an industry built on CSV files. What is missing though are some of the function operators that I am used to using from my work with F#. This means I keep having to type brackets to terminate long expressions:</p>

<pre><code>(a(b(c(d(2)))))
</code></pre>

<p>Fortunately functions are first class citizens in R and you can define infix operators. So the operators I am used to using in F# (>>, &lt;&lt;, |> and &lt;|) are only a function definition away:</p>

<pre><code>"%&gt;&gt;%" &lt;- function(a,b) {
   function(x) {
     b(a(x))
   }
}

"%&lt;&lt;%" &lt;- function(a,b) {
  function(x) {
    a(b(x))
  }
}

"%|&gt;%" &lt;- function(x,f) {
  f(x)
}

"%&lt;|%" &lt;- function(f,x) {
  f(x)
}
</code></pre>

<p>Now I can write function compositions without the hefty bracket tax:</p>

<pre><code>(a %&gt;&gt;% b %&gt;&gt;% c %&gt;&gt;% d)(2)
</code></pre>

<p>and pipeline function applications too </p>

<pre><code>2 %|&gt;% function(x) { 2 * x } %|&gt;% function(x) { 2 + x }
</code></pre>

<p>Now my R code can look a bit more like my F# code.</p>
]]></description><wfw:commentRss>http://www.simontylercousins.net/journal/rss-comments-entry-32554982.xml</wfw:commentRss></item><item><title>Progressive F# Tutorials 2012</title><category>f#</category><category>talk</category><dc:creator>Simon Tyler Cousins</dc:creator><pubDate>Wed, 31 Oct 2012 14:15:24 +0000</pubDate><link>http://www.simontylercousins.net/journal/2012/10/31/progressive-f-tutorials-2012.html</link><guid isPermaLink="false">740536:8686775:30188458</guid><description><![CDATA[<p>It's that time of year again and I will be presenting a session at the <a href="http://skillsmatter.com/event/scala/progfsharp-2012">Progressive F# Tutorials 2012</a> with Tomas Petricek on asynchronous programming in F#. See you there.</p>

<p>The introductory slide pack is <a href="http://simontylercousins.squarespace.com/storage/progressive-fsharp-2012.pdf">here</a>.</p>

<p>The code samples I will be covering are available on BitBucket <a href="https://bitbucket.org/simontcousins/progressive-fsharp-tutorials-2012">here</a>.</p>

<p>The FSharpEnt library is <a href="https://bitbucket.org/colinbul/fsharpent">here</a>.</p>
]]></description><wfw:commentRss>http://www.simontylercousins.net/journal/rss-comments-entry-30188458.xml</wfw:commentRss></item><item><title>Manifesto for Not Only Object-Oriented Development</title><dc:creator>Simon Tyler Cousins</dc:creator><pubDate>Wed, 12 Sep 2012 09:23:17 +0000</pubDate><link>http://www.simontylercousins.net/journal/2012/9/12/manifesto-for-not-only-object-oriented-development.html</link><guid isPermaLink="false">740536:8686775:28707982</guid><description><![CDATA[<p>I am pleased to announce the launch of a new web-site: <a href="http://notonlyoo.org">notonlyoo.org</a> </p>

<p>This site is aimed at capturing the zeitgeist of the nascent Not Only OO movement.</p>
]]></description><wfw:commentRss>http://www.simontylercousins.net/journal/rss-comments-entry-28707982.xml</wfw:commentRss></item><item><title>Integration Testing with Node.js</title><category>asp.net</category><category>node.js</category><category>testing</category><dc:creator>Simon Tyler Cousins</dc:creator><pubDate>Thu, 24 May 2012 07:57:11 +0000</pubDate><link>http://www.simontylercousins.net/journal/2012/5/24/integration-testing-with-nodejs.html</link><guid isPermaLink="false">740536:8686775:16423449</guid><description><![CDATA[<p>One of the joys of enterprise programming is working with legacy applications. Recently I had to update a legacy application to reflect some changes to a third party HTTP API that it relied upon. The third party had published the API specifications but, as is often the case, did not provide an implementation to perform integration tests against. So, I needed to implement a stub for the HTTP API that, in addition to handling the functional API calls, would also have to handle the session management cookies dictated by the specifications.</p>

<p>Fortunately installing Visual Studio 2003, .NET 1.1 and all of the associated service packs gave me plenty of time to consider my options. By the time all the installers had completed I had decided to use <a href="http://nodejs.org/" title="nodejs.org">node.js</a>, implemented and had running my first node.js server using node's <a href="http://expressjs.com/" title="expressjs.com">express</a> web development framework. As it states in the excellent <a href="http://expressjs.com/guide.html" title="expressjs.com/guide.html">express guide</a> and using the command line node package manager <a href="http://npmjs.org/" title="npmjs.org">(npm)</a>, this is as simple as:</p>

<pre><code>// Install express
$ npm install express
// Create server
$ express apistub &amp;&amp; cd apistub
// Install dependence
$ npm install -d
// Run the server
$ node app.js
</code></pre>

<p>To add the API handlers to match the specification required a little extra effort:</p>

<pre><code>// Login API
app.post('/apistub/controllers/ApiLogin/', function(req, res) {
  req.session.identifier = uuid.v4();
  console.log("LoginAPI [%s]", req.session.identifier);
  res.writeHead(404, authenticatedCookie(req.session.identifier));
  res.end();
})

// Logout API
app.post('/home/common/jsp/smlogout.jsp', function(req, res) {
  console.log("LogoutAPI [%s]", req.session.identifier);
  req.session.destroy();
  res.writeHead(302);
  res.end();
});

// Entry API
app.post('/apistub/controllers/:api/', function(req,res) {
  var xmlBaseFolder = 'api\\entry\\';
  var xsdBaseFolder = 'schema\\entry\\';
  handleApiCall(req,res,xmlBaseFolder,xsdBaseFolder);
});

// Exit API
app.post('/exit/controllers/:api/', function(req,res) {
  var xmlBaseFolder = 'api\\exit\\';
  var xsdBaseFolder = 'schema\\exit\\';
  handleApiCall(req,res,xmlBaseFolder,xsdBaseFolder);
});
</code></pre>

<p>The functional APIs send an XML document in the body of the request and return another XML document in the body of the response. Ideally I would like to validate the request XML against the schemas published in the specification. This is where things got tricky. As a .NET developer I am used to having libraries readily to hand to solve such problems. The node runtime is very minimal and XML schema validation is not something you get out-of-the-box.</p>

<p>Eventually I decided to fire-up my newly installed Visual Studio 2003 and create a .NET 1.1 console application that accepted an XML file and XML schema file as arguments and validated the XML against the schema using the usual (circa 2003) .NET libraries. I could then execute the XML validation application from within node like so:</p>

<pre><code>var handleApiCall = function(req,res,xmlBaseFolder,xsdBaseFolder) {
  console.log("%s [%s]", req.params.api, req.session.identifier);
  // Validate session cookie.
  if (req.cookies.smsession != req.session.identifier) {
    res.writeHead(401, notAuthenticatedCookie(req.session.identifier));    
    res.end();
  } else { 
    // Validate request xml against request schema.
    var xmlFile = xmlBaseFolder + req.params.api + 'Request.xml';
    var schemaFile = xsdBaseFolder + req.params.api + 'Request.xsd';
    fs.writeFileSync(xmlFile, req.body.INPUT);
    var child = spawn(validateXml, [xmlFile, schemaFile]);
    child.stdout.on('data', function(data) {
      console.log('stdout: ' + data);
    });
    child.on('exit', function(code){
      if (code == 0) {
        // Request is valid so send response xml.
        var responseXmlFile = 
            xmlBaseFolder + req.params.api + 'Response.xml';
        var responseXml = fs.readFileSync(responseXmlFile);
        res.writeHead(200, authenticatedCookie(req.session.identifier));
        res.end(responseXml);
      } else {
        // Request is invalid so send error xml.
        res.writeHead(500, authenticatedCookie(req.session.identifier));
        res.end(errorInvalidXml);
      }
    });
  }
}
</code></pre>

<p>The response cookies were set using:</p>

<pre><code>var authenticatedCookie = function(identifier) {
  return [['Set-Cookie', 
    'APIAUTHENTICATION=xxxx; APIAUTHORIZATION=xxxx; SMSESSION=' 
    + identifier + 
    '; TEST_STUB']];  
}

var notAuthenticatedCookie = function(identifier) {
  return [['Set-Cookie',
    'APIAUTHENTICATION=xxxx; APIAUTHORIZATION=xxxx; SMSESSION='
    + identifier +
    '; TEST_STUB']];
}
</code></pre>

<p>Job done! Integration testing can proceed using a simple, lightweight, self-contained HTTP server to mimic the behaviour of the third party API. I liked the results and can see it being used for stubbing other HTTP APIs in my landscape.</p>

<p>An alternative .NET only approach would have been to use the shiny new <a href="http://www.asp.net/web-api" title="ASP.NET Web API">ASP.NET Web API</a>. However, this would have introduced .NET 4 dependencies into the legacy application and, at the time of writing, the support for cookies is not good - <a href="http://aspnetwebstack.codeplex.com/SourceControl/network/forks/marcind/marcind/changeset/changes/488e2bcad815" title="aspnetwebstack.codeplex.com">although it is on its way</a>.</p>
]]></description><wfw:commentRss>http://www.simontylercousins.net/journal/rss-comments-entry-16423449.xml</wfw:commentRss></item><item><title>NoOO + NoSQL = Real-time Domain Model</title><dc:creator>Simon Tyler Cousins</dc:creator><pubDate>Sun, 06 May 2012 08:26:35 +0000</pubDate><link>http://www.simontylercousins.net/journal/2012/5/6/nooo-nosql-real-time-domain-model.html</link><guid isPermaLink="false">740536:8686775:16146814</guid><description><![CDATA[<!DOCTYPE html>
<html>
  <head>
    <title>Force-Directed Layout</title>
    <!--<script type="text/javascript" src="../../d3.v2.js"></script>-->
    <script type="text/javascript" src="http://www.simontylercousins.net/storage/actors/d3.v2.js"></script>
    <link type="text/css" rel="stylesheet" href="http://www.simontylercousins.net/storage/actors/actors.css"/>
  </head>
  <body>
    <div id="graph"></div>
    <script type="text/javascript" src="http://www.simontylercousins.net/storage/actors/actors.js"></script>
    <p>
The graph above (you will not see anything in IE8 and below) represents a domain model for a power market comprising
settled (past), trading (present) and forecast (future) data. 
</p>
<p>
Each node
in the graph represents something of interest in the market, e.g. energy
production, energy consumption, temperature, wind, energy price, capacity,
flow, dynamic forecast, foreign exchange etc. modelled as a collection of time series data
over a rolling time window.
</p>
<p>
Some of the nodes subscribe to market datastreams and update their
state on receipt of market data messages. Once their state is updated
they notify connected nodes which in turn update their state based on
the newly arrived data. For example, the dynamic forecast nodes would
trigger a recalculation of their market forecast.
</p>
<h3>NoOO (Not Only Object Oriented) + NoSQL</h3>
<p>
OO is supposed by some to be good for domain modelling and a possible implementation for the domain model would be as an object
graph persisted in a relational database. However, inspired by Joe Armstrong's
assertion that Erlang is the most objected oriented language, I opted to implement the domain model as a collection of
message passing actors - this has some very useful consequences.
</p>
<p>
The domain model is concurrent. Updates to a node asynchronously and concurrently trigger updates to other nodes.
</p>
<p>
Each node in the network is the guardian of its own state and
is responsible for its persistence in a document database. Gone are the
complications of ORMs and managing units of work. The persisted state
is eventually consistent, ideal for a domain model being continually updated in real-time where consistency
is a slippery concept.
</p>
<p>
The implementation used F# mailbox processors for the actors and RavenDB for the
document store (a previous post presented the concept for this, but now the implementation is complete). The visualisation uses d3 (hover the nodes to see the labels, click and drag to
rearrange nodes).
</p> 
  </body>
</html>]]></description><wfw:commentRss>http://www.simontylercousins.net/journal/rss-comments-entry-16146814.xml</wfw:commentRss></item><item><title>Evangelising F# Within Your Organisation</title><dc:creator>Simon Tyler Cousins</dc:creator><pubDate>Tue, 07 Jun 2011 08:24:54 +0000</pubDate><link>http://www.simontylercousins.net/journal/2011/6/7/evangelising-f-within-your-organisation.html</link><guid isPermaLink="false">740536:8686775:11719776</guid><description><![CDATA[<p>I will be appearing on the Evangelising F# panel tonight at <a href="http://www.meetup.com/FSharpLondon/events/16285720/">F#unctional Londoners Meetup Group<a> hosted by Skillsmatters.</p>]]></description><wfw:commentRss>http://www.simontylercousins.net/journal/rss-comments-entry-11719776.xml</wfw:commentRss></item><item><title>F# in the Enterprise Panel Discussion</title><category>f#</category><category>talk</category><dc:creator>Simon Tyler Cousins</dc:creator><pubDate>Mon, 09 May 2011 11:28:19 +0000</pubDate><link>http://www.simontylercousins.net/journal/2011/5/9/f-in-the-enterprise-panel-discussion.html</link><guid isPermaLink="false">740536:8686775:11404492</guid><description><![CDATA[<p>I will be taking part in the Community for F# live meeting panel discussion on F# in the Enterprise on 17/05/2011. For the details go <a href="http://www.communityforfsharp.net/may-2011-live-meeting">here</a>.</p>]]></description><wfw:commentRss>http://www.simontylercousins.net/journal/rss-comments-entry-11404492.xml</wfw:commentRss></item></channel></rss>