<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>exoteric</title>
	<atom:link href="http://xosfaere.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://xosfaere.wordpress.com</link>
	<description>Travelling at the outer edge of the blogosphere</description>
	<lastBuildDate>Sun, 26 Jun 2011 18:10:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='xosfaere.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/e8a3173501c961ad6d00a6c61363e2f8?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>exoteric</title>
		<link>http://xosfaere.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://xosfaere.wordpress.com/osd.xml" title="exoteric" />
	<atom:link rel='hub' href='http://xosfaere.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Code-First Development (EF) w/ SQL CE 4.0</title>
		<link>http://xosfaere.wordpress.com/2011/01/30/entity-framework-code-first-development-with-sql-ce-4-0/</link>
		<comments>http://xosfaere.wordpress.com/2011/01/30/entity-framework-code-first-development-with-sql-ce-4-0/#comments</comments>
		<pubDate>Sun, 30 Jan 2011 19:12:59 +0000</pubDate>
		<dc:creator>xosfaere</dc:creator>
				<category><![CDATA[Datamodel]]></category>
		<category><![CDATA[Declarative]]></category>
		<category><![CDATA[Imperative]]></category>
		<category><![CDATA[Paradigm]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[Code-First]]></category>
		<category><![CDATA[Community Technology Preview]]></category>
		<category><![CDATA[Compact Edition]]></category>
		<category><![CDATA[CTP]]></category>
		<category><![CDATA[Domain Model]]></category>
		<category><![CDATA[EDM]]></category>
		<category><![CDATA[EF]]></category>
		<category><![CDATA[Entity Data Model]]></category>
		<category><![CDATA[Entity Framework]]></category>
		<category><![CDATA[LinkedIN]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[LINQ2SQL]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Model-First]]></category>
		<category><![CDATA[ORM]]></category>
		<category><![CDATA[SDF]]></category>
		<category><![CDATA[SQL CE]]></category>
		<category><![CDATA[SQL CE 4.0]]></category>
		<category><![CDATA[SSCE]]></category>
		<category><![CDATA[WebMatrix]]></category>

		<guid isPermaLink="false">http://xosfaere.wordpress.com/?p=1242</guid>
		<description><![CDATA[I&#8217;ve been playing with the new Microsoft WebMatrix IDE. It&#8217;s a very neat little piece of software that takes the effort out of many things. It&#8217;s great for small Web projects. The problem with out-of-the-box WebMatrix development is that it &#8230; <a href="http://xosfaere.wordpress.com/2011/01/30/entity-framework-code-first-development-with-sql-ce-4-0/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&amp;blog=1884763&amp;post=1242&amp;subd=xosfaere&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been playing with the new Microsoft WebMatrix IDE. It&#8217;s a very neat little piece of software that takes the effort out of many things. It&#8217;s great for small Web projects.</p>
<p>The problem with out-of-the-box WebMatrix development is that it encourages you to use direct SQL programming with embedded SQL queries. The world has moved away from embedded SQL queries in favor of object-relational mapping and (domain-un-specific) query syntax such as LINQ.</p>
<p>I wanted to test out using LINQ2SQL with WebMatrix. The tool to use when doing Database-First LINQ2SQL development is called SQLmetal. It queries the database schema and generates mapping classes (one class per table) that allows one to use LINQ syntax in C# or VB.NET directly against the source data.</p>
<p>The problem, though, is that SQLmetal does not appear to work with SQL CE 4.0. So, what to do?</p>
<p>Microsoft&#8217;s next-generation O-R mapper &#8211; Entity Framework (EF) &#8211; is one possibility. Entity Framework uses the <a title="Entity Data Model (EDM)" href="http://msdn.microsoft.com/en-us/library/ee382825.aspx">Entity Data Model (EDM)</a> as its conceptual mapping framework.</p>
<p>Microsoft has three basic strategies for using the Entity Framework (very roughly):</p>
<ul>
<li><strong>Database-First</strong>: Start with a database and create an Entity Data Model (EDM) that maps to that database</li>
<li><strong>Model-First</strong>: Start with an Entity Data Model and generate classes and database from that model</li>
<li><strong>Code-First</strong>: Start with classes and generate a database from those classes; use data annotation attributes to guide the mapping</li>
</ul>
<p>It is the Model-First and the Code-First approaches that I find most interesting. In this case I chose the Code-First approach because it appears easier to work with without any tooling support.</p>
<p>So what do we need to work with Code-First and SQL CE 4.0?</p>
<p>We need to</p>
<ul>
<li>download and install SQL CE 4.0</li>
<li>download and install Entity Framework Code-First (currently at CTP 5 status)</li>
</ul>
<p>Then we need to setup a basic project. Let&#8217;s just make a C# console application.</p>
<p>Then we need to reference some assemblies. We need these ones:</p>
<ul>
<li>System.ComponentModel.DataAnnotations.dll</li>
<li>EntityFramework.dll (Code-First CTP 5)</li>
<li>System.Data.SqlServerCe.dll (SQL CE 4.0)</li>
</ul>
<p>Then we need to import some namespaces beyond the default ones:</p>
<ul>
<li>System.Data</li>
<li>System.Data.Entity</li>
<li>System.Data.Entity.Database</li>
<li>System.Data.SqlServerCe</li>
<li>System.ComponentModel.DataAnnotations</li>
</ul>
<p>That settles our external dependencies. Now onto the data modeling.</p>
<p>Most Web sites will want a user type, for logins and such. Let&#8217;s create a basic user domain model using Code-First code:</p>
<pre class="brush: csharp;">
public class User
{
    public string Name { get; set; }

    public string Password { get; set; }

    public string PrimaryEmailAddress { get; set; }

    public string SecondaryEmailAddress { get; set; }

    public DateTime Creation { get; set; }

    public bool Active { get; set; }
}
</pre>
<p>Now, for the database mapping to make a little more sense we&#8217;ll add some constraints via attributes:</p>
<pre class="brush: csharp;">
public class User
{
    [Key, StringLength(50)]
    public string Name { get; set; }

    [Required, StringLength(100)]
    public string Password { get; set; }

    [Required, StringLength(320)]
    public string PrimaryEmailAddress { get; set; }

    [StringLength(320)]
    public string SecondaryEmailAddress { get; set; }

    [Required]
    public DateTime Creation { get; set; }

    public bool Active { get; set; }
}
</pre>
<p>The attributes are pretty self-explanatory.</p>
<p>We need one more thing in order to be able to use this, a DbContext-derived class that references our User domain model class.</p>
<pre class="brush: csharp;">
public class ProtoCatalog : DbContext
{
    public DbSet&lt;User&gt; Users { get; set; }
}
</pre>
<p>Now we are ready to actually use the model. The following code will insert a new user into the database. Assuming there isn&#8217;t already a database file present, one will be automatically generated for us:</p>
<pre class="brush: csharp;">
static void Main(string[] args)
{
    DbDatabase.DefaultConnectionFactory = new SqlCeConnectionFactory(&quot;System.Data.SqlServerCe.4.0&quot;);

    using (var db = new ProtoCatalog())
    {
        var user = new User
        {
            Name = &quot;bob&quot;,
            Password = &quot;123&quot;,
            Creation = DateTime.Now,
            PrimaryEmailAddress = &quot;bob@example.com&quot;
        };

        db.Users.Add(user);

        db.SaveChanges();
    }
}
</pre>
<p>That&#8217;s it. We now have a new Entity Framework-generated SQL CE 4.0 database with data. It was generated from a simple class modeling our simple domain.</p>
<p>I don&#8217;t think the Entity Framework Code-First CTP API is quite as nice as it could be though:  setting a static property on the DbDatabase class to use a specific database driver is not that clean. It&#8217;s global state and we don&#8217;t like global state.</p>
<p>Let&#8217;s try and open the new database in WebMatrix and see what happens.</p>
<p><a href="http://xosfaere.files.wordpress.com/2011/01/webmatrix-ef-sdf.png"><img class="aligncenter size-full wp-image-1243" title="webmatrix-ef-sdf" src="http://xosfaere.files.wordpress.com/2011/01/webmatrix-ef-sdf.png?w=640&#038;h=469" alt="" width="640" height="469" /></a></p>
<p>Let&#8217;s see the data as well:</p>
<p><a href="http://xosfaere.files.wordpress.com/2011/01/webmatrix-ef-sdf-data.png"><img class="aligncenter size-full wp-image-1244" title="webmatrix-ef-sdf-data" src="http://xosfaere.files.wordpress.com/2011/01/webmatrix-ef-sdf-data.png?w=640&#038;h=412" alt="" width="640" height="412" /></a></p>
<p>So, we&#8217;ve designed a Code-First data model. We&#8217;ve made some code to insert data into a database fitting this model. The EF code automatically generated a SQL CE 4.0 database when no previous database file existed. And finally we&#8217;ve seen the database schema and data inside of WebMatrix.</p>
<p>Presto.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xosfaere.wordpress.com/1242/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xosfaere.wordpress.com/1242/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xosfaere.wordpress.com/1242/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xosfaere.wordpress.com/1242/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xosfaere.wordpress.com/1242/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xosfaere.wordpress.com/1242/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xosfaere.wordpress.com/1242/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xosfaere.wordpress.com/1242/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xosfaere.wordpress.com/1242/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xosfaere.wordpress.com/1242/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xosfaere.wordpress.com/1242/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xosfaere.wordpress.com/1242/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xosfaere.wordpress.com/1242/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xosfaere.wordpress.com/1242/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&amp;blog=1884763&amp;post=1242&amp;subd=xosfaere&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xosfaere.wordpress.com/2011/01/30/entity-framework-code-first-development-with-sql-ce-4-0/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f816a0c0bd66d40be3b47d586c76a1ea?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Bent</media:title>
		</media:content>

		<media:content url="http://xosfaere.files.wordpress.com/2011/01/webmatrix-ef-sdf.png" medium="image">
			<media:title type="html">webmatrix-ef-sdf</media:title>
		</media:content>

		<media:content url="http://xosfaere.files.wordpress.com/2011/01/webmatrix-ef-sdf-data.png" medium="image">
			<media:title type="html">webmatrix-ef-sdf-data</media:title>
		</media:content>
	</item>
		<item>
		<title>Pixels en masse</title>
		<link>http://xosfaere.wordpress.com/2010/11/23/pixels-en-masse/</link>
		<comments>http://xosfaere.wordpress.com/2010/11/23/pixels-en-masse/#comments</comments>
		<pubDate>Tue, 23 Nov 2010 20:43:18 +0000</pubDate>
		<dc:creator>xosfaere</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[2D]]></category>
		<category><![CDATA[3D]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Image Processing]]></category>
		<category><![CDATA[LinkedIN]]></category>
		<category><![CDATA[LINQPad]]></category>
		<category><![CDATA[Parallel]]></category>
		<category><![CDATA[Pixel shader]]></category>

		<guid isPermaLink="false">http://xosfaere.wordpress.com/?p=1236</guid>
		<description><![CDATA[In this post I&#8217;ll show you how to do image processing in 50 lines of C# code, or less. To do this, we&#8217;ll need a few trustees: Microsoft .Net, our software platform of choice LinqPad, our software environment of choice &#8230; <a href="http://xosfaere.wordpress.com/2010/11/23/pixels-en-masse/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&amp;blog=1884763&amp;post=1236&amp;subd=xosfaere&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In this post I&#8217;ll show you how to do image processing in 50 lines of C# code, or less.</p>
<p>To do this, we&#8217;ll need a few trustees:</p>
<ul>
<li><span style="font-size:15.6px;">Microsoft .Net, our software platform of choice</span></li>
<li><span style="font-size:15.6px;">LinqPad, our software environment of choice</span></li>
</ul>
<p>First, fire up LinqPad and start by importing System.Drawing. All other needed namespaces are imported by LinqPad.</p>
<p>Then we need to change the script type from Expression to Program. This gives us the full expressive power of C#, including the ability to do statements, create methods, classes, structs, etc.</p>
<p>Then we define a main method:</p>
<pre class="brush: csharp;">
void Main()
{
	var desktop = Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop);
	var droplet = Path.Combine(desktop, &quot;droplet.jpg&quot;);
	Render(new Bitmap(droplet), PixelShader1).Dump();
}
</pre>
<p>The first lines defines the desktop folder path.  The second line defines the path to an image I have on my desktop. The third is where the action starts. This line calls the Render method, passing along the droplet image and then a method delegate. The result of the call is dumped to the output. The Dump method is a special LinqPad extension method that normally outputs a textual representation of the state of the object being dumped out. It does however handle XML data and image data specially. In the case of image data it will show the data as an image.</p>
<p>Next we define the Render method. Note that this is a straight-forward higher-order method that takes in a bitmap and a shader and gives back a new and shaded copy of the source bitmap.</p>
<pre class="brush: csharp;">
IEnumerable&lt;Bitmap&gt; Render(Bitmap source, PixelShader shader)
{
	var w = source.Width;
	var h = source.Height;

	var pixels =
		from x in Enumerable.Range(0, w)
		from y in Enumerable.Range(0, h)
		let  p = source.GetPixel(x, y)
		select new { X = x, Y = y, Color = p };

	var target = (Bitmap)source.Clone();

	foreach (var p in pixels)
	{
		target.SetPixel(p.X, p.Y, shader(p.X, p.Y, w, h, p.Color));
	}

	yield return source;
	yield return target;
}
</pre>
<p>Well, that description is not entirely accurate. I&#8217;ve set it up so that it actually returns a stream of images. So far it will only return the source and target images but it can now be easily extended to generates animations, courtesy of iterators (see &#8220;yield return&#8221;).</p>
<p>There&#8217;s a couple of things to notice about this code</p>
<ul>
<li>the code is sequential</li>
<li>the code uses linq</li>
</ul>
<p>These are by no means opposites but in 50 lines of code, I&#8217;ll not show you parallel LINQ or parallel code. It is however easy to bolt on and I&#8217;ll leave this as an exercise to the reader. Beware that the Bitmap class is not thread-safe!</p>
<p>Now it&#8217;s time to define what a pixel shader is (in this narrow context). It&#8217;s simple</p>
<pre class="brush: csharp;">
delegate Color PixelShader(int x, int y, int w, int h, Color source);
</pre>
<p>The PixelShader is just a function from a coordinate set (x,y), a dimension (w,h) and a color to a new color. This representation lets you do a lot of magic but you can easily extend it to include a pixel matrix and a time parameter for added power.</p>
<p>Now let&#8217;s define a simple pixel shader that just swaps the two color channels red and green:</p>
<pre class="brush: csharp;">
Color PixelShader1(int x, int y, int w, int h, Color source)
{
	var a = source.A;
	var r = source.R;
	var g = source.G;
	var b = source.B;

	Swap(ref r, ref g);

	return Color.FromArgb(a, r, g, b);
}
</pre>
<p>First we read out the alpha, red, green and blue pixel values, then we swap red and green and then we construct a new color from that.</p>
<p>Last but not least, a little helper function for swapping values:</p>
<pre class="brush: csharp;">
void Swap&lt;T&gt;(ref T a, ref T b)
{
	var t = a;
	a = b;
	b = t;
}
</pre>
<p>I&#8217;ve previously written against using methods with ref and out parameters but in some cases, they are quite useful.</p>
<p>That&#8217;s it! &#8211; A compositional image processing script in 50 lines of code.</p>
<p>The output looks like this (<a href="http://img696.imageshack.us/img696/2313/generativefull.png">full image</a>):</p>
<p><a href="http://xosfaere.files.wordpress.com/2010/11/generative.png"><img class="aligncenter size-full wp-image-1239" title="generative" src="http://xosfaere.files.wordpress.com/2010/11/generative.png?w=380&#038;h=384" alt="" width="380" height="384" /></a></p>
<p>Some extensions left as an exercise for the reader:</p>
<ul>
<li><strong>multi-threading</strong> (Threads/ThreadPool or better Tasks/Parallel or perhaps PLINQ)</li>
<li><strong>animation</strong></li>
<li><strong>color space conversion </strong>(RGB, HSL, LAB, CMYK, &#8230;)</li>
<li><strong>3D/4D image processing and synthesis</strong></li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xosfaere.wordpress.com/1236/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xosfaere.wordpress.com/1236/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xosfaere.wordpress.com/1236/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xosfaere.wordpress.com/1236/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xosfaere.wordpress.com/1236/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xosfaere.wordpress.com/1236/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xosfaere.wordpress.com/1236/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xosfaere.wordpress.com/1236/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xosfaere.wordpress.com/1236/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xosfaere.wordpress.com/1236/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xosfaere.wordpress.com/1236/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xosfaere.wordpress.com/1236/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xosfaere.wordpress.com/1236/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xosfaere.wordpress.com/1236/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&amp;blog=1884763&amp;post=1236&amp;subd=xosfaere&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xosfaere.wordpress.com/2010/11/23/pixels-en-masse/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f816a0c0bd66d40be3b47d586c76a1ea?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Bent</media:title>
		</media:content>

		<media:content url="http://xosfaere.files.wordpress.com/2010/11/generative.png" medium="image">
			<media:title type="html">generative</media:title>
		</media:content>
	</item>
		<item>
		<title>Tablet, The Ultimate</title>
		<link>http://xosfaere.wordpress.com/2010/11/02/tablet-the-ultimate/</link>
		<comments>http://xosfaere.wordpress.com/2010/11/02/tablet-the-ultimate/#comments</comments>
		<pubDate>Tue, 02 Nov 2010 22:40:12 +0000</pubDate>
		<dc:creator>xosfaere</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[Augmented Reality]]></category>
		<category><![CDATA[IPad]]></category>
		<category><![CDATA[LinkedIN]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Microsoft Research]]></category>
		<category><![CDATA[Multi-touch]]></category>
		<category><![CDATA[Tablets]]></category>
		<category><![CDATA[Wi-Fi]]></category>

		<guid isPermaLink="false">http://xosfaere.wordpress.com/?p=1228</guid>
		<description><![CDATA[The tablet PC is a fascinating creature. The flat multi-touch surface provides a great opportunity to make the PC natural, intuitive and to some extent tangible. It will empower artists and narrow the gap between impression and expression, between thought &#8230; <a href="http://xosfaere.wordpress.com/2010/11/02/tablet-the-ultimate/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&amp;blog=1884763&amp;post=1228&amp;subd=xosfaere&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The tablet PC is a fascinating creature. The flat <a class="zem_slink" title="Multi-touch" rel="wikipedia" href="http://en.wikipedia.org/wiki/Multi-touch">multi-touch</a> surface provides a great opportunity to make the PC natural, intuitive and to some extent tangible. It will empower artists and narrow the gap between impression and expression, between thought and creation.</p>
<p>The most amazing fact of the tablet, however, is the time it has taken the industry to realize it in a quasi-interesting form.</p>
<p>I&#8217;ve always felt that the mouse and keyboard was, although great for many tasks, utter limiting for other tasks of a more creative nature.</p>
<p>For audio and music the tablet provides a cool multi-touch interface that shortens the cognitive path between idea and output, it enables one to make changes faster and more real-time. Special-purpose multi-touch tablets are starting to appear for audio synthesis and sequencing purposes. It just makes sense.</p>
<p>In the realm of graphics, in particular 3-dimensional graphics, I&#8217;ve always felt that mouse and keyboard simply isn&#8217;t the right medium. Surely we can do better. Multi-touch is a great next step. An accellerometer and compas equipped tablet could be used as a physical camera into a virtual world. Moving the tablet around shows the scene. One could imagine setting up virtual cameras this way by moving the tablet around and then pinning virtual manifestations of it to whereever.</p>
<p>There are several annoying limitations of mainstream technology though; primarily, I think these:</p>
<ul>
<li>Thickness: they are getting there, but they are still a little bulky</li>
<li>Weight: they are not as light-weight as one could hope for, making prolonged use somewhat tiresome</li>
<li>Flex: they are rigid, unlike say, a newspaper, which is an inconvenience as reading is one of the nice applications of tablets; there are research prototypes for flexible electronic paper, however</li>
<li>Pressure: they are not pressure sensitive beyond 1-bit binary sensitivity: touch or no touch; for audio and music, a pressure sensitive touch surface is important; likewise for 3-dimensional graphics pressure senitivity would allow artists and industrial designers finer control in modelling scenarios, where virtual matter is shaped like clay</li>
<li>Tactile: they do not provide much tactile feedback beyond flat touch; <a class="zem_slink" title="Microsoft Research" rel="homepage" href="http://research.microsoft.com/">Microsoft Research</a> has some prototypes for devices that attach directly to the body; one could potentially conceive of a system that provides nervous system feedback, tricking the brain into thinking there is a landscape in mid-air; at some point, we may want to skip the tablet altogether and just use this virtual tactile feedback combined with stereo-projected images on variable-transparency glasses; this will also make augmented reality almost transparent; well, beyond computational contact-lenses and &#8220;wet-ware&#8221; cybernetics.</li>
</ul>
<p>The space of potential applications, however, is awesome. At least with the hardware we&#8217;ll hopefully see with the next 10 years and beyond. Not so long ago, Microsoft provided a series of concept videos &#8211; Future Visions &#8211; which show-cased where Microsoft thinks the future is. Suffice it to say: the future is bright.</p>
<p>For now, I&#8217;m happy to have bought a device that brings us a couple of steps closer to this dream: The Apple iPad.</p>
<p>So far my experience is that it&#8217;s a great device and has muted the need for my laptop PC which is now idle. The iPad is a great social networking tool with applications providing specialized user experiences fit for <a class="zem_slink" title="iPad" rel="homepage" href="http://www.apple.com/ipad/">the iPad</a> form factor and surface.</p>
<p>Location awareness is also an awesome feature which is sure to come in very handy.</p>
<p>Music is remote-controlled from the living room, with control signals sent to iTunes on the main PC, sending music streaming through a TOSLink optical cable and into the stereo. A bit of a bulky remote (in the absence of an iPhone), but cool nonetheless.</p>
<p>The things that annoy me about it is that there doesn&#8217;t appear to be a way to organize applications into folders on the desktop surface and when in the App Store, when buying an application you will leave the store and go to the desktop which is not so nice when &#8220;power shopping&#8221; (free apps or not).</p>
<p>There&#8217;s a lot to love about this little gem of a device though!</p>
<p>This is my second Apple product. The first one was the Apple Wireless Keyboard. Not because I have anything against Apple (well actually, their closed-world policy, with respect to programming languages and in general is&#8230; vexing), but mostly due to the price tag on many of their products.</p>
<p>I see Microsoft making headway with the pretty cool Windows Phone 7 OS with its Silverlight UX and for the sake of consumer wallets everywhere, and industry progress, I hope Microsoft will also (re-) enter this market. Witnessing Windows Phone 7, the software for this hypothetical tablet ought to be great but witnessing some of the phone hardware provided by 3rd parties, optimism dims a little. The finish of an Apple product is hard to beat.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xosfaere.wordpress.com/1228/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xosfaere.wordpress.com/1228/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xosfaere.wordpress.com/1228/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xosfaere.wordpress.com/1228/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xosfaere.wordpress.com/1228/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xosfaere.wordpress.com/1228/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xosfaere.wordpress.com/1228/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xosfaere.wordpress.com/1228/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xosfaere.wordpress.com/1228/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xosfaere.wordpress.com/1228/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xosfaere.wordpress.com/1228/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xosfaere.wordpress.com/1228/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xosfaere.wordpress.com/1228/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xosfaere.wordpress.com/1228/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&amp;blog=1884763&amp;post=1228&amp;subd=xosfaere&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xosfaere.wordpress.com/2010/11/02/tablet-the-ultimate/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f816a0c0bd66d40be3b47d586c76a1ea?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Bent</media:title>
		</media:content>
	</item>
		<item>
		<title>Shapely Monads</title>
		<link>http://xosfaere.wordpress.com/2010/10/05/shapely-monads/</link>
		<comments>http://xosfaere.wordpress.com/2010/10/05/shapely-monads/#comments</comments>
		<pubDate>Tue, 05 Oct 2010 18:09:15 +0000</pubDate>
		<dc:creator>xosfaere</dc:creator>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Datamodel]]></category>
		<category><![CDATA[Declarative]]></category>
		<category><![CDATA[Imperative]]></category>
		<category><![CDATA[Paradigm]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Channel 9]]></category>
		<category><![CDATA[Greg Meredith]]></category>
		<category><![CDATA[identity]]></category>
		<category><![CDATA[Lecture Series]]></category>
		<category><![CDATA[LinkedIN]]></category>
		<category><![CDATA[List]]></category>
		<category><![CDATA[Maybe]]></category>
		<category><![CDATA[Metaphor]]></category>
		<category><![CDATA[Monads]]></category>
		<category><![CDATA[Set]]></category>
		<category><![CDATA[Shapely Monads]]></category>
		<category><![CDATA[State]]></category>

		<guid isPermaLink="false">http://xosfaere.wordpress.com/?p=1200</guid>
		<description><![CDATA[&#8220;A new way to think about monads.&#8221; 0. Index Greg Meredith on Monads Definition Syntax The List Shape &#160;&#160;&#160;3.0. Shape &#160;&#160;&#160;3.1. Wrap &#160;&#160;&#160;3.3. Roll Equations Shapes &#38; Monads &#160;&#160;&#160;5.1. The Identity Monad &#160;&#160;&#160;5.2. The  Maybe Monad &#160;&#160;&#160;5.3. The List Monad &#8230; <a href="http://xosfaere.wordpress.com/2010/10/05/shapely-monads/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&amp;blog=1884763&amp;post=1200&amp;subd=xosfaere&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><em>&#8220;A new way to think about monads.&#8221;</em></p>
<p><strong>0. Index</strong></p>
<ol>
<li>Greg Meredith on Monads</li>
<li>Definition</li>
<li>Syntax</li>
<li>The List Shape<br />
&nbsp;&nbsp;&nbsp;3.0. Shape<br />
&nbsp;&nbsp;&nbsp;3.1. Wrap<br />
&nbsp;&nbsp;&nbsp;3.3. Roll</li>
<li>Equations</li>
<li>Shapes &amp; Monads<br />
&nbsp;&nbsp;&nbsp;5.1. The <span style="color:#33cccc;"><em>Identity</em> </span>Monad<br />
&nbsp;&nbsp;&nbsp;5.2. The  <span style="color:#800080;"><em>Maybe </em></span>Monad<br />
&nbsp;&nbsp;&nbsp;5.3. The <span style="color:#ff0000;"><em>List </em></span>Monad<br />
&nbsp;&nbsp;&nbsp;5.4. The <span style="color:#339966;"><em>Set </em></span>Monad</li>
<li>Lessons</li>
</ol>
<p><strong>1. Greg Meredith on Monads</strong></p>
<p>I&#8217;ve found a wonderful metaphor for the elusive concept of monads. This metaphor was created by Greg Meredith, mathematician, computer scientist and monad expert.</p>
<p>See his presentation:</p>
<ul>
<li><a href="http://channel9.msdn.com/Blogs/Charles/C9-Lectures-Greg-Meredith-Monadic-Design-Patterns-for-the-Web-Introduction-to-Monads">Greg Meredith on Monads</a></li>
</ul>
<p>I&#8217;ll try to sumarize my own understanding of the main points of Greg&#8217;s presentation below; for myself and for anyone else interested. Please correct me if you think I&#8217;ve misunderstood something.</p>
<p>Note. This blog post will evolve. I periodically update it.</p>
<p><strong>2. Definition</strong></p>
<p>The metaphor consists of three parts:</p>
<ul>
<li>Shape</li>
<li>wrap</li>
<li>roll</li>
</ul>
<p>Monads with structure also have this part:</p>
<p><span style="font-family:Georgia, 'Bitstream Charter', serif;line-height:24px;font-size:16px;"> </span></p>
<ul>
<li>compose</li>
</ul>
<p><strong>3. Syntax</strong></p>
<p><span style="color:#000000;">The syntax chosen is important to how easy to understand something is. Greg has found that using markup syntax (angle bracket syntax, e.g. &lt;list&gt;1,2,3&lt;/list&gt;) is a useful way to think about the shape of monad instances; therefore Shapely Monads.</span></p>
<p>I&#8217;m going to augment this by translating it into domain-specific syntax for lists as well, to make structure even more easy to see.</p>
<p><span style="color:#000000;">In the following examples I&#8217;ll use 4 syntaxes:</span></p>
<ul>
<li><span style="color:#333333;">function call syntax, e.g. wrap(3); how one would write in a program; qualified (e.g. List.wrap, or Set.wrap) and unqualified (e.g. wrap; this <em>assuming</em> some shape in the context of its use.)</span></li>
<li>abbreviated function call syntax, e.g. w(3) is the same as wrap(3)</li>
<li>shape-specific syntax, e.g. <span style="color:#ff0000;">[</span>a,b,c,...<span style="color:#ff0000;">]</span> for lists, simply because it&#8217;s easy to understand; other examples: <span style="color:#339966;">{</span>a,b,c,&#8230;<span style="color:#339966;">}</span> for sets.</li>
<li>markup syntax, e.g. <span style="color:#ff0000;">&lt;list&gt;</span>a,b,c,&#8230;<span style="color:#ff0000;">&lt;/list&gt;</span> for lists (same as <span style="color:#ff0000;">[</span>a,b,c,...<span style="color:#ff0000;">]</span>) whereas <span style="color:#339966;">&lt;set&gt;</span>a,b,c,&#8230;<span style="color:#339966;">&lt;/set&gt;</span> is for sets (same as <span style="color:#339966;">{</span>a,b,c,&#8230;<span style="color:#339966;">})</span>, etc.</li>
</ul>
<p>I&#8217;ll be careful to make the syntax obvious.</p>
<p><strong>4. The List Shape</strong></p>
<p>To start with some concrete examples, let&#8217;s use the monad of lists, the list monad.</p>
<p><strong>4.0. Shape</strong></p>
<p><span style="color:#000000;">The list shape is something which we can symbolize as:</span></p>
<ul>
<li><span style="color:#ff0000;">[]</span> is the empty list; <span style="color:#ff0000;">&lt;list&gt;&lt;/list&gt;</span></li>
<li><span style="color:#ff0000;">[</span>a<span style="color:#ff0000;">]</span> is the singleton list; <span style="color:#ff0000;">&lt;list&gt;</span>a<span style="color:#ff0000;">&lt;/list&gt;</span></li>
<li><span style="color:#ff0000;">[</span>a,b,c<span style="color:#ff0000;">]</span> is a list of three elements; <span style="color:#ff0000;">&lt;list&gt;</span>a,b,c<span style="color:#ff0000;">&lt;/list&gt;</span></li>
<li>and so on</li>
</ul>
<p>The sequare bracket syntax is just domain-specific syntax for lists. We use it here to make it easy to see the structure of values.</p>
<p><strong>4.1. Wrap</strong></p>
<p>First let&#8217;s create a list of one element, the number zero:</p>
<ul>
<li><span style="color:#333333;">List.wrap</span>(0) = <span style="color:#ff0000;">&lt;</span><span style="color:#ff0000;">list</span><span style="color:#ff0000;">&gt;</span>0<span style="color:#ff0000;">&lt;/</span><span style="color:#ff0000;">list</span><span style="color:#ff0000;">&gt;</span> = <span style="color:#ff0000;">[</span>0<span style="color:#ff0000;">]</span></li>
</ul>
<p>So we&#8217;ve now put the value 0 <em>into</em> the list monad.</p>
<p>List elements can be other lists, so for example:</p>
<ul>
<li><span style="color:#ff0000;">[[</span>a],<span style="color:#ff0000;">[</span>b,c<span style="color:#ff0000;">]]</span> is a list of a list of a, followed by a list of b and c</li>
</ul>
<p>The operator expression to construct this sequence is</p>
<blockquote><p><span style="font-style:normal;"><span style="color:#333333;">List</span><span style="color:#333333;">.wrap(List.wrap(a),List.wrap(List.wrap(b)+List.wrap(c)))</span><br />
=<br />
<span style="color:#333333;"> List</span><span style="color:#333333;">.wrap</span>(<span style="color:#ff0000;">&lt;list&gt;</span>a<span style="color:#ff0000;">&lt;/list&gt;</span>,<span style="color:#ff0000;">&lt;list&gt;</span>b,c<span style="color:#ff0000;">&lt;/list&gt;</span>)<br />
=<br />
<span style="color:#ff0000;"> &lt;list&gt;</span><br />
&nbsp;&nbsp;&nbsp;<span style="color:#ff0000;">&lt;list&gt;</span>a<span style="color:#ff0000;">&lt;/list&gt;</span><br />
&nbsp;&nbsp;&nbsp;<span style="color:#ff0000;"> &lt;list&gt;</span>b,c<span style="color:#ff0000;">&lt;/list&gt;</span><br />
<span style="color:#ff0000;"> &lt;/list&gt;</span><br />
=<br />
<span style="color:#ff0000;"> [[</span>a<span style="color:#ff0000;">]</span>,<span style="color:#ff0000;">[</span>b,c<span style="color:#ff0000;">]]</span></span></p></blockquote>
<p><strong>4.2. Compose</strong></p>
<p>To compose lists (append lists to eachother), we can write</p>
<ul>
<li><span style="color:#333333;">List</span><span style="color:#333333;">.compose(List.wrap(0),List.wrap(1))</span> = <span style="color:#ff0000;">&lt;list&gt;</span>0,1<span style="color:#ff0000;">&lt;/list&gt;</span> = <span style="color:#ff0000;">[</span>0,1<span style="color:#ff0000;">]</span></li>
</ul>
<p>this will create the singleton list of the number zero composed with the singleton list of the number one, creating a new list of two elements, zero and one.</p>
<p>So far we&#8217;ve leared that:</p>
<ul>
<li>List is <em>a</em> Shape; we use <span style="color:#ff0000;">color </span>here to help recognize lists</li>
<li>List.wrap(x) constructs a new list of one element, i.e. <span style="color:#ff0000;">[</span>x<span style="color:#ff0000;">]</span></li>
<li>List.compose is the append operation; it takes two lists and creates a new list which is the two lists in sucession</li>
</ul>
<p>Note also that the neutral instance of the list monad is <span style="color:#ff0000;">[]</span>, i.e. <span style="color:#ff0000;">&lt;list&gt;&lt;/list&gt;</span> or what we might express as List.wrap(); composing an empty list with any other list yields the same list; it has no effect; we can see this as</p>
<ul>
<li><span style="color:#ff0000;">&lt;list&gt;</span>x<span style="color:#ff0000;">&lt;/list&gt;</span> + <span style="color:#ff0000;">&lt;list&gt;&lt;/list&gt;</span> = <span style="color:#ff0000;">&lt;list&gt;</span>x<span style="color:#ff0000;">&lt;/list&gt;</span>
<p>XML has special support for empty elements, which we can take advantage of</p>
<p><span style="color:#ff0000;">&lt;list&gt;</span>x<span style="color:#ff0000;">&lt;/list&gt;</span> + <span style="color:#ff0000;">&lt;list/&gt;</span> = <span style="color:#ff0000;">&lt;list&gt;</span>x<span style="color:#ff0000;">&lt;/list&gt;</span></p>
<p><span>or, equivalently, using the short-hand syntax for lists</span></p>
<p><span style="color:#ff0000;">[</span>x<span style="color:#ff0000;">]</span> + <span style="color:#ff0000;">[]</span> = <span style="color:#ff0000;">[</span>x<span style="color:#ff0000;">]</span></li>
</ul>
<p>Now, in the following, for syntactic brevity we&#8217;ll assume the List monad and not qualify the operations with the specific shape type (List, Set, Graph, etc.)</p>
<p><strong>4.3. Roll</strong></p>
<p>Suppose we create one more level of nesting:</p>
<ul>
<li>wrap(compose(wrap(0),wrap(1))<br />
=<br />
wrap(<span style="color:#ff0000;">&lt;list&gt;</span>0,1<span style="color:#ff0000;">&lt;/list&gt;</span>)<br />
=<br />
<span style="color:#ff0000;"> &lt;list&gt;</span><br />
<span style="color:#ff0000;"> &lt;list&gt;</span>0,1<span style="color:#ff0000;">&lt;/list&gt;</span><br />
<span style="color:#ff0000;"> &lt;/list&gt;</span><br />
=<br />
<span style="color:#ff0000;"> [[</span>0,1<span style="color:#ff0000;">]]</span></li>
</ul>
<p>Then we can use roll on that to remove the superfluous nesting again:</p>
<ul>
<li>roll(wrap(compose(wrap(0),wrap(1)))<br />
=<br />
roll(wrap(<span style="color:#ff0000;">&lt;list&gt;</span>0,1<span style="color:#ff0000;">&lt;/list&gt;</span>))<br />
=<br />
roll(<span style="color:#ff0000;">&lt;list&gt;&lt;list&gt;</span>0,1<span style="color:#ff0000;">&lt;/list&gt;&lt;/list&gt;</span>)<br />
=<br />
<span style="color:#ff0000;"> &lt;list&gt;</span>0,1<span style="color:#ff0000;">&lt;/list&gt;</span><br />
=<br />
<span style="color:#ff0000;"> [</span>0,1<span style="color:#ff0000;">]</span></li>
</ul>
<p>More clearly, if we have</p>
<ul>
<li><span style="color:#ff0000;">[[</span>0,1<span style="color:#ff0000;">]</span>,[2,3<span style="color:#ff0000;">]]</span></li>
</ul>
<p>Then rolling that gives</p>
<ul>
<li>roll(<span style="color:#ff0000;">[[</span>0,1<span style="color:#ff0000;">]</span>,<span style="color:#ff0000;">[</span>2,3<span style="color:#ff0000;">]]</span>) = <span style="color:#ff0000;">[</span>1,2,3,4<span style="color:#ff0000;">]</span></li>
</ul>
<p>So rolling is an act of flattening or leveling a container; in this case a list of lists of numbers is rolled out to just to a list of numbers.</p>
<p>Let&#8217;s sweeten the syntax up a little further by saying that + is an operator symbol for compose, that w is the same as wrap and that r is the same as roll; that gives us expressions such as</p>
<ul>
<li>r(w(w(a)+w(b)) = r(w(<span style="color:#ff0000;">[</span>a,b<span style="color:#ff0000;">]</span>)) = r(<span style="color:#ff0000;">[[</span>a,b<span style="color:#ff0000;">]]</span>) = <span style="color:#ff0000;">[</span>a,b<span style="color:#ff0000;">]</span></li>
</ul>
<p><strong>5. Equations</strong></p>
<p>There are equations associated with shapes or more precisely with shape composition operators. For List.append there are no such equations.</p>
<p>Set <em>union</em>, on the other hand, does have equations:</p>
<ul>
<li>a + a = a // idempotency</li>
<li>a + b = b + a // commutativity</li>
</ul>
<p>The first equation says that composing (uniting) a set with itself yields an identical set. It&#8217;s a no-op. The second equation says that the order of a and b is irrelevant to the outcome..</p>
<p>Greg also talks about three laws that relate to the parts of the monad metaphor (and indeed the formal definition of a monad). I&#8217;m still learning about these.</p>
<p><strong>6. Shapes &amp; Monads</strong></p>
<p>There are many kinds of structures that qualify as monads.</p>
<p><strong>6.1. The Identity Monad</strong></p>
<p>This is the no-operation monad; the simplest of all monads.</p>
<ul>
<li>w(x) = <span style="color:#33cccc;">&lt;id&gt;</span>x<span style="color:#33cccc;">&lt;/id&gt;</span></li>
<li>w(w(x)) = <span style="color:#33cccc;">&lt;id&gt;&lt;id&gt;</span>x<span style="color:#33cccc;">&lt;/id&gt;&lt;/id&gt;</span></li>
<li>r(w(w(x))) = <span style="color:#33cccc;">&lt;id&gt;</span>x<span style="color:#33cccc;">&lt;/id&gt;</span></li>
</ul>
<p>There&#8217;s not really a definition for + for this monad, but we could perhaps define + as w so that composition is wrapping.</p>
<p><strong>6.2 The Maybe Monad</strong></p>
<p>This is the monad of optional values. They are useful for certain functions that may not have useful results in some cases.</p>
<ul>
<li>w() = <span style="color:#800080;">&lt;maybe&gt;&lt;/maybe&gt;</span> = <span style="color:#800080;">&lt;maybe/&gt;</span></li>
<li>w(x) = <span style="color:#800080;">&lt;maybe&gt;</span>x<span style="color:#800080;">&lt;/maybe&gt;</span></li>
<li>r(w(w())) = <span style="color:#800080;">&lt;maybe/&gt;</span></li>
<li>r(w(w(x))) =<span style="color:#800080;"> &lt;maybe&gt;</span>x<span style="color:#800080;">&lt;/maybe&gt;</span></li>
</ul>
<p>There&#8217;s not really a definition for + for this monad, but we could perhaps define + as w so that composition is the same as wrapping.</p>
<p><em>Trivia</em>: In Haskell Just(x) is the constructor for <span style="color:#800080;">&lt;maybe&gt;</span>x<span style="color:#33cccc;"><span style="color:#800080;">&lt;/maybe&gt;</span> <span style="color:#333333;">whereas Nothing is the constructor for <span style="color:#800080;">&lt;maybe/&gt;</span>. In SML these are called Some and None, respectively.</span></span></p>
<p><strong>6.3 The List Monad</strong></p>
<p>This is the monad of lists of values that we&#8217;ve already seen. For this monad we have a meaningful composition operation, which is append; append will join two lists together into a new list where the elements of the two are in sequence in the new list.</p>
<ul>
<li>w() = <span style="color:#ff0000;">[]</span></li>
<li>w(x) = <span style="color:#ff0000;">[</span>x<span style="color:#ff0000;">]</span></li>
<li>w(w()) = <span style="color:#ff0000;">[[]]</span></li>
<li>w(w(x)) = <span style="color:#ff0000;">[[</span>x<span style="color:#ff0000;">]]</span></li>
<li>r(w(w(x))) = r(<span style="color:#ff0000;">[[</span>x<span style="color:#ff0000;">]]</span>) = <span style="color:#ff0000;">[</span>x<span style="color:#ff0000;">]</span></li>
<li>w(a)+w(b) = <span style="color:#ff0000;">[</span>a,b<span style="color:#ff0000;">]</span></li>
<li>w(w(a)+w(b))+w(w(c)+w(d)) = <span style="color:#ff0000;">[[</span>a,b<span style="color:#ff0000;">]</span>,<span style="color:#ff0000;">[</span>c,d<span style="color:#ff0000;">]]</span></li>
<li>r(w(w(a)+w(b))+w(w(c)+w(d))) = r(<span style="color:#ff0000;">[[</span>a,b<span style="color:#ff0000;">]</span>,<span style="color:#ff0000;">[</span>c,d<span style="color:#ff0000;">]]</span>) = <span style="color:#ff0000;">[</span>a,b,c,d<span style="color:#ff0000;">]</span></li>
</ul>
<p>In these examples I&#8217;ve not used markup syntax but I hope that by now you can intuit the simple translation between <span style="color:#ff0000;">[</span>...<span style="color:#ff0000;">]</span> and <span style="color:#ff0000;">&lt;list&gt;</span>&#8230;<span style="color:#ff0000;">&lt;/list&gt;</span>.</p>
<p><strong>6.4 The Set Monad</strong></p>
<p>This is the monad of sets of values. In this case I&#8217;ll use {} as the syntactic delimiter of set literal expressions, just to make it clear that these are sets and what the left-hand-side monadic expressions actually mean.</p>
<p>Under set union the semantics are as follows:</p>
<ul>
<li>w() = <span style="color:#339966;">{}</span></li>
<li>w(x) = <span style="color:#339966;">{</span>x<span style="color:#339966;">}</span></li>
<li>w(w()) = <span style="color:#339966;">{{}}</span></li>
<li>w(w(x)) = <span style="color:#339966;">{{</span>x<span style="color:#339966;">}}</span></li>
<li>r(w(w(x))) = r(<span style="color:#339966;">{{</span>x<span style="color:#339966;">}}</span>) = <span style="color:#339966;">{</span>x<span style="color:#339966;">}</span></li>
<li>w(a)+w(b) = <span style="color:#339966;">{</span>a,b<span style="color:#339966;">}</span></li>
<li>w(w(a)+w(b))+w(w(c)+w(d)) = <span style="color:#339966;">{{</span>a,b<span style="color:#339966;">}</span>,<span style="color:#339966;">{</span>c,d<span style="color:#339966;">}}</span></li>
<li>r(w(w(a)+w(b))+w(w(c)+w(d))) = r(<span style="color:#339966;">{{</span>a,b<span style="color:#339966;">}</span>,<span style="color:#339966;">{</span>c,d<span style="color:#339966;">}}</span>) = <span style="color:#339966;">{</span>a,b,c,d<span style="color:#339966;">}</span></li>
</ul>
<p>however, if we throw in a couple of duplicate values, the semantic distinctions between sets and lists becomes clear:</p>
<ul>
<li>w(a)+w(a) = <span style="color:#339966;">{</span>a}+<span style="color:#339966;">{</span>a<span style="color:#339966;">}</span> = <span style="color:#339966;">{</span>a<span style="color:#339966;">}</span></li>
<li>w(w(a)+w(b))+w(w(b)+w(a)) = <span style="color:#339966;">{{</span>a,b<span style="color:#339966;">}</span>+<span style="color:#339966;">{</span>b,a<span style="color:#339966;">}}</span> = <span style="color:#339966;">{{</span>a,b<span style="color:#339966;">}}</span></li>
<li>r(w(w(a)+w(b))+w(w(c)+w(b))) = r(<span style="color:#339966;">{{</span>a,b<span style="color:#339966;">}</span>,<span style="color:#339966;">{</span>c,b<span style="color:#339966;">}}</span>) = <span style="color:#339966;">{</span>a,b,c<span style="color:#339966;">}</span></li>
</ul>
<p>These three expressions would have a different meaning under list composition.</p>
<p><strong>7. Lessons</strong></p>
<p>These lecture notes do not capture all the knowledge of the first lecture by Greg Meredith but they do show some simple examples of what the monadic operators do. I find this a more syntactic way of thinking that is actually quite appealing. It&#8217;s not the whole story though; only a fraction. The theory of monads goes deep, as does its practice.</p>
<p>In the following lectures, Greg will supposedly go into concrete applications of monads in the software design of Web applications. In other words, Greg will show-case monadic Web programming. I can&#8217;t wait to see what he&#8217;s cooked up.</p>
<p>The monad examples shown here are just of a fraction of the monads that I&#8217;ve seen examples of. This really goes to show the fundamental strength of the monadic abstraction.</p>
<div class="zemanta-pixie" style="margin-top:10px;height:15px;"><a class="zemanta-pixie-a" title="Enhanced by Zemanta" href="http://www.zemanta.com/"><img class="zemanta-pixie-img" style="border:none;float:right;" src="http://img.zemanta.com/zemified_e.png?x-id=9ef75580-2eda-448b-9570-5997b15c0a65" alt="Enhanced by Zemanta" /></a></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xosfaere.wordpress.com/1200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xosfaere.wordpress.com/1200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xosfaere.wordpress.com/1200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xosfaere.wordpress.com/1200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xosfaere.wordpress.com/1200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xosfaere.wordpress.com/1200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xosfaere.wordpress.com/1200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xosfaere.wordpress.com/1200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xosfaere.wordpress.com/1200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xosfaere.wordpress.com/1200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xosfaere.wordpress.com/1200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xosfaere.wordpress.com/1200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xosfaere.wordpress.com/1200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xosfaere.wordpress.com/1200/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&amp;blog=1884763&amp;post=1200&amp;subd=xosfaere&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xosfaere.wordpress.com/2010/10/05/shapely-monads/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f816a0c0bd66d40be3b47d586c76a1ea?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Bent</media:title>
		</media:content>

		<media:content url="http://img.zemanta.com/zemified_e.png?x-id=9ef75580-2eda-448b-9570-5997b15c0a65" medium="image">
			<media:title type="html">Enhanced by Zemanta</media:title>
		</media:content>
	</item>
		<item>
		<title>Trust, but verify</title>
		<link>http://xosfaere.wordpress.com/2010/09/01/trust-but-verify/</link>
		<comments>http://xosfaere.wordpress.com/2010/09/01/trust-but-verify/#comments</comments>
		<pubDate>Wed, 01 Sep 2010 19:24:25 +0000</pubDate>
		<dc:creator>xosfaere</dc:creator>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Datamodel]]></category>
		<category><![CDATA[Declarative]]></category>
		<category><![CDATA[Imperative]]></category>
		<category><![CDATA[Paradigm]]></category>
		<category><![CDATA[Program]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Caching]]></category>
		<category><![CDATA[Language Integrated Query]]></category>
		<category><![CDATA[LinkedIN]]></category>
		<category><![CDATA[LINQPad]]></category>
		<category><![CDATA[Microsoft Dynamics NAV]]></category>
		<category><![CDATA[Navision]]></category>
		<category><![CDATA[ORM]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Web Service]]></category>
		<category><![CDATA[Workflow]]></category>

		<guid isPermaLink="false">http://xosfaere.wordpress.com/?p=1132</guid>
		<description><![CDATA[1. Prelude Today, I want show how one of the best query tools in the world, can be used to easily and quickly create integration tests for workflow services. These integration tests will seamlessly automate the testing and verification of &#8230; <a href="http://xosfaere.wordpress.com/2010/09/01/trust-but-verify/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&amp;blog=1884763&amp;post=1132&amp;subd=xosfaere&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>1. Prelude</strong></p>
<p>Today, I want show how one of the best query tools in the world, can be used to easily and quickly create integration tests for workflow services. These integration tests will seamlessly automate the testing and verification of workflows that are created by web services.</p>
<p>This article is borne out of practical experience in the context of the Dynamics NAV (Navision) business software environment. This is an implementation detail, however; the method doesn&#8217;t depend on that.</p>
<p><strong>Note</strong>: this article assumes the reader has some familiarity with LINQ. Should you not be familiar with LINQ, I strongly urge you to become so. LINQ is based on monads which come from the esoteric branch of mathematics known as Category Theory. This branch unifies vast areas of mathematics and provides extreme generality and expressiveness. It is however completely unnecessary to know about these deep things to be able to use and understand LINQ, which is in fact very easy to use and intuitive, even more so than SQL; it does <em>not</em>, however, replace SQL or T-SQL.</p>
<p><strong>2. Setup</strong></p>
<p>The basic setup is this:</p>
<ol>
<li>a script creates an order which it then posts to a web service</li>
<li>the web service creates a workflow</li>
<li>the workflow is executed</li>
<li>the web service responds back (okay, error)</li>
<li>the script queries the database to see if the changes made (or not made) matches expectations; these queries form our test-cases</li>
</ol>
<p>we can visualize the method like this</p>
<p><a href="http://xosfaere.files.wordpress.com/2010/09/setup1.png"><img class="aligncenter size-full wp-image-1136" title="setup" src="http://xosfaere.files.wordpress.com/2010/09/setup1.png?w=640&#038;h=425" alt="" width="640" height="425" /></a></p>
<p><strong>3. Implementation</strong></p>
<p>The little notepad symbol in the above diagram is the logo for the <a href="http://www.linqpad.net/">LINQPad</a> tool. This tool is the software equivalent of a <a href="http://www.swiss-knife.com/">Swiss knife</a>.</p>
<p>LINQPad makes it easy to connect to a database and execute queries against an object-relational mapping, meaning you can query C# objects that nicely represent the data domain.</p>
<p>Scripts can be made as C#/VB expressions, C#/VB statements or C#/VB programs. In our case we&#8217;ll need the full power of C# programs so we select that.</p>
<p><a href="http://xosfaere.files.wordpress.com/2010/09/linqpad.png"><img class="aligncenter size-full wp-image-1137" title="linqpad" src="http://xosfaere.files.wordpress.com/2010/09/linqpad.png?w=574&#038;h=410" alt="" width="574" height="410" /></a>To send orders, we&#8217;ll make a trivial HTTP POST method:</p>
<pre class="brush: csharp;">
string HttpPost(string service, string order)
{
     // trivial implementation left as an exercise for the reader ...
}
</pre>
<p>Next we want to build an actual order, we can do that using LINQ to XML. And we can in fact use LINQ to SQL queries to build up these orders from existing data in the system if needed.</p>
<p>LINQPad exposes the tables of the connected database as C# types. Let&#8217;s have a look at an actual data source:</p>
<p><a href="http://xosfaere.files.wordpress.com/2010/09/data-source.png"><img class="aligncenter size-full wp-image-1154" title="data source" src="http://xosfaere.files.wordpress.com/2010/09/data-source.png?w=422&#038;h=530" alt="" width="422" height="530" /></a></p>
<p>The types are shown in the upper-left corner. I should note here that I did not connect to a SQL database because I didn&#8217;t have one ready at home but instead used a free web data source (it follows the <a href="http://www.odata.org/">OData</a> protocol).</p>
<p>There is one important thing to keep in mind, however. When doing tests where an external system modifies the database, it doesn&#8217;t make sense to cache data. The reason is that we cannot see changes made to the database in the same session if we have caching enabled because the LINQ to SQL query provider is unaware of these changes. We cannot have valid tests without up-to-date data. The solution is simple; just put this statement into the main method:</p>
<pre class="brush: csharp;">
void Main()
{
    ObjectTrackingEnabled = false;
    // ...
}
</pre>
<p>In the context of Navision there is one thing which will annoy any user of LINQPad. That is the fact that Navision has one table for each company, meaning if there are three companies in the database, then there will be three customer tables. So if you wish to query all three companies, you&#8217;ll have to do some search-replacing &#8211; but luckily that&#8217;s trivial, if a slight nuisance.</p>
<p>One could imagine building &#8220;Navision awareness&#8221; into a LINQPad, since it is in fact possible to extend LINQPad, but I&#8217;ve not had the time to do this. This might make it possible to just have a variable decide what table version is currently being used. That&#8217;s a side-effecting rabbit hole of its own, though.</p>
<p>Now onto the actual tests. These can be quite trivial, so let me make up a toy example:</p>
<pre class="brush: csharp;">
// ...

var customersMissingTopRef =
        from c in CompanyCustomers
        where c.ParentCustomerNo != &quot;&quot; &amp;&amp; c.TopCustomerNo == &quot;&quot;
        select c;
// ...

Test(customersMissingTopRef.Any(), &quot;customers with missing top reference&quot;);
// ...
</pre>
<p>The Test method could print out the name of the test case and whether it succeeded or failed.</p>
<p>The type of the customersMissingTopRef variable will be: IQueryable&lt;CompanyCustomer&gt;. The IQueryable supports the standard query operators such as Select, SelectMany, Where, GroupBy, OrderBy, Take, etc.</p>
<p><strong>4. Conclusion</strong></p>
<p>This approach is a light-weight one. A more solid approach would be to build a full object-relational mapping from the database and code up test cases in stand-alone files that will be run as part of a test framework.</p>
<p>Nonetheless, the method shown here is straight-forward, easy to implement, and can save hours of tedious manual testing and retesting and can be considered first step with a low barrier-to-entry. I&#8217;ve already saved what would amount to several days worth of manual testing due to this method and have found several software defects and regressions.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xosfaere.wordpress.com/1132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xosfaere.wordpress.com/1132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xosfaere.wordpress.com/1132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xosfaere.wordpress.com/1132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xosfaere.wordpress.com/1132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xosfaere.wordpress.com/1132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xosfaere.wordpress.com/1132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xosfaere.wordpress.com/1132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xosfaere.wordpress.com/1132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xosfaere.wordpress.com/1132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xosfaere.wordpress.com/1132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xosfaere.wordpress.com/1132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xosfaere.wordpress.com/1132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xosfaere.wordpress.com/1132/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&amp;blog=1884763&amp;post=1132&amp;subd=xosfaere&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xosfaere.wordpress.com/2010/09/01/trust-but-verify/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f816a0c0bd66d40be3b47d586c76a1ea?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Bent</media:title>
		</media:content>

		<media:content url="http://xosfaere.files.wordpress.com/2010/09/setup1.png" medium="image">
			<media:title type="html">setup</media:title>
		</media:content>

		<media:content url="http://xosfaere.files.wordpress.com/2010/09/linqpad.png" medium="image">
			<media:title type="html">linqpad</media:title>
		</media:content>

		<media:content url="http://xosfaere.files.wordpress.com/2010/09/data-source.png" medium="image">
			<media:title type="html">data source</media:title>
		</media:content>
	</item>
		<item>
		<title>Illustration</title>
		<link>http://xosfaere.wordpress.com/2010/07/21/illustrations/</link>
		<comments>http://xosfaere.wordpress.com/2010/07/21/illustrations/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 20:56:32 +0000</pubDate>
		<dc:creator>xosfaere</dc:creator>
				<category><![CDATA[Art]]></category>
		<category><![CDATA[Datamodel]]></category>
		<category><![CDATA[Operating System]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[Architechture]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[Domain Name System]]></category>
		<category><![CDATA[Illustration]]></category>
		<category><![CDATA[LinkedIN]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://xosfaere.wordpress.com/?p=1045</guid>
		<description><![CDATA[Illustrations, I love them. Today, I caught some great ones in the net. 1. Language Integrated Query (Linq) The dutch company Solid Innovator made this quite beautiful illustration of the standard Linq sequence operators. Download the PDF at Solid Innovator. &#8230; <a href="http://xosfaere.wordpress.com/2010/07/21/illustrations/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&amp;blog=1884763&amp;post=1045&amp;subd=xosfaere&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Illustrations, I love them. Today, I caught some great ones in the net.</p>
<p><strong>1. <a class="zem_slink" title="Language Integrated Query" rel="wikipedia" href="http://en.wikipedia.org/wiki/Language_Integrated_Query">Language Integrated Query</a> (Linq)</strong></p>
<p>The dutch company Solid Innovator made this quite beautiful illustration of the standard Linq sequence operators.</p>
<p><a href="http://xosfaere.files.wordpress.com/2010/07/641a57c5-a778-46e4-9395-674e422dd2bc.jpg"><img class="aligncenter size-full wp-image-1085" title="poster_liggend_DRUK_v2" src="http://xosfaere.files.wordpress.com/2010/07/641a57c5-a778-46e4-9395-674e422dd2bc.jpg?w=397&#038;h=281" alt="" width="397" height="281" /></a>Download the <a href="http://www.infosupport.com/LINQ">PDF at Solid Innovator</a>.</p>
<p><strong>2. Anatomy of a <a class="zem_slink" title="Linux" rel="wikipedia" href="http://en.wikipedia.org/wiki/Linux">Linux</a> System</strong></p>
<p>I don&#8217;t use Linux but I love this illustration; the only problem is that the original vector graphics in the middle has been rasterized and in far too low resolution so you can&#8217;t zoom properly into it without seeing artifacts. A shame.</p>
<p><a href="http://xosfaere.files.wordpress.com/2010/07/linuxanatomy_0101_poster.gif"><img class="aligncenter size-full wp-image-1071" title="linuxanatomy_0101_poster" src="http://xosfaere.files.wordpress.com/2010/07/linuxanatomy_0101_poster.gif?w=350&#038;h=350" alt="" width="350" height="350" /></a></p>
<p>Download the <a href="http://www.oreillynet.com/pub/a/oreilly/linux/news/linuxanatomy_0101.html">PDF at O&#8217;Reilly</a>.</p>
<p><strong>3. <a class="zem_slink" title="Domain Name System" rel="wikipedia" href="http://en.wikipedia.org/wiki/Domain_Name_System">Domain Name System</a> (DNS)</strong></p>
<p>This is a complex illustration or visual guide to the Domain Name System. The illustration is made by Dubberly Design Office (ddo).</p>
<p><a href="http://xosfaere.files.wordpress.com/2010/07/ddo-concept-map-dns-440x619.jpg"><img class="aligncenter size-full wp-image-1046" title="ddo-concept-map-dns-440x619" src="http://xosfaere.files.wordpress.com/2010/07/ddo-concept-map-dns-440x619.jpg?w=440&#038;h=619" alt="" width="440" height="619" /></a></p>
<p>Download <a href="http://www.dubberly.com/maps/domain-name-system.html">PDF at ddo</a>.</p>
<div class="zemanta-pixie" style="margin-top:10px;height:15px;"><a class="zemanta-pixie-a" title="Enhanced by Zemanta" href="http://www.zemanta.com/"><img class="zemanta-pixie-img" style="border:none;float:right;" src="http://img.zemanta.com/zemified_e.png?x-id=4bd8c7ae-0e48-40fd-aa56-e9a7b337bd46" alt="Enhanced by Zemanta" /></a></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xosfaere.wordpress.com/1045/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xosfaere.wordpress.com/1045/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xosfaere.wordpress.com/1045/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xosfaere.wordpress.com/1045/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xosfaere.wordpress.com/1045/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xosfaere.wordpress.com/1045/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xosfaere.wordpress.com/1045/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xosfaere.wordpress.com/1045/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xosfaere.wordpress.com/1045/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xosfaere.wordpress.com/1045/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xosfaere.wordpress.com/1045/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xosfaere.wordpress.com/1045/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xosfaere.wordpress.com/1045/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xosfaere.wordpress.com/1045/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&amp;blog=1884763&amp;post=1045&amp;subd=xosfaere&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xosfaere.wordpress.com/2010/07/21/illustrations/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f816a0c0bd66d40be3b47d586c76a1ea?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Bent</media:title>
		</media:content>

		<media:content url="http://xosfaere.files.wordpress.com/2010/07/641a57c5-a778-46e4-9395-674e422dd2bc.jpg" medium="image">
			<media:title type="html">poster_liggend_DRUK_v2</media:title>
		</media:content>

		<media:content url="http://xosfaere.files.wordpress.com/2010/07/linuxanatomy_0101_poster.gif" medium="image">
			<media:title type="html">linuxanatomy_0101_poster</media:title>
		</media:content>

		<media:content url="http://xosfaere.files.wordpress.com/2010/07/ddo-concept-map-dns-440x619.jpg" medium="image">
			<media:title type="html">ddo-concept-map-dns-440x619</media:title>
		</media:content>

		<media:content url="http://img.zemanta.com/zemified_e.png?x-id=4bd8c7ae-0e48-40fd-aa56-e9a7b337bd46" medium="image">
			<media:title type="html">Enhanced by Zemanta</media:title>
		</media:content>
	</item>
		<item>
		<title>Workflows</title>
		<link>http://xosfaere.wordpress.com/2010/07/17/workflows/</link>
		<comments>http://xosfaere.wordpress.com/2010/07/17/workflows/#comments</comments>
		<pubDate>Sat, 17 Jul 2010 20:50:19 +0000</pubDate>
		<dc:creator>xosfaere</dc:creator>
				<category><![CDATA[Datamodel]]></category>
		<category><![CDATA[Imperative]]></category>
		<category><![CDATA[Navision]]></category>
		<category><![CDATA[Paradigm]]></category>
		<category><![CDATA[Program]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[Design by Contract]]></category>
		<category><![CDATA[Input validation]]></category>
		<category><![CDATA[LinkedIN]]></category>
		<category><![CDATA[Metaprogramming]]></category>
		<category><![CDATA[Metaprograms]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Programs]]></category>
		<category><![CDATA[WCF]]></category>
		<category><![CDATA[WF]]></category>
		<category><![CDATA[Windows Communications Foundation]]></category>
		<category><![CDATA[Windows Workflow Foundation]]></category>
		<category><![CDATA[Workflow Services]]></category>
		<category><![CDATA[WWF]]></category>

		<guid isPermaLink="false">http://xosfaere.wordpress.com/?p=966</guid>
		<description><![CDATA[1. Rationale In the computational space we know as software, there appears to be a growing trend to recognize and encode processes as workflows. These workflows can be business processes that require input from customer service or other personel, span &#8230; <a href="http://xosfaere.wordpress.com/2010/07/17/workflows/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&amp;blog=1884763&amp;post=966&amp;subd=xosfaere&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>1. Rationale</strong></p>
<p>In the computational space we know as software, there appears to be a growing trend to recognize and encode processes as workflows. These workflows can be <a class="zem_slink" title="Business process" rel="wikipedia" href="http://en.wikipedia.org/wiki/Business_process">business processes</a> that require input from customer service or other personel, span several organizations and involve web service calls.</p>
<p>Due to the latency and often distributed nature of workflows, it is often not natural to express workflows directly as code. If a process can span days, weeks or perhaps even months, it does not naturally fit conventional programming models.</p>
<p>Therefore workflow models are invented. These are data structures that can be used to express workflow processes at a high level. Workflow activities delimit significant or meaningful work, e.g. &#8220;wait for quality control&#8221;, &#8220;send e-mail to customer&#8221; or &#8220;perform credit check&#8221;.</p>
<p><strong>2. Metaprograms</strong></p>
<p>Workflows are coarse-grained algorithms; do this, do that, if this then that, and so on.</p>
<p>These differ from [conventional*] programs where the code is code, data is data and the two are distinct. With workflows, code <em>is</em> data. Workflow engines are virtual machines and workflow data models are meta-programming languages; I like to think of them as meta-programs and meta-machines; the abstraction level is &#8220;one up&#8221;; n+1. * In that sense, the perfect language to encode workflows would perhaps be Lisp, a language where all code is data and all data takes the same form.</p>
<p>This is an important fact! It means that we can think about workflows as programs and think of workflow models as programming languages and evaluate them as we would any other programming language.</p>
<p><strong>3. Practicalities</strong></p>
<p>I first encountered workflows in Navision[1], a business process platform. There is no real built-in workflow engine in Navision but one can create one; and several companies have done so.</p>
<p>The pervasive use of workflows is probably why Microsoft, who now owns Navision, has incorporated a workflow programming model, Windows Workflow Foundation (WF), into the .NET Framework.</p>
<p>One issue that faced me early on was the transactional nature of the workflow model. This meant that a long workflow could fail after many steps had been completed and comitted to the database. A nice solution to this problem is to do more validation up-front. This means creating an activity that does combined state validation before allowing the rest of the workflow to execute. It&#8217;s a simple measure but it is an imporant one. This approach can also be combined with design by contract style programming where &#8220;internal state&#8221; is checked for correctness up-front; it is assumed correct but if not, then fail early and often &#8211; in other words: fail fast.</p>
<p>The transactional nature of workflows also come into play in the sense of &#8220;point of no return&#8221; actions. If an e-mail has been sent to a customer we can&#8217;t &#8220;roll back&#8221;. There is no retroactive erasure for e-mails &#8211; we can&#8217;t unsend it. This makes up-front validation and sanity checking more important.</p>
<p>I&#8217;ve also come to realize that developing with workflows can benefit from <a class="zem_slink" title="Unit testing" rel="wikipedia" href="http://en.wikipedia.org/wiki/Unit_testing">unit tests</a>. This again follows from the simple fact that unit tests benefit normal programs and these meta-programs can benefit from unit tests for precisely the same reasons. The unit tests may look somewhat different though. Perhaps the unit tests are even themselves workflows.</p>
<p>Many workflows are probably more difficult to test than regular programs because their effects often span several <a class="zem_slink" title="Distributed computing" rel="wikipedia" href="http://en.wikipedia.org/wiki/Distributed_computing">distributed systems</a> but this only makes testing even more important.</p>
<p><strong>4. Services</strong></p>
<p>The distributed nature of workflows is probably also why Microsoft emphasises the integration between Windows Workflow Foundation (WF) and Windows Communications Foundation (<a class="zem_slink" title="Windows Communication Foundation" rel="wikipedia" href="http://en.wikipedia.org/wiki/Windows_Communication_Foundation">WCF</a>). Services that use workflows are appropriately called Workflow Services. I look forward to possibly designing Workflow Services some time in the future.</p>
<p><strong>5. Designer</strong></p>
<p>I also really like the idea of a workflow designer[2] where one can embed a workflow designer in an application and allow users to see a running workflow and even redesign a running workflow; a somewhat theoretical scenario but possible. Windows Workflow Foundation has such a designer. Appendix 1 shows a simple example of a workflow. The graphical nature of the designer makes it very intuitive and easy to see what&#8217;s going on.</p>
<p>The designer can be tailored so that users can only compose high-level activities and stay clear of low-level activities that could wreak havoc in the wrong hands.</p>
<p><strong>6. References</strong></p>
<p><span style="font-family:Georgia, 'Bitstream Charter', serif;line-height:24px;font-size:16px;"> </span></p>
<ol>
<li><a href="http://www.microsoft.com/dynamics/en/us/products/nav-overview.aspx">Microsoft Dynamics NAV</a></li>
<li><a href="http://www.microsoftpdc.com/2009/FT17">WF &amp; Microsoft Dynamics AX</a></li>
</ol>
<p><strong>Appendix 1</strong></p>
<p>This is a simple example of a nested workflow Sequence:</p>
<p style="padding-left:30px;"><a href="http://xosfaere.files.wordpress.com/2010/07/wf-designer-ex.jpg"><img title="wf designer ex" src="http://xosfaere.files.wordpress.com/2010/07/wf-designer-ex.jpg?w=624&#038;h=415" alt="" width="624" height="415" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xosfaere.wordpress.com/966/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xosfaere.wordpress.com/966/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xosfaere.wordpress.com/966/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xosfaere.wordpress.com/966/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xosfaere.wordpress.com/966/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xosfaere.wordpress.com/966/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xosfaere.wordpress.com/966/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xosfaere.wordpress.com/966/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xosfaere.wordpress.com/966/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xosfaere.wordpress.com/966/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xosfaere.wordpress.com/966/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xosfaere.wordpress.com/966/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xosfaere.wordpress.com/966/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xosfaere.wordpress.com/966/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&amp;blog=1884763&amp;post=966&amp;subd=xosfaere&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xosfaere.wordpress.com/2010/07/17/workflows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f816a0c0bd66d40be3b47d586c76a1ea?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Bent</media:title>
		</media:content>

		<media:content url="http://xosfaere.files.wordpress.com/2010/07/wf-designer-ex.jpg" medium="image">
			<media:title type="html">wf designer ex</media:title>
		</media:content>
	</item>
		<item>
		<title>An anti-pattern: return w/ out</title>
		<link>http://xosfaere.wordpress.com/2010/07/10/out-return/</link>
		<comments>http://xosfaere.wordpress.com/2010/07/10/out-return/#comments</comments>
		<pubDate>Sat, 10 Jul 2010 11:29:03 +0000</pubDate>
		<dc:creator>xosfaere</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Cast]]></category>
		<category><![CDATA[Eric Lippert]]></category>
		<category><![CDATA[LinkedIN]]></category>
		<category><![CDATA[Null-coalescing operator]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tuple]]></category>

		<guid isPermaLink="false">http://xosfaere.wordpress.com/?p=800</guid>
		<description><![CDATA[Eric Lippert, a member of the C# design team has an excellent little factoid about the C# cast operator and how some code can lead to surprising results. I&#8217;d like to take a step back and examine the problematic code &#8230; <a href="http://xosfaere.wordpress.com/2010/07/10/out-return/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&amp;blog=1884763&amp;post=800&amp;subd=xosfaere&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Eric Lippert, a member of the C# design team has an excellent little <a href="http://blogs.msdn.com/b/ericlippert/archive/2010/05/27/cast-operators-do-not-obey-the-distributive-law.aspx">factoid</a> about the C# <code>cast</code> operator and how some code can lead to surprising results.</p>
<p>I&#8217;d like to take a step back and examine the problematic code from a different angle. First, let&#8217;s see the code:</p>
<pre class="brush: csharp;">
object result;
bool isDecimal = GetAmount(out result);
decimal amount = (decimal)(isDecimal ? result : 0);
</pre>
<p>Aside from the fact that the decimal cast here will not work at run-time, do you, dear reader, see anything suspicious about this piece of code?</p>
<p>The problem is that the <code>GetAmount</code> function uses an <code>out</code> parameter. What this effectively does is allow <code>GetAmount</code> to write back to our local <code>result</code> variable. The <code>GetAmount</code> function also returns a boolean value by the usual means, answering the question &#8220;is this amount a decimal&#8221;?</p>
<p>That first part of the code will work, but it makes the code less obvious and obstructs the purity of the code. That&#8217;s a somewhat subjective assessment but if all functions returned values using out then the code definitely would be much less readable.</p>
<p>So what to do here? We basically have the problem that we want to return two values: the amount and whether this amount is a decimal. Well, since C# 2.0, we&#8217;ve had nullable types. This means we can create a nullable type for any primitive (non-nullable) type. For example, a decimal is not nullable but we can create a variant that is: <code>decimal?</code> or <code>Nullable&lt;decimal&gt;</code> (the questionmark defines nullability). This means our decimal now has the potential to hold an extra value: <code>null</code>. We can use this value to designate whether the value is a decimal or not.</p>
<p>So let&#8217;s first change the above code to take out &#8220;<code>out</code>&#8220;:</p>
<pre class="brush: csharp;">
decimal? temp = GetAmount();
decimal amount = temp.HasValue ? temp.Value : 0.0m;
</pre>
<p>That&#8217;s better and shorter. Can we make it shorter still? Allow me to introduce my new friend: the <a class="zem_slink" title="Null coalescing operator" rel="wikipedia" href="http://en.wikipedia.org/wiki/Null_coalescing_operator">null-coalescing operator</a> from C# 3.0:</p>
<pre class="brush: csharp; light: true;">
decimal amount = GetAmount() ?? 0.0m;
</pre>
<p>The null-coalescing operator (<code>??</code>) will evaluate to the right side of the operator (<code>0.0m</code> in this case), if the left side of the operator happens to be <code>null</code>; otherwise it will evaluate to the left side.</p>
<p>We can even save 4 extra characters by using C# 3.0 type-inference:</p>
<pre class="brush: csharp; light: true;">
var amount = GetAmount() ?? 0.0m;
</pre>
<p>So what happened here is this:</p>
<ol>
<li>we took out <code>out</code></li>
<li>we took out <code>cast</code></li>
<li>we took out two variables</li>
<li>we took out two thirds of the code! (104 down to 33 characters)</li>
</ol>
<p>In effect, we&#8217;ve seriously unspaghettified the code.</p>
<p>The reader might object: but what if we have 3 or more values we need to return. Well, in that case I have two answers:</p>
<ol>
<li>use objects, that&#8217;s what they&#8217;re there for, and</li>
<li>use <a class="zem_slink" title="Tuple" rel="wikipedia" href="http://en.wikipedia.org/wiki/Tuple">tuples</a>, a new .NET Framework 4.0 type that allows easy return of multiple-values</li>
</ol>
<p>This pattern here, of using nullable types is extremely useful and can help clean up code in many places. Not just for return values but also for parameters. They also have synergy with default parameters as introduced in C# 4.0.</p>
<p>I hope you&#8217;ll use this pattern instead and only use out parameters in very rare cases. In many cases, using <code>out</code> parameters is an anti-pattern.</p>
<div class="zemanta-pixie" style="margin-top:10px;height:15px;"><a class="zemanta-pixie-a" title="Enhanced by Zemanta" href="http://www.zemanta.com/"><img class="zemanta-pixie-img" style="float:right;border-style:none;" src="http://img.zemanta.com/zemified_e.png?x-id=f1c230ed-bc3f-4417-9dc0-a57b359b2352" alt="Enhanced by Zemanta" /></a></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xosfaere.wordpress.com/800/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xosfaere.wordpress.com/800/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xosfaere.wordpress.com/800/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xosfaere.wordpress.com/800/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xosfaere.wordpress.com/800/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xosfaere.wordpress.com/800/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xosfaere.wordpress.com/800/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xosfaere.wordpress.com/800/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xosfaere.wordpress.com/800/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xosfaere.wordpress.com/800/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xosfaere.wordpress.com/800/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xosfaere.wordpress.com/800/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xosfaere.wordpress.com/800/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xosfaere.wordpress.com/800/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&amp;blog=1884763&amp;post=800&amp;subd=xosfaere&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xosfaere.wordpress.com/2010/07/10/out-return/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f816a0c0bd66d40be3b47d586c76a1ea?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Bent</media:title>
		</media:content>

		<media:content url="http://img.zemanta.com/zemified_e.png?x-id=f1c230ed-bc3f-4417-9dc0-a57b359b2352" medium="image">
			<media:title type="html">Enhanced by Zemanta</media:title>
		</media:content>
	</item>
		<item>
		<title>Beyond Windows</title>
		<link>http://xosfaere.wordpress.com/2010/06/06/beyond-windows/</link>
		<comments>http://xosfaere.wordpress.com/2010/06/06/beyond-windows/#comments</comments>
		<pubDate>Sun, 06 Jun 2010 21:56:45 +0000</pubDate>
		<dc:creator>xosfaere</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Analog]]></category>
		<category><![CDATA[Compiz Fusion]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[LinkedIN]]></category>
		<category><![CDATA[Microsoft Windows]]></category>
		<category><![CDATA[NUI]]></category>
		<category><![CDATA[Operating System]]></category>
		<category><![CDATA[Taskbar]]></category>
		<category><![CDATA[Usability]]></category>
		<category><![CDATA[User Experience]]></category>
		<category><![CDATA[Windows 7]]></category>
		<category><![CDATA[Windows Presentation Foundation]]></category>
		<category><![CDATA[Windows Vista]]></category>

		<guid isPermaLink="false">http://xosfaere.wordpress.com/?p=756</guid>
		<description><![CDATA[What users see, when they use Windows and other operating systems are&#8230; Windows. Precious little innovation has taken place in the user experience space on Windows, Linux, Macintosh/OSX, etc. The basic paradigm consists of a desktop, a taskbar and some &#8230; <a href="http://xosfaere.wordpress.com/2010/06/06/beyond-windows/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&amp;blog=1884763&amp;post=756&amp;subd=xosfaere&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>What users see, when they use <a class="zem_slink" title="Windows" rel="homepage" href="http://www.microsoft.com/WINDOWS">Windows</a> and other operating systems are&#8230; Windows. Precious little innovation has taken place in the user experience space on Windows, Linux, Macintosh/OSX, etc. The basic paradigm consists of a desktop, a <a class="zem_slink" title="Taskbar" rel="wikipedia" href="http://en.wikipedia.org/wiki/Taskbar">taskbar</a> and some open windows. The windows have different user experiences attached to them. There are mainly file system windows representing files and folders, either locally or remote and application windows with custom user experiences.</p>
<p>Now, the reader may object that it is in fact not true that no real innovation has taken place on the desktop and in window managers. In <a class="zem_slink" title="Windows Vista" rel="homepage" href="http://www.microsoft.com/windows/windows-vista/default.aspx">Windows Vista</a> we have <a class="zem_slink" title="Windows Aero" rel="homepage" href="http://www.microsoft.com/windows/products/windowsvista/features/experiences/aero.mspx">Flip 3D</a> and very nice semi-transparent windows. In Windows 7 we have <a href="http://blogs.msdn.com/b/e7/archive/2009/03/17/designing-aero-snap.aspx">Aero Snap</a> which allows us to easily snap windows to parts of the desktop. On Linux there is <a class="zem_slink" title="Compiz Fusion" rel="homepage" href="http://www.compiz-fusion.org/">Compiz Fusion</a> with wobbly windows effects, cube mapping etc. There are also extensions to Windows for these kinds of things. It is also typical on Linux to have multiple desktops.</p>
<p>I claim that none of these things are novel in any way.</p>
<p>That&#8217;s an easy claim to make of course, talk is cheap as they say, but let&#8217;s examine the significance of these inventions from a usability view.</p>
<p>Does the <a href="http://www.youtube.com/watch?v=82ZTV82OmKo">wobbly windows</a> of Compiz Fusion give any kind of benefit from a usability point of view? One will be hard pressed to find any task that one can perform more efficiently by having such an effect on windows. It is not completely worthless, however, as it adds a level of physics that one might refer to as Natural <a class="zem_slink" title="User interface" rel="wikipedia" href="http://en.wikipedia.org/wiki/User_interface">User Interface</a> (NUI) but in and of itself, a wobbly window hardly makes the user more efficient in performing tasks of any kind.</p>
<p>Then what about the more exotic cube-, cylinder- and torus-mapped windows? Again, while fancy to look at, I think one is hard pressed to say that these form a leap forward in usability. Still, these do warp and twist the fabric of the desktop and represent a tiny little step forward but perhaps a step or two backwards as well: is reading text from and recognizing objects from warped windows easy?</p>
<p>Then we have Aero Snap in Windows 7. This is what I consider a small feature but in fact a genuine usability feature. This will indeed help speed up some tasks. The user does not have to resize a window by draging edges and moving several windows around. So points to that feature.</p>
<p>So what about the multi-sector desktop, typically manifested by a little grid depicting the different desktop sectors, is that perhaps a usability improvement? Yes. This is indeed also a usability improvement as it helps the user more easily manage many windows. On the other hand it forms an unnatural and artificial split between applications.</p>
<p>To me, all these features are either minor usability improvements or pure eye candy devoid of usability benefits.</p>
<p>What is needed then?</p>
<p>I believe what we need is something very simple but something which makes the limits of the desktop disappear. What is needed is something which makes the desktop appear less &#8220;digital&#8221; and more &#8220;analog&#8221; and natural.</p>
<p>We cannot currently move or zoom in or out of the desktop itself.  The desktop space is a discrete space that our applications and data is trapped inside. What if the desktop was like giant, seemlingly unbounded map, like what we see when gazing into the sky? Our field of view is still limited but we can move our eyes and turn to new places in a fluent and seamless way. No desktop that I know of currently allows one to perform this seemingly trivial task.</p>
<p>This user experience is as simple as it is strikingly absent in todays (at least mainstream) desktops. However the user experience is not unknown, it&#8217;s widely used in games where in, for example strategy games, one has a giant map that one can translate and zoom in and out of and even tilt in 3D. Indeed even web services like Google and Bing Maps have this feature but somehow, when it comes to the desktop itself, we are stuck in a narrow constrained space and have been so for far too many years.</p>
<p>Windows, the operating system, has made major strides in usability in its software platform via the &#8220;Avalon&#8221; (now <a class="zem_slink" title="Windows Presentation Foundation" rel="wikipedia" href="http://en.wikipedia.org/wiki/Windows_Presentation_Foundation">Windows Presentation Foundation</a> (WPF)) architechtural pillar. However not that many developers use it and far fewer to full effect (myself included). WPF allows quite radical user experiences to be built in 2D and 3D and the retained-mode, scene graph architechture ensures that repainting is done in an optimal fashion. WPF does not have an equal on any other platform but even WPF does not really help us with the constraints of the desktop as, at least to my knowledge, one cannot build a window manager replacement in WPF. It&#8217;s simply too hardwired into Windows.</p>
<p>There have been rumors floating around that Windows 8 will feature some radical changes in user experience and if true, such changes will be very welcomed. Surface computing and NUI as seen in Microsoft Surface, is also bound to inspire the Windows 8 desktop and others.</p>
<p>See also</p>
<ul>
<li><a href="http://xosfaere.wordpress.com/2009/08/08/osw/">OS/W</a></li>
<li><a href="http://www.ted.com/talks/scott_mccloud_on_comics.html">Scott McCloud on comics</a></li>
</ul>
<div class="zemanta-pixie" style="margin-top:10px;height:15px;"><a class="zemanta-pixie-a" title="Reblog this post [with Zemanta]" href="http://reblog.zemanta.com/zemified/b3d6160f-3c87-4069-96f8-3dbff9d66ed1/"><img class="zemanta-pixie-img" style="border:none;float:right;" src="http://img.zemanta.com/reblog_e.png?x-id=b3d6160f-3c87-4069-96f8-3dbff9d66ed1" alt="Reblog this post [with Zemanta]" /></a></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xosfaere.wordpress.com/756/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xosfaere.wordpress.com/756/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xosfaere.wordpress.com/756/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xosfaere.wordpress.com/756/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xosfaere.wordpress.com/756/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xosfaere.wordpress.com/756/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xosfaere.wordpress.com/756/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xosfaere.wordpress.com/756/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xosfaere.wordpress.com/756/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xosfaere.wordpress.com/756/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xosfaere.wordpress.com/756/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xosfaere.wordpress.com/756/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xosfaere.wordpress.com/756/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xosfaere.wordpress.com/756/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&amp;blog=1884763&amp;post=756&amp;subd=xosfaere&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xosfaere.wordpress.com/2010/06/06/beyond-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f816a0c0bd66d40be3b47d586c76a1ea?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Bent</media:title>
		</media:content>

		<media:content url="http://img.zemanta.com/reblog_e.png?x-id=b3d6160f-3c87-4069-96f8-3dbff9d66ed1" medium="image">
			<media:title type="html">Reblog this post [with Zemanta]</media:title>
		</media:content>
	</item>
		<item>
		<title>Motivation</title>
		<link>http://xosfaere.wordpress.com/2010/05/28/motivation/</link>
		<comments>http://xosfaere.wordpress.com/2010/05/28/motivation/#comments</comments>
		<pubDate>Fri, 28 May 2010 21:32:51 +0000</pubDate>
		<dc:creator>xosfaere</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[LinkedIN]]></category>
		<category><![CDATA[Motivation]]></category>
		<category><![CDATA[Research]]></category>
		<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://xosfaere.wordpress.com/?p=741</guid>
		<description><![CDATA[This is why micro-management and pure economic incentives are poison for any non-trivial creative work and workplace. [Daniel Pink on the social and behavioural science of motivation.] The key motivational factors: autonomy (self-direction), mastery (the desire to become better) and purpose (being &#8230; <a href="http://xosfaere.wordpress.com/2010/05/28/motivation/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&amp;blog=1884763&amp;post=741&amp;subd=xosfaere&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is why <a class="zem_slink" title="Micromanagement" rel="wikipedia" href="http://en.wikipedia.org/wiki/Micromanagement">micro-management</a> and pure economic incentives are poison for any non-trivial creative work and workplace.</p>
<p>[<a title="Daniel H. Pink" rel="wikipedia" href="http://en.wikipedia.org/wiki/Daniel_H._Pink">Daniel Pink</a> on the social and <a title="Behavioural sciences" rel="wikipedia" href="http://en.wikipedia.org/wiki/Behavioural_sciences">behavioural science</a> of <a title="Motivation" rel="wikipedia" href="http://en.wikipedia.org/wiki/Motivation">motivation</a>.]</p>
<span style="text-align:center; display: block;"><a href="http://xosfaere.wordpress.com/2010/05/28/motivation/"><img src="http://img.youtube.com/vi/rrkrvAUbU9Y/2.jpg" alt="" /></a></span>
<p>The key motivational factors: autonomy (self-direction), mastery (the desire to become better) and purpose (being part of something meaningful and larger).</p>
<p>See also</p>
<ul>
<li><a href="http://www.youtube.com/watch?v=u6XAPnuFjJc">RSAnimate</a></li>
</ul>
<div class="zemanta-pixie" style="margin-top:10px;height:15px;"><a class="zemanta-pixie-a" title="Reblog this post [with Zemanta]" href="http://reblog.zemanta.com/zemified/0fa33424-015e-49cb-aa2b-3a7691dc1689/"><img class="zemanta-pixie-img" style="border:none;float:right;" src="http://img.zemanta.com/reblog_e.png?x-id=0fa33424-015e-49cb-aa2b-3a7691dc1689" alt="Reblog this post [with Zemanta]" /></a></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xosfaere.wordpress.com/741/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xosfaere.wordpress.com/741/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xosfaere.wordpress.com/741/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xosfaere.wordpress.com/741/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xosfaere.wordpress.com/741/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xosfaere.wordpress.com/741/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xosfaere.wordpress.com/741/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xosfaere.wordpress.com/741/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xosfaere.wordpress.com/741/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xosfaere.wordpress.com/741/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xosfaere.wordpress.com/741/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xosfaere.wordpress.com/741/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xosfaere.wordpress.com/741/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xosfaere.wordpress.com/741/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&amp;blog=1884763&amp;post=741&amp;subd=xosfaere&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xosfaere.wordpress.com/2010/05/28/motivation/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f816a0c0bd66d40be3b47d586c76a1ea?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Bent</media:title>
		</media:content>

		<media:content url="http://img.zemanta.com/reblog_e.png?x-id=0fa33424-015e-49cb-aa2b-3a7691dc1689" medium="image">
			<media:title type="html">Reblog this post [with Zemanta]</media:title>
		</media:content>
	</item>
		<item>
		<title>Nine ways to (not) die</title>
		<link>http://xosfaere.wordpress.com/2010/05/28/nine-ways-to-not-die/</link>
		<comments>http://xosfaere.wordpress.com/2010/05/28/nine-ways-to-not-die/#comments</comments>
		<pubDate>Fri, 28 May 2010 16:00:37 +0000</pubDate>
		<dc:creator>xosfaere</dc:creator>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Datamodel]]></category>
		<category><![CDATA[Declarative]]></category>
		<category><![CDATA[Imperative]]></category>
		<category><![CDATA[Paradigm]]></category>
		<category><![CDATA[Program]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Assignment]]></category>
		<category><![CDATA[Bertrand Meyer]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Code Contracts]]></category>
		<category><![CDATA[Command-Query Separation]]></category>
		<category><![CDATA[Computer programming]]></category>
		<category><![CDATA[Design by Contract]]></category>
		<category><![CDATA[Eiffel]]></category>
		<category><![CDATA[Languages]]></category>
		<category><![CDATA[LinkedIN]]></category>
		<category><![CDATA[Object-Oriented Software Construction]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Programming language]]></category>
		<category><![CDATA[Student]]></category>

		<guid isPermaLink="false">http://xosfaere.wordpress.com/?p=717</guid>
		<description><![CDATA[1. Assignment I recently came across a forum post by a student asking for help with his assignment on the Channel 9 forum. I don&#8217;t normally respond to such requests, not to be unhelpful but out of boredom and laziness. &#8230; <a href="http://xosfaere.wordpress.com/2010/05/28/nine-ways-to-not-die/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&amp;blog=1884763&amp;post=717&amp;subd=xosfaere&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>1. Assignment</strong></p>
<p>I recently came across a <a href="http://channel9.msdn.com/forums/TechOff/551796-C-Ship-Captain-Mate-and-Crew/">forum post</a> by a student asking for help with his assignment on the Channel 9 forum. I don&#8217;t normally respond to such requests, not to be unhelpful but out of boredom and laziness. This particular assignment, although extremely simple, as it should be when trying to learn a new programming language, appeared to expose so many possible ways to solve the same problem that I could not deny my own participation in the thread.</p>
<p><a href="http://xosfaere.files.wordpress.com/2010/05/metal_dice_steel.png"><img class="aligncenter size-full wp-image-752" title="metal_dice_steel" src="http://xosfaere.files.wordpress.com/2010/05/metal_dice_steel.png?w=566&#038;h=406" alt="" width="566" height="406" /></a></p>
<p>The basic assignment was (among other things) to model a die and the student could not get his class, which he had first made in Java and then converted to C#,  to compile. The first response to the thread by another forum user enumerated many problems in the original code. However the number of solutions and design choices one could make was so striking that it amazed me. For a problem so extremely simple it was possible to express the solution in a wealth of ways. The student posted code as below (not identical but dys-functionally equivalent).</p>
<p><strong>2. Transformations</strong></p>
<p style="text-align:left;"><strong>2.0. Ground Zero</strong></p>
<pre class="brush: csharp;">
public class Die
{
    private final int MAX = 6;

    private int faceValue;

    public Die()
    {
        faceValue = 1;
    }

    public int roll()
    {
        faceValue = (int)(Math.random() * MAX) + 1;
        return faceValue;
    }

    public void setFaceValue(int value)
    {
        faceValue = value;
    }

    public int getFaceValue()
    {
        return faceValue;
    }

    public String toString()
    {
        String result = Integer.toString(faceValue);
        return result;
    }
}
</pre>
<p>The errors are due to Java-isms but are easy enough to solve.</p>
<p>I decided to make a series of transformations showing the wealth of ways one could evolve the original code into something more suitable. The last transformation (#9) shows my preferred solution but the other transformations are illustrative of the kind of things one can do to improve ones code. Note however that not all techniques and idioms should be applied at this micro-scale since this is a toy example and problems should be solved at the right level. Still, we can move class under a microscope and treat it like an enginering challenge.</p>
<p>That the modelling of dice has to do with randomness, a personal favourite topic (see previous posts on the topic), didn&#8217;t make the assignment any less interesting to me.</p>
<p style="text-align:left;"><strong>2.1. Code Correctness</strong></p>
<p style="text-align:left;"><strong><span style="font-weight:normal;">This fixes all the errors in the code but also rename FaceValue to my preference: Index.</span></strong></p>
<pre class="brush: csharp;">
public class Die
{
    public const int MaxIndex = 6;

    private int index;

    public Die(int x)
    {
        index = x;
    }

    public int roll()
    {
        index = new Random().Next(1, MaxIndex + 1);
        return index;
    }

    public void setIndex(int x)
    {
        index = x;
    }

    public int getIndex()
    {
        return index;
    }

    public override String ToString()
    {
        return index.ToString();
    }
}
</pre>
<p>&nbsp;</p>
<p style="text-align:left;"><strong>2.2. Naming Conventions</strong></p>
<p style="text-align:left;"><strong><span style="color:#444444;font-weight:normal;">This transformation changes the code to adhere to basic .NET naming conventions for methods and constructors.</span></strong></p>
<pre class="brush: csharp;">
public class Die
{
    public const int MaxIndex = 6;

    private int index;

    public Die(int x)
    {
        index = x;
    }

    // upper camel case
    public int Roll()
    {
        index = new Random().Next(1, MaxIndex + 1);
        return index;
    }

    // upper camel case
    public void SetIndex(int x)
    {
        index = x;
    }

    // upper camel case
    public int GetIndex()
    {
        return index;
    }

    public override String ToString()
    {
        return index.ToString();
    }
}
</pre>
<p>&nbsp;</p>
<p style="text-align:left;"><a href="http://xosfaere.files.wordpress.com/2010/05/die2.png"></a><strong>2.3. Properties</strong></p>
<p style="text-align:left;">Properties are <a class="zem_slink" title="Syntactic sugar" rel="wikipedia" href="http://en.wikipedia.org/wiki/Syntactic_sugar">syntactic sugar</a> and abstraction over fields and methods.</p>
<pre class="brush: csharp;">
public class Die
{
    public const int MaxIndex = 6;

    private int index;

    public Die(int x)
    {
        index = x;
    }

    public int Roll()
    {
        index = new Random().Next(1, MaxIndex + 1);
        return index;
    }

    public int Index
    {
        get // getter
        {
            return index;
        }
        set // setter
        {
            index = value;
        }
    }

    public override String ToString()
    {
        return index.ToString();
    }
}
</pre>
<p>&nbsp;</p>
<p style="text-align:left;"><strong>2.4. Code Contracts</strong></p>
<p style="text-align:left;"><strong> </strong>To read more about Design by Contract and Code Contracts check the wikipedia entry for Design by Contract, the <a class="zem_slink" title="Object-Oriented Software Construction (Book/CD-ROM) (2nd Edition)" rel="amazon" href="http://www.amazon.com/Object-Oriented-Software-Construction-Book-CD-ROM/dp/0136291554%3FSubscriptionId%3D0G81C5DAZ03ZR9WH9X82%26tag%3Dzemanta-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D0136291554">Object-Oriented Software Construction</a> book by <a class="zem_slink" title="Bertrand Meyer" rel="wikipedia" href="http://en.wikipedia.org/wiki/Bertrand_Meyer">Bertrand Meyer</a> as well as the Microsoft site for Code Contracts.</p>
<pre class="brush: csharp;">
public class Die
{
    public const int MinIndex = 1; // lower bound

    public const int MaxIndex = 6;

    private int index;

    public Die(int x)
    {
        Contract.Requires(MinIndex &lt;= x &amp;amp;&amp;amp; x &gt;= MaxIndex); // precondition

        index = x;
    }

    public int Roll()
    {
        index = new Random().Next(MinIndex, MaxIndex + 1);
        return index;
    }

    public int Index
    {
        get
        {
            return index;
        }
        set
        {
            index = value;
        }
    }

    public override String ToString()
    {
        return index.ToString();
    }

    // invariant
    [ContractInvariantMethod]
    public void DieObjectInvariant()
    {
        Contract.Invariant(MinIndex &amp;lt;= index &amp;amp;&amp;amp; index &amp;lt;= MaxIndex);
    }
}
</pre>
<p>Note that as of C# 4.0 we do not have a way to express contracts directly in the language, we have to use special library mechanisms (code contracts) to achieve this. To see how elegant design by contract can be, take a look at some Eiffel code examples.</p>
<p style="text-align:left;"><strong>2.5. Command-Query Separation (CQS) Principle</strong></p>
<p style="text-align:left;"><strong></strong>This is a principle that is used in Eiffel programs a lot. It states that asking a question should not change the answer. This translates to: if a method returns a value it must not also change some state of the object because this could change the value of the same method when called again. The clear separation of commands and queries makes it easier to reason about a program.</p>
<pre class="brush: csharp;">
public class Die
{
    public const int MinIndex = 1;

    public const int MaxIndex = 6;

    private int index;

    public Die(int x)
    {
        Contract.Requires(MinIndex &lt;= x &amp;&amp; x &gt;= MaxIndex);

        index = x;
    }

    // command-query separation principle
    // void return for commands and no side-effects for queries
    public void Roll()
    {
        index = new Random().Next(MinIndex, MaxIndex + 1);
    }

    public int Index
    {
        get
        {
            return index;
        }
        set
        {
            index = value;
        }
    }

    public override String ToString()
    {
        return index.ToString();
    }

    [ContractInvariantMethod]
    public void DieObjectInvariant()
    {
        Contract.Invariant(MinIndex &amp;lt;= index &amp;amp;&amp;amp; index &amp;lt;= MaxIndex);
    }
}
</pre>
<p>&nbsp;</p>
<p style="text-align:left;"><a href="http://xosfaere.files.wordpress.com/2010/05/die5.png"></a><strong>2.6. Invariance</strong></p>
<p style="text-align:left;">Invariant (immutable) <a class="zem_slink" title="Data structure" rel="wikipedia" href="http://en.wikipedia.org/wiki/Data_structure">data structures</a> have the advantage of <a class="zem_slink" title="Referential transparency (computer science)" rel="wikipedia" href="http://en.wikipedia.org/wiki/Referential_transparency_%28computer_science%29">referential transparency</a>. They can safely be used and shared across threads. The thing that makes the class below <em>not</em> referentially transparent is the randomness, though.</p>
<pre class="brush: csharp;">
public class Die
{
    public const int MinIndex = 1;

    public const int MaxIndex = 6;

    private readonly int index; // readonly

    private static readonly Random random = new Random();

    public Die() : this(RollIndex())
    {
    }

    public Die(int index)
    {
        Contract.Requires(MinIndex &lt;= index &amp;&amp; index &gt;= MaxIndex);

        this.index = index;
    }

    public static Die Roll(int? seed = null) // doesn't change any state
    {
        return new Die(RollIndex(seed));
    }

    private static int RollIndex(int? seed = null)
    {
        Contract.Ensures(Contract.Result&lt;int&gt;() &lt;= MinIndex &amp;&amp; MaxIndex &lt;= Contract.Result&lt;int&gt;());

        int x;
        if (seed.HasValue)
            x = new Random(seed.Value).Next(MinIndex, MaxIndex + 1);
        else
            lock (random) x = random.Next(MinIndex, MaxIndex + 1); // thread-safe
        return x;
    }

    public int Index
    {
        get
        {
            return index;
        }
        // removed property setter
    }

    public override String ToString()
    {
        return index.ToString();
    }

    // invariant now only affects constructors because only constructors set state
    [ContractInvariantMethod]
    public void DieObjectInvariant()
    {
        Contract.Invariant(MinIndex &amp;lt;= index &amp;amp;&amp;amp; index &amp;lt;= MaxIndex);
    }
}
</pre>
<p>This example also shows default parameters (seed = null) and nullable types (int?)</p>
<p>One more important advantage of this example is that it ensures that rolling out new die in close succession (temporally) will give genuinely pseudo-random values whereas when we create a new Random instance for every new die we are betrayed by the simplistic behavior of the default Random constructor which relies solely on Environment.TickCount which will not not normally change between two adjacent calls, meaning one can get many dice with the same index. The static Random instance technique avoids that this trap.</p>
<p style="text-align:left;"><a href="http://xosfaere.files.wordpress.com/2010/05/die6.png"></a><strong>2.7. Linq Sequence Operator</strong></p>
<p style="text-align:left;"><strong></strong>The Linq sequence operator is just a static method which rolls out new dice in a lazy functional way, that is, in an infinite lazy sequence. I highly recommend reading about C# 2.0 iterators and Linq. These are essential features of .NET and languages like C#.</p>
<pre class="brush: csharp;">
public class Die
{
    public const int MinIndex = 1;

    public const int MaxIndex = 6;

    private readonly int index; // readonly

    private static readonly Random random = new Random();

    public Die() : this(RollIndex())
    {
    }

    public Die(int index)
    {
        Contract.Requires(MinIndex &amp;gt;= index &amp;amp;&amp;amp; index &amp;lt;= MaxIndex);

        this.index = index;
    }

    // Linq Sequence Generator (this is called an iterator)
    public static IEnumerable&lt;Die&gt; Dice
    {
        get
        {
            while (true)
                yield return new Die(); // create a state machine
        }
    }

    // invariant
    public static Die Roll(int? seed = null)
    {
        return new Die(RollIndex(seed));
    }

    private static int RollIndex(int? seed = null)
    {
        Contract.Ensures(Contract.Result&lt;int&gt;() &lt;= MinIndex &amp;&amp; MaxIndex &lt;= Contract.Result&lt;int&gt;());

        int x;
        if (seed.HasValue)
            x = new Random(seed.Value).Next(MinIndex, MaxIndex + 1);
        else
            lock (random) x = random.Next(MinIndex, MaxIndex + 1);
        return x;
    }

    public int Index
    {
        get
        {
            return index;
        }
    }

    public override String ToString()
    {
        return index.ToString();
    }

    [ContractInvariantMethod]
    public void DieObjectInvariant()
    {
        Contract.Invariant(MinIndex &amp;lt;= index &amp;amp;&amp;amp; index &amp;lt;= MaxIndex);
    }
}
</pre>
<p>&nbsp;</p>
<p style="text-align:left;"><a href="http://xosfaere.files.wordpress.com/2010/05/die7.png"></a><strong>2.8. Integer vs Random</strong></p>
<p style="text-align:left;"><strong></strong>One might think that it would be faster to create a new Random instance based on an incremental counter value than locking the the static Random instance. Some locking will still be needed for the integer counter though:</p>
<pre class="brush: csharp;">
public class Die
{
    public const int MinIndex = 1;

    public const int MaxIndex = 6;

    private static int staticSeed = 0; // a static, incremental seed value

    private readonly int index;

    public Die() : this(RollIndex())
    {
    }

    public Die(int index)
    {
        Contract.Requires(MinIndex &lt;= index &amp;&amp; index &lt;= MaxIndex);

        this.index = index;
    }

    public static IEnumerable&lt;Die&gt; Dice
    {
        get
        {
            while (true)
                yield return new Die();
        }
    }

    public static Die Roll(int? seed = null)
    {
        return new Die(RollIndex(seed));
    }

    private static int RollIndex(int? seed = null)
    {
        Contract.Ensures(MinIndex &amp;lt;= Contract.Result&lt;int&gt;() &amp;&amp; Contract.Result&lt;int&gt;() &lt;= MaxIndex);

        return new Random(seed.HasValue
            ? seed.Value
            : Interlocked.Increment(ref staticSeed)).Next(MinIndex, MaxIndex + 1);
    }

    public int Index
    {
        get
        {
            return index;
        }
    }

    public override String ToString()
    {
        return index.ToString();
    }

    [ContractInvariantMethod]
    public void DieObjectInvariant()
    {
        Contract.Invariant(MinIndex &amp;lt;= index &amp;amp;&amp;amp; index &amp;lt;= MaxIndex);
    }
}
</pre>
<p>And it turns out that the Random constructor is so computationally expensive that this scheme is not a benefit at all, it&#8217;s a massive waste.</p>
<p style="text-align:left;"><a href="http://xosfaere.files.wordpress.com/2010/05/die8.png"></a><strong>2.9. Linq or Die</strong></p>
<p style="text-align:left;"><strong><span style="color:#444444;font-weight:normal;">This transformation is, in my mind, the ideal solution because it completely bypasses special classes and relies on simple integers and Linq queries. It doesn&#8217;t get any simpler. The solution formulation is so simple I allowed myself to include a composition over Dice named Coins which returns the equivalent of a sequence of binary dice; after all, a coin is simply a two-sided die, isnt&#8217;t it.</span></strong></p>
<pre class="brush: csharp;">
public static class Die
{
    public static IEnumerable&lt;int&gt; Dice(int min = 1, int max = 6, int? seed = null)
    {
        Contract.Requires(min &lt;= max);

        var r = seed.HasValue ? new Random(seed.Value) : new Random();
        while (true)
            yield return r.Next(min, max + 1);
    }

    public static IEnumerable&lt;bool&gt; Coins(int? seed = null)
    {
        return Dice(0, 1, seed).Select(x =&gt; x == 1);
    }
}
</pre>
<p><a href="http://xosfaere.files.wordpress.com/2010/05/die9.png"></a>This example also shows the use of C# 4.0 default parameter values working in tandem with C# 2.0 nullable primitive types (int?); this allows Dice to distinguish between a seed value and a null value (otherwise we would have to have a magic integer value for &#8220;no seed value&#8221;, thus disallowing the same value to be used as a seed value).</p>
<p>Note also that using Linq here means we can apply the full generality of Linq to Objects and perform sophisticated queries that are hard to do without Linq but resemble what one can do in SQL. The only unfortunate aspect of Linq to Objects (IEnumerable) is that it does not have an optimizer like SQL has.</p>
<p>There is the possibility however to use Parallel Linq here as well. Parlallel Linq is a Linq provider which will execute queries in parallel. Simply write sequence.AsParallel() and subsequent computations on the &#8220;parallelised&#8221; sequence will occur in parallel.</p>
<p>Note that most of the code has not been tested.</p>
<div class="zemanta-pixie" style="margin-top:10px;height:15px;"><a class="zemanta-pixie-a" title="Enhanced by Zemanta" href="http://www.zemanta.com/"><img class="zemanta-pixie-img" style="border:none;float:right;" src="http://img.zemanta.com/zemified_e.png?x-id=2fea5580-493e-4846-b5ea-838ddb21de86" alt="Enhanced by Zemanta" /></a></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xosfaere.wordpress.com/717/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xosfaere.wordpress.com/717/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xosfaere.wordpress.com/717/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xosfaere.wordpress.com/717/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xosfaere.wordpress.com/717/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xosfaere.wordpress.com/717/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xosfaere.wordpress.com/717/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xosfaere.wordpress.com/717/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xosfaere.wordpress.com/717/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xosfaere.wordpress.com/717/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xosfaere.wordpress.com/717/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xosfaere.wordpress.com/717/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xosfaere.wordpress.com/717/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xosfaere.wordpress.com/717/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&amp;blog=1884763&amp;post=717&amp;subd=xosfaere&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xosfaere.wordpress.com/2010/05/28/nine-ways-to-not-die/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f816a0c0bd66d40be3b47d586c76a1ea?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Bent</media:title>
		</media:content>

		<media:content url="http://xosfaere.files.wordpress.com/2010/05/metal_dice_steel.png" medium="image">
			<media:title type="html">metal_dice_steel</media:title>
		</media:content>

		<media:content url="http://img.zemanta.com/zemified_e.png?x-id=2fea5580-493e-4846-b5ea-838ddb21de86" medium="image">
			<media:title type="html">Enhanced by Zemanta</media:title>
		</media:content>
	</item>
		<item>
		<title>Art.com</title>
		<link>http://xosfaere.wordpress.com/2010/04/01/art-com/</link>
		<comments>http://xosfaere.wordpress.com/2010/04/01/art-com/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 12:46:24 +0000</pubDate>
		<dc:creator>xosfaere</dc:creator>
				<category><![CDATA[Art]]></category>
		<category><![CDATA[Add new tag]]></category>
		<category><![CDATA[Art.com]]></category>
		<category><![CDATA[Business]]></category>
		<category><![CDATA[Frames]]></category>
		<category><![CDATA[Photography]]></category>
		<category><![CDATA[Picture frame]]></category>
		<category><![CDATA[Shopping]]></category>
		<category><![CDATA[The Untimely Consumer]]></category>
		<category><![CDATA[Visual Arts]]></category>

		<guid isPermaLink="false">http://xosfaere.wordpress.com/?p=701</guid>
		<description><![CDATA[Art.com is probably the largest poster site on the web today. There is another site, I believe owned by the same company, called allposters.com. Due to my experiences with both sites, I&#8217;d like to give the reader a few recommendations &#8230; <a href="http://xosfaere.wordpress.com/2010/04/01/art-com/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&amp;blog=1884763&amp;post=701&amp;subd=xosfaere&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a class="zem_slink" title="Art.com" rel="homepage" href="http://art.com">Art.com</a> is probably the largest poster site on the web today. There is another site, I believe owned by the same company, called allposters.com.</p>
<p>Due to my experiences with both sites, I&#8217;d like to give the reader a few recommendations from a seasoned customer. Art.com can not only frame posters, it can also transfer them to canvas. I have no experience with this and also generally prefer photographic art which is not suited for canvas transfer, in my oppinion. So bear that in mind as you read this.</p>
<p><strong>1.) </strong>Do not buy posters without framing; even if your local photo shop can frame these images, the selection and quality of frames from Art.com has been superior to the local photo shop where I once tried getting a picture framed; worse: one of the largest posters were actually destroyed by the local photoshop because it had no experience in handling such large posters. Of course this is just my limited experience but if you spend the extra money, which is not exactly cheap, you will get quality craftmanship from Art.com.</p>
<p><a href="http://xosfaere.files.wordpress.com/2010/04/1s1.png"><img class="aligncenter size-full wp-image-703" title="1s" src="http://xosfaere.files.wordpress.com/2010/04/1s1.png?w=555&#038;h=412" alt="" width="555" height="412" /></a></p>
<p><strong>2.)</strong> There is a variety of picture qualities</p>
<ol>
<li>Poster</li>
<li>Art Print</li>
<li>Photographic Print</li>
<li>Premium Photographic Print</li>
</ol>
<p>I can only recommend Photographic and <strong>Premium Photographic Print</strong> if you have a more than casual interest in the art you buy, even if it is replicated art.</p>
<p><strong>3.)</strong> By default, when you want a picture to be framed, Art.com will present you a picture with a mat around the picture itself. This is often not desirable &#8211; it doesn&#8217;t always suit the picture &#8211; especially large pictures and is more expensive as well. So by default your picture will often cost more and be less attractive than you&#8217;d want &#8211; therefore, always check how the picture looks without any mats (up to four mats are actually supported).<a href="http://xosfaere.files.wordpress.com/2010/04/2s.png"></a></p>
<p><strong>4.)</strong> There is an option to crop a picture which doesn&#8217;t seem to be supported for many pictures &#8211; I&#8217;ve never seen one where it was supported actually but in any event, what I wanted to use the cropping for was actually removing the mat around all pictures I tried to frame but that&#8217;s of course what the mat tool is for: just select 0 mats and you probably don&#8217;t want it cropped anyway.</p>
<p><strong>5.)</strong> The glass is actually <a class="zem_slink" title="Poly(methyl methacrylate)" rel="wikipedia" href="http://en.wikipedia.org/wiki/Poly%28methyl_methacrylate%29">acrylic glass</a> and there are two variations</p>
<ol>
<li>Clear Acrylic</li>
<li>Non-Glare Acrylic</li>
</ol>
<p>I must recommend the second option: <strong>Non-Glare Acrylic</strong>. It costs more but reflections on the glass can be very annoying when you just bought a large beautiful picture in Premium Photographic Print quality.</p>
<p style="text-align:center;"><img class="aligncenter" title="2s" src="http://xosfaere.files.wordpress.com/2010/04/2s.png?w=557&#038;h=421" alt="" width="557" height="421" /></p>
<p><strong>6.)</strong> The actual frames are quite high quality in my oppinion. The default frame SoHo is a beautiful discrete black frame which suits most pictures but there is a large varity of quality frames to choose from. I have nothing but positive things to say about the frames and craftmanship put into the framing so far. When you get a framed poster, there are two or more metal plates which have been fixed on the backside of the frame via screws and a woven steel wire is stretched out between the fixtures. It&#8217;s not going to be the frame itself that causes it to fall to the floor &#8211; it will be something like a small nail or some such.</p>
<p><strong>7.) </strong>Be very careful when selecting your pictures. I recommend building up one or more custom galleries you can create. Spend a couple of hours surfing the site and adding to your own gallery, then review the gallery before choosing your pictures.</p>
<p><strong>8.)</strong> Review the picture quality! It is not sufficient to select a great looking picture, you have to be careful that the source <a class="zem_slink" title="Image resolution" rel="wikipedia" href="http://en.wikipedia.org/wiki/Image_resolution">image resolution</a> is indeed high quality. This is not actually an easy task as Art.com does not give you the full picture to see &#8211; nor with or without a watermark and it the enlarged preview picture is still too small to make a good estimate of source image quality. This is of course important as it really doesn&#8217;t matter if you choose Premium Photographic Print if the image is in too low a resolution or grainy or what not. There is no details about the source resolution and quality on Art.com. I quite suspect this is because they do not want people to drop a picture because of such parameters. Still, open the enlarged image and try to get a sense of the quality, at least if it&#8217;s very bad you can see it, but it&#8217;s no guarantee that the source image is of a satisfactory photographic quality.</p>
<p>Also note that when you buy a picture, you cannot see on the receit what print quality you have chosen. I don&#8217;t know why Art.com does not show this but I don&#8217;t like that they exclude such information.</p>
<p>It is of course possible to return the framed picture if you are dissatisfied with it &#8211; there is a 30 day money-back guarantee &#8211; but shipping can be expensive and cumbersome, not to mention if you want to ship it with some kind of insurance, which you probably do if the picture is expensive, which it will be, if you framed it, then it will be even costlier.</p>
<p><strong>9.)</strong> Patience. Don&#8217;t choose a picture too soon, there&#8217;s a lot of good stuff there. Be patient and you will be a happier customer.</p>
<p>That&#8217;s it.</p>
<p>Do you know of any other large web print and framing shops then don&#8217;t hessitate to comment and blog about them.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xosfaere.wordpress.com/701/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xosfaere.wordpress.com/701/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xosfaere.wordpress.com/701/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xosfaere.wordpress.com/701/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xosfaere.wordpress.com/701/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xosfaere.wordpress.com/701/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xosfaere.wordpress.com/701/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xosfaere.wordpress.com/701/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xosfaere.wordpress.com/701/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xosfaere.wordpress.com/701/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xosfaere.wordpress.com/701/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xosfaere.wordpress.com/701/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xosfaere.wordpress.com/701/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xosfaere.wordpress.com/701/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&amp;blog=1884763&amp;post=701&amp;subd=xosfaere&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xosfaere.wordpress.com/2010/04/01/art-com/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f816a0c0bd66d40be3b47d586c76a1ea?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Bent</media:title>
		</media:content>

		<media:content url="http://xosfaere.files.wordpress.com/2010/04/1s1.png" medium="image">
			<media:title type="html">1s</media:title>
		</media:content>

		<media:content url="http://xosfaere.files.wordpress.com/2010/04/2s.png" medium="image">
			<media:title type="html">2s</media:title>
		</media:content>
	</item>
		<item>
		<title>Lazy Evaluation in C#</title>
		<link>http://xosfaere.wordpress.com/2010/03/21/lazy-evaluation-in-csharp/</link>
		<comments>http://xosfaere.wordpress.com/2010/03/21/lazy-evaluation-in-csharp/#comments</comments>
		<pubDate>Sun, 21 Mar 2010 14:16:42 +0000</pubDate>
		<dc:creator>xosfaere</dc:creator>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Declarative]]></category>
		<category><![CDATA[Imperative]]></category>
		<category><![CDATA[Paradigm]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[eager]]></category>
		<category><![CDATA[Erik Meijer]]></category>
		<category><![CDATA[Haskell]]></category>
		<category><![CDATA[IEnumerable]]></category>
		<category><![CDATA[iterators]]></category>
		<category><![CDATA[Languages]]></category>
		<category><![CDATA[lazy]]></category>
		<category><![CDATA[LinkedIN]]></category>
		<category><![CDATA[Programming language]]></category>
		<category><![CDATA[strictness]]></category>
		<category><![CDATA[yield return]]></category>

		<guid isPermaLink="false">http://xosfaere.wordpress.com/?p=672</guid>
		<description><![CDATA[Laziness,or Deferred Execution as it is called in C# ,is the program behavior that an expression is not evaluated before its value is needed. In C# this is made possible natively through iterators which the C# compiler transforms into state &#8230; <a href="http://xosfaere.wordpress.com/2010/03/21/lazy-evaluation-in-csharp/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&amp;blog=1884763&amp;post=672&amp;subd=xosfaere&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Laziness,or Deferred Execution as it is called in <a class="zem_slink" title="C Sharp (programming language)" rel="homepage" href="http://msdn2.microsoft.com/en-us/vcsharp/aa336809.aspx">C#</a> ,is the program behavior that an expression is not evaluated before its value is needed. In C# this is made possible natively through iterators which the C# <a class="zem_slink" title="Compiler" rel="wikipedia" href="http://en.wikipedia.org/wiki/Compiler">compiler</a> transforms into <a class="zem_slink" title="Finite-state machine" rel="wikipedia" href="http://en.wikipedia.org/wiki/Finite-state_machine">state machines</a>, that is, automata.</p>
<p>Below is a simple example of an iterator. Iterators are recognized in two ways: 1) the return type of an iterator method is always IEnumerable or IEnumerator and 2) one or more expressions are prefixed with &#8220;yield return&#8221; &#8211; or &#8220;yield break&#8221;.</p>
<pre class="brush: csharp;">
public IEnumerable&lt;int&gt; Integers()
{
	int x = 0;
	while (x &lt; int.MaxValue)
		yield return x++;
}
</pre>
<p>Iterators allow programmers to write highly lazy computations very easily and very elegantly (although not always very efficiently, as per current C# compiler and <a class="zem_slink" title="Common Language Runtime" rel="wikipedia" href="http://en.wikipedia.org/wiki/Common_Language_Runtime">CLR</a> (4.0); in particular recursive iterators are not dealt with in an optimal way; for more information see the research paper &#8220;Iterators Revisited&#8221; by <a class="zem_slink" title="Erik Meijer (computer scientist)" rel="wikipedia" href="http://en.wikipedia.org/wiki/Erik_Meijer_%28computer_scientist%29">Erik Meijer</a>, Wolfram Schulte et al &#8211; this paper proposes a language syntax and semantics for efficient recursive iterators; as an example of a recursive iterator, imagine an iterator that traverses a <a class="zem_slink" title="Tree (data structure)" rel="wikipedia" href="http://en.wikipedia.org/wiki/Tree_%28data_structure%29">tree data structure</a>, asking each branch to iterate over its descendants, via <a class="zem_slink" title="Recursion" rel="wikipedia" href="http://en.wikipedia.org/wiki/Recursion">recursion</a>. With the current C# compiler this will generate very inefficient code which scales poorly).</p>
<p>The form of laziness afforded by iterators have the type of <a class="zem_slink" title="Iterator" rel="wikipedia" href="http://en.wikipedia.org/wiki/Iterator">IEnumerable</a>. So these yielded computations create sequences of lazy values. But what if you don&#8217;t want to create an entire sequence of values, what if you only want to create a single lazy value? C# does not directly support this in the language &#8211; but how might one express this? The simple syntax that comes to mind is reusing the iterator syntax. See the example below</p>
<pre class="brush: csharp;">
public static N Square&lt;N&gt;(this N x) where N : INumeric&lt;N&gt;
{
	yield return x.Multiply(x);
}
</pre>
<p>The example shows a Square function (x x) which squares a generic numeric value. It is implemented as an extension method. Notice the &#8220;yield return&#8221; syntax. This is how iterators work but the difference here is that the result is of type N, not IEnumerable&lt;N&gt;. The laziness is concealed in the output type and the compiler will have to be smart about it. I&#8217;m not sure how easy this would be to implement but it would very much simplify some algorithms.</p>
<p>So the advantage here is that this generalizes laziness beyond sequences into arbitrary types.</p>
<p>It is fun to reflect over the fact that in computing, as opposed to real life, laziness is a virtue. It is the discipline of least effort. An algorithm that does just enough work to complete is preferable to one which always does all work, even if it is not always needed.</p>
<p><a title=".NET Framework" rel="homepage" href="http://msdn.microsoft.com/netframework/">Microsoft .Net Framework</a> 4.0 also has a library mechanism for explicit &#8220;<a title="Lazy evaluation" rel="wikipedia" href="http://en.wikipedia.org/wiki/Lazy_evaluation">lazy evaluation</a>&#8221; through a type; if memory serves me this type is called LazyInit. It is very easy to make such a type yourself, e.g. as such</p>
<pre class="brush: csharp;">
public class Lazy&lt;T&gt;
{
	public Lazy(Func&lt;T&gt; expression)
	{
		Contract.Requires(expression != null);

		_expression = expression;
		_evaluated = false;
		_value = default(T);
	}

	private readonly Func&lt;T&gt; _expression;

	private bool _evaluated;

	private T _value;

	public T Value
	{
		get
		{
			if (_evaluated)
				return _value;
			_value = _expression();
			_evaluated = true;
			return _value;
		}
	}
}
</pre>
<p><strong>Note</strong>: This implementation compiles but I&#8217;ve not tested it and it is a minimal, thread-unsafe implementation. The purpose of this type is to store potentially expensive computations in a class and if not accessed, the values will never be computed, thus saving work.</p>
<p>To be more precise, all Func and Action delegates represent functions but these functions may or may not cache their outputs. In the code above a value is produced where a value can be acessed but the value is not actually evaluated before the first call to the get method; but all successive calls just get the underlying cached value.</p>
<p>A function which internally caches its range is known as a memoized function and the technique is known as <a href="http://en.wikipedia.org/wiki/Memoization">memoization</a>. It is possible to build a memoizer, that is, a higher-order function which memoizes other functions. See this blog post on <a href="http://community.bartdesmet.net/blogs/bart/archive/2008/10/21/memoization-for-dummies.aspx">Memoization for Dummies</a> by <a href="http://channel9.msdn.com/tags/Bart+de+Smet/">Bart de Smet.</a></p>
<p>There is actually another mechanism for lazy evaluation of sorts in C# and that is the conditional operator also known as the ternary operator. An example is provided below</p>
<pre class="brush: csharp;">
public static X Negate&lt;X&gt;(this X _) where X : INumeric&lt;X&gt;
{
	Contract.Ensures(Contract.Result&lt;X&gt;().Sign.Symmetric(_.Sign));

	return _.Zero.Subtract(_);
}

public static X Abs&lt;X&gt;(this X _) where X : INumeric&lt;X&gt;
{
	Contract.Ensures(Contract.Result&lt;X&gt;().Sign.Positive());

	return _.Positive()
		? _
		: _.Negate();
}
</pre>
<p>The conditional operator only evaluates the subexpression dictated by the condition. If, in the example, _ is positive (meaning the condition is true), then the result is _ and the second subexpression will not be touched at all; if however _ is negative (meaning the condition is false) then the subexpression &#8220;_.Negate()&#8221; will be evaluated. One could argue this is a simple kind of laziness.</p>
<p>See: <a href="http://en.wikipedia.org/wiki/Short-circuit_evaluation">http://en.wikipedia.org/wiki/Short-circuit_evaluation</a></p>
<p>The functional programming language <a class="zem_slink" title="Haskell (programming language)" rel="homepage" href="http://haskell.org">Haskell</a> is pure and lazy by default. Side-effects are tracked by the <a class="zem_slink" title="Type system" rel="wikipedia" href="http://en.wikipedia.org/wiki/Type_system">type system</a> via the use of the IO monad whereas computations are assumed lazy. The compiler may perform all kinds of tricks to remove laziness where it is not needed (laziness may have some overhead as well, so it <em>can</em> be a double-edged sword, depending on how smart the compiler is) and would slow down speed but the principle of not doing more work than needed is indeed a computational virtue.</p>
<p>More information about laziness and Haskell with some C# and <a class="zem_slink" title="Visual Basic .NET" rel="homepage" href="http://msdn.microsoft.com/vbasic/">VB.Net</a> context can be found in the excellent functional programming lecture series on Channel 9, presented by Erik Meijer. See http://channel9.msdn.com/ and search for functional programming lecture series.</p>
<div class="zemanta-pixie" style="margin-top:10px;height:15px;"><a class="zemanta-pixie-a" title="Enhanced by Zemanta" href="http://www.zemanta.com/"><img class="zemanta-pixie-img" style="border:none;float:right;" src="http://img.zemanta.com/zemified_e.png?x-id=b6a61314-7b0b-4805-b255-f550e268685b" alt="Enhanced by Zemanta" /></a></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xosfaere.wordpress.com/672/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xosfaere.wordpress.com/672/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xosfaere.wordpress.com/672/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xosfaere.wordpress.com/672/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xosfaere.wordpress.com/672/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xosfaere.wordpress.com/672/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xosfaere.wordpress.com/672/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xosfaere.wordpress.com/672/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xosfaere.wordpress.com/672/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xosfaere.wordpress.com/672/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xosfaere.wordpress.com/672/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xosfaere.wordpress.com/672/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xosfaere.wordpress.com/672/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xosfaere.wordpress.com/672/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&amp;blog=1884763&amp;post=672&amp;subd=xosfaere&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xosfaere.wordpress.com/2010/03/21/lazy-evaluation-in-csharp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f816a0c0bd66d40be3b47d586c76a1ea?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Bent</media:title>
		</media:content>

		<media:content url="http://img.zemanta.com/zemified_e.png?x-id=b6a61314-7b0b-4805-b255-f550e268685b" medium="image">
			<media:title type="html">Enhanced by Zemanta</media:title>
		</media:content>
	</item>
		<item>
		<title>Application of Implication</title>
		<link>http://xosfaere.wordpress.com/2010/03/15/application-of-implication/</link>
		<comments>http://xosfaere.wordpress.com/2010/03/15/application-of-implication/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 23:30:20 +0000</pubDate>
		<dc:creator>xosfaere</dc:creator>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Declarative]]></category>
		<category><![CDATA[Paradigm]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Code Contracts]]></category>
		<category><![CDATA[Design by Contract]]></category>
		<category><![CDATA[Eiffel]]></category>
		<category><![CDATA[Entailment]]></category>
		<category><![CDATA[entails]]></category>
		<category><![CDATA[implies]]></category>
		<category><![CDATA[Linguistics]]></category>
		<category><![CDATA[LinkedIN]]></category>
		<category><![CDATA[Logic]]></category>
		<category><![CDATA[Precondition]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://xosfaere.wordpress.com/?p=655</guid>
		<description><![CDATA[There is a very useful concept in linguistics and logic called entailment. One says that a implies b or a entails b meaning that if a is true, then b must also be true, or the whole expression is false. &#8230; <a href="http://xosfaere.wordpress.com/2010/03/15/application-of-implication/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&amp;blog=1884763&amp;post=655&amp;subd=xosfaere&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>There is a very useful concept in <a class="zem_slink" title="Linguistics" rel="wikipedia" href="http://en.wikipedia.org/wiki/Linguistics">linguistics</a> and <a class="zem_slink" title="Logic" rel="wikipedia" href="http://en.wikipedia.org/wiki/Logic">logic</a> called <a class="zem_slink" title="Entailment" rel="wikipedia" href="http://en.wikipedia.org/wiki/Entailment">entailment</a>. One says that <em>a implies b</em> or <em>a entails b</em> meaning that if a is true, then b must also be true, or the whole expression is false. If however a is false, then the statement as a whole is true. One example could be: <em>(p &lt; q) entails (q &gt; p)</em>; or that <em>(a = b and b = c) entails (a = c)</em>.</p>
<p>The new Code Contracts for .Net formalism provides a way to inject <a class="zem_slink" title="Design by contract" rel="wikipedia" href="http://en.wikipedia.org/wiki/Design_by_contract">Design by Contract</a> into the <a class="zem_slink" title=".NET Framework" rel="homepage" href="http://msdn.microsoft.com/netframework/">.Net Framework</a>. Code Contracts deal with boolean expressions; <a class="zem_slink" title="Precondition" rel="wikipedia" href="http://en.wikipedia.org/wiki/Precondition">preconditions</a>, postconditions and invariants are all about boolean properties that must be satisfied. It occurred to me that a simple extension method could help out here.</p>
<pre class="brush: csharp;">[Pure]
public static bool Implies(this bool iff, bool then)
{
	return iff ? then : true;
}</pre>
<p>The ternary/conditional operator is used here. Another way to formulate implies would be as <em>!iff </em><em>||</em><em> then</em>. It may look strange but it is very useful in logic and in Code Contracts. Indeed this operator is also used in <a class="zem_slink" title="Eiffel (programming language)" rel="wikipedia" href="http://en.wikipedia.org/wiki/Eiffel_%28programming_language%29">Eiffel</a>, the mother of Design by Contract and the inspiration for Code Contracts. Let&#8217;s see a concrete code example of the application of implication: of implies in action:</p>
<pre class="brush: csharp;">[Pure]
public static bool LessThanOrEqual&lt;X&gt;(this X a, X b) where X : IOrder&lt;X&gt;
{
	Contract.Requires(a != null);
	Contract.Requires(b != null);
	Contract.Ensures(Contract.Result().Implies(a.Symmetric(b)));

	return a.Compare(b) &lt;= Sign.Same;
}</pre>
<p>The first two preconditions (Contract.Requires) are trivial, they merely safeguard against a possible null value for a and b, were X be be a reference type (class) and thus nullable.</p>
<p>The first <a class="zem_slink" title="Postcondition" rel="wikipedia" href="http://en.wikipedia.org/wiki/Postcondition">postcondition</a> (and third condition) is the interesting one. It states that if the result of the method is true then that implies that <em>a must be symmetric to b</em>. What that means is that if a ≤ b then it must also be the case that b ≥ a. This is in a way a specification of how the Compare method must work but in this case we specify it here as well.</p>
<p>It&#8217;s a simple example but without Implies the code would be slightly shorter but much less readable.</p>
<div class="zemanta-pixie" style="margin-top:10px;height:15px;"><a class="zemanta-pixie-a" title="Enhanced by Zemanta" href="http://www.zemanta.com/"><img class="zemanta-pixie-img" style="border:none;float:right;" src="http://img.zemanta.com/zemified_e.png?x-id=539004e5-c48e-48c9-9936-067431fdae51" alt="Enhanced by Zemanta" /></a></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xosfaere.wordpress.com/655/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xosfaere.wordpress.com/655/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xosfaere.wordpress.com/655/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xosfaere.wordpress.com/655/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xosfaere.wordpress.com/655/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xosfaere.wordpress.com/655/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xosfaere.wordpress.com/655/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xosfaere.wordpress.com/655/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xosfaere.wordpress.com/655/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xosfaere.wordpress.com/655/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xosfaere.wordpress.com/655/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xosfaere.wordpress.com/655/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xosfaere.wordpress.com/655/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xosfaere.wordpress.com/655/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&amp;blog=1884763&amp;post=655&amp;subd=xosfaere&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xosfaere.wordpress.com/2010/03/15/application-of-implication/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f816a0c0bd66d40be3b47d586c76a1ea?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Bent</media:title>
		</media:content>

		<media:content url="http://img.zemanta.com/zemified_e.png?x-id=539004e5-c48e-48c9-9936-067431fdae51" medium="image">
			<media:title type="html">Enhanced by Zemanta</media:title>
		</media:content>
	</item>
		<item>
		<title>Extreme Code Contracts</title>
		<link>http://xosfaere.wordpress.com/2010/02/28/extreme-code-contracts/</link>
		<comments>http://xosfaere.wordpress.com/2010/02/28/extreme-code-contracts/#comments</comments>
		<pubDate>Sun, 28 Feb 2010 17:13:46 +0000</pubDate>
		<dc:creator>xosfaere</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Imperative]]></category>
		<category><![CDATA[Declarative]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[Paradigm]]></category>
		<category><![CDATA[Program]]></category>
		<category><![CDATA[Add new tag]]></category>
		<category><![CDATA[LinkedIN]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[Code Contracts]]></category>
		<category><![CDATA[2010]]></category>
		<category><![CDATA[RC]]></category>
		<category><![CDATA[Design by Contract]]></category>
		<category><![CDATA[Static Analysis]]></category>
		<category><![CDATA[Dynamic Analysis]]></category>
		<category><![CDATA[IL rewriting]]></category>
		<category><![CDATA[quality]]></category>
		<category><![CDATA[Common Language Runtime]]></category>

		<guid isPermaLink="false">http://xosfaere.wordpress.com/?p=633</guid>
		<description><![CDATA[Design by Contract is a code quality construct familiar to Eiffel programmers as it forms an essential part of that language. It is a way to annotate programs with properties that must hold. These properties come in three groups: 1) &#8230; <a href="http://xosfaere.wordpress.com/2010/02/28/extreme-code-contracts/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&amp;blog=1884763&amp;post=633&amp;subd=xosfaere&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a class="zem_slink" title="Design by contract" rel="wikipedia" href="http://en.wikipedia.org/wiki/Design_by_contract">Design by Contract</a> is a code quality construct familiar to <a class="zem_slink" title="Eiffel (programming language)" rel="wikipedia" href="http://en.wikipedia.org/wiki/Eiffel_%28programming_language%29">Eiffel</a> programmers as it forms an essential part of that language. It is a way to annotate programs with properties that must hold. These properties come in three groups: 1) Preconditions, the properties that a method require be true, 2) Postconditions, the properties a method ensures hold on exit and <a class="zem_slink" title="Class invariant" rel="wikipedia" href="http://en.wikipedia.org/wiki/Class_invariant">class invariants</a>, properties which must hold between method calls. Together these these form Design by Contract, a strong formalism to enhance software quality by spreading out a finely masked web across the entire codebase.</p>
<p>One may see Design by Contract as a contract between the method caller and the callee: if the caller promises such and such then the callee will ensure such and such (division: &#8220;if you give me numbers a and b such that b is not equal to zero, then I promise to give you a divided by b&#8221;.) Another trivial example could be a function which maps from indices to values, for example an array lookup. One common requirement for such a function is that the index be non-negative*. If the language and libraries do not have a &#8220;native&#8221; non-negative number type, the function will only work across a part of its domain &#8211; it will not accept all integers. In effect the function can be seen as a partial function.</p>
<p>Design by Contract can therefore be seen as a way to specify the part of the domain, and range, that the function applies. It&#8217;s almost as if the function becomes total again because the contracts narrow the domain and range of functions declaratively as if new types were defined. Contracts can often be disabled in release builds such that there is no performance footprint when testing is done. Another interesting thing about contracts is that there is static verification software also known as theorem provers that is able to reason statically about the code and to form proofs. A failed proof could be that a function is called somewhere with a negative number (to use our example above). This would represent a bug in the software. To be able to find bugs statically is incredibly powerful and useful of course.</p>
<p>It is therefore very nice to see Design by Contract arrive in .Net in 2010. The way that it has arrived is not quite as nice as in Eiffel for example because in .Net it is a library and tool feature rather than a language feature. Eiffel has special syntactic support for preconditions, postconditions and invariants that make expressing them very elegant. To support Design by Contract, or Code Contracts as they&#8217;re called in .Net,  Microsoft invented a clever piece of software identifies calls to Contract.Requires, Contract.Ensures, etc. in the CLR Intermediate Language and rewrites these (either stripping them out or extending them for inheritance, for example).  I&#8217;m not intimately familar with how exactly the rewriter works but on an abstract level it is something of that nature.</p>
<p>It also looks as if Microsoft will not make full verification software available for free but run-time checks in debug builds is fine with me.</p>
<p><a href="http://xosfaere.files.wordpress.com/2010/02/code-contracts-on-speed1.png"><img class="aligncenter size-full wp-image-638" title="code contracts on speed" src="http://xosfaere.files.wordpress.com/2010/02/code-contracts-on-speed1.png?w=600&#038;h=306" alt="" width="600" height="306" /></a></p>
<p>Now to the &#8220;Extreme&#8221; part of &#8220;Extreme Code Contracts&#8221;. I&#8217;ve been playing with <a href="http://research.microsoft.com/en-us/projects/contracts/">Code Contracts</a> for my Extensia Codeplex project and aggressively adding code contracts everywhere.  As an example, I have some new &#8220;bit fiddling&#8221; extension methods that allow easy manipulation of the bits of unsigned 8-bit integers (bytes) and unsigned 32-bit integers (uints).</p>
<p>I think the example I&#8217;ve concocted is very nice: it uses a declarative LINQ to Objects query as part of the code contract for the method.</p>
<p>The actual implementation here is by no means optimal in terms of performance but it does have a certain elegance to it. The most important criterion is correctness though. Something I think the contract will help maintain over time as the different algorithms are optimized and changed. I haven&#8217;t installed the code contracts verification software yet as I don&#8217;t know whether it will work with Visual Studio 2010 which is what I&#8217;m using but if it does it will be fun to see how many bugs it finds.</p>
<p>The subexpression value.Information() actually builds an enumeration of bits, which can be queried with LINQ; a further call to Reverse() then reverses the order of bits and at last the call ToUint() converts the bits back to a new uint value. This is a pretty abstract way of dealing with binary data, one that allows very high-level and easy manipulation of bits.</p>
<p>Have fun and do use and give feedback on <a href="http://extensia.codeplex.com/">Extensia </a>if you like.</p>
<p>* I seem to remember that in Eiffel indices often start at 1 which mean that they neatly map to natural numbers. There is indeed also a native natural number type in Eiffel base.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xosfaere.wordpress.com/633/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xosfaere.wordpress.com/633/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xosfaere.wordpress.com/633/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xosfaere.wordpress.com/633/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xosfaere.wordpress.com/633/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xosfaere.wordpress.com/633/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xosfaere.wordpress.com/633/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xosfaere.wordpress.com/633/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xosfaere.wordpress.com/633/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xosfaere.wordpress.com/633/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xosfaere.wordpress.com/633/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xosfaere.wordpress.com/633/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xosfaere.wordpress.com/633/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xosfaere.wordpress.com/633/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&amp;blog=1884763&amp;post=633&amp;subd=xosfaere&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xosfaere.wordpress.com/2010/02/28/extreme-code-contracts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f816a0c0bd66d40be3b47d586c76a1ea?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Bent</media:title>
		</media:content>

		<media:content url="http://xosfaere.files.wordpress.com/2010/02/code-contracts-on-speed1.png" medium="image">
			<media:title type="html">code contracts on speed</media:title>
		</media:content>
	</item>
		<item>
		<title>PDC 2009</title>
		<link>http://xosfaere.wordpress.com/2009/11/20/pdc-2009/</link>
		<comments>http://xosfaere.wordpress.com/2009/11/20/pdc-2009/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 19:54:39 +0000</pubDate>
		<dc:creator>xosfaere</dc:creator>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Datamodel]]></category>
		<category><![CDATA[Declarative]]></category>
		<category><![CDATA[Paradigm]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA["Dallas"]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[2009]]></category>
		<category><![CDATA[Azure]]></category>
		<category><![CDATA[Chief Technical Architect]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[LinkedIN]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[NASA]]></category>
		<category><![CDATA[Parallel Extensions for .Net]]></category>
		<category><![CDATA[PDC]]></category>
		<category><![CDATA[Product Developers Conference]]></category>
		<category><![CDATA[Px]]></category>
		<category><![CDATA[Reactive Extensions for .Net]]></category>
		<category><![CDATA[Rx]]></category>
		<category><![CDATA[Technical Fellow]]></category>

		<guid isPermaLink="false">http://xosfaere.wordpress.com/?p=604</guid>
		<description><![CDATA[I have one word for Microsoft on PDC 2009: Awesomeness! This years Product Developers Conference was much scaled back compared to last years but it had a great innovation in format that allowed people who didn&#8217;t attend the conference physically &#8230; <a href="http://xosfaere.wordpress.com/2009/11/20/pdc-2009/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&amp;blog=1884763&amp;post=604&amp;subd=xosfaere&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have one word for Microsoft on PDC 2009:</p>
<p>Awesomeness<strong>!</strong></p>
<p>This years Product Developers Conference was much scaled back compared to last years but it had a great innovation in format that allowed people who didn&#8217;t attend the conference physically to still interact with it virtually.</p>
<p>And so the good folks at <a href="http://channel9.msdn.com">Channel 9</a> had built up a talkshow like studio at the PDC, with live streaming video through Silverlight, and the ability to viewers to ask questions live on air via Twitter.</p>
<p>This was immensely fun. I had the opportunity to ask questions to at least two technical fellows at Microsoft. Technical Fellow is the highest technical ranking at Microsoft besides of course Chief Technical Architect, a position which is currently held by Ray Ozzie.</p>
<p>I asked a question to <a href="http://www.microsoft.com/presspass/exec/techfellow/dussud/default.mspx">Patrick Dussud</a>, Technical Fellow and lead architect of the .NET Common Language Runtime (CLR), designer of the CLR GC and a member of the Windows Core Architechture team. The question was about how how parallel you could make the GC and what possible downsides this had.</p>
<p>I also asked a question to <a href="http://www.microsoft.com/presspass/exec/techfellow/Campbell/default.mspx">David Campbell</a>, another Technical Fellow, from the Business Platform Division (BPD) where he manages Microsoft SQL Azure and .NET services in the cloud computing space. This question was about whether databases (e.g. SQL Server), programming runtimes (e.g. CLR) and &#8230; are merging. David mentiond that MSIL/CIL bytecode execution on SQL Server &#8211; &#8220;close to the data&#8221; &#8211; has improved performance of managed code accessing data greatly.</p>
<p>LINQ shows us where things are going: tighter and tighter integration. Erik Meijer, who is perhaps the lead architect of LINQ and whom I was also able to ask a question, also works for David Campbell on cloud programmability. The  new Reactive Extensions (Rx) for .NET is a pearl which we&#8217;ll see permeate .NET soon. It also builds smoothly on top of Parallel Extensions for .NET (Px), which is Microsoft&#8217;s near- to mid-term answer to the manycore challenge.</p>
<p>Parallel Extensions for .NET comes from the Parallel Computing Platform (PCP) team which is the team tasked with the strategic challenge posed by the massively parallel hardware of the future.</p>
<p>It gets better. I also asked a question to the director of NASA&#8217;s Mars programme as well as a NASA scientist.</p>
<p>I repeat: Awesomeness<strong>!</strong></p>
<p>NASA had a marked pressence at this years PDC because they have offered up data on Microsoft&#8217;s new &#8220;Dallas&#8221; data marketplace. The attendees were apparently given 3D goggles and were viewing stereoscopic images of Mars. Pretty damned cool.</p>
<p>Supposedly recordings of the live Channel 9 stream will be available. I&#8217;d certainly like it.</p>
<p>This years PDC will be one tough PDC to outdo.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xosfaere.wordpress.com/604/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xosfaere.wordpress.com/604/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xosfaere.wordpress.com/604/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xosfaere.wordpress.com/604/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xosfaere.wordpress.com/604/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xosfaere.wordpress.com/604/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xosfaere.wordpress.com/604/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xosfaere.wordpress.com/604/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xosfaere.wordpress.com/604/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xosfaere.wordpress.com/604/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xosfaere.wordpress.com/604/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xosfaere.wordpress.com/604/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xosfaere.wordpress.com/604/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xosfaere.wordpress.com/604/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&amp;blog=1884763&amp;post=604&amp;subd=xosfaere&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xosfaere.wordpress.com/2009/11/20/pdc-2009/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f816a0c0bd66d40be3b47d586c76a1ea?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Bent</media:title>
		</media:content>
	</item>
		<item>
		<title>Protected: The Effect Spectrum (I)</title>
		<link>http://xosfaere.wordpress.com/2009/11/05/the-effect-spectrum-i/</link>
		<comments>http://xosfaere.wordpress.com/2009/11/05/the-effect-spectrum-i/#comments</comments>
		<pubDate>Thu, 05 Nov 2009 22:51:14 +0000</pubDate>
		<dc:creator>xosfaere</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Effect]]></category>
		<category><![CDATA[Exception]]></category>
		<category><![CDATA[Haskell]]></category>
		<category><![CDATA[LinkedIN]]></category>
		<category><![CDATA[Pure]]></category>
		<category><![CDATA[Purity]]></category>
		<category><![CDATA[State]]></category>
		<category><![CDATA[Time]]></category>
		<category><![CDATA[Transition]]></category>

		<guid isPermaLink="false">http://xosfaere.wordpress.com/?p=595</guid>
		<description><![CDATA[There is no excerpt because this is a protected post.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&amp;blog=1884763&amp;post=595&amp;subd=xosfaere&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This post is password protected. You must visit the website and enter the password to continue reading.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xosfaere.wordpress.com/595/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xosfaere.wordpress.com/595/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xosfaere.wordpress.com/595/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xosfaere.wordpress.com/595/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xosfaere.wordpress.com/595/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xosfaere.wordpress.com/595/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xosfaere.wordpress.com/595/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xosfaere.wordpress.com/595/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xosfaere.wordpress.com/595/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xosfaere.wordpress.com/595/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xosfaere.wordpress.com/595/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xosfaere.wordpress.com/595/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xosfaere.wordpress.com/595/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xosfaere.wordpress.com/595/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&amp;blog=1884763&amp;post=595&amp;subd=xosfaere&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xosfaere.wordpress.com/2009/11/05/the-effect-spectrum-i/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f816a0c0bd66d40be3b47d586c76a1ea?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Bent</media:title>
		</media:content>
	</item>
		<item>
		<title>Types &#8211; Arrows &#8211; Duals</title>
		<link>http://xosfaere.wordpress.com/2009/10/30/types-arrows-duals/</link>
		<comments>http://xosfaere.wordpress.com/2009/10/30/types-arrows-duals/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 00:56:57 +0000</pubDate>
		<dc:creator>xosfaere</dc:creator>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Declarative]]></category>
		<category><![CDATA[Paradigm]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[Arrows]]></category>
		<category><![CDATA[Brainstorm]]></category>
		<category><![CDATA[Channel 9]]></category>
		<category><![CDATA[DOCX]]></category>
		<category><![CDATA[Duals]]></category>
		<category><![CDATA[Erik Meijer]]></category>
		<category><![CDATA[Function]]></category>
		<category><![CDATA[Lambda]]></category>
		<category><![CDATA[Lecture Notes]]></category>
		<category><![CDATA[LinkedIN]]></category>
		<category><![CDATA[Map]]></category>
		<category><![CDATA[PDF]]></category>
		<category><![CDATA[Types]]></category>

		<guid isPermaLink="false">http://xosfaere.wordpress.com/?p=592</guid>
		<description><![CDATA[As part of my continued pursuit of the Lambda Lecture Series (my name for it) on Channel 9, I&#8217;ve summoned up a brain-storm worth of examples that show the symmetry and dualism of some functions and types. I&#8217;m not yet &#8230; <a href="http://xosfaere.wordpress.com/2009/10/30/types-arrows-duals/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&amp;blog=1884763&amp;post=592&amp;subd=xosfaere&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As part of my continued pursuit of the Lambda Lecture Series (my name for it) on Channel 9, I&#8217;ve summoned up a brain-storm worth of examples that show the symmetry and dualism of some functions and types. I&#8217;m not yet familiar with the higher-level abstract concepts of Arrows so arrow here simply means function.</p>
<p><a href="http://xosfaere.files.wordpress.com/2009/10/morf-s.png"><img class="aligncenter size-full wp-image-905" title="morf-s" src="http://xosfaere.files.wordpress.com/2009/10/morf-s.png?w=640&#038;h=382" alt="" width="640" height="382" /></a></p>
<p><strong>References<br />
</strong> &#8211; <a href="http://cid-e189d6f0d12fdc06.skydrive.live.com/browse.aspx/Public/Types%20Arrows%20Duals?uc=5">Types &#8211; Arrows &#8211; Duals</a> [SkyDrive]</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xosfaere.wordpress.com/592/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xosfaere.wordpress.com/592/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xosfaere.wordpress.com/592/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xosfaere.wordpress.com/592/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xosfaere.wordpress.com/592/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xosfaere.wordpress.com/592/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xosfaere.wordpress.com/592/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xosfaere.wordpress.com/592/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xosfaere.wordpress.com/592/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xosfaere.wordpress.com/592/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xosfaere.wordpress.com/592/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xosfaere.wordpress.com/592/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xosfaere.wordpress.com/592/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xosfaere.wordpress.com/592/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&amp;blog=1884763&amp;post=592&amp;subd=xosfaere&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xosfaere.wordpress.com/2009/10/30/types-arrows-duals/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f816a0c0bd66d40be3b47d586c76a1ea?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Bent</media:title>
		</media:content>

		<media:content url="http://xosfaere.files.wordpress.com/2009/10/morf-s.png" medium="image">
			<media:title type="html">morf-s</media:title>
		</media:content>
	</item>
		<item>
		<title>Adversus Nullus, Unnullable&lt;T&gt;</title>
		<link>http://xosfaere.wordpress.com/2009/10/27/adversus-nullus/</link>
		<comments>http://xosfaere.wordpress.com/2009/10/27/adversus-nullus/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 19:58:21 +0000</pubDate>
		<dc:creator>xosfaere</dc:creator>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Declarative]]></category>
		<category><![CDATA[Imperative]]></category>
		<category><![CDATA[Paradigm]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Class]]></category>
		<category><![CDATA[Exception]]></category>
		<category><![CDATA[Generic]]></category>
		<category><![CDATA[LinkedIN]]></category>
		<category><![CDATA[Non-Null]]></category>
		<category><![CDATA[Null]]></category>
		<category><![CDATA[Nullable]]></category>
		<category><![CDATA[Nullpointer]]></category>
		<category><![CDATA[Safety]]></category>
		<category><![CDATA[Struct]]></category>
		<category><![CDATA[Unnullable]]></category>
		<category><![CDATA[Void-safety]]></category>

		<guid isPermaLink="false">http://xosfaere.wordpress.com/?p=571</guid>
		<description><![CDATA[Let&#8217;s fix C.A.R. Hoare&#8216;s billion dollar mistake for C#: Null-pointer dereferences. &#8211; Isn&#8217;t hindsight great? By default, C# reference types are nullable, meaning one can assign a null value to a variable of a reference type. These null values can &#8230; <a href="http://xosfaere.wordpress.com/2009/10/27/adversus-nullus/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&amp;blog=1884763&amp;post=571&amp;subd=xosfaere&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s fix <a href="http://en.wikipedia.org/wiki/C._A._R._Hoare">C.A.R. Hoare</a>&#8216;s <a href="http://www.infoq.com/presentations/Null-References-The-Billion-Dollar-Mistake-Tony-Hoare">billion dollar mistake</a> for C#: Null-pointer dereferences. &#8211; Isn&#8217;t hindsight great?</p>
<p>By default, C# reference types are nullable, meaning one can assign a null value to a variable of a reference type. These null values can propagate away from the point of origin and spread terror and havoc. There is a good and sound principle in software engineering that says: <em>fail early, fail often</em>. This means that a program should detect or exhibit a software defect right where it occurs (which is as soon as it occurs; well possibly sooner using static analysis and symbolic execution) and it should exibit a predictable behavior towards it, failing each time, reflexively. A program that just carries on can end up making much more damage along the way and can be harder to debug.</p>
<p>Then of course we might choose to interpret what we mean by &#8220;fail&#8221;. It might be a brutal failure or a recovered failure. The base philosophy has to be that the defect is at least signalled at its origin, handled or not.</p>
<p>One approach to dealing with this issue is using contracts. One can annotate function and method definitions with pre- and post-conditions expressing that the input and output of a piece of code will not and must not accept or deliver a null value. If spread everywhere, this will help catch the error where it occurs. It&#8217;s like a finely masked web spread out over the code, which will not allow a null value much freedom to move around before it is caught: thus enforcing the fail fast principle.</p>
<p>In Microsoft .Net, traditionally, there has not been support for contract programming or what is known as Design by Contract from Eiffel. People can write their own assert functions and sprinkle them all over the place which may help but it is not a very good contract solution. Things improve in .Net 4.0 with language-agnostic contract support.</p>
<p>A different approach is to have types help out.</p>
<p>In software engineering we face the same problem over and over again: in an imperative world it used to be fine to have object be mutable by default. In the new manycore world this approach is untennable. Similarly, in the past, it used to be (somewhat) ok to have reference types include null in the domain. It just turns out that in practice this was a really bad mistake. Null-pointer exceptions én masse. In the first case a paradigm shift forces us to change strategy, at least gradually. In the second, a painful history of bugs teaches us better ways.</p>
<p>As an aside, recently Dr. Erik Meijer and team have dualized the <em>IEnumerable/IEnumerator</em> types, creating the quite beautiful <em>IObservable/IObserver</em> types. In other words, the two type sets form eachothers duals. That is not to say that the former is no longer needed but it&#8217;s one more example of dualization. Mutable vs Immutable another (well an opposite at least).</p>
<p>New since, what, .Net 2.0 is Nullable&lt;T&gt;. This type allows us to define primitive (struct) types as nullable by wrapping them in another type that signal whether the wrapped value is actually null. It will not work for classes since they are already nullable and the Nullable type is defined to only work for T where T is a struct type.</p>
<p>The obvious thought here is: OK, we had integers that we needed to be nullable. Now we have objects that we need not to be nullable. Let&#8217;s &#8220;dualize&#8221; this. And so I made a simple struct to demonstrate the idea. This would benefit from language support but can really help out on its own. The Nullable&lt;T&gt; type has syntactic support in C# via the T? notation.</p>
<p>The definition is as follows.</p>
<pre class="brush: csharp;">
public struct Unnullable&lt;T&gt; where T : class
{
    public Unnullable(T x)
    {
        if (x == null)
            throw new NullReferenceException();
        item = x;
    }

    public T Item
    {
        get
        {
            return item;
        }
    }

    private readonly T item;
}
</pre>
<p>I made it up an early morning, after waking up far far too early and it has to be tested out thouroughly. But just quickly trying some obvious null assignments fails. Even not assigning a value to a newly declared Unnullable&lt;T&gt; variable will fail at compile-time; well, even before, as Intellisense and background compilation will warn you before you run a regular compile. At least if you use Visual Studio.</p>
<p>It&#8217;s impossible to construct an Unnullable that contains a null. So it really is <em>un-nullable</em>. At least if not resorting to evil means such as reflection. If this type is used, whereever it is used it will provide null-safety, i.e. non-nullness.</p>
<p>In a not too distant future we may see this built into C# and VB, maybe even on the class level where we can say that a class is unnullable by design. This may create other problems that we&#8217;ll defer indefinitely &#8211; for now.</p>
<p>2011-02-11 note: we could also combine Code Contracts with this design this way:</p>
<pre class="brush: csharp;">
public struct Unnullable&lt;T&gt; where T : class
{
    public Unnullable(T x)
    {
        Contract.Requires(x != null);
        item = x;
    }

    public T Item
    {
        get
        {
            return item;
        }
    }

    private readonly T item;
}
</pre>
<p><strong>References</strong></p>
<p>- <a href="http://channel9.msdn.com/forums/TechOff/499699-Suggestions-for-C-50/#Page=2">A Channel 9 thread on ideas for C# 5.0</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xosfaere.wordpress.com/571/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xosfaere.wordpress.com/571/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xosfaere.wordpress.com/571/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xosfaere.wordpress.com/571/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xosfaere.wordpress.com/571/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xosfaere.wordpress.com/571/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xosfaere.wordpress.com/571/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xosfaere.wordpress.com/571/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xosfaere.wordpress.com/571/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xosfaere.wordpress.com/571/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xosfaere.wordpress.com/571/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xosfaere.wordpress.com/571/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xosfaere.wordpress.com/571/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xosfaere.wordpress.com/571/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&amp;blog=1884763&amp;post=571&amp;subd=xosfaere&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xosfaere.wordpress.com/2009/10/27/adversus-nullus/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f816a0c0bd66d40be3b47d586c76a1ea?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Bent</media:title>
		</media:content>
	</item>
		<item>
		<title>Lambda Lecture Series</title>
		<link>http://xosfaere.wordpress.com/2009/10/11/lambda-lecture-series/</link>
		<comments>http://xosfaere.wordpress.com/2009/10/11/lambda-lecture-series/#comments</comments>
		<pubDate>Sun, 11 Oct 2009 21:50:30 +0000</pubDate>
		<dc:creator>xosfaere</dc:creator>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Declarative]]></category>
		<category><![CDATA[Paradigm]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[$]]></category>
		<category><![CDATA[.]]></category>
		<category><![CDATA[Application]]></category>
		<category><![CDATA[Channel 9]]></category>
		<category><![CDATA[Charles Torre]]></category>
		<category><![CDATA[Composition]]></category>
		<category><![CDATA[Dr. Erik Meijer]]></category>
		<category><![CDATA[Education]]></category>
		<category><![CDATA[Expression]]></category>
		<category><![CDATA[Fun]]></category>
		<category><![CDATA[Function]]></category>
		<category><![CDATA[functional programming]]></category>
		<category><![CDATA[Infix]]></category>
		<category><![CDATA[λ]]></category>
		<category><![CDATA[Lambda]]></category>
		<category><![CDATA[Language]]></category>
		<category><![CDATA[Lecture]]></category>
		<category><![CDATA[LinkedIN]]></category>
		<category><![CDATA[Material]]></category>
		<category><![CDATA[Operator]]></category>
		<category><![CDATA[Prefix]]></category>
		<category><![CDATA[Series]]></category>
		<category><![CDATA[\]]></category>

		<guid isPermaLink="false">http://xosfaere.wordpress.com/?p=555</guid>
		<description><![CDATA[There is a new lecture series on Channel 9 by Dr. Erik Meijer. It is about functional programming and is using Haskell as the the means of expression although the exact language is not so important; but Haskell is appropriate &#8230; <a href="http://xosfaere.wordpress.com/2009/10/11/lambda-lecture-series/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&amp;blog=1884763&amp;post=555&amp;subd=xosfaere&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>There is a new lecture series on Channel 9 by Dr. Erik Meijer. It is about functional programming and is using Haskell as the the means of expression although the exact language is not so important; but Haskell is appropriate in that it is pure, lazy and has a discrete syntax.</p>
<p>There was a couple of questions about the execution of the programs in the beginning of the series and so for weekend fun I prepared a small document that shows two different (actually not so different) REPL&#8217;s. These may be used to execute Haskell expressions directly.</p>
<p>References</p>
<ul>
<li><a href="http://channel9.msdn.com/shows/Going+Deep/Lecture-Series-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-1/">Lecture Series</a> [channel 9]</li>
<li><a href="http://cid-e189d6f0d12fdc06.skydrive.live.com/browse.aspx/Public/Lambda%20Lecture%20Series">Lecture Reference</a> [SkyDrive]</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xosfaere.wordpress.com/555/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xosfaere.wordpress.com/555/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xosfaere.wordpress.com/555/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xosfaere.wordpress.com/555/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xosfaere.wordpress.com/555/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xosfaere.wordpress.com/555/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xosfaere.wordpress.com/555/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xosfaere.wordpress.com/555/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xosfaere.wordpress.com/555/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xosfaere.wordpress.com/555/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xosfaere.wordpress.com/555/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xosfaere.wordpress.com/555/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xosfaere.wordpress.com/555/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xosfaere.wordpress.com/555/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xosfaere.wordpress.com&amp;blog=1884763&amp;post=555&amp;subd=xosfaere&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xosfaere.wordpress.com/2009/10/11/lambda-lecture-series/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f816a0c0bd66d40be3b47d586c76a1ea?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Bent</media:title>
		</media:content>
	</item>
	</channel>
</rss>
