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

<channel>
	<title>Elegant Code &#187; Jan Van Ryswyck</title>
	<atom:link href="http://elegantcode.com/author/jryswyck/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com</link>
	<description></description>
	<lastBuildDate>Tue, 09 Mar 2010 01:56:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Behaviors with MSpec</title>
		<link>http://elegantcode.com/2010/02/26/behaviors-with-mspec/</link>
		<comments>http://elegantcode.com/2010/02/26/behaviors-with-mspec/#comments</comments>
		<pubDate>Fri, 26 Feb 2010 23:33:28 +0000</pubDate>
		<dc:creator>Jan Van Ryswyck</dc:creator>
				<category><![CDATA[BDD]]></category>
		<category><![CDATA[Unit Testing]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/02/26/behaviors-with-mspec/</guid>
		<description><![CDATA[In my previous posts, I showed the syntax for context/specifications using Machine.Specifications (or MSpec for short) and how to use an auto mocking container in conjunction with this excellent Behavior-Driven Development (BDD) framework. For this post, I want to show you one of the nice features of MSpec called behaviors.
Suppose we have to create some [...]]]></description>
			<content:encoded><![CDATA[<p>In my previous posts, I showed the <a href="http://elegantcode.com/2010/02/19/getting-started-with-machine-specifications-mspec/">syntax for context/specifications</a> using <a href="http://github.com/machine/machine.specifications">Machine.Specifications</a> (or MSpec for short) and <a href="http://elegantcode.com/2010/02/23/mspec-and-auto-mocking">how to use an auto mocking container</a> in conjunction with this excellent Behavior-Driven Development (BDD) framework. For this post, I want to show you one of the nice features of MSpec called <em>behaviors</em>.</p>
<p>Suppose we have to create some sort of specification that validates the format of an e-mail address. We typically use some regular expression in order to ensure that a specified e-mail address is properly formatted.</p>
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> EmailSpecification
{
    <span class="kwrd">private</span> <span class="kwrd">const</span> String EmailRegexPattern = <span class="str">@&quot;.. SOME_REGEX_PATTERN ...&quot;</span>;

    <span class="kwrd">public</span> Boolean IsSatisfiedBy(String candidate)
    {
        var regex = <span class="kwrd">new</span> Regex(EmailRegexPattern);
        <span class="kwrd">return</span> regex.IsMatch(candidate);
    }
}</pre>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>&#160;</p>
<p>I guess this is pretty common and straightforward. One way to provide some unit tests for this particular piece of code is to check a whole number of e-mail addresses that either pass or fail the specification. The following example shows only a couple of scenarios:</p>
<pre class="csharpcode">[TestFixture]
<span class="kwrd">public</span> <span class="kwrd">class</span> When_validating_an_email
    : ContextSpecification&lt;EmailSpecification&gt;
{
    <span class="kwrd">protected</span> <span class="kwrd">override</span> EmailSpecification Create_subject_under_test()
    {
        <span class="kwrd">return</span> <span class="kwrd">new</span> EmailSpecification();
    }

    [Test]
    <span class="kwrd">public</span> <span class="kwrd">void</span> ShouldBeSatisfied()
    {
        Assert.That(SUT.IsSatisfiedBy(<span class="str">&quot;one2@three.com&quot;</span>));
        Assert.That(SUT.IsSatisfiedBy(<span class="str">&quot;one@two3.com&quot;</span>));
    }

    [Test]
    <span class="kwrd">public</span> <span class="kwrd">void</span> ShouldNotBeSatisfied()
    {
        Assert.That(SUT.IsSatisfiedBy(<span class="str">&quot;one_two.com&quot;</span>), Is.False);
        Assert.That(SUT.IsSatisfiedBy(<span class="str">&quot;one_two@&quot;</span>), Is.False);
    }
}</pre>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>&#160;</p>
<p>A slightly more concise approach for these kind of unit tests can be accomplished by utilizing a feature of any decent unit test framework called <em>row tests. </em>With this approach we can, at the very least, reduce the number of asserts we have to write for each unit test.<em>&#160;</em></p>
<pre class="csharpcode">[TestFixture]
<span class="kwrd">public</span> <span class="kwrd">class</span> When_validating_an_email__approach_2
    : ContextSpecification&lt;EmailSpecification&gt;
{
    <span class="kwrd">protected</span> <span class="kwrd">override</span> EmailSpecification Create_subject_under_test()
    {
        <span class="kwrd">return</span> <span class="kwrd">new</span> EmailSpecification();
    }

    [RowTest]
    [Row(<span class="str">&quot;one2@three.com&quot;</span>)]
    [Row(<span class="str">&quot;one@two3.com&quot;</span>)]
    <span class="kwrd">public</span> <span class="kwrd">void</span> ShouldBeSatisfied(String email)
    {
        Assert.That(SUT.IsSatisfiedBy(email));
    }

    [RowTest]
    [Row(<span class="str">&quot;one_two.com&quot;</span>)]
    [Row(<span class="str">&quot;one_two@&quot;</span>)]
    <span class="kwrd">public</span> <span class="kwrd">void</span> ShouldNotBeSatisfied(String email)
    {
        Assert.That(SUT.IsSatisfiedBy(email), Is.False);
    }
}</pre>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>&#160;</p>
<p>Notice that I explicitly called both of these approaches <em>unit tests</em> as they don’t have much to do with BDD in my opinion. I’m not saying that using regular unit tests is a bad thing, but with&#160; behavior-driven development context is king. So these unit tests are perfect examples of ‘<a href="http://elegantcode.com/2008/12/30/dont-sell-out-on-the-context-dude/">context betrayal</a>’ when following the BDD approach. </p>
<p>Lets see what MSpec can bring to the table for these kind of scenarios:</p>
<pre class="csharpcode">[Subject(<span class="kwrd">typeof</span>(EmailSpecification), <span class="str">&quot;is satisfied&quot;</span>)]
<span class="kwrd">public</span> <span class="kwrd">class</span> when_validating_an_email_address_with_a_number_in_the_local_part
    : email_specification_specs
{
    Establish context = () =&gt;
        EmailAddress = <span class="str">&quot;one2@three.com&quot;</span>;

    Behaves_like&lt;SatisfiedSpecificationBehavior&gt; a_satisfied_specification;
}

[Subject(<span class="kwrd">typeof</span>(EmailSpecification), <span class="str">&quot;is satisfied&quot;</span>)]
<span class="kwrd">public</span> <span class="kwrd">class</span> when_validating_an_email_address_with_a_number_in_the_domain_name
    : email_specification_specs
{
    Establish context = () =&gt;
        EmailAddress = <span class="str">&quot;one@two3.com&quot;</span>;

    Behaves_like&lt;SatisfiedSpecificationBehavior&gt; a_satisfied_specification;
}

[Subject(<span class="kwrd">typeof</span>(EmailSpecification), <span class="str">&quot;is satisfied&quot;</span>)]
<span class="kwrd">public</span> <span class="kwrd">class</span> when_validating_an_email_address_without_an_At_sign
    : email_specification_specs
{
    Establish context = () =&gt;
        EmailAddress = <span class="str">&quot;one_two.com&quot;</span>;

    Behaves_like&lt;UnsatisfiedSpecificationBehavior&gt; an_unsatisfied_specification;
}

[Subject(<span class="kwrd">typeof</span>(EmailSpecification), <span class="str">&quot;is satisfied&quot;</span>)]
<span class="kwrd">public</span> <span class="kwrd">class</span> when_validating_an_email_address_without_a_domain
    : email_specification_specs
{
    Establish context = () =&gt;
        EmailAddress = <span class="str">&quot;one_two@&quot;</span>;

    Behaves_like&lt;UnsatisfiedSpecificationBehavior&gt; an_unsatisfied_specification;
}</pre>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>&#160;</p>
<p>In order to escape ‘context betrayal’, we’ve split up every context into a separate context/specification. In order to reduce the amount of effort caused by duplicate code, we stripped the context setup to the bare minimum (just a particular e-mail address in this case). The observations are isolated into MSpec behaviors which provides a very readable description of their outcome. Lets take a look at what is needed in order to get these <em>behaviors</em> to work.</p>
<p>But first lets take at look at the abstract base class that we’ve used for the context/specifications we’ve just shown.</p>
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">abstract</span> <span class="kwrd">class</span> email_specification_specs
{
    Establish context = () =&gt;
    {
        SUT = <span class="kwrd">new</span> EmailSpecification();
    };

    Because of = () =&gt;
        Result = SUT.IsSatisfiedBy(EmailAddress);

    <span class="kwrd">protected</span> <span class="kwrd">static</span> Boolean Result;
    <span class="kwrd">protected</span> <span class="kwrd">static</span> String EmailAddress { get; set; }
    <span class="kwrd">protected</span> <span class="kwrd">static</span> EmailSpecification SUT { get; set; }
}</pre>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
</p>
<p>&#160;</p>
<p>We abstracted as much as possible into this base class in order to remove duplication in the context/specifications. The creation of the subject-under-test and the calling of its <em>IsSatisfiedBy</em> method, but the important one is the declaration of the <em>Result</em> field. This field contains the outcome of the <em>IsSatisfiedBy</em> method. Finally, lets have a look at the behaviors themselves:</p>
<pre class="csharpcode">[Behaviors]
<span class="kwrd">public</span> <span class="kwrd">class</span> SatisfiedSpecificationBehavior
{
    <span class="kwrd">protected</span> <span class="kwrd">static</span> Boolean Result;

    It should_satisfy_the_specification = () =&gt;
        Result.ShouldBeTrue();
}

[Behaviors]
<span class="kwrd">public</span> <span class="kwrd">class</span> UnsatisfiedSpecificationBehavior
{
    <span class="kwrd">protected</span> <span class="kwrd">static</span> Boolean Result;

    It should_not_satisfy_the_specification = () =&gt;
        Result.ShouldBeFalse();
}</pre>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>&#160;</p>
<p>In order to create an MSpec behavior, we just have to create a separate class that we decorate with the <em>Behaviors</em> attribute. Also notice that we have the same declaration of the <em>Result</em> field. MSpec ensures that this field gets initialized with the value of the other <em>Result</em> field that is set in the base class of the context/specifications. Note that you don’t necessarily need to put this field in a base class. You can have that field in every context/specification if you’d like (not sure why) as long as the names match with the fields used in the defined behaviors.</p>
<p>I personally like the way how the MSpec contributors tried to solve testing the same logic with different input patterns and the syntax they provided to back this up.&#160;&#160; </p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/02/26/behaviors-with-mspec/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>MSpec and Auto Mocking</title>
		<link>http://elegantcode.com/2010/02/23/mspec-and-auto-mocking/</link>
		<comments>http://elegantcode.com/2010/02/23/mspec-and-auto-mocking/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 20:38:54 +0000</pubDate>
		<dc:creator>Jan Van Ryswyck</dc:creator>
				<category><![CDATA[BDD]]></category>
		<category><![CDATA[Unit Testing]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/02/23/mspec-and-auto-mocking/</guid>
		<description><![CDATA[In my previous post, I explained how to get started with Machine.Specifications (or MSpec for short) and showed you how the syntax for context/specifications looks like when using this BDD framework. For this post, I want to show you how to use an auto mocking container (we’ll be using the one provided by StructureMap off [...]]]></description>
			<content:encoded><![CDATA[<p>In my <a href="http://elegantcode.com/2010/02/19/getting-started-with-machine-specifications-mspec/">previous post</a>, I explained how to get started with <a href="http://github.com/machine/machine.specifications">Machine.Specifications</a> (or MSpec for short) and showed you how the syntax for context/specifications looks like when using this BDD framework. For this post, I want to show you how to use an <a href="http://vanryswyckjan.blogspot.com/2008/01/automocking-container.html">auto mocking container</a> (we’ll be using the one provided by StructureMap off course).</p>
<p>We’ll use the same example as the one used in the previous post, but now we’ll deal with the message handler that makes a particular customer preferred.</p>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<pre class="csharpcode"><span class="rem">//</span>
<span class="rem">// Subject under test</span>
<span class="rem">//</span>
<span class="kwrd">public</span> <span class="kwrd">class</span> MakeCustomerPreferredMessageHandler
{
    <span class="kwrd">private</span> <span class="kwrd">readonly</span> ICustomerRepository&lt;ICanMakeCustomerPreferred&gt; _repository;

    <span class="kwrd">public</span> MakeCustomerPreferredMessageHandler(
        ICustomerRepository&lt;ICanMakeCustomerPreferred&gt; repository)
    {
        _repository = repository;
    }

    <span class="kwrd">public</span> <span class="kwrd">void</span> Handle(MakeCustomerPreferredMessage message)
    {
        var customer = _repository.Get(message.CustomerId);
        <span class="kwrd">if</span>(<span class="kwrd">null</span> == customer)
            <span class="kwrd">throw</span> <span class="kwrd">new</span> InvalidOperationException(
                <span class="str">&quot;No customer for specified identifier&quot;</span>);

        customer.MakePreferred();
        _repository.Save(customer);
    }
}</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>&#160;</p>
<p>The <em>Customer</em> class implements a ‘<a href="http://martinfowler.com/bliki/RoleInterface.html">role interface’</a> called <em>ICanMakeCustomerPreferred</em>. We retrieve a customer from the repository and make it preferred. We throw an exception in case the customer cannot be found in the data store.</p>
<p>Here are the context/specifications for this easy example:</p>
<pre class="csharpcode">[Subject(<span class="str">&quot;Making a customer preferred&quot;</span>)]
<span class="kwrd">public</span> <span class="kwrd">class</span> when_making_a_customer_preferred
    : context_specification&lt;MakeCustomerPreferredMessageHandler&gt;
{
    Establish context = () =&gt;
    {
        _message = <span class="kwrd">new</span> MakeCustomerPreferredMessage { CustomerId = 6412 };

        Repository.Stub(repository =&gt; repository.Get(_message.CustomerId))
            .Return(Customer);
    };

    Because of = () =&gt;
        SUT.Handle(_message);

    It should_mark_the_customer_as_preferred = () =&gt;
        Customer.AssertWasCalled(customer =&gt; customer.MakePreferred());

    It should_save_the_customer_in_the_repository = () =&gt;
        Repository.AssertWasCalled(repository =&gt; repository.Save(Customer));

    <span class="kwrd">private</span> <span class="kwrd">static</span> ICanMakeCustomerPreferred Customer
    {
        get { <span class="kwrd">return</span> Dependency&lt;ICanMakeCustomerPreferred&gt;(); }
    }

    <span class="kwrd">private</span> <span class="kwrd">static</span> ICustomerRepository&lt;ICanMakeCustomerPreferred&gt; Repository
    {
        get { <span class="kwrd">return</span> Dependency&lt;ICustomerRepository&lt;ICanMakeCustomerPreferred&gt;&gt;(); }
    }

    <span class="kwrd">private</span> <span class="kwrd">static</span> MakeCustomerPreferredMessage _message;
}

[Subject(<span class="str">&quot;Making a customer preferred&quot;</span>)]
<span class="kwrd">public</span> <span class="kwrd">class</span> when_making_an_unexisting_customer_preferred
    : context_specification&lt;MakeCustomerPreferredMessageHandler&gt;
{
    Establish context = () =&gt;
    {
        _message = <span class="kwrd">new</span> MakeCustomerPreferredMessage() { CustomerId = 61544 };

        Dependency&lt;ICustomerRepository&lt;ICanMakeCustomerPreferred&gt;&gt;()
            .Stub(repository =&gt; repository.Get(_message.CustomerId))
            .Return(<span class="kwrd">null</span>);
    };

    Because of = () =&gt;
        _resultingException = Catch.Exception(() =&gt; SUT.Handle(_message));

    It should_result_in_an_error = () =&gt;
        _resultingException.ShouldBeOfType&lt;InvalidOperationException&gt;();

    <span class="kwrd">private</span> <span class="kwrd">static</span> MakeCustomerPreferredMessage _message;
    <span class="kwrd">private</span> <span class="kwrd">static</span> Exception _resultingException;
}</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>&#160;</p>
<p>I want to point out that all fields and properties are made static. This is needed so that the anonymous methods can access them. I’m also using a base class for these specifications which I’ll show next. This base class uses an auto mocking container for providing the requested mocks and stubs through the <em>Dependency</em> and <em>Stub</em> methods. </p>
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">abstract</span> <span class="kwrd">class</span> context_specification&lt;TSubjectUnderTest&gt;
    <span class="kwrd">where</span> TSubjectUnderTest : <span class="kwrd">class</span>
{
    <span class="kwrd">private</span> <span class="kwrd">static</span> IAutoMockingContainer&lt;TSubjectUnderTest&gt; _autoMockingContainer;
    <span class="kwrd">protected</span> <span class="kwrd">static</span> TSubjectUnderTest SUT { get; set; }

    Establish context = () =&gt;
    {
        _autoMockingContainer = <span class="kwrd">new</span> StructureMapAMC&lt;TSubjectUnderTest&gt;();
        SUT = _autoMockingContainer.Create();
    };

    Cleanup stuff = () =&gt;
    {
        SUT = <span class="kwrd">null</span>;
        _autoMockingContainer = <span class="kwrd">null</span>;
    };

    <span class="kwrd">protected</span> <span class="kwrd">static</span> TDependency Dependency&lt;TDependency&gt;()
        <span class="kwrd">where</span> TDependency : <span class="kwrd">class</span>
    {
        <span class="kwrd">return</span> _autoMockingContainer.GetMock&lt;TDependency&gt;();
    }

    <span class="kwrd">protected</span> <span class="kwrd">static</span> TStub Stub&lt;TStub&gt;()
        <span class="kwrd">where</span> TStub : <span class="kwrd">class</span>
    {
        <span class="kwrd">return</span> _autoMockingContainer.GetStub&lt;TStub&gt;();
    }
}

<span class="kwrd">public</span> <span class="kwrd">interface</span> IAutoMockingContainer&lt;TSubject&gt;
    <span class="kwrd">where</span> TSubject : <span class="kwrd">class</span>
{
    TSubject Create();
    TMock GetMock&lt;TMock&gt;() <span class="kwrd">where</span> TMock : <span class="kwrd">class</span>;
    TStub GetStub&lt;TStub&gt;() <span class="kwrd">where</span> TStub : <span class="kwrd">class</span>;
}

<span class="kwrd">public</span> <span class="kwrd">class</span> StructureMapAMC&lt;TSubject&gt;
    : IAutoMockingContainer&lt;TSubject&gt;
    <span class="kwrd">where</span> TSubject : <span class="kwrd">class</span>
{
    <span class="kwrd">private</span> <span class="kwrd">readonly</span> RhinoAutoMocker&lt;TSubject&gt; _rhinoAutoMocker;

    <span class="kwrd">public</span> StructureMapAMC()
    {
        _rhinoAutoMocker =
            <span class="kwrd">new</span> RhinoAutoMocker&lt;TSubject&gt;(MockMode.AAA);
    }

    <span class="kwrd">public</span> TSubject Create()
    {
        <span class="kwrd">return</span> _rhinoAutoMocker.ClassUnderTest;
    }

    <span class="kwrd">public</span> TMock GetMock&lt;TMock&gt;()
        <span class="kwrd">where</span> TMock : <span class="kwrd">class</span>
    {
        <span class="kwrd">return</span> GetDependency&lt;TMock&gt;();
    }

    <span class="kwrd">public</span> TStub GetStub&lt;TStub&gt;()
        <span class="kwrd">where</span> TStub : <span class="kwrd">class</span>
    {
        <span class="kwrd">return</span> GetDependency&lt;TStub&gt;();
    }

    <span class="kwrd">private</span> TDependency GetDependency&lt;TDependency&gt;()
        <span class="kwrd">where</span> TDependency : <span class="kwrd">class</span>
    {
        <span class="kwrd">return</span> _rhinoAutoMocker.Get&lt;TDependency&gt;();
    }
}</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>&#160;</p>
<p>Notice that I’m using the <em>Establish</em> and <em>Cleanup</em> delegates in the <em>context_specification</em> base class. This doesn’t prevent that these can be used again in derived context/specifications. MSpec ensures that the anonymous methods are called in the right order. This means that the <em>Establish</em> method of the base class is called before the <em>Establish</em> method of the derived context/specifications.&#160;&#160;&#160;&#160; </p>
<p>Absolutely no rocket science here, but I figured it might come in handy when you need it. For the next post I’ll try to demonstrate how to deal with reusable behaviors.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/02/23/mspec-and-auto-mocking/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Getting Started With Machine.Specifications (MSpec)</title>
		<link>http://elegantcode.com/2010/02/19/getting-started-with-machine-specifications-mspec/</link>
		<comments>http://elegantcode.com/2010/02/19/getting-started-with-machine-specifications-mspec/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 21:34:17 +0000</pubDate>
		<dc:creator>Jan Van Ryswyck</dc:creator>
				<category><![CDATA[BDD]]></category>
		<category><![CDATA[Unit Testing]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/02/19/getting-started-with-machine-specifications-mspec/</guid>
		<description><![CDATA[Its been a while since I evaluated and evolved my approach to BDD. The way I’ve been doing BDD up until now is described in this blog post which goes way back to 2008. Everyone has kind of their own style nowadays. Below you can find the code of two context/specifications for a method named [...]]]></description>
			<content:encoded><![CDATA[<p>Its been a while since I evaluated and evolved my approach to BDD. The way I’ve been doing BDD up until now is described in <a href="http://elegantcode.com/2008/10/25/refining-contextspecification-bdd-using-rhino-mocks-35/">this blog post</a> which goes way back to 2008. Everyone has kind of their own style nowadays. Below you can find the code of two context/specifications for a method named <em>MakePreferred</em> on a <em>Customer </em>class. This simple example clarifies the style that I’ve been following up until now.</p>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<pre class="csharpcode">[TestFixture]
<span class="kwrd">public</span> <span class="kwrd">class</span> When_making_a_regular_customer_preferred
    : ContextSpecification&lt;Customer&gt;
{
    <span class="kwrd">protected</span> <span class="kwrd">override</span> Customer Create_subject_under_test()
    {
        <span class="kwrd">return</span> <span class="kwrd">new</span> Customer(<span class="kwrd">new</span>[] { _order });
    }

    <span class="kwrd">protected</span> <span class="kwrd">override</span> <span class="kwrd">void</span> Establish_context()
    {
        _order = <span class="kwrd">new</span> Order(<span class="kwrd">new</span>[] { <span class="kwrd">new</span> OrderItem(12),
                                   <span class="kwrd">new</span> OrderItem(16) });

        _totalAmountWithoutDiscount = _order.TotalAmount;
    }

    <span class="kwrd">protected</span> <span class="kwrd">override</span> <span class="kwrd">void</span> Because()
    {
        SUT.MakePreferred();
    }

    [Test]
    <span class="kwrd">public</span> <span class="kwrd">void</span> Then_the_customer_should_be_marked_as_preferred()
    {
        SUT.IsPreferred.ShouldBeTrue();
    }

    [Test]
    <span class="kwrd">public</span> <span class="kwrd">void</span> Then_a_ten_percent_discount_should_be_applied_to_all_outstanding_orders()
    {
        _order.TotalAmount.ShouldBeEqualTo(
            _totalAmountWithoutDiscount * 0.9);
    }

    <span class="kwrd">private</span> Order _order;
    <span class="kwrd">private</span> Double _totalAmountWithoutDiscount;
}

[TestFixture]
<span class="kwrd">public</span> <span class="kwrd">class</span> When_making_a_preferred_customer_preferred
    : ContextSpecification&lt;Customer&gt;
{
    <span class="kwrd">protected</span> <span class="kwrd">override</span> Customer Create_subject_under_test()
    {
        var customer = <span class="kwrd">new</span> Customer(<span class="kwrd">new</span>[] { _order });
        customer.MakePreferred();
        <span class="kwrd">return</span> customer;
    }

    <span class="kwrd">protected</span> <span class="kwrd">override</span> <span class="kwrd">void</span> Establish_context()
    {
        _order = <span class="kwrd">new</span> Order(<span class="kwrd">new</span>[] { <span class="kwrd">new</span> OrderItem(12),
                                   <span class="kwrd">new</span> OrderItem(16) });
        _totalAmountWithoutDiscount = _order.TotalAmount;
    }

    <span class="kwrd">protected</span> <span class="kwrd">override</span> <span class="kwrd">void</span> Because()
    {
        SUT.MakePreferred();
    }

    [Test]
    <span class="kwrd">public</span> <span class="kwrd">void</span> Then_no_additional_discount_should_be_applied_to_the_outstanding_orders()
    {
        _order.TotalAmount.ShouldNotBeEqualTo(
            _totalAmountWithoutDiscount * 0.81);
    }

    <span class="kwrd">private</span> Order _order;
    <span class="kwrd">private</span> Double _totalAmountWithoutDiscount;
}

<span class="rem">//</span>
<span class="rem">// Subject under test</span>
<span class="rem">//</span>
<span class="kwrd">public</span> <span class="kwrd">class</span> Customer
{
    <span class="kwrd">private</span> <span class="kwrd">readonly</span> List&lt;Order&gt; _orders;
    <span class="kwrd">public</span> Boolean IsPreferred { get; <span class="kwrd">private</span> set; }

    <span class="kwrd">public</span> Customer(IEnumerable&lt;Order&gt; orders)
    {
        _orders = <span class="kwrd">new</span> List&lt;Order&gt;(orders);
    }

    <span class="kwrd">public</span> <span class="kwrd">void</span> MakePreferred()
    {
        <span class="kwrd">if</span>(IsPreferred)
            <span class="kwrd">return</span>;

        IsPreferred = <span class="kwrd">true</span>;
        _orders.ForEach(order =&gt; order.ApplyDiscount(10));
    }
}</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>&#160;</p>
<p>The bottom line of this example is that preferred customers get a 10 percent discount. Customers that are already preferred do not get an additional discount or otherwise we’re out of business <img src='http://elegantcode.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> . </p>
<p>I’ve been pretty happy with this approach so far, although sometimes there were some quirks associated with this. So it was time for me to look beyond the horizon again, trying to look for ways to improve. </p>
<p><a href="http://github.com/machine/machine.specifications">Machine.Specifications</a> or MSpec for short is something that has been on my ‘cool-things-to-learn-list’ for quite some time now. As you will see later in this post, the syntax is a bit different as one would come to expect from a context/specification framework that targets the C# programming language. Its seems to be heavily inspired by Scott Bellware’s <a href="http://code.google.com/p/specunit-net/">SpecUnit framework</a> and <a href="http://rspec.info/">RSpec</a>.</p>
<p>Lets see how to set things up first. </p>
<p>The most obvious starting point is downloading the bits and bytes. You can grab the <a href="http://github.com/machine/machine.specifications">source code</a> from GitHub and build it or you can wuss out like I did and get the latest build from the <a href="http://teamcity.codebetter.com/login.html">TeamCity.CodeBetter.com</a> builder server (you can log on as a guest and search the artifacts for a latest build).&#160; </p>
<p>When you’re heavily addicted to <a href="http://www.testdriven.net/">TestDriven.NET</a> like I am, then its possible to keep using this wonderful Visual Studio add-in for running MSpec context/specifications. Just create a directory named <em>Machine.Specifications</em> in {$Program_Files}\TestDriven.NET 2.0 and copy the following files:</p>
<ul>
<li>Machine.Specifications.dll</li>
<li>Machine.Specifications.TDNetRunner.dll</li>
<li>InstallTDNetRunner.bat</li>
</ul>
<ul>Run the InstallTDNetRunner.bat file and you’re able to run all MSpec context/specifications using TestDriven.NET.</ul>
<p>I also strongly encourage you to install the plugin for the Resharper test runner (if only to prevent some Resharper warnings later on). First step is to add a directory named <em>Plugins</em> to the <em>Bin</em> directory of Resharper ({$Program_Files}\JetBrains\ReSharper\v4.5\Bin\). Then create a directory named <em>Machine.Specifications</em> in the <em>Plugins</em> directory you just created and copy the following files:</p>
<ul>
<li>Machine.Specifications.dll</li>
<li>Machine.Specifications.ReSharperRunner.4.5.dll</li>
<li>InstallResharperRunner.4.5.bat</li>
</ul>
<p>Run the InstallResharperRunner.4.5.bat file and you’re also able to run MSpec context/specifications using the Resharper test runner.</p>
<p>I’m not going to put this off any longer. Lets look at the code of the context/specifications shown earlier but completely revamped using the MSpec syntax:</p>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<pre class="csharpcode">[Subject(<span class="str">&quot;Making a customer preferred&quot;</span>)]
<span class="kwrd">public</span> <span class="kwrd">class</span> when_a_regular_customer_is_made_preferred
{
    Establish context = () =&gt;
    {
        _order = <span class="kwrd">new</span> Order(<span class="kwrd">new</span>[] { <span class="kwrd">new</span> OrderItem(12),
                                   <span class="kwrd">new</span> OrderItem(16) });
        _totalAmountWithoutDiscount = _order.TotalAmount;

        SUT = <span class="kwrd">new</span> Customer(<span class="kwrd">new</span>[] { _order });
    };

    Because of = () =&gt;
        SUT.MakePreferred();

    It should_mark_the_customer_as_preferred = () =&gt;
        SUT.IsPreferred.ShouldBeTrue();

    It should_apply_a_ten_percent_discount_to_all_outstanding_orders = () =&gt;
        _order.TotalAmount.ShouldEqual(_totalAmountWithoutDiscount * 0.9);      

    <span class="kwrd">private</span> <span class="kwrd">static</span> Customer SUT;

    <span class="kwrd">private</span> <span class="kwrd">static</span> Order _order;
    <span class="kwrd">private</span> <span class="kwrd">static</span> Double _totalAmountWithoutDiscount;
}

[Subject(<span class="str">&quot;Making a customer preferred&quot;</span>)]
<span class="kwrd">public</span> <span class="kwrd">class</span> when_a_preferred_customer_is_made_preferred
{
    Establish context = () =&gt;
    {
        _order = <span class="kwrd">new</span> Order(<span class="kwrd">new</span>[] { <span class="kwrd">new</span> OrderItem(12),
                                   <span class="kwrd">new</span> OrderItem(16) });
        _totalAmountWithoutDiscount = _order.TotalAmount;

        SUT = <span class="kwrd">new</span> Customer(<span class="kwrd">new</span>[] { _order });
        SUT.MakePreferred();
    };

    Because of = () =&gt;
        SUT.MakePreferred();

    It should_apply_no_additional_discount_to_the_outstanding_orders = () =&gt;
        _order.TotalAmount.ShouldNotEqual(_totalAmountWithoutDiscount * 0.81);

    <span class="kwrd">private</span> <span class="kwrd">static</span> Customer SUT;

    <span class="kwrd">private</span> <span class="kwrd">static</span> Order _order;
    <span class="kwrd">private</span> <span class="kwrd">static</span> Double _totalAmountWithoutDiscount;
}</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>&#160;</p>
<p>I warned you about the syntax, didn’t I <img src='http://elegantcode.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> . It only took me a couple of seconds to get used to this syntax but now I’m completely hooked. Instead of using methods and attributes, MSpec utilizes delegates and anonymous methods. But there’s more. </p>
<p>When using <a href="http://www.nunit.com/index.php">NUnit</a> for writing context/ specifications, the <em>Establish_context</em> and <em>Because</em> methods of the example shown earlier is executed before every observation (test). With MSpec, the <em>Establish</em> and <em>Because</em> anonymous methods are executed only once for every context no matter how many observations a particular context class contains. Big difference? Well, at first glance not but on second hand it does make <a href="http://elegantcode.com/2008/12/30/dont-sell-out-on-the-context-dude/">selling out on the context</a> a bit more difficult as it will probably blow up in your face sooner than later. You can force MSpec to execute the <em>Establish</em> and <em>Because</em> anonymous methods before every observation by applying the <em>SetupForEachSpecification</em> attribute to the context class, but I strongly encourage you to stay away from that unless absolutely needed.</p>
<p>Also notice that the fields in the contexts are now all static. This is needed so that the anonymous methods can access those.&#160;&#160;&#160;&#160;&#160; </p>
<p>Running these context/specifications using TestDriven.NET yields the following output in the output window of Visual Studio:</p>
<blockquote>
<p><font face="Arial">Making a customer preferred, when a regular customer is made preferred<br />
      <br />» should mark the customer as preferred</p>
<p>» should apply a ten percent discount to all outstanding orders</font></p>
<p><font face="Arial">Making a customer preferred, when a preferred customer is made preferred<br />
      <br />» should apply no additional discount to the outstanding orders</font></p>
</blockquote>
<p>What’s not to like? Well, the only downside so far is that Resharper was giving me some warnings about classes and fields not being used etc. … . Many of those warnings disappeared by registering the MSpec plugin for the Resharper test runner as I explained earlier.</p>
<p>So far, so good. I’ve got two more posts coming up on MSpec, so stay tuned.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/02/19/getting-started-with-machine-specifications-mspec/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Is NoSQL Finally Going Mainstream?</title>
		<link>http://elegantcode.com/2010/02/12/is-nosql-finally-going-mainstream/</link>
		<comments>http://elegantcode.com/2010/02/12/is-nosql-finally-going-mainstream/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 23:00:31 +0000</pubDate>
		<dc:creator>Jan Van Ryswyck</dc:creator>
				<category><![CDATA[CQRS]]></category>
		<category><![CDATA[CouchDB]]></category>
		<category><![CDATA[NoSQL]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/02/12/is-nosql-finally-going-mainstream/</guid>
		<description><![CDATA[Its been a while since I enjoyed my adventures with CouchDB. I sure wish I could have some extra time to pick this up again, but getting some sleep at night is nice too once in a while. I noticed that OO databases and document/key-value stores are getting more and more traction lately and I [...]]]></description>
			<content:encoded><![CDATA[<p>Its been a while since I enjoyed <a href="http://elegantcode.com/category/couchdb/">my adventures with CouchDB</a>. I sure wish I could have some extra time to pick this up again, but getting some sleep at night is nice too once in a while. I noticed that OO databases and document/key-value stores are getting more and more traction lately and I must say that its about time.</p>
<p><a href="http://blog.wekeroad.com">Rob Conery</a> hits the nail right on the head in his post on <a href="http://blog.wekeroad.com/2010/02/05/reporting-in-nosql">Reporting in NoSQL</a>.</p>
<blockquote><p><em>Put as gently as I can – </em><a href="http://blogs.computerworld.com/15510/the_end_of_sql_and_relational_databases_part_1_of_3"><em>relational systems are an answer to a problem that we faced 30 years ago</em></a><em>. What you’re doing now is nothing other than compensating for a lack of imagination from the platform developers. Think about it – we code using Object Oriented approaches, we store those objects in a relational system.</em></p>
</blockquote>
<p>What we should all learn in this industry is to <strong>stop assuming that a relational database is the default option</strong> for storing the data of every solution we build. This is what we have been doing for a long time and its pure madness, plain and simple.</p>
<blockquote><p><em>RDBMS don’t fit for holding your application’s data, and they don’t fit for reporting. They’re a solution for a problem that doesn’t exist anymore. Time to kick them to the curb.</em></p>
</blockquote>
<p>The most typical setup you see is a single relational database that is used for both storing the data of an application as well as reporting from this data. The relational schema usually sits between normalized and denormalized tables, which means having a compromise for both needs. You can get away with this for small to medium-sized applications, but when you start working on mission-critical solutions with higher volumes, this compromise isn’t going to cut it anymore. This is why <a href="http://codebetter.com/blogs/gregyoung/">Greg Young</a>, <a href="http://www.udidahan.com/">Udi Dahan</a> and <a href="http://elegantcode.com/about/mark-nijhof/">Mark Nijhof</a> amongst others are advocating command query separation. For these kind of solutions, you want to have the best option for handling commands, which could be an OO database or a document/key-value store (with or without <a href="http://elegantcode.com/2010/02/05/cqrs-event-sourcing/">event-sourcing</a>) and for reporting you’d want the best option available as well like an OLAP system. What I’m describing here is just the elevator pitch, so if you want to learn more about this then do checkout the resources that these gentlemen mentioned above have already put on their blogs.</p>
<p>I hope that one day we realize that a relational database was just a means for optimizing file storage, which is hardly a need anymore these days. We shouldn’t be struggling with how to solve the impedance mismatch between relational databases and OO programming in any kind of application. The one thing we should care about is how to provide solid and clean solutions to our businesses without having to worry about tables and those zealots with their holy database schemas. Just store the objects you want and worry about other things like the so-called ‘<a href="http://www.codesqueeze.com/the-7-software-ilities-you-need-to-know/">ilities</a>’ and being able to respond to business needs in a timely manner.&#160; </p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/02/12/is-nosql-finally-going-mainstream/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>Integrating ELMAH for a WCF Service</title>
		<link>http://elegantcode.com/2010/02/05/integrating-elmah-for-a-wcf-service/</link>
		<comments>http://elegantcode.com/2010/02/05/integrating-elmah-for-a-wcf-service/#comments</comments>
		<pubDate>Fri, 05 Feb 2010 20:57:08 +0000</pubDate>
		<dc:creator>Jan Van Ryswyck</dc:creator>
				<category><![CDATA[WCF]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/02/05/integrating-elmah-for-a-wcf-service/</guid>
		<description><![CDATA[Peter Cosemans, who is one of my colleagues, found a nice way to integrate ELMAH for a WCF service. ELMAH is an error logging facility for logging unhandled exceptions particularly focused on ASP.NET web applications. There are plenty of sources out there, like this blog post by Scott Hanselman, that describe how to get ELMAH [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://twitter.com/cosemansp">Peter Cosemans</a>, who is one of my colleagues, found a nice way to integrate <a href="http://code.google.com/p/elmah/">ELMAH</a> for a WCF service. ELMAH is an error logging facility for logging unhandled exceptions particularly focused on ASP.NET web applications. There are plenty of sources out there, like <a href="http://www.hanselman.com/blog/ELMAHErrorLoggingModulesAndHandlersForASPNETAndMVCToo.aspx">this blog post</a> by Scott Hanselman, that describe how to get ELMAH up and running for an ASP.NET web application.</p>
<p>In order to get it working for WCF, you need to provide a custom error handler by implementing the <a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.dispatcher.ierrorhandler.aspx">IErrorHandler</a> interface:</p>
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> ElmahErrorHandler : IErrorHandler
{
    <span class="kwrd">public</span> <span class="kwrd">void</span> ProvideFault(Exception error, MessageVersion version,
                             <span class="kwrd">ref</span> Message fault)
    {
        var dummyRequest =
            <span class="kwrd">new</span> SimpleWorkerRequest(<span class="str">&quot;dummy&quot;</span>, <span class="str">&quot;&quot;</span>, <span class="kwrd">new</span> StringWriter());
        var context = <span class="kwrd">new</span> HttpContext(dummyRequest);

        var elmahLogger = Elmah.ErrorLog.GetDefault(context);
        elmahLogger.Log(<span class="kwrd">new</span> Elmah.Error(error));
    }

    <span class="kwrd">public</span> Boolean HandleError(Exception error)
    {
        SDExceptionHandler.DoHandle(error);
        <span class="kwrd">return</span> <span class="kwrd">true</span>;
    }
}</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>&#160;</p>
<p>This error handler needs to be added to the stack of error handlers. You can do this in a couple of ways, for example by providing a custom attribute that implements <a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.description.iservicebehavior.aspx">IServiceBehavior</a> and then applying this attribute to your service class.</p>
<p>Next you need to add some configuration to your web.config and your all good to go:</p>
<pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">system.web</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">httpHandlers</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">add</span> <span class="attr">verb</span><span class="kwrd">=&quot;POST,GET,HEAD&quot;</span>
             <span class="attr">path</span><span class="kwrd">=&quot;MyService.Elmah.axd&quot;</span>
             <span class="attr">type</span><span class="kwrd">=&quot;Elmah.ErrorLogPageFactory, Elmah&quot;</span> <span class="kwrd">/&gt;</span>
    <span class="kwrd">&lt;/</span><span class="html">httpHandlers</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">system.web</span><span class="kwrd">&gt;</span>

<span class="kwrd">&lt;</span><span class="html">elmah</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">errorLog</span> <span class="attr">type</span><span class="kwrd">=&quot;Elmah.XmlFileErrorLog, Elmah&quot;</span>
              <span class="attr">logPath</span><span class="kwrd">=&quot;C:\MyServiceLog\&quot;</span><span class="kwrd">/&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">elmah</span><span class="kwrd">&gt;</span></pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>&#160;</p>
<p>What’s nice about this approach is that you don’t need to run the WCF service in ASP.NET compatibility mode, which is a major bonus.</p>
<p>Hope this helps</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/02/05/integrating-elmah-for-a-wcf-service/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>JetBrains Web IDE</title>
		<link>http://elegantcode.com/2010/01/29/jetbrains-web-ide/</link>
		<comments>http://elegantcode.com/2010/01/29/jetbrains-web-ide/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 21:03:26 +0000</pubDate>
		<dc:creator>Jan Van Ryswyck</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/01/29/jetbrains-web-ide/</guid>
		<description><![CDATA[As I already mentioned in a previous blog post, I’m kind of (re-)learning HTML and CSS. The best way for me to pick things up again is by getting my hands dirty and work myself through a simple example. So I decided to work on some sort of prototype of a web application without using [...]]]></description>
			<content:encoded><![CDATA[<p>As I already mentioned in a <a href="http://elegantcode.com/2010/01/26/css-basics-the-box-model/">previous blog post</a>, I’m kind of (re-)learning HTML and CSS. The best way for me to pick things up again is by getting my hands dirty and work myself through a simple example. So I decided to work on some sort of prototype of a web application without using any web framework like ASP.NET MVC, Fubu MVC, Ruby on Rails, etc. … Just plain old HTML and CSS, like the Internet gods intended. I also didn’t want to suck all the fun out of it either, so I decided to use <a href="http://www.jetbrains.com/webide/index.html">Web IDE</a> from <a href="http://www.jetbrains.com/index.html">JetBrains</a> as my IDE for churning out this prototype. </p>
<p>I must say that I was pleasantly surprised by some of the features that this IDE has to offer. The first and most obvious one is probably intellisense that just works as expected.</p>
<p><a href="http://elegantcode.com/wp-content/uploads/2010/01/image9.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/01/image_thumb9.png" width="553" height="385" /></a> </p>
<p>Also notice the on-the-fly code inspection (colored marker bar on the right) that should be familiar when you’re a Resharper addict like me. Web IDE provides W3C XHTML/CSS validation while working in the editor which is really useful. </p>
<p><a href="http://elegantcode.com/wp-content/uploads/2010/01/image10.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/01/image_thumb10.png" width="548" height="381" /></a> </p>
<p>Being the uncertain type, it was also nice to see all the familiar refactoring features from Resharper being available as well. Renaming a class or id is just a breeze. All the corresponding HTML or CSS files are consistently updated.</p>
<p><a href="http://elegantcode.com/wp-content/uploads/2010/01/image11.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/01/image_thumb11.png" width="546" height="382" /></a> </p>
<p>Navigation is there as well (CTRL-N and CTRL-SHIFT-N).</p>
<p><a href="http://elegantcode.com/wp-content/uploads/2010/01/image12.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/01/image_thumb12.png" width="543" height="378" /></a> </p>
<p>This looks just like <a href="http://www.jetbrains.com/resharper/index.html">Resharper</a> for web developers, but there’s more. At first, I had all the HTML and CSS files including all the image file in the root folder of the project. I wanted to divide and conquer by putting the images and CSS files into their own separate folder. As I prepared myself to change all the references in the HTML files, Web IDE did that all for me when I dragged the files to their final destination. Now I didn’t had to go over all the HTML files and manually change the links. How cool is that!</p>
<p>Web IDE also provides source-control integration Subversion, Git, Perforce, etc … and that’s just the tip of the iceberg. While working on the prototype of the web application, I mostly focused on the layout and not so much on the behavior so I didn’t use much of the JavaScript capabilities. But I was told that it is comparable with the JavaScript features in <a href="http://www.jetbrains.com/ruby/index.html">RubyMine</a> as described by Peter in <a href="http://peter.worksontheweb.net/post/An-alternative-to-editing-JavaScript-in-Visual-Studio-RubyMine.aspx">this blog post</a>. This is something that I’m going to explore when I start learning more about JavaScript <img src='http://elegantcode.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> . </p>
<p>Although being the first version and still in beta, the IDE seems pretty stable and I couldn’t notice any performance hiccups so far (which <a href="http://davybrion.com/blog/2010/01/i-still-have-low-expectations-for-visual-studio-2010/">cannot be said for all IDE’s</a> these days). </p>
<p>I do hope that there will be some support for ASP.NET or other view engines like <a href="http://sparkviewengine.com/">Spark</a>, <a href="http://nvelocity.sourceforge.net/">NVelocity</a>, etc. … in future versions. In fact, I still silently wish that JetBrains would come up with an IDE for .NET. Being realistic about it, I don’t have high hopes for something like that coming out but it would totally rock if they decided to build one. Sweet dreams <img src='http://elegantcode.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Bottom line, when you’re doing web development in Visual Studio, make sure to also check out Web IDE. It will probably help you to become more productive along the way.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/01/29/jetbrains-web-ide/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Calling Non-Public Methods</title>
		<link>http://elegantcode.com/2010/01/28/calling-non-public-methods/</link>
		<comments>http://elegantcode.com/2010/01/28/calling-non-public-methods/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 19:47:39 +0000</pubDate>
		<dc:creator>Jan Van Ryswyck</dc:creator>
				<category><![CDATA[.Net 3.5]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/01/28/calling-non-public-methods/</guid>
		<description><![CDATA[A typical way for invoking a non-public method of a class is by using reflection. This can come in handy in a number of cases. One typical scenario that comes to mind is when the designers of the .NET Framework or another 3rd party framework decided to bury a class or a method as internal [...]]]></description>
			<content:encoded><![CDATA[<p>A typical way for invoking a non-public method of a class is by using reflection. This can come in handy in a number of cases. One typical scenario that comes to mind is when the designers of the .NET Framework or another 3rd party framework decided to bury a class or a method as internal while this could perfectly solve a problem (I just hate it when they do that).</p>
<p>Invoking private methods is not considered a best practice in general, but there are cases where you have no other option than to fall back on using reflection. The following code snippet shows how one would typically accomplish that.</p>
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> Subject
{
    <span class="kwrd">private</span> String DoSomething(String input)
    {
        <span class="kwrd">return</span> input;
    }
}

<span class="rem">// Calling code</span>
var subject = <span class="kwrd">new</span> Subject();
var doSomething = <span class="kwrd">typeof</span>(Subject).GetMethod(<span class="str">&quot;DoSomething&quot;</span>,
    BindingFlags.Instance | BindingFlags.NonPublic);
var result = doSomething.Invoke(subject, <span class="kwrd">new</span>[] { <span class="str">&quot;Hello Muppets&quot;</span> });
Console.WriteLine(result);  </pre>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>&#160;</p>
<p>We all recognize this piece of code as we’ve done this at some point in one of our coding sessions. What I want to share here is a slightly nicer way to accomplish the same without all the usual reflection ugliness.</p>
<pre class="csharpcode"><span class="rem">// Calling code that uses delegates</span>
var subject = <span class="kwrd">new</span> Subject();
var doSomething = (Func&lt;String, String&gt;)
    Delegate.CreateDelegate(<span class="kwrd">typeof</span>(Func&lt;String, String&gt;), subject, <span class="str">&quot;DoSomething&quot;</span>);
Console.WriteLine(doSomething(<span class="str">&quot;Hello Freggles&quot;</span>));</pre>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>&#160;</p>
<p>This code just creates a delegate that matches the signature of the non-public method that we want to call. To me, this approach looks far more elegant. Note that this only works for instance methods and not for static methods. </p>
<p>I hope that this can be of some use.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/01/28/calling-non-public-methods/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>CSS Basics: The Box Model</title>
		<link>http://elegantcode.com/2010/01/26/css-basics-the-box-model/</link>
		<comments>http://elegantcode.com/2010/01/26/css-basics-the-box-model/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 19:52:34 +0000</pubDate>
		<dc:creator>Jan Van Ryswyck</dc:creator>
				<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/01/26/css-basics-the-box-model/</guid>
		<description><![CDATA[If you’ve been using CSS for a while, then this post will probably teach you nothing new. I just wanted to state the obvious even if I’m the only one who benefits from it.
While I was (re-)learning CSS, I came across these two properties called margin and padding. At first, they seem to be doing [...]]]></description>
			<content:encoded><![CDATA[<p>If you’ve been using CSS for a while, then this post will probably teach you nothing new. I just wanted to state the obvious even if I’m the only one who benefits from it.</p>
<p>While I was (re-)learning CSS, I came across these two properties called <em>margin</em> and <em>padding</em>. At first, they seem to be doing the same thing namely providing space between HTML elements. But although they seem to fulfill the same purpose, there’s a clear distinction between the two.</p>
<p><a href="http://elegantcode.com/wp-content/uploads/2010/01/image5.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/01/image_thumb5.png" width="240" height="145" /></a>&#160;</p>
</p>
<p>The margin is intended for providing space between outside HTML elements or the sides of the page. Padding is used for providing visual space between the content and the border of the box. </p>
<div style="border-bottom: #000000 2px dashed; border-left: #000000 2px dashed; margin: 25px; background: #4f81bd; border-top: #000000 2px dashed; font-weight: bold; border-right: #000000 2px dashed"><font color="#ffffff">Some margin, no padding</font> </div>
<div style="border-bottom: #000000 2px dashed; border-left: #000000 2px dashed; padding-bottom: 25px; padding-left: 25px; padding-right: 25px; background: #4f81bd; border-top: #000000 2px dashed; font-weight: bold; border-right: #000000 2px dashed; padding-top: 25px"><font color="#ffffff">Some padding, no margin</font> </div>
<p>&#160;</p>
<p>The first example provides a margin to add visual space between the border and the parent element. The second one provides space between the border and the content.</p>
<p>I agree that this is trivial, but it matters to understand the difference between these two properties when using CSS. </p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/01/26/css-basics-the-box-model/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Kicking Off the New E-VAN Season</title>
		<link>http://elegantcode.com/2010/01/25/kicking-off-the-new-e-van-season/</link>
		<comments>http://elegantcode.com/2010/01/25/kicking-off-the-new-e-van-season/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 19:47:09 +0000</pubDate>
		<dc:creator>Jan Van Ryswyck</dc:creator>
				<category><![CDATA[E-VAN]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/01/25/kicking-off-the-new-e-van-season/</guid>
		<description><![CDATA[You can read all about it here.
]]></description>
			<content:encoded><![CDATA[<p>You can read all about it <a href="http://europevan.blogspot.com/2010/01/next-european-van-on-08-february-2010.html">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/01/25/kicking-off-the-new-e-van-season/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Retrospective of 2009, Planning for 2010</title>
		<link>http://elegantcode.com/2009/12/30/retrospective-of-2009-planning-for-2010/</link>
		<comments>http://elegantcode.com/2009/12/30/retrospective-of-2009-planning-for-2010/#comments</comments>
		<pubDate>Wed, 30 Dec 2009 20:55:10 +0000</pubDate>
		<dc:creator>Jan Van Ryswyck</dc:creator>
				<category><![CDATA[Esoterica]]></category>
		<category><![CDATA[Goals]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/12/30/retrospective-of-2009-planning-for-2010/</guid>
		<description><![CDATA[After the Kaizenconf of 2008, I wrote down a couple of things I wanted to learn throughout 2009. Looking back at that list for the past year, I think I did fairly well.
Retrospective of 2009

I learned more about integration patterns and ESB’s. I also learned about NServiceBus and I’m going to take this a few [...]]]></description>
			<content:encoded><![CDATA[<p>After the Kaizenconf of 2008, I wrote down a couple of things I wanted to learn throughout 2009. Looking back at <a href="http://elegantcode.com/2008/11/05/kaizenconf-part-3-taking-action/">that list</a> for the past year, I think I did fairly well.</p>
<h2>Retrospective of 2009</h2>
<ul>
<li>I learned more about <a href="http://elegantcode.com/2009/08/18/book-review-enterprise-integration-patterns/">integration patterns</a> and <a href="http://elegantcode.com/2009/10/30/book-review-enterprise-service-bus/">ESB</a>’s. I also learned about <a href="http://elegantcode.com/2009/10/09/exploring-nservicebus/">NServiceBus</a> and I’m going to take this a few steps further in 2010. I’m hoping to get some real-world experience with a true Service-Oriented Architecture. </li>
<li><a href="http://structuremap.sourceforge.net/Default.htm">StructureMap</a> is now <a href="http://elegantcode.com/2008/12/12/learning-about-structuremap/">my IoC container of choice</a>. </li>
<li>I definitely <a href="http://elegantcode.com/2009/07/13/using-nhibernate-for-legacy-databases/">learned</a> <a href="http://elegantcode.com/2009/07/19/nhibernate-2-1-and-collection-event-listeners/">a lot</a> about <a href="http://nhforge.org/">NHibernate</a> this year and I’m still a huge fan. I’m also looking forward to see what <a href="http://fabiomaulo.blogspot.com/2009/06/criteria-on-nh300.html">NHibernate 3.0</a> will bring to the table in 2010. </li>
<li>Thanks to the European VAN presentations of <a href="http://vimeo.com/3171910">Greg Young on DDD</a> and <a href="http://vimeo.com/7838858">Mark Nijhof’s CQRS sample application</a>, I learned a tremendous deal about Domain-Driven Design. I finally understand some of the stuff that <a href="http://codebetter.com/blogs/gregyoung/">Greg Young</a> and <a href="http://www.udidahan.com/?blog=true">Udi Dahan</a> are talking about for a couple of years now.&#160; </li>
<li>I (re)learned HTML/XHTML and picked up some basic knowledge about CSS during the last couple of weeks. My goal is not to become a CSS jedi, but I just want to have enough knowledge and experience in order to prevent the most obvious rookie mistakes. </li>
<li>I took my first baby-steps in Ruby earlier this year, but I definitely need more study and practical use in order to become a more proficient user. </li>
</ul>
<p>There’s some stuff on the list that I didn’t managed to learn about:</p>
<ul>
<li>JavaScript and jQuery </li>
<li>Lean/Kanban </li>
<li>F# </li>
</ul>
<p>On the the other hand, I was able to learn about <a href="http://elegantcode.com/category/couchdb/">CouchDB</a> and the <a href="http://en.wikipedia.org/wiki/NoSQL">NoSQL movement</a>. I also learned a significant deal about <a href="http://en.wikipedia.org/wiki/Representational_State_Transfer">RESTful architectures</a>.</p>
<p>I also gained a lot of experience with WCF (Windows Communication Foundation) throughout the year, but I regret to say that it was mostly negative than positive. I don’t think that I’m going to consider this technology again in its current state. Maybe I’ll reconsider it again after it further matures.</p>
<h2>Planning for 2010</h2>
<p>Hereby the stuff I want to learn more about in 2010:</p>
<ul>
<li>Continue exploring NServiceBus and using it in a real-world project. </li>
<li>Web development is something that I want to become more familiar with. JavaScript and jQuery are still high on the list, but I also want to take an in-depth look at some of the web development frameworks out there. I’m looking forward to learning about ASP.NET MVC, <a href="http://code.google.com/p/fubumvc/">Fubu MVC</a>, <a href="http://www.djangoproject.com/">Django</a>, <a href="http://trac.caffeine-it.com/openrasta">OpenRasta</a> and <a href="http://rubyonrails.org/">Ruby on Rails</a>. </li>
<li>Following my new motto of<em> learning one NoSQL database each year</em>, this year I’m going to take a closer look at <a href="http://www.mongodb.org/display/DOCS/Home">MongoDB</a>. </li>
<li>Following the same credo applied on programming languages,&#160; I’m currently very interested in learning <a href="http://clojure.org/">Clojure</a>, and not only because it can also <a href="http://github.com/richhickey/clojure-clr">target the CLR</a>. As already mentioned, I also want to become more proficient at Ruby.<br />
<h2>Community</h2>
<p> On the community side, I’ll continue to co-organize the <a href="http://europevan.blogspot.com/">European VAN</a> meetings with <a href="http://colinjack.blogspot.com/">Colin Jack</a>. We’ll try to do them on a more regular basis. I also hope to put out more blog posts in 2010 than I did in 2009. In 2007 and 2008 I managed to write ~100 blog posts a year. This past year, I didn’t even manage to publish half of that and I’m not very pleased with that. While I was evaluating the past year, I’ve come to some conclusions about what might be causing this. Maybe I’ll get back to this in a later blog post.</li>
</ul>
<ul></ul>
<ul>Well, there you have it. I would love to hear about some of the things that you, my dear readers, are planning to learn in 2010. I wish you all a happy and successful new year.</ul>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/12/30/retrospective-of-2009-planning-for-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
