<?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; cbilson</title>
	<atom:link href="http://elegantcode.com/author/cbilson/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com</link>
	<description></description>
	<lastBuildDate>Sun, 12 Feb 2012 04:40:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.5</generator>
		<item>
		<title>Fluent Context Builders</title>
		<link>http://elegantcode.com/2009/07/07/fluent-context-builders/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=fluent-context-builders</link>
		<comments>http://elegantcode.com/2009/07/07/fluent-context-builders/#comments</comments>
		<pubDate>Tue, 07 Jul 2009 21:52:26 +0000</pubDate>
		<dc:creator>cbilson</dc:creator>
				<category><![CDATA[Unit Testing]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/07/07/fluent-context-builders/</guid>
		<description><![CDATA[One thing I’ve been doing more and more of, especially as I use MSpec and context/spec driven development, is using lambdas and fluent-interface style programming to capture the essence of the spec’s I’m working on and keep them separate from the details of the code that implements them. What the heck does that mean? Well, [...]]]></description>
			<content:encoded><![CDATA[<p>One thing I’ve been doing more and more of, especially as I use MSpec and context/spec driven development, is using lambdas and fluent-interface style programming to capture the essence of the spec’s I’m working on and keep them separate from the details of the code that implements them.</p>
<p>What the heck does that mean? Well, let’s say I get the following story:</p>
<pre><code>    As a customer of our website
    When I order a medical product
    And I want it shipped to a state with no sales tax on medical products
    I should see that there is no tax for the item
    And no sales tax for that item should be incorporated in the final price</code></pre>
<p>Quite a mouth full, yet completely contrived.</p>
<p>What does my executable specification for this look like? Well, first, let’s name it:</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"><span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> when_I_order_medial_products_for_shipment_to_places_where_they_arent_subject_to_sales_tax { }</pre>
<p></div>
<p>I changed the wording around a little. I would probably work on this with a business expert to make sure I understood the story right. I might even come up with something more concise and understand the story/business even better from the conversation.</p>
<p>Next, the asserts:</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">It shows_me_there_is_no_sales_tax_for_the_item;It doesnt_include_any_tax_for_the_item_in_the_total;</pre>
<p></div>
<p>Personally, I prefer writing my specs in active voice. It helps me get in the role of the person that we’re doing this for.</p>
<p>If I run this now, I get the “pending” behavior we talked about in <a href="http://elegantcode.com/2009/07/05/mspec-take-2/">my last post</a>:</p>
<pre><code> when I order medial products for shipment to places where they arent subject to sales tax
 » shows me there is no sales tax for the item (NOT IMPLEMENTED)
 » doesnt include any tax for the item in the total (NOT IMPLEMENTED)</code></pre>
<p>Before I can implement the assertions, I need to be able to build the context up:</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">Because of = () =&gt; {    <span style="color: #008000">// TODO: Shit...I don't know</span>};</pre>
<p></div>
<p>If you are used to test-first design, you are probably familiar with the concept of “<strong><em>write the code you wish you had</em></strong>.” Increasingly, I am finding, even if just for design purposes, the code I wish I had was wrapped in a fluent builder for the contexts I am testing:</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">Because of = () =&gt; {    var invoice = <span style="color: #0000ff">new</span> Invoice()        .with_some_medical_product()        .shipping_to(<span style="color: #0000ff">new</span> Address().where_medical_products_arent_taxed());};</pre>
<p></div>
<p>That pretty much sums up the scenario I want. I just need to implement these extension methods.</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"><span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">class</span> ContextBuilder{  <span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> Invoice with_some_medical_product(<span style="color: #0000ff">this</span> Invoice invoice)  {      invoice.Items.Add(<span style="color: #0000ff">new</span> InvoiceItem { });

      <span style="color: #0000ff">return</span> invoice;  }}</pre>
<p></div>
<p>So, what makes something a medical product in our system? Is it simply an attribute of a product?</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">invoice.Items.Add(<span style="color: #0000ff">new</span> InvoiceItem {   Product = <span style="color: #0000ff">new</span> Product { Category = Category.MedicalSupplies });</pre>
<p></div>
<p>Or is there some service that figures that out?</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">

<span style="color: #0000ff">static</span> IProductCategoryFigureOuter categories = MockRepository.GenerateStub&lt;IProductCategoryFigureOuter&gt;();

<span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> Invoice with_some_medical_product(<span style="color: #0000ff">this</span> Invoice invoice){    Product medicalProduct = <span style="color: #0000ff">new</span> Product { };    categories.Stub(x =&gt; x.IsMedicalProduct(medicalProduct)).Return(<span style="color: #0000ff">true</span>);

    invoice.Items.Add(<span style="color: #0000ff">new</span> InvoiceItem {        Product = medicalProduct    });

    <span style="color: #0000ff">return</span> invoice;}
</pre>
<p></div>
<p>We need to ask the SME/business expert more questions to figure out how best to represent this in our system.</p>
<p>How do we make an address where_medical_products_arent_taxed? Another service?</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">

<span style="color: #0000ff">static</span> ITaxInfoService taxInfo = MockRepository.GenerateStub&lt;ITaxInfoService&gt;();

<span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> Address where_medical_products_arent_taxed(<span style="color: #0000ff">this</span> Address address){    taxInfo.Stub(x =&gt; x.AreMedicalProductsTaxedIn(address)).Return(<span style="color: #0000ff">false</span>);

    <span style="color: #0000ff">return</span> address;}
</pre>
<p></div>
<p>We’re starting to get close to where we are going to have to write some real code. Up until this point, all we’ve done is sketch out how it might look structurally, from a high level, but we’ve done this while keeping real business concerns in mind the whole time. Using fluent-style builders to help manage and create the context helped us do that and name the actors that make up the context. The problem is decomposing naturally into smaller problem.</p>
<p>If we’ve gotten good answers to the questions we surfaced during this process, chances are high that our application closely resembles the actual business we’re modeling.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/07/07/fluent-context-builders/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MSpec &#8211; Take 2</title>
		<link>http://elegantcode.com/2009/07/05/mspec-take-2/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mspec-take-2</link>
		<comments>http://elegantcode.com/2009/07/05/mspec-take-2/#comments</comments>
		<pubDate>Sun, 05 Jul 2009 19:38:25 +0000</pubDate>
		<dc:creator>cbilson</dc:creator>
				<category><![CDATA[Testing]]></category>
		<category><![CDATA[Tools and Utilities]]></category>
		<category><![CDATA[Unit Testing]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/07/05/mspec-take-2/</guid>
		<description><![CDATA[About a year ago, I remember first hearing about Machine.Specifications (github) and trying it out for something I was developing. I liked it right away, especially the way it cut away a lot of the noise involved with writing tests/specifications. I never really ended up using MSpec on things at work. There were lots of [...]]]></description>
			<content:encoded><![CDATA[<p>About a year ago, <a href="http://codebetter.com/blogs/gregyoung/archive/2008/07/19/bellware-driven-design.aspx">I remember first hearing about</a> <a href="http://codebetter.com/blogs/aaron.jensen/archive/2008/05/08/introducing-machine-specifications-or-mspec-for-short.aspx">Machine.Specifications</a> <a href="http://github.com/machine/machine.specifications/tree/master">(github)</a> and trying it out for something I was developing. I liked it right away, especially the way it cut away a lot of the noise involved with writing tests/specifications.</p>
<p>I never really ended up using MSpec on things at work. There were lots of lame reasons:</p>
<ul>
<li>We were using MbUnit and MSpec worked with NUnit (like I really care, seriously) </li>
<li>We already had lots of existing tests and didn&#8217;t want the disjointed feeling of having two ways to do things </li>
<li>I was already struggling at work getting people to adopt the new things I had <em>already</em> introduced into our environment. </li>
</ul>
<p>I took what I could out of MSpec and the other Spec Driven Development stuff I got from the community and kind of rolled my own style of doing spec driven development just using MbUnit. I&#8217;ve since gathered that there are lots of people doing this.</p>
<p>Recently I had to do a small sample application in a short period of time. It wasn&#8217;t for work (i.e. no MbUnit legacy) and I still wanted to do it spec first, so I grabbed the latest MSpec and used that.</p>
<p>I noticed there are several small but appreciated changes that have been made since the last time I used MSpec, namely:</p>
<h4>XUnit and (kind of) Gallio Support</h4>
<p>To use Gallio/MbUnit or xUnit with MSpec, there&#8217;s really nothing special to do &#8211; just reference the testing framework you want to use and the adapter assembly. </p>
<p>The adapter assembly is the magic part of MSpec. It helps the unit testing framework build a model of the tests to run. When using MSpec, you&#8217;re not putting attributes on things anymore to indicate they are unit tests. The adapter is needed so the unit testing framework knows what to run as tests.</p>
<p>For NUnit and xUnit, there are a bunch of nice extension methods defined for doing <em>systemUnderTest</em>.<em>ShouldXXX</em>() style assertions. There aren&#8217;t any for MbUnit, but I made <a href="http://github.com/cbilson/machine.specifications/blob/e922df9b5367072167694a6a887f6ece1aea518c/Source/Machine.Specifications.Example.UsingGallio/GallioExtensionMethods.cs">some</a> in <a href="http://github.com/cbilson/machine.specifications/tree/master">my fork of MSpec</a> if you&#8217;re interested. </p>
<p>I imagine you could write an adapter for MSTest, as well as some extension methods, but my interest in MSTest-ifying MSpec this ends there.</p>
<p>Once you start using these extension methods, the unit testing framework dependencies kind of melt away:</p>
<blockquote><pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> when_pricing_an_item_that_requires_no_sales_tax : with_an_item_to_price
{
    <span class="kwrd">static</span> Money price;

    Because of = () =&gt; {

        the_product.is_not_taxed()
                   .when_shipped_to(our_destination);

        price = pricingService.PriceItem(1, the_product, our_destination);
    };

    It prices_as_the_base_price = () =&gt;
        price.ShouldEqual(our_base_price);
}</pre>
</blockquote>
<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>Where&#8217;s the test framework code? Does this use NUnit? MbUnit? The only assertion here is in ShouldEqual, which is one of those extension methods that calls who cares which unit testing framework.</p>
<p>That&#8217;s the real lesson here: who cares which unit testing framework you&#8217;re using &#8211; that decision doesn&#8217;t add any value to your product, and doesn&#8217;t make this a valid excuse for not using MSpec. If one framework or the other works better with your build process or some tool you are using, just use that framework.</p>
<h4>Pending</h4>
<pre class="csharpcode">    <span class="kwrd">public</span> <span class="kwrd">class</span> when_pricing_an_item_that_requires_sales_tax_where_we_are_shipping : with_an_item_to_price
    {
            It includes_the_tax_in_the_price;
            It includes_the_tax_in_the_total_tax;
            It doesnt_include_the_tax_in_the_subtotal;
            It doesnt_include_the_tax_in_the_line_item_total;
    }</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>I saw Aaron demo this somewhere once, maybe at an #altnetseattle meeting or something, but I didn&#8217;t get it at first. I thought it was about going off and writing a bunch of <em>Tests</em> then implementing them. My view that you write one <em>Test</em>, then implement, then another, etc.</p>
<p>The difference is, when doing things <em>Spec</em> first, it&#8217;s&#8230;well&#8230;it&#8217;s just different. I think one reason I like one test at a time is that I am testing close to the implementation at that point. Since I am in the process of designing the system while doing TDD, I don&#8217;t know what the rest of the design is going to look like till I get there. If I write too many tests, I am speculating about what the design is going to look like.</p>
<p>Specs aren&#8217;t so much about the physical design of the system so they don&#8217;t change (as much) as the design evolves. If they do, they have good (read: business) reason. It&#8217;s not wrong to translate specs into code as part of the same process you are getting them (ex.: talking with a product owner&#8230;taking notes in the form of &quot;public class whatever_context { It does_this; It does_that; &#8230;}&quot;.) That process is unlikely to be as granular as TDD tests, as no business person that is making money wants to hold your hand all day while they spoon feed you one thing at a time.</p>
<p>The output from running the above specs is:</p>
<blockquote>
<pre><code>when pricing an item that requires sales tax where we are shipping
&gt;&gt; includes the tax in the price (NOT IMPLEMENTED)
&gt;&gt; the tax in the total tax (NOT IMPLEMENTED)
&gt;&gt; include the tax in the subtotal (NOT IMPLEMENTED)
&gt;&gt; include the tax in the line item total (NOT IMPLEMENTED)
</code></pre>
</blockquote>
<p>You can go ahead and spec things out ahead of time just saying &quot;It does_whatever&quot; and you&#8217;ll get a nice report of what&#8217;s to be done.</p>
<h4>Behavior</h4>
<p>This feature answers a question I&#8217;ve had since the first time I saw someone do BDD: What do you do when you want to specify the same behavior for multiple contexts?</p>
<blockquote>
<pre class="csharpcode">[Subject(<span class="str">&quot;Calculating sales tax&quot;</span>)]
<span class="kwrd">public</span> <span class="kwrd">class</span> when_an_item_is_a_kind_of_food : with_an_invoice_with_one_item
{
    Because of = () =&gt; invoice = <span class="kwrd">new</span> Invoice().WithSomeKindOf(Category.Food);
    Behaves_like&lt;NoSalesTaxAdded&gt; no_sales_tax_added;
}

[Subject(<span class="str">&quot;Calculating sales tax&quot;</span>)]
<span class="kwrd">public</span> <span class="kwrd">class</span> when_an_item_is_a_kind_of_medical_supply : with_an_invoice_with_one_item
{
    Because of = () =&gt; invoice = <span class="kwrd">new</span> Invoice().WithSomeKindOf(Category.MedicalSupplies);
    Behaves_like&lt;NoSalesTaxAdded&gt; no_sales_tax_added;
}

[Behaviors]
<span class="kwrd">public</span> <span class="kwrd">class</span> NoSalesTaxAdded
{
    <span class="kwrd">protected</span> <span class="kwrd">static</span> Invoice invoice;

    It has_no_sales_tax_added = () =&gt;
    {
        <span class="kwrd">foreach</span> (var item <span class="kwrd">in</span> invoice.Items)
            invoice.GetPostTaxValueFor(item).ShouldEqual(item.Value);
    };
}</pre>
</blockquote>
<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>In the samples that come with MSpec, there is an example of two implementations of the same interface, like a <a href="http://weblogs.asp.net/astopford/archive/2008/08/25/mbunit-typefixture.aspx">TypeFixture</a> in MbUnit. </p>
<p>It seems like, in the applications I work on, I rarely run across a need to use this kind of test, but I do sometimes need <a href="http://weblogs.asp.net/astopford/archive/2008/08/25/mbunit-rowtest.aspx">RowTest</a>-like tests, or, more often, <a href="http://weblogs.asp.net/astopford/archive/2008/08/26/mbunit-factory.aspx">factory</a> driven tests &#8211; like to specify that for a certain set of contexts, there is some behavior. My example above is a lame attempt to illustrate this.</p>
<h4>What&#8217;s Next</h4>
<p>That&#8217;s kind of the technical view of things. Hopefully I&#8217;ve gotten your attention and you are git clone-ing MSpec in the background right now. I hope to post part 2 of this in a couple of days, with some examples of how I use MSpec in real code.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/07/05/mspec-take-2/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Olympia Software Craftsmanship Workshop &#8211; Postmortem</title>
		<link>http://elegantcode.com/2009/06/09/olympia-software-craftsmanship-workshop-postmortem/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=olympia-software-craftsmanship-workshop-postmortem</link>
		<comments>http://elegantcode.com/2009/06/09/olympia-software-craftsmanship-workshop-postmortem/#comments</comments>
		<pubDate>Tue, 09 Jun 2009 13:51:01 +0000</pubDate>
		<dc:creator>cbilson</dc:creator>
				<category><![CDATA[ALT.NET]]></category>
		<category><![CDATA[Craftsmanship]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/06/09/olympia-software-craftsmanship-workshop-postmortem/</guid>
		<description><![CDATA[On Saturday, some of us folks from the Seattle ALT.NET community held a workshop in Olympia, covering some software craftsmanship principles. Overall, I think the workshop went pretty well, with the usual assortment of things to learn from. Things That Went Well I was impressed by everyone&#8217;s enthusiasm. I was a little worried that we [...]]]></description>
			<content:encoded><![CDATA[<p>On Saturday, some of us folks from the Seattle ALT.NET community held a workshop in Olympia, covering some software craftsmanship principles. Overall, I think the workshop went pretty well, with the usual assortment of things to learn from.</p>
<h2>Things That Went Well</h2>
<ul>
<li>I was impressed by everyone&#8217;s enthusiasm. I was a little worried that we were under-prepared going in, but the enthusiasm and depth of knowledge that the presenters shared was impressive.</li>
<li>People really liked the Outside-in Testing (Jeff Olson) and TDD sessions (Robin Clowers). These had the most code shown during their presentations, which, I think, says something.</li>
<li>The facilities were just about right. We were a tiny bit over capacity (technically we were under, but it didn&#8217;t feel that way to me.)</li>
<li>We had the right refreshments and stuff to keep people from getting hungry and distracted. At one point, someone I know asked if we had anything besides pizza, as he has dietary reasons for avoiding it. I felt bad and told him no, making a mental note that we should have some other food available next time, until I realized Anne had prepared Salad and lunch meats. Yay!</li>
</ul>
<h2>To Work on for Next Time</h2>
<ul>
<li>We tried to cover way to much ground for one day. I think we all knew this going in, but were just in denial or something. <strong>Next time</strong>: I think we&#8217;re going to cover just one topic.</li>
<li>We hardly got to show any code. I had code that I wanted to show for both the refactoring and patterns talks that I didn&#8217;t even get to. I got to show a tiny bit of code in the refactoring talk, but I had a whole series of small refactorings I wanted to do but didn&#8217;t. I think we went over in a few of the earlier sessions, it felt right then, but then it compressed the sessions for the rest of the day. The one person that just showed code the whole time, Robin, received props for that. <strong>Next time</strong>: no slides for me.</li>
<li>We asked people to bring laptops, then never worked on any code. This was mostly a side effect of the above, I think. <strong>Next time</strong>: give them the code ahead of time and use the pauses while people catch up with coding tasks to answer off-the-rails questions.</li>
<li>Some people weren&#8217;t into the whole &quot;be interactive&quot; thing. At the start of the workshop we asked everyone to shout out questions as soon as they had them, but some felt this led to derailment. <strong>Next time</strong>: I think we&#8217;ll save space at the end or at pre-determined spots for questions, although I personally feel this leads to people forgetting their questions.</li>
<li>We (the hosts) didn&#8217;t communicate enough before the event and I think it showed. <strong>Next time</strong>: I think we need to get together on a Saturday a few weeks before the event and make sure we&#8217;re all on the same page. I think this is one area where I personally did a pretty poor job, kind of assuming everyone was &quot;directionally correct&quot; and just kind of knew what to do. For the most part this was true, but I think this will be something we improve upon.</li>
<li>Using git and markdown was great for the geekier amongst us, but proved a burden for some of the presenters and the attendees. <strong>Next time</strong>: git for us to share the code, zip files (skydrive?) for everything else and for code for the attendees to download.</li>
</ul>
<p>In summary, I think the loudest message was: more code. I am in total agreement and I usually don&#8217;t like to use any slides at all if I can help it, but somehow got the wrong headed idea that I needed to have something to look at while I did the talking, intro-part of my sessions.</p>
<p>I also tried rehearsing more than usual for this and it turned out to be a complete waste of time. The actual session went wayyyy slower than then I rehearsed. I must be doing it wrong. <font color="#008000">// TODO: Imagine Arun     <br />asking questions while I am rehearsing.</font></p>
<p>It sounded like the majority of the attendees would like to come back for another session like this, more focused on one topic. The organizers are going to hold a skype retrospective sometime in the next few days and figure out what we want to do next.</p>
<p>I’d like to give mass props to the people that made this happen: <a href="http://www.aboutjustin.com/">Justin Bozonier</a>, <a href="http://twitter.com/RobinClowers">Robin Clowers</a>, <a href="www.iamnotmyself.com">Bobby Johnson</a>, <a href="http://twitter.com/olsonjeffery">Jeff Olson</a>, <a href="http://twitter.com/trevorrotzien">Trevor Rotzien</a>, and <a href="http://twitter.com/qrose57">Anne Wax</a>. Together we are helping ALT.NET grow from a small fringe group into something that’s doing real work and making things better than when we got here. </p>
<p>&#160;</p>
<p><strong>UPDATE</strong>: We actually held the retrospective last night. We&#8217;re planning another event soon, possibly in more locations, something more focused. Keep your eyes peeled.    </p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/06/09/olympia-software-craftsmanship-workshop-postmortem/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Announcing: Olympia Software Craftsmanship Workshop</title>
		<link>http://elegantcode.com/2009/05/05/announcing-olympia-software-craftsmanship-workshop/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=announcing-olympia-software-craftsmanship-workshop</link>
		<comments>http://elegantcode.com/2009/05/05/announcing-olympia-software-craftsmanship-workshop/#comments</comments>
		<pubDate>Tue, 05 May 2009 14:29:29 +0000</pubDate>
		<dc:creator>cbilson</dc:creator>
				<category><![CDATA[ALT.NET]]></category>
		<category><![CDATA[Craftsmanship]]></category>
		<category><![CDATA[User Group]]></category>

		<guid isPermaLink="false">http://elegantcode.com/?p=2326</guid>
		<description><![CDATA[Some of us folks from ALT.NET Seattle have been working on putting together a workshop for developers in Olympia, WA, focusing on Software Craftsmanship – which, to us, means caring about our craft and applying the principles we know work to what we are doing. The workshop is inspired by some of the discussions started [...]]]></description>
			<content:encoded><![CDATA[<p>Some of us folks from ALT.NET Seattle have been working on putting together a workshop for developers in Olympia, WA, focusing on Software Craftsmanship – which, to us, means caring about our craft and applying the principles we know work to what we are doing. The workshop is inspired by some of the discussions started in the much despised, “<a href="http://altnetseattle.pbworks.com/Why-So-Mean">Why So Mean</a>” session at the <a href="http://altnetseattle.pbworks.com/">recent Seattle ALT.NET conference</a>, as well as discussions in the follow up (and less controversial) “<a href="http://altnetseattle.pbworks.com/ALTNET-Pedagogy">ALT.NET Pedagogy</a>” session, as well as what <a href="http://twitter.com/briandonahue">@briandonahue</a> has been doing in Philadelphia with the &#8220;<a href="http://persistall.com/archive/2009/01/14/introducing-the-quotfoundation-seriesquot.aspx">Foundation Series</a>.”</p>
<p>I am hoping this will raise the bar a little bit and get more people walking the walk. My view has always been that we all have to work together, so better to get everyone up to speed on what’s working and what’s not, and for as many people to be passionate and excited about the work they are doing as possible.</p>
<p>Anyway, here’s the official announcement:</p>
<blockquote><p>You&#8217;re at work and you catch yourself writing another 100 line method that you can&#8217;t test and really can&#8217;t even understand. You scour the internet for ideas but there are so many ideas. Some say don&#8217;t test, others says don&#8217;t test anything, still others say test every keystroke! You just let your head drop to your desk with a solid thud. You think to yourself, &#8220;Is this really the best I can do?&#8221;</p>
<p>The Olympia Software Craftsmanship Workshop is one day workshop, developed with the intention of increasing the level of awareness of practices and skills that can improve our software.</p>
<p>Any developer interested in improving and learning new skills is welcome. If you can bring a laptop, please do. We will provide the software you need. If you can&#8217;t bring a laptop, don&#8217;t worry, you can pair up with someone who has one.</p>
<p>*************************************************************************</p>
<p>What: Olympia Software Craftsmanship Workshop</p>
<p>Where: Olympia Center, 222 Columbia St NW, Olympia, WA 98501</p>
<p>When: Saturday June 6, 2009.  10 am to 4 pm</p>
<p>How much does it cost? $25.00 to cover the cost of the facility and lunch.</p>
<p>How do I sign up? Go to <a href="http://www.olympiasoftwarecraftsmanship.org" target="_blank">www.olympiasoftwarecraftsmanship.org</a></p>
<p>The workshop is hosted by members of the South Sound.NET users group and Alt.Net Seattle who want to help others build better software.</p>
<p>For more information: <a href="http://github.com/altnetseattle/olympia_software_craftsmanship_workshop/tree/master">http://github.com/altnetseattle/olympia_software_craftsmanship_workshop/tree/master</a></p>
<p>Or contact Bobby Johnson at <a href="mailto:bobby.johnson@gmail.com">bobby.johnson@gmail.com</a></p></blockquote>
<p>I hope to see some of you there!</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/05/05/announcing-olympia-software-craftsmanship-workshop/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Simple Retrospectives</title>
		<link>http://elegantcode.com/2009/04/09/simple-retrospectives/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=simple-retrospectives</link>
		<comments>http://elegantcode.com/2009/04/09/simple-retrospectives/#comments</comments>
		<pubDate>Thu, 09 Apr 2009 11:06:10 +0000</pubDate>
		<dc:creator>cbilson</dc:creator>
				<category><![CDATA[Esoterica]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/04/09/simple-retrospectives/</guid>
		<description><![CDATA[While I think agile engineering practices are step 0 in building an efficient agile team, there are few of the “soft” practices which seem like low hanging fruit for a team that wants to grow more efficient over time. In my opinion, the most bang for the buck comes from Retrospectives. Disclaimer: I am far [...]]]></description>
			<content:encoded><![CDATA[<p>While I think agile engineering practices are step 0 in building an efficient agile team, there are few of the “soft” practices which seem like low hanging fruit for a team that wants to grow more efficient over time. In my opinion, the most bang for the buck comes from Retrospectives. </p>
<p><strong><em>Disclaimer: I am far from an expert on retrospectives (for that, see <a href="http://www.futureworksconsulting.com/blog/">Diana Larsen</a>). What I know about retrospectives has been gleaned from listening to other people and trying a few things. I am writing this more to start a conversation than to preach my interpretation of what makes a good retrospective.</em></strong></p>
<p>At <a href="http://russell.com/">Russell</a>, for the first couple of retrospectives we did, I think it felt too “touchy feely” for most of the group and they had trouble getting started saying what they needed to. Once they got going, it turned a little dark and we started focusing on negatives, especially unsolvable ones. By the end, we were wondering what was supposed to happen next. This wasn’t how the people at the conference I went to did it. What was going wrong?</p>
<p>For one thing, our teams are too small (3-5 people) to include much of the ceremony around retrospectives. Eventually, we ended up doing a simpler kind of retrospective:</p>
<ol>
<li>Get a room. </li>
<li>We make a list, two columns, good and bad things about the iteration. </li>
<li>Quickly, roughly size the things. </li>
<li>Pick 3 </li>
<li>Figure out how we’re going to address them </li>
</ol>
<p>We usually only end up with technical people in the retrospective. For whatever reason, what’s expected of product owners generally remains static across iterations, so there isn’t too much for them to improve on. Depends on the product owner.<a href="http://elegantcode.com/wp-content/uploads/2009/04/image-154.jpg"><img title="IMAGE_154" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; margin: 10px 0px 5px 15px; border-right-width: 0px" height="196" alt="IMAGE_154" src="http://elegantcode.com/wp-content/uploads/2009/04/image-154-thumb.jpg" width="244" align="right" border="0" /></a></p>
<p>Making the list takes up the biggest part of the meeting, from 10-30 minutes for us. Towards the end, it’s usually one person, reaching way deep into things that aren’t going to get addressed anyway. It’s good to cut this off, but my feeling is you need to let it go on for a little bit, so everyone feels they had a chance to say what they needed to.</p>
<p>As I mentioned earlier, sometimes this turns into an…umm…”complaint”-fest. It’s <em>important</em> to cut this off. We’re listing things, not trying to solve anything or blame anyone. We just want to build a mini-backlog of potential things to address, not address them. Addressing them before we know they are the next most important things is waste.</p>
<p>The sizing part is quick and easy. Just Small/Medium/Large, 1/2/3, A/B/C, whatever. The main thing is to call out those big things that you probably won’t be able to address and to get an idea of your velocity in getting these things done.</p>
<p>Picking 3 is the magic part. The three isn’t magical, just a good starting number. Once you’ve gotten and idea of how many “retro points” your team can handle in an iteration, you can use that instead, if you want. Here’s where we have to be honest about what we can get done, in addition to all our other work, as part of the next iteration. If we pick a hard thing, are we really going to have time to address two more little things? Are these little things over here really valuable enough to spend time on? The selection criteria is a function of value <em>and</em> cost, so there is no sense going into problem solving mode until you have those two pieces of information and can select the right amount of stuff to work on.</p>
<p>Once you’ve picked out the things you want to tackle, figuring out how to do it is usually pretty easy. Just don’t let anyone sneak their favorite unaddressed item into the problem solving phase. Focus on just the things you know you’re going to get done.</p>
<p>Finally, everyone agrees that we’re going to address the things we picked. At the end of the iteration, we’ll measure the teams performance against the goals they picked, so it’s important we all agree.</p>
<p>If this sounds a lot like the way we do features and stories in an agile process, yeah, that’s kind of how I think about this. It’s how we address things in our process that we can’t/don’t want to, for whatever reason, introduce into the main backlog for the project. Process improvement is overhead, and the things we come up with in our retrospectives are our backlog for overhead. <strong>These things don’t have first order business value, but second, or third order.</strong></p>
<p><a href="http://www.agilemanagement.net/Articles/Weblog/KanbanRetrospectives.html">Some Lean teams have sworn off retrospectives</a>, perceiving them as waste. Like anything else, retrospectives aren’t going to add value for every team. For my team, retrospectives are quick, easy, and valuable when we stick to the important parts.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/04/09/simple-retrospectives/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Hello World</title>
		<link>http://elegantcode.com/2009/03/05/hello-world/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=hello-world</link>
		<comments>http://elegantcode.com/2009/03/05/hello-world/#comments</comments>
		<pubDate>Thu, 05 Mar 2009 22:28:22 +0000</pubDate>
		<dc:creator>cbilson</dc:creator>
				<category><![CDATA[Esoterica]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/03/05/hello-world/</guid>
		<description><![CDATA[If you can see this, I am blogging for Elegant Code. This is awesome for me and I am totally excited and honored! For those who don’t know me, I am a .NET developer at an investment company in Tacoma, WA. I participate in the Seattle ALT.NET and try to go to local user groups, [...]]]></description>
			<content:encoded><![CDATA[<p>If you can see this, I am blogging for Elegant Code. This is awesome for me and I am totally excited and honored!</p>
<p>For those who don’t know me, I am a .NET developer at <a href="http://russell.com/">an investment company in Tacoma, WA</a>. I participate in the <a href="http://groups.google.com/group/altnetseattle">Seattle ALT.NET</a> and try to go to local user groups, code camps, and other events, when I get a chance…which hasn’t been as often as I’d like this past year with a new baby and a 6 year old!</p>
<p>Anyway, thanks to the Elegant Code crew for inviting me. I am looking forward to starting some good conversations here!</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/03/05/hello-world/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

