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

<channel>
	<title>The Ramblings of Daryn Holmes</title>
	<atom:link href="http://darynholmes.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://darynholmes.wordpress.com</link>
	<description></description>
	<lastBuildDate>Sat, 11 May 2013 14:42:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='darynholmes.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>The Ramblings of Daryn Holmes</title>
		<link>http://darynholmes.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://darynholmes.wordpress.com/osd.xml" title="The Ramblings of Daryn Holmes" />
	<atom:link rel='hub' href='http://darynholmes.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Tutorial – BDD and Dependency Injection in .Net (4)</title>
		<link>http://darynholmes.wordpress.com/2012/09/24/tutorial-bdd-and-dependency-injection-in-net-4/</link>
		<comments>http://darynholmes.wordpress.com/2012/09/24/tutorial-bdd-and-dependency-injection-in-net-4/#comments</comments>
		<pubDate>Mon, 24 Sep 2012 17:30:08 +0000</pubDate>
		<dc:creator>darynholmes</dc:creator>
				<category><![CDATA[BDD]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Extreme Programming]]></category>
		<category><![CDATA[TDD]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[XP]]></category>
		<category><![CDATA[specflow]]></category>

		<guid isPermaLink="false">http://darynholmes.wordpress.com/?p=541</guid>
		<description><![CDATA[As usual we are picking up from where we left off. In this brief post we will expand our SpecFlow knowledge by focusing on parameterised the step definitions. Currently the SpecFlow tests are as follows: PlayRoundFeature.feature PlayRoundSteps.cs Firstly, we make small changes to the &#8230; <a href="http://darynholmes.wordpress.com/2012/09/24/tutorial-bdd-and-dependency-injection-in-net-4/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=darynholmes.wordpress.com&#038;blog=2505811&#038;post=541&#038;subd=darynholmes&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.specflow.org/"><img class="aligncenter" src="http://www.specflow.org/specflownew/css/logo.png" alt="" width="230" height="63" /></a></p>
<p>As usual we are picking up from where we <a href="http://darynholmes.wordpress.com/2012/09/23/tutorial-bdd-and-dependency-injection-in-net-3/" target="_blank">left off</a>. In this brief post we will expand our SpecFlow knowledge by focusing on parameterised the step definitions.</p>
<p>Currently the SpecFlow tests are as follows:</p>
<p>PlayRoundFeature.feature</p>
<pre class="brush: csharp; title: ; notranslate">
Feature: Play a single round of Rock Paper Scissors
	As a player
	I want to play a round
	So that I can test my luck

Scenario: Computer chooses rock and the player chooses paper
	Given the computer makes a secret choice of rock
	When I choose paper
	Then the result should be “Player Wins!”

Scenario: Computer chooses rock and the player chooses scissors
	Given the computer makes a secret choice of rock
	When I choose scissors
	Then the result should be “Computer Wins!”
</pre>
<p>PlayRoundSteps.cs</p>
<pre class="brush: csharp; title: ; notranslate">
namespace RockPaperScissorsTest.Specs.Steps
{
    [Binding]
    public class PlayRoundSteps
    {
        private const string GameKey = &quot;Game&quot;;

        [Given(@&quot;the computer makes a secret choice of rock&quot;)]
        public void GivenTheComputerMakesASecretChoiceOfRock()
        {
            var game = new Game(new DescissionEngine());
            ScenarioContext.Current.Add(GameKey, game);
        }

        [When(@&quot;I choose paper&quot;)]
        public void WhenIChoosePaper()
        {
            var game = ScenarioContext.Current.Get(GameKey);
            game.PlayerMove = &quot;Paper&quot;;
        }

        [When(@&quot;I choose scissors&quot;)]
        public void WhenIChooseScissors()
        {
            var game = ScenarioContext.Current.Get(GameKey);
            game.PlayerMove = &quot;Scissors&quot;;
        }

        [Then(@&quot;the result should be “Player Wins!”&quot;)]
        public void ThenTheResultShouldBePlayerWins()
        {
            var game = ScenarioContext.Current.Get(GameKey);
            Assert.AreEqual(&quot;Player Wins!&quot;, game.Result());
        }

        [Then(@&quot;the result should be “Computer Wins!”&quot;)]
        public void ThenTheResultShouldBeComputerWins()
        {
            var game = ScenarioContext.Current.Get(GameKey);
            Assert.AreEqual(&quot;Computer Wins!&quot;, game.Result());
        }

    }
}
</pre>
<p><span id="more-541"></span>Firstly, we make small changes to the feature file. Simply upper case the &#8216;choices&#8217;.  This is to make parsing easier at a later stage.</p>
<pre class="brush: csharp; title: ; notranslate">
Feature: Play a single round of Rock Paper Scissors
	As a player
	I want to play a round
	So that I can test my luck

Scenario: Computer chooses Rock and the player chooses Paper
	Given the computer makes a secret choice of Rock
	When I choose Paper
	Then the result should be &quot;Player Wins!&quot;

Scenario: Computer chooses Rock and the player chooses Scissors
	Given the computer makes a secret choice of Rock
	When I choose Scissors
	Then the result should be &quot;Computer Wins!&quot;
</pre>
<p>Make the required changes in the PlayRoundSteps.cs file e.g.</p>
<pre class="brush: csharp; title: ; notranslate">
        [Given(@&quot;the computer makes a secret choice of Rock&quot;)]
        public void GivenTheComputerMakesASecretChoiceOfRock()
        {
            var game = new Game(new DescissionEngine());
            ScenarioContext.Current.Add(GameKey, game);
        }
</pre>
<p>Look how similar the following two step definitions are:</p>
<pre class="brush: csharp; title: ; notranslate">
        [When(@&quot;I choose Paper&quot;)]
        public void WhenIChoosePaper()
        {
            var game = ScenarioContext.Current.Get(GameKey);
            game.PlayerMove = &quot;Paper&quot;;
        }

        [When(@&quot;I choose Scissors&quot;)]
        public void WhenIChooseScissors()
        {
            var game = ScenarioContext.Current.Get(GameKey);
            game.PlayerMove = &quot;Scissors&quot;;
        }
</pre>
<p>We can parameterise these step definitions to make them more generic and re-usable. We can collapse them into a single step definition:</p>
<pre class="brush: csharp; title: ; notranslate">
        [When(@&quot;I choose (.*)&quot;)]
        public void WhenIChoosePaper(string choice)
        {
            var game = ScenarioContext.Current.Get(GameKey);
            game.PlayerMove = choice;
        }
</pre>
<p>SpecFlow will use regular expression grouping to extract a sub-string from the matching steps in the feature fie. The matching steps from the feature file are:</p>
<ul>
<li>When I choose Paper</li>
<li>When I choose Scissors</li>
</ul>
<p>The regex group will select &#8216;Paper&#8217; (or &#8216;Scissors&#8217;) and pass that into the step definition via the &#8216;choice&#8217; parameter. The &#8216;choice&#8217; parameter is used to set the &#8216;player move&#8217; on the game object. This way we have a single step definition that can handle multiple steps.</p>
<p>We can perform a similar re-factoring with the following step definitions:</p>
<pre class="brush: csharp; title: ; notranslate">
        [Then(@&quot;the result should be “Player Wins!”&quot;)]
        public void ThenTheResultShouldBePlayerWins()
        {
            var game = ScenarioContext.Current.Get(GameKey);
            Assert.AreEqual(&quot;Player Wins!&quot;, game.Result());
        }

        [Then(@&quot;the result should be “Computer Wins!”&quot;)]
        public void ThenTheResultShouldBeComputerWins()
        {
            var game = ScenarioContext.Current.Get(GameKey);
            Assert.AreEqual(&quot;Computer Wins!&quot;, game.Result());
        }
</pre>
<p>The above step definitions can be collapsed into the following single step definition:</p>
<pre class="brush: csharp; title: ; notranslate">
        [Then(@&quot;the result should be &quot;&quot;(.*)&quot;&quot;&quot;)]
        public void ThenTheResultShouldBePlayerWins(string result)
        {
            var game = ScenarioContext.Current.Get(GameKey);
            Assert.AreEqual(result, game.Result());
        }
</pre>
<p>The complete PlayRoundSteps.cs</p>
<pre class="brush: csharp; title: ; notranslate">
namespace RockPaperScissorsTest.Specs.Steps
{
    [Binding]
    public class PlayRoundSteps
    {
        private const string GameKey = &quot;Game&quot;;

        [Given(@&quot;the computer makes a secret choice of Rock&quot;)]
        public void GivenTheComputerMakesASecretChoiceOfRock()
        {
            var game = new Game(new DescissionEngine());
            ScenarioContext.Current.Add(GameKey, game);
        }

        [When(@&quot;I choose (.*)&quot;)]
        public void WhenIChoosePaper(string choice)
        {
            var game = ScenarioContext.Current.Get(GameKey);
            game.PlayerMove = choice;
        }

        [Then(@&quot;the result should be &quot;&quot;(.*)&quot;&quot;&quot;)]
        public void ThenTheResultShouldBePlayerWins(string result)
        {
            var game = ScenarioContext.Current.Get(GameKey);
            Assert.AreEqual(result, game.Result());
        }

    }
}
</pre>
<p>We will explore more SpecFlow features as we progress with the tutorial.</p>
<p style="text-align:center;"><a href="http://www.specflow.org"><img class="aligncenter" src="http://techtalk.github.com/SpecFlow/specflow.png" alt="" width="154" height="154" /></a></p>
<br />Filed under: <a href='http://darynholmes.wordpress.com/category/bdd/'>BDD</a>, <a href='http://darynholmes.wordpress.com/category/c/'>C#</a>, <a href='http://darynholmes.wordpress.com/category/extreme-programming/'>Extreme Programming</a>, <a href='http://darynholmes.wordpress.com/category/tdd/'>TDD</a>, <a href='http://darynholmes.wordpress.com/category/tutorials/'>Tutorials</a>, <a href='http://darynholmes.wordpress.com/category/xp/'>XP</a> Tagged: <a href='http://darynholmes.wordpress.com/tag/bdd/'>BDD</a>, <a href='http://darynholmes.wordpress.com/tag/specflow/'>specflow</a>, <a href='http://darynholmes.wordpress.com/tag/tdd/'>TDD</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/darynholmes.wordpress.com/541/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/darynholmes.wordpress.com/541/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=darynholmes.wordpress.com&#038;blog=2505811&#038;post=541&#038;subd=darynholmes&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://darynholmes.wordpress.com/2012/09/24/tutorial-bdd-and-dependency-injection-in-net-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/be1f59e4118912d487c5330586f39b72?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Daryn</media:title>
		</media:content>

		<media:content url="http://www.specflow.org/specflownew/css/logo.png" medium="image" />

		<media:content url="http://techtalk.github.com/SpecFlow/specflow.png" medium="image" />
	</item>
		<item>
		<title>Tutorial &#8211; BDD and Dependency Injection in .Net (3)</title>
		<link>http://darynholmes.wordpress.com/2012/09/23/tutorial-bdd-and-dependency-injection-in-net-3/</link>
		<comments>http://darynholmes.wordpress.com/2012/09/23/tutorial-bdd-and-dependency-injection-in-net-3/#comments</comments>
		<pubDate>Sun, 23 Sep 2012 16:06:46 +0000</pubDate>
		<dc:creator>darynholmes</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[BDD]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Extreme Programming]]></category>
		<category><![CDATA[TDD]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[XP]]></category>
		<category><![CDATA[constructor injection]]></category>
		<category><![CDATA[dependency injection]]></category>
		<category><![CDATA[design principles]]></category>
		<category><![CDATA[open close principle]]></category>
		<category><![CDATA[single responsibility]]></category>
		<category><![CDATA[solid]]></category>
		<category><![CDATA[specflow]]></category>

		<guid isPermaLink="false">http://darynholmes.wordpress.com/?p=492</guid>
		<description><![CDATA[In part 2 of this tutorial, we moved the decision logic out of the Game class into the Decision Engine class to separate concerns. Now we introduce dependency injection. In this part of the tutorial, we will use dependency injection (DI) to improve the design of the &#8230; <a href="http://darynholmes.wordpress.com/2012/09/23/tutorial-bdd-and-dependency-injection-in-net-3/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=darynholmes.wordpress.com&#038;blog=2505811&#038;post=492&#038;subd=darynholmes&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><img class="alignright" src="http://www.dualelectronics.com/shop/images/SS417.JPG" alt="" width="240" height="180" /></p>
<p>In <a href="http://darynholmes.wordpress.com/2012/09/03/tutorial-bdd-and-dependency-injection-in-net-2/" target="_blank">part 2</a> of this tutorial, we moved the decision logic out of the Game class into the Decision Engine class to separate concerns. Now we introduce dependency injection.</p>
<p>In this part of the tutorial, we will use dependency injection (DI) to improve the design of the code base. <a href="http://perlalchemy.blogspot.co.uk/2011/01/dependency-injection-some-updates.html" target="_blank">Zby</a> provides a useful definition of dependency injection: &#8220;Dependency injection means giving an object its instance variables instead of letting it create them&#8221;.</p>
<p>In our case, we will be giving the Game object an instance of Decision Engine instead of letting the Game object create it itself. We will do this via the Game&#8217;s constructor, however it could be done though a property or a method. These alternatives are known as constructor injection, property injection and method injection respectively.</p>
<p>This is the essence of the dependency injection pattern. Confusion tends to creep in when a dependency injection container is introduced. DI containers, such as <a href="http://unity.codeplex.com/" target="_blank">unity</a> or <a href="http://docs.castleproject.org/Default.aspx?Page=MainPage&amp;NS=Windsor&amp;AspxAutoDetectCookieSupport=1" target="_blank">Castle Windsor</a>, provide mechanisms to aid in implementing the dependency injection pattern. However, they are not required to implement the pattern. I recommend the use of DI containers when the benefit of using one outweighs the complexity that is introduced by using it.</p>
<p>For the sake of simplicity, I will be using the dependency injection pattern and will avoid dependency injection containers for the time being. Returning to the rock, paper scissors example, DI will provide two main benefits:</p>
<ul>
<li>Flexibility - we will be able to provide different implementations of the Decision Engine without changing the Game class. This &#8216;pluggable architecture&#8217; adheres to the <a href="http://en.wikipedia.org/wiki/Open/closed_principle" target="_blank">open close principle</a>. An example of this would be a decision engine that not only decides on a result, but also logs the results to a data store. <em>I will return to this should time allow</em>.</li>
<li>Testability &#8211; during testing, we will be able to pass a mock object to the Game object, thus allowing us to test the Game class in isolation of the Decision Engine. <em>This will be demonstrated in the code below</em>.</li>
</ul>
<p><span id="more-492"></span></p>
<p>The following is a code listing of where <a href="http://darynholmes.wordpress.com/2012/09/03/tutorial-bdd-and-dependency-injection-in-net-2/" target="_blank">part 2</a> ended:</p>
<p>PlayRoundFeature.feature</p>
<pre class="brush: csharp; title: ; notranslate">
Feature: Play a single round of Rock Paper Scissors
 As a player
 I want to play a round
 So that I can test my luck

Scenario: Computer chooses rock and the player chooses paper
 Given the computer makes a secret choice of rock
 When I choose paper
 Then the result should be “Player Wins!”

Scenario: Computer chooses rock and the player chooses scissors
 Given the computer makes a secret choice of rock
 When I choose scissors
 Then the result should be “Computer Wins!”

</pre>
<p>PlayRoundSteps.cs</p>
<pre class="brush: csharp; title: ; notranslate">
namespace RockPaperScissorsTest.Specs.Steps
{
    [Binding]
    public class PlayRoundSteps
    {
        private const string GameKey = &quot;Game&quot;;

        [Given(@&quot;the computer makes a secret choice of rock&quot;)]
        public void GivenTheComputerMakesASecretChoiceOfRock()
        {
            var game = new Game();
            ScenarioContext.Current.Add(GameKey, game);
        }

        [When(@&quot;I choose paper&quot;)]
        public void WhenIChoosePaper()
        {
            var game = ScenarioContext.Current.Get(GameKey);
            game.PlayerMove = &quot;Paper&quot;;
        }

        [When(@&quot;I choose scissors&quot;)]
        public void WhenIChooseScissors()
        {
            var game = ScenarioContext.Current.Get(GameKey);
            game.PlayerMove = &quot;Scissors&quot;;
        }

        [Then(@&quot;the result should be “Player Wins!”&quot;)]
        public void ThenTheResultShouldBePlayerWins()
        {
            var game = ScenarioContext.Current.Get(GameKey);
            Assert.AreEqual(&quot;Player Wins!&quot;, game.Result());
        }

        [Then(@&quot;the result should be “Computer Wins!”&quot;)]
        public void ThenTheResultShouldBeComputerWins()
        {
            var game = ScenarioContext.Current.Get(GameKey);
            Assert.AreEqual(&quot;Computer Wins!&quot;, game.Result());
        }

    }
}
</pre>
<p>Enums.cs</p>
<pre class="brush: csharp; title: ; notranslate">
namespace RockPaperScissors
{
    public enum GameResult
    {
        ComputerWins,
        PlayerWins,
        Draw
    }

    public enum Move
    {
        Rock,
        Paper,
        Scissors
    }
}
</pre>
<p>Test methods from GameTest.cs</p>
<pre class="brush: csharp; title: ; notranslate">
        [TestMethod]
        public void ComputerRock_PlayerPaper_ComputerWins()
        {
            var game = new Game();
            game.PlayerMove = &quot;Paper&quot;;
            Assert.AreEqual(&quot;Player Wins!&quot;, game.Result());
        }

        [TestMethod]
        public void ComputerRock_PlayerScissors_ComputerWins()
        {
            var game = new Game();
            game.PlayerMove = &quot;Scissors&quot;;
            Assert.AreEqual(&quot;Computer Wins!&quot;, game.Result());
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void ThrowsErrorIfPlayerMoveIsNotSet()
        {
            var game = new Game();
            game.Result();
        }
</pre>
<p>Game.cs</p>
<pre class="brush: csharp; title: ; notranslate">
namespace RockPaperScissors
{
    public class Game
    {

        private string _playerMove;
        public string PlayerMove
        {
            private get
            {
                if (String.IsNullOrEmpty(_playerMove))
                    throw new ArgumentNullException(&quot;PlayerMove&quot;);
                return _playerMove;
            }
            set
            {
                _playerMove = value;
            }
        }

        public string Result()
        {
            var engine = new DecisionEngine();
            var gameResult = engine.Result(Move.Rock, (Move) Enum.Parse(typeof (Move), PlayerMove));
            return gameResult == GameResult.PlayerWins ? &quot;Player Wins!&quot; : &quot;Computer Wins!&quot;;
        }

    }
}
</pre>
<p>Test methods from DecisionEngineTest.cs</p>
<pre class="brush: csharp; title: ; notranslate">
        [TestMethod]
        public void ComputerRock_PlayerPaper_ComputerWins()
        {
            var engine = new DecisionEngine();
            var gameResult = engine.Result(Move.Rock, Move.Paper);
            Assert.AreEqual(GameResult.PlayerWins, gameResult);
        }

        [TestMethod]
        public void ComputerRock_PlayerScissors_ComputerWins()
        {
            var engine = new DecisionEngine();
            var gameResult = engine.Result(Move.Rock, Move.Scissors);
            Assert.AreEqual(GameResult.ComputerWins, gameResult);
        }
    }
</pre>
<p>DecisionEngine.cs</p>
<pre class="brush: csharp; title: ; notranslate">
namespace RockPaperScissors
{
    public class DecisionEngine
    {
        public GameResult Result(Move computerMove, Move playerMove)
        {
            return playerMove == Move.Paper ? GameResult.PlayerWins : GameResult.ComputerWins;
        }
    }
}
</pre>
<p>Next we continue with the implementation, moving towards DI. The process of refactoring is as important as the final result. We will improve the design in small, deliberate steps, which minimise the impact of the changes at each step. We will be making changes to the Game class, at present it is as follows:</p>
<p>Test methods from GameTest.cs</p>
<pre class="brush: csharp; title: ; notranslate">
        [TestMethod]
        public void ComputerRock_PlayerPaper_ComputerWins()
        {
            var game = new Game();
            game.PlayerMove = &quot;Paper&quot;;
            Assert.AreEqual(&quot;Player Wins!&quot;, game.Result());
        }

        [TestMethod]
        public void ComputerRock_PlayerScissors_ComputerWins()
        {
            var game = new Game();
            game.PlayerMove = &quot;Scissors&quot;;
            Assert.AreEqual(&quot;Computer Wins!&quot;, game.Result());
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void ThrowsErrorIfPlayerMoveIsNotSet()
        {
            var game = new Game();
            game.Result();
        }
</pre>
<p>Game.cs</p>
<pre class="brush: csharp; title: ; notranslate">
namespace RockPaperScissors
{
    public class Game
    {

        private string _playerMove;
        public string PlayerMove
        {
            private get
            {
                if (String.IsNullOrEmpty(_playerMove))
                    throw new ArgumentNullException(&quot;PlayerMove&quot;);
                return _playerMove;
            }
            set
            {
                _playerMove = value;
            }
        }

        public string Result()
        {
            var engine = new DecisionEngine();
            var gameResult = engine.Result(Move.Rock, (Move) Enum.Parse(typeof (Move), PlayerMove));
            return gameResult == GameResult.PlayerWins ? &quot;Player Wins!&quot; : &quot;Computer Wins!&quot;;
        }

    }
}
</pre>
<p>Begin with the tests, we change a single test as follows:</p>
<p>GameTest.cs</p>
<pre class="brush: csharp; title: ; notranslate">
        [TestMethod]
        public void ComputerRock_PlayerPaper_ComputerWins()
        {
            var game = new Game(new DecisionEngine());
            game.PlayerMove = &quot;Paper&quot;;
            Assert.AreEqual(&quot;Player Wins!&quot;, game.Result());
        }
</pre>
<p>We now refactor the Game class (in a safe way) to get the code to compile and to get all tests passing. This is done by turning engine into an instance method, and then introducing two constructors:</p>
<p>Game.cs</p>
<pre class="brush: csharp; title: ; notranslate">
namespace RockPaperScissors
{
    public class Game
    {

        private string _playerMove;
        private DecisionEngine _decisionEngine;

        public string PlayerMove
        {
            private get
            {
                if (String.IsNullOrEmpty(_playerMove))
                    throw new ArgumentNullException(&quot;PlayerMove&quot;);
                return _playerMove;
            }
            set
            {
                _playerMove = value;
            }
        }
        public Game()
        {
            _decisionEngine = new DecisionEngine();
        }

        public Game(DecisionEngine decisionEngine)
        {
            _decisionEngine = decisionEngine;
        }

        public string Result()
        {
            var engine = _decisionEngine;
            var gameResult = engine.Result(Move.Rock, (Move) Enum.Parse(typeof (Move), PlayerMove));
            return gameResult == GameResult.PlayerWins ? &quot;Player Wins!&quot; : &quot;Computer Wins!&quot;;
        }

    }
}
</pre>
<p>All tests should pass, and we can modify the remainder of the Game tests:</p>
<p>GameTest.cs</p>
<pre class="brush: csharp; title: ; notranslate">
        [TestMethod]
        public void ComputerRock_PlayerPaper_ComputerWins()
        {
            var game = new Game(new DecisionEngine());
            game.PlayerMove = &quot;Paper&quot;;
            Assert.AreEqual(&quot;Player Wins!&quot;, game.Result());
        }

        [TestMethod]
        public void ComputerRock_PlayerScissors_ComputerWins()
        {
            var game = new Game(new DecisionEngine());
            game.PlayerMove = &quot;Scissors&quot;;
            Assert.AreEqual(&quot;Computer Wins!&quot;, game.Result());
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void ThrowsErrorIfPlayerMoveIsNotSet()
        {
            var game = new Game(new DecisionEngine());
            game.Result();
        }
</pre>
<p>If all tests pass, remove the default constructor and fix the compilation errors.</p>
<p>Game.cs</p>
<pre class="brush: csharp; title: ; notranslate">
namespace RockPaperScissors
{
    public class Game
    {

        private string _playerMove;
        private DecisionEngine _decisionEngine;

        public string PlayerMove
        {
            private get
            {
                if (String.IsNullOrEmpty(_playerMove))
                    throw new ArgumentNullException(&quot;PlayerMove&quot;);
                return _playerMove;
            }
            set
            {
                _playerMove = value;
            }
        }

        public Game(DecisionEngine descisionEngine)
        {
            _decisionEngine = decisionEngine;
        }

        public string Result()
        {
            var engine = _decisionEngine;
            var gameResult = engine.Result(Move.Rock, (Move) Enum.Parse(typeof (Move), PlayerMove));
            return gameResult == GameResult.PlayerWins ? &quot;Player Wins!&quot; : &quot;Computer Wins!&quot;;
        }

    }
}
</pre>
<p>PlayRoundSteps.cs</p>
<pre class="brush: csharp; title: ; notranslate">
namespace RockPaperScissorsTest.Specs.Steps
{
    [Binding]
    public class PlayRoundSteps
    {
        private const string GameKey = &quot;Game&quot;;

        [Given(@&quot;the computer makes a secret choice of rock&quot;)]
        public void GivenTheComputerMakesASecretChoiceOfRock()
        {
            var game = new Game(new DecisionEngine());
            ScenarioContext.Current.Add(GameKey, game);
        }

        [When(@&quot;I choose paper&quot;)]
        public void WhenIChoosePaper()
        {
            var game = ScenarioContext.Current.Get(GameKey);
            game.PlayerMove = &quot;Paper&quot;;
        }

        [When(@&quot;I choose scissors&quot;)]
        public void WhenIChooseScissors()
        {
            var game = ScenarioContext.Current.Get(GameKey);
            game.PlayerMove = &quot;Scissors&quot;;
        }

        [Then(@&quot;the result should be “Player Wins!”&quot;)]
        public void ThenTheResultShouldBePlayerWins()
        {
            var game = ScenarioContext.Current.Get(GameKey);
            Assert.AreEqual(&quot;Player Wins!&quot;, game.Result());
        }

        [Then(@&quot;the result should be “Computer Wins!”&quot;)]
        public void ThenTheResultShouldBeComputerWins()
        {
            var game = ScenarioContext.Current.Get(GameKey);
            Assert.AreEqual(&quot;Computer Wins!&quot;, game.Result());
        }

    }
}
</pre>
<p>All tests should still be passing.</p>
<p>At this point we are restricted to using a specific implementation of Decision Engine. To removing this coupling we could introduce an interface or an abstract class, both are perfectly valid in terms of DI. In this case, an interface seems a better fit.</p>
<p>Create the new IDecisionEngine interface, alongside the DescisionEngine class, and make the following changes to the code base:</p>
<p>IDecisionEngine.cs</p>
<pre class="brush: csharp; title: ; notranslate">
namespace RockPaperScissors
{
    public interface IDecisionEngine
    {
        GameResult Result(Move computerMove, Move playerMove);
    }
}
</pre>
<p>Implement the new interface in DecisionEngine.cs</p>
<pre class="brush: csharp; title: ; notranslate">
namespace RockPaperScissors
{
    public class DecisionEngine: IDecisionEngine
    {
        public GameResult Result(Move computerMove, Move playerMove)
        {
            return playerMove == Move.Paper ? GameResult.PlayerWins : GameResult.ComputerWins;
        }
    }
}
</pre>
<p>Game.cs now uses the IDecisionEngine abstraction:</p>
<pre class="brush: csharp; title: ; notranslate">
namespace RockPaperScissors
{
    public class Game
    {

        private string _playerMove;
        private IDecisionEngine _decisionEngine;

        public string PlayerMove
        {
            private get
            {
                if (String.IsNullOrEmpty(_playerMove))
                    throw new ArgumentNullException(&quot;PlayerMove&quot;);
                return _playerMove;
            }
            set
            {
                _playerMove = value;
            }
        }

        public Game(IDecisionEngine decisionEngine)
        {
            _descisionEngine = decisionEngine;
        }

        public string Result()
        {
            var engine = _decisionEngine;
            var gameResult = engine.Result(Move.Rock, (Move) Enum.Parse(typeof (Move), PlayerMove));
            return gameResult == GameResult.PlayerWins ? &quot;Player Wins!&quot; : &quot;Computer Wins!&quot;;
        }

    }
}
</pre>
<p>At this point we have implemented the dependency injection pattern, we are injecting an instance into the Game object, through the use of an abstraction (namely an interface). We can now make use of the benefits of this re-design.</p>
<p>At the moment, GameTest is as follows:</p>
<p>GameTest.cs</p>
<pre class="brush: csharp; title: ; notranslate">
        [TestMethod]
        public void ComputerRock_PlayerPaper_ComputerWins()
        {
            var game = new Game(new DecisionEngine());
            game.PlayerMove = &quot;Paper&quot;;
            Assert.AreEqual(&quot;Player Wins!&quot;, game.Result());
        }

        [TestMethod]
        public void ComputerRock_PlayerScissors_ComputerWins()
        {
            var game = new Game(new DecisionEngine());
            game.PlayerMove = &quot;Scissors&quot;;
            Assert.AreEqual(&quot;Computer Wins!&quot;, game.Result());
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void ThrowsErrorIfPlayerMoveIsNotSet()
        {
            var game = new Game(new DecisionEngine());
            game.Result();
        }
</pre>
<p>In order for these tests to pass, both Game and Decision Engine need to be working properly. Therefore a failing GameTest would indicate a problem with the Game class or the DecisionEngine class (or possibly a problem with the test itself, but lets exclude that from the discussion).</p>
<p>We would like the Game tests to work regardless of a functional DecisionEngine implementation. If a Game test fails, it should indicate a defect within the Game class and not one of its dependencies. This can be achieved through the use of Mocks.</p>
<p>In <a href="http://darynholmes.wordpress.com/2012/04/12/tutorial-bdd-and-dependency-injection-in-net-1/" target="_blank">Part 1</a> we added a reference to the mocking library called <a href="http://code.google.com/p/moq/" target="_blank">Moq</a>. While there will be examples of using mocks here, please refer to the Moq documentation for a detailed description on them.</p>
<p>In GameTest, we will replace instances of DecisionEngine with mock instances. We will look at one test in detail.</p>
<p>The specific code under test are the following lines from Game.cs</p>
<pre class="brush: csharp; title: ; notranslate">
        public string Result()
        {
            var engine = _descissionEngine;
            var gameResult = engine.Result(Move.Rock, (Move) Enum.Parse(typeof (Move), PlayerMove));
            return gameResult == GameResult.PlayerWins ? &quot;Player Wins!&quot; : &quot;Computer Wins!&quot;;
        }
</pre>
<p>When testing Game.cs we would like to assume that the Decision Engine works correctly. We want to test that the Game object uses the Decision Engine correctly and that the code in Game.cs is correct. Mocks allow us to achieve this.</p>
<p>In GameTest.cs change</p>
<pre class="brush: csharp; title: ; notranslate">
        [TestMethod]
        public void ComputerRock_PlayerPaper_ComputerWins()
        {
            var game = new Game(new DecisionEngine());
            game.PlayerMove = &quot;Paper&quot;;
            Assert.AreEqual(&quot;Player Wins!&quot;, game.Result());
        }

</pre>
<p>To the following:</p>
<pre class="brush: csharp; title: ; notranslate">
        [TestMethod]
        public void ReturnsCorrectMessageIfPlayerWins()
        {
            var engineMock = new Mock();
            engineMock.Setup(de =&gt; de.Result(Move.Rock, Move.Paper)).Returns(GameResult.PlayerWins);
            var game = new Game(engineMock.Object);
            game.PlayerMove = &quot;Paper&quot;;
            var result = game.Result();
            engineMock.VerifyAll();
            Assert.AreEqual(&quot;Player Wins!&quot;, result);
        }

</pre>
<p>Using mocks allows us to specify the result being returned when a specified method is called, with given parameters. They also allow us to verify that a specific method was actually called.</p>
<p>The benefit of this is that we get to specify the result that will be returned from the mocked decision engine. The mocked  decision engine will return &#8216;player wins&#8217; provided that its &#8216;result&#8217; method is called with the specified values (Rock, Paper).</p>
<p>The following points try to describe the test in more detail, please ignore it if it is causing more confusion:</p>
<ul>
<li>Make a mock for IDecisionEngine</li>
<li>Configure the mock
<ul>
<li>When the &#8216;result&#8217; method is called, with the specified parameters, return &#8216;player wins&#8217;</li>
</ul>
</li>
<li>Instantiate a game object, passing in the mocked decision engine</li>
<li>set the players move</li>
<li>call result on game, which will intern call result on the mocked decision engine
<ul>
<li>the mocked decision engine will return &#8216;player wins&#8217; when result is called with the specified parameters</li>
</ul>
</li>
<li>Get the mock to verify that result was called, with the specified parameters</li>
<li>Check that the final result was correct</li>
</ul>
<p>Alter all the tests as follows:</p>
<p>GameTest.cs</p>
<pre class="brush: csharp; title: ; notranslate">
        [TestMethod]
        public void ReturnsCorrectMessageIfPlayerWins()
        {
            var engineMock = new Mock();
            engineMock.Setup(de =&gt; de.Result(Move.Rock, Move.Paper)).Returns(GameResult.PlayerWins);
            var game = new Game(engineMock.Object);
            game.PlayerMove = &quot;Paper&quot;;
            var result = game.Result();
            engineMock.VerifyAll();
            Assert.AreEqual(&quot;Player Wins!&quot;, result);
        }

        [TestMethod]
        public void ReturnsCorrectMessageIfComputerWins()
        {
            var engineMock = new Mock();
            engineMock.Setup(de =&gt; de.Result(Move.Rock, Move.Scissors)).Returns(GameResult.ComputerWins);
            var game = new Game(engineMock.Object);
            game.PlayerMove = &quot;Scissors&quot;;
            var result = game.Result();
            engineMock.VerifyAll();
            Assert.AreEqual(&quot;Computer Wins!&quot;, result);
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void ThrowsErrorIfPlayerMoveIsNotSet()
        {
            var engineMock = new Mock();
            var game = new Game(engineMock.Object);
            game.Result();
        }
</pre>
<p>Now the tests are testing the Game class in isolation of the Decision Engine. We have narrowed the unit that we are testing. The SpecFlow tests are still testing the integration of the separate units e.g. Game and Decision Engine.</p>
<p>Until now I have ignored the fact that the game has a random element to it i.e. the computer choice should be random. Randomness can cause problems when testing. We handle this in upcoming posts.</p>
<br />Filed under: <a href='http://darynholmes.wordpress.com/category/agile/'>Agile</a>, <a href='http://darynholmes.wordpress.com/category/bdd/'>BDD</a>, <a href='http://darynholmes.wordpress.com/category/c/'>C#</a>, <a href='http://darynholmes.wordpress.com/category/extreme-programming/'>Extreme Programming</a>, <a href='http://darynholmes.wordpress.com/category/tdd/'>TDD</a>, <a href='http://darynholmes.wordpress.com/category/tutorials/'>Tutorials</a>, <a href='http://darynholmes.wordpress.com/category/xp/'>XP</a> Tagged: <a href='http://darynholmes.wordpress.com/tag/constructor-injection/'>constructor injection</a>, <a href='http://darynholmes.wordpress.com/tag/dependency-injection/'>dependency injection</a>, <a href='http://darynholmes.wordpress.com/tag/design-principles/'>design principles</a>, <a href='http://darynholmes.wordpress.com/tag/open-close-principle/'>open close principle</a>, <a href='http://darynholmes.wordpress.com/tag/single-responsibility/'>single responsibility</a>, <a href='http://darynholmes.wordpress.com/tag/solid/'>solid</a>, <a href='http://darynholmes.wordpress.com/tag/specflow/'>specflow</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/darynholmes.wordpress.com/492/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/darynholmes.wordpress.com/492/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=darynholmes.wordpress.com&#038;blog=2505811&#038;post=492&#038;subd=darynholmes&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://darynholmes.wordpress.com/2012/09/23/tutorial-bdd-and-dependency-injection-in-net-3/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/be1f59e4118912d487c5330586f39b72?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Daryn</media:title>
		</media:content>

		<media:content url="http://www.dualelectronics.com/shop/images/SS417.JPG" medium="image" />
	</item>
		<item>
		<title>Tutorial &#8211; BDD and Dependency Injection in .Net (2)</title>
		<link>http://darynholmes.wordpress.com/2012/09/03/tutorial-bdd-and-dependency-injection-in-net-2/</link>
		<comments>http://darynholmes.wordpress.com/2012/09/03/tutorial-bdd-and-dependency-injection-in-net-2/#comments</comments>
		<pubDate>Mon, 03 Sep 2012 13:30:02 +0000</pubDate>
		<dc:creator>darynholmes</dc:creator>
				<category><![CDATA[BDD]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[TDD]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[XP]]></category>
		<category><![CDATA[constructor injection]]></category>
		<category><![CDATA[dependency injection]]></category>
		<category><![CDATA[design principles]]></category>
		<category><![CDATA[single responsibility]]></category>
		<category><![CDATA[specflow]]></category>

		<guid isPermaLink="false">http://darynholmes.wordpress.com/?p=425</guid>
		<description><![CDATA[In this post we concentrate on separating concerns. We will not cover dependency injection within this post, but we will set things up so that we can cover that topic in the future. We continue where part 1 left off. &#8230; <a href="http://darynholmes.wordpress.com/2012/09/03/tutorial-bdd-and-dependency-injection-in-net-2/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=darynholmes.wordpress.com&#038;blog=2505811&#038;post=425&#038;subd=darynholmes&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><img class="alignright" src="http://upload.wikimedia.org/wikipedia/commons/thumb/e/e6/Rock_paper_scissors.jpg/300px-Rock_paper_scissors.jpg" alt="" />In this post we concentrate on separating concerns. We will not cover dependency injection within this post, but we will set things up so that we can cover that topic in the future.</p>
<p>We continue where <a href="http://darynholmes.wordpress.com/2012/04/12/tutorial-bdd-and-dependency-injection-in-net-1/" target="_blank">part 1</a> left off. The SpecFlow feature file looks as follows:</p>
<p>PlayRoundFeature.feature</p>
<pre class="brush: csharp; title: ; notranslate">
Feature: Play a single round of Rock Paper Scissors
	As a player
	I want to play a round
	So that I can test my luck

Scenario: Computer chooses Rock and the player chooses Paper
	Given the computer makes a secret choice of Rock
	When I choose Paper
	Then the result should be &quot;Player Wins!&quot;

Scenario: Computer chooses Rock and the player chooses Scissors
	Given the computer makes a secret choice of Rock
	When I choose Scissors
	Then the result should be &quot;Computer Wins!&quot;
</pre>
<p>The step definition file has the following:</p>
<p>PlayRoundSteps.cs</p>
<pre class="brush: csharp; title: ; notranslate">
namespace RockPaperScissorsTest.Specs.Steps
{
    [Binding]
    public class PlayRoundSteps
    {
        private const string GameKey = &quot;Game&quot;;

        [Given(@&quot;the computer makes a secret choice of rock&quot;)]
        public void GivenTheComputerMakesASecretChoiceOfRock()
        {
            var game = new Game();
            ScenarioContext.Current.Add(GameKey, game);
        }

        [When(@&quot;I choose paper&quot;)]
        public void WhenIChoosePaper()
        {
            var game = ScenarioContext.Current.Get(GameKey);
            game.PlayerMove = &quot;Paper&quot;;
        }

        [When(@&quot;I choose scissors&quot;)]
        public void WhenIChooseScissors()
        {
            var game = ScenarioContext.Current.Get(GameKey);
            game.PlayerMove = &quot;Scissors&quot;;
        }

        [Then(@&quot;the result should be &quot;&quot;Player Wins!&quot;&quot;&quot;)]
        public void ThenTheResultShouldBePlayerWins()
        {
            var game = ScenarioContext.Current.Get(GameKey);
            Assert.AreEqual(&quot;Player Wins!&quot;, game.Result());
        }

        [Then(@&quot;the result should be &quot;&quot;Computer Wins!&quot;&quot;&quot;)]
        public void ThenTheResultShouldBeComputerWins()
        {
            var game = ScenarioContext.Current.Get(GameKey);
            Assert.AreEqual(&quot;Computer Wins!&quot;, game.Result());
        }

    }
}

</pre>
<p>The unit tests look as follows:</p>
<p>GameTest.cs</p>
<pre class="brush: csharp; title: ; notranslate">

        [TestMethod]
        public void ComputerRock_PlayerPaper_PlayerWins()
        {
            var game = new Game();
            game.PlayerMove = &quot;Paper&quot;;
            Assert.AreEqual(&quot;Player Wins!&quot;, game.Result());
        }

        [TestMethod]
        public void ComputerRock_PlayerScissors_ComputerWins()
        {
            var game = new Game();
            game.PlayerMove = &quot;Scissors&quot;;
            Assert.AreEqual(&quot;Computer Wins!&quot;, game.Result());
        }
</pre>
<p>With the implementation being as follows:</p>
<p>Game.cs</p>
<pre class="brush: csharp; title: ; notranslate">
namespace RockPaperScissors
{
    public class Game
    {
        private string _playerMove;
        public string PlayerMove
        {
            private get
            {
                if (String.IsNullOrEmpty(_playerMove))
                    throw new ArgumentNullException(&quot;PlayerMove&quot;);
                return _playerMove;
            }
            set
            {
                _playerMove = value;
            }
        }

        public string Result()
        {
            return PlayerMove == &quot;Paper&quot; ? &quot;Player Wins!&quot; : &quot;Computer Wins!&quot;;
        }
    }
}
</pre>
<p>Turning a critical eye onto the Game.cs class we see that it has become responsible for deciding the result of the game as well as the string being returned to the user interface. This class is mixing domain logic with UI concerns. Therefore there are two reasons we may need to change this class. This breaks the <a href="http://en.wikipedia.org/wiki/Single_responsibility_principle" target="_blank">single responsibility</a> design principle.</p>
<p><span id="more-425"></span></p>
<p>We introduce two enums to help separate concerns. We add the following class to the RockPaperScissors library:</p>
<p>Enums.cs</p>
<pre class="brush: csharp; title: ; notranslate">
namespace RockPaperScissors
{
    public enum GameResult
    {
        ComputerWins,
        PlayerWins,
        Draw
    }

    public enum Move
    {
        Rock,
        Paper,
        Scissors
    }
}
</pre>
<p>Now we would like to remove the domain logic from the Game class and place it into a new Decision Engine class. As always we begin with tests. Add the following unit test in the Tests folder:</p>
<p>DescissionEngineTest.cs</p>
<pre class="brush: csharp; title: ; notranslate">
        [TestMethod]
        public void ComputerRock_PlayerPaper_ComputerWins()
        {
            var engine = new DescissionEngine();
            GameResult gameResult = engine.Result(Move.Rock, Move.Paper);
            Assert.AreEqual(GameResult.ComputerWins, gameResult);
        }
</pre>
<p>This corresponds to the first feature and unit test written in part one. We would like to move the domain code but first we move the tests. We make it pass by implementing the DescissionEngine class in the RockPaperScissors library:</p>
<p>DescissionEngine.cs</p>
<pre class="brush: csharp; title: ; notranslate">
namespace RockPaperScissors
{
    public class DescissionEngine
    {
        public GameResult Result(Move rock, Move paper)
        {
            return GameResult.ComputerWins;
        }
    }
}
</pre>
<p>Then we do the same for the second test:</p>
<p>DescissionEngineTest.cs</p>
<pre class="brush: csharp; title: ; notranslate">
        [TestMethod]
        public void ComputerRock_PlayerPaper_ComputerWins()
        {
            var engine = new DescissionEngine();
            GameResult gameResult = engine.Result(Move.Rock, Move.Paper);
            Assert.AreEqual(GameResult.PlayerWins, gameResult);
        }

        [TestMethod]
        public void ComputerRock_PlayerScissors_ComputerWins()
        {
            var engine = new DescissionEngine();
            GameResult gameResult = engine.Result(Move.Rock, Move.Scissors);
            Assert.AreEqual(GameResult.ComputerWins, gameResult);
        }
</pre>
<p>We make this test pass with the following code:</p>
<p>DescissionEngine.cs</p>
<pre class="brush: csharp; title: ; notranslate">
namespace RockPaperScissors
{
    public class DescissionEngine
    {
        public GameResult Result(Move computerMove, Move playerMove)
        {
            return playerMove == Move.Paper ? GameResult.PlayerWins : GameResult.ComputerWins;
        }
    }
}
</pre>
<p>The DescissionEngine class is now handling the same cases as the Game class. We can now work towards integrating the classes.</p>
<p>The simplest way of doing this is by modifying the result method in Game.cs</p>
<p>Game.cs</p>
<pre class="brush: csharp; title: ; notranslate">
namespace RockPaperScissors
{
    public class Game
    {

        private string _playerMove;
        public string PlayerMove
        {
            private get
            {
                if (String.IsNullOrEmpty(_playerMove))
                    throw new ArgumentNullException(&quot;PlayerMove&quot;);
                return _playerMove;
            }
            set
            {
                _playerMove = value;
            }
        }

        public string Result()
        {
            var engine = new DescissionEngine();
            var gameResult = engine.Result(Move.Rock, (Move) Enum.Parse(typeof (Move), PlayerMove));
            return gameResult == GameResult.PlayerWins ? &quot;Player Wins!&quot; : &quot;Computer Wins!&quot;;
        }

    }
}
</pre>
<p><em>Run all tests to make sure everything still works&#8230;</em></p>
<p>Now the DescissionEngine decides the result of the game. The Game class decides which UI string to use based on the result of the game. The Game class will only need to worry about three cases e.g. computer wins, player wins and draw. The DescissionEngine can be fleshed out separately to handle all the rules of the game.</p>
<p>At the moment the Game class is tightly coupled to the DecisionEngine. This is the result of instantiating the DecisionEngine within the Game class. This means we would have to edit the Game class should we ever want to use an alternate &#8216;decision engine&#8217;. We can break up this tightly coupled code by using dependency injection, specifically <a href="http://www.codeproject.com/Articles/13831/Dependency-Injection-for-Loose-Coupling" target="_blank">constructor injection</a>. In addition to this flexibility, using dependency injection will allow us to use mocks to test smaller units of functionality. I will cover this in upcoming posts.</p>
<p>Please leave questions and comments below, I will try to get the next post out shortly&#8230;</p>
<br />Filed under: <a href='http://darynholmes.wordpress.com/category/bdd/'>BDD</a>, <a href='http://darynholmes.wordpress.com/category/c/'>C#</a>, <a href='http://darynholmes.wordpress.com/category/tdd/'>TDD</a>, <a href='http://darynholmes.wordpress.com/category/tutorials/'>Tutorials</a>, <a href='http://darynholmes.wordpress.com/category/xp/'>XP</a> Tagged: <a href='http://darynholmes.wordpress.com/tag/constructor-injection/'>constructor injection</a>, <a href='http://darynholmes.wordpress.com/tag/dependency-injection/'>dependency injection</a>, <a href='http://darynholmes.wordpress.com/tag/design-principles/'>design principles</a>, <a href='http://darynholmes.wordpress.com/tag/single-responsibility/'>single responsibility</a>, <a href='http://darynholmes.wordpress.com/tag/specflow/'>specflow</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/darynholmes.wordpress.com/425/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/darynholmes.wordpress.com/425/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=darynholmes.wordpress.com&#038;blog=2505811&#038;post=425&#038;subd=darynholmes&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://darynholmes.wordpress.com/2012/09/03/tutorial-bdd-and-dependency-injection-in-net-2/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/be1f59e4118912d487c5330586f39b72?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Daryn</media:title>
		</media:content>

		<media:content url="http://upload.wikimedia.org/wikipedia/commons/thumb/e/e6/Rock_paper_scissors.jpg/300px-Rock_paper_scissors.jpg" medium="image" />
	</item>
		<item>
		<title>Tutorial &#8211; BDD and Dependency Injection in .Net (1)</title>
		<link>http://darynholmes.wordpress.com/2012/04/12/tutorial-bdd-and-dependency-injection-in-net-1/</link>
		<comments>http://darynholmes.wordpress.com/2012/04/12/tutorial-bdd-and-dependency-injection-in-net-1/#comments</comments>
		<pubDate>Thu, 12 Apr 2012 17:33:21 +0000</pubDate>
		<dc:creator>darynholmes</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[BDD]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Extreme Programming]]></category>
		<category><![CDATA[TDD]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[XP]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[dependency injection]]></category>
		<category><![CDATA[specflow]]></category>
		<category><![CDATA[unit tests]]></category>

		<guid isPermaLink="false">http://darynholmes.wordpress.com/?p=395</guid>
		<description><![CDATA[This tutorial focuses on Behaviour Driven Development, Dependency Injection and application design in general. The primary technologies being used will be SpecFlow and MS Test. While we are targeting the .Net platform the content is applicable to most object oriented languages. &#8230; <a href="http://darynholmes.wordpress.com/2012/04/12/tutorial-bdd-and-dependency-injection-in-net-1/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=darynholmes.wordpress.com&#038;blog=2505811&#038;post=395&#038;subd=darynholmes&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>This tutorial focuses on Behaviour Driven Development, Dependency Injection and application design in general. The primary technologies being used will be SpecFlow and MS Test. While we are targeting the .Net platform the content is applicable to most object oriented languages.</p>
<h2>A Brief Introduction to Behaviour Driven Development</h2>
<p>Behaviour Driven Development (BDD) is an &#8216;outside in&#8217; or &#8216;top down&#8217; development approach. Development starts from the user interface downwards as opposed to starting with the database design.  When there is no user interface (as in the beginning of this tutorial) we work from the highest level possible.</p>
<p>BDD encourages thin slices of work. Where we break features down into very small &#8216;end-to-end&#8217; pieces of work. This work is expressed in the form of examples. This is known as <a href="http://en.wikipedia.org/wiki/Specification_by_example" target="_blank">specification by example</a> and we will see this in the tutorial.</p>
<p>In SpecFlow speak, each example is known as a scenario. We need to implement a number of scenarios before the feature is considered complete. We will flesh out the design as we implement each scenario.</p>
<p>The following diagram from <a href="http://pragprog.com/book/achbd/the-rspec-book" target="_blank">The RSpec Book</a> shows the BDD cycle:</p>
<p><a href="http://darynholmes.files.wordpress.com/2012/04/bddcycle.jpg"><img class="aligncenter size-full wp-image-433" title="BDD Cycle" src="http://darynholmes.files.wordpress.com/2012/04/bddcycle.jpg?w=584" alt="BDD Cycle"   /></a></p>
<p>As depicted, there are two levels of testing &#8211; high level system or integration tests and lower level unit testing. The high level tests often drive a user interface and may be referred to as automated acceptance tests.</p>
<p>Not only will we be following the BDD cycle, but we will only implement the code we need to make the existing tests pass &#8211; and no more. We will be very strict with this. This may seem tedious to some however this approach is good to practice. You can always fall back to this approach should you become stuck when writing production code.</p>
<p>Interestingly TDD was always meant to have multiple levels of testing. In <a href="http://www.amazon.co.uk/Extreme-Programming-Explained-Embrace-Change/dp/0201616416">Extreme Programming Explained</a>, Kent Beck and Cynthia Andres have the following to say about architects: &#8220;Architects on an XP team look for and execute large-scale refactorings, write system-level tests that stress the architecture, and implement stories&#8221;. This is similar to what we are trying to achieve in BDD. In fact Dan North introduced the term BDD to help him <a href="http://dannorth.net/introducing-bdd/" target="_blank">explain TDD</a> to developers. This is why I say that <strong>BDD is TDD done properly</strong>.</p>
<p>These days it is common to hear teams say they are doing &#8220;TDD but not BDD&#8221;. By this they sometimes mean that they are writing system tests and unit tets, but they are not using a &#8220;BDD testing framework&#8221; like <a href="http://cukes.info/">Cucumber</a> or <a href="http://fitnesse.org/">FitNesse</a>. There is nothing wrong with this approach. Sometimes &#8220;we do TDD but not BDD&#8217; means that the team members are not writing system level integration tests. This is better than no tests at all, however it is not true TDD and they are missing a trick.</p>
<h2>A Brief Introduction to Dependency Injection</h2>
<p>James Shaw does a great job of explaining <a href="http://jamesshore.com/Blog/Dependency-Injection-Demystified.html">Dependency Injection</a> (DI). He points out that &#8220;Dependency Injection means giving an object its instance variables&#8221;. The instance variables are typically reference types which provide a layer of abstraction. We can give an object it&#8217;s instance variables through a number of different ways namely constructor injection, property injection, method injection.</p>
<p>There are many reasons for using Dependency Injection. The most obvious reason is that it makes the code more testable. It makes it easy to use mock objects in place of the real dependencies during testing. Testability is not the only reason, when done properly code which uses dependency injection tends to support the <a href="http://en.wikipedia.org/wiki/SOLID_(object-oriented_design)">SOLID design principles</a>, most notably the <a title="Single responsibility principle" href="http://en.wikipedia.org/wiki/Single_responsibility_principle">Single responsibility principle</a> and <a title="Open/closed principle" href="http://en.wikipedia.org/wiki/Open/closed_principle">Open/closed principle</a>. This will be shown in the tutorial.</p>
<p>Dependency Injection is a simple concept, the confusion seems arise when Dependency Injection containers enter the discussion. For this reason I will not use DI Containers for the first few parts of this tutorial. All I will say is that DI Containers may help when composing objects, however they are not required to implement the dependency injection pattern.</p>
<p><span id="more-395"></span></p>
<h2>The Tutorial &#8211; Part 1</h2>
<p><em>When I began playing cricket at school, the coach instructed me to change the way I gripped the bat. At first the new grip seemed strange and uncomfortable. After many practice sessions I began hitting the ball further with more accuracy while using less effort. </em><em>When I adopted TDD I went through a similar experience. I first felt discomfort and frustration but after practising the technique I found I was achieving better results with less effort.</em></p>
<p>In this tutorial we will build a <a href="http://en.wikipedia.org/wiki/Rock-paper-scissors">Rock Paper Scissors game</a>. We will focus on building a library that can be used with any front end e.g. a console application, WPF etc.</p>
<p>Part 1 covers the solution set up and the basics of SpecFlow. In this first section we are cover the set up and we get used to the BDD cycle. There is no dependency injection in this part, we will move onto that and more interesting topics in part 2. I will not spend much time explaining SpecFlow, we will get the hang of it as we go.</p>
<p><strong>Solution Setup</strong></p>
<p>Firstly download and install <a href="http://www.specflow.org/downloads/installer.aspx">TechTalk.SpeckFlow</a>. We will also need the latest version of <a href="http://code.google.com/p/moq/downloads/list">Moq</a>.</p>
<p>We begin by creating a new project in Visual Studio. Select a Class Library (C#) template. Name it RockPaperScissors. Class1 can be deleted.</p>
<p>Add a new project to the solution. This should be a Test Project (C#), call it RockPaperScissorsTest. UnitTest1 can be deleted. Add the two new folders called Tests and Specs. Then add a &#8216;Steps&#8217; folder under the &#8216;Specs&#8217; folder, see image below.</p>
<p>The Tests folder will contain the unit tests, the Specs and Steps folders are used for SpecFlow tests.</p>
<p>Add a reference to the latest version of <a href="http://code.google.com/p/moq/downloads/list">Moq</a>, <a href="http://www.specflow.org/downloads/installer.aspx">TechTalk.SpeckFlow</a> and the RockPaperScissors class library.</p>
<p><a href="http://darynholmes.files.wordpress.com/2012/04/solutionsetup.png"><img class="aligncenter size-full wp-image-473" title="SolutionSetup" src="http://darynholmes.files.wordpress.com/2012/04/solutionsetup.png?w=584" alt="Solution Setup"   /></a></p>
<p>SpecFlow uses NUnit by default. In order to use SpecFlow with MS Test we need to add an App.config file to the test project. Modify the App.config file to look as follows:</p>
<p>App.config</p>
<pre class="brush: xml; title: ; notranslate">&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?--&gt;

&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
&lt;configuration&gt;
  &lt;configSections&gt;
    &lt;section
       name=&quot;specFlow&quot;
       type=&quot;TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow&quot;/&gt;
  &lt;/configSections&gt;
  &lt;specFlow&gt;
    &lt;unitTestProvider name=&quot;MsTest&quot; /&gt;
  &lt;/specFlow&gt;
&lt;/configuration&gt;

</pre>
<p><strong>Enter SpecFlow</strong></p>
<p>Add a new a SpecFlow Feature file, with the following:</p>
<p>PlayRoundFeature.feature</p>
<pre class="brush: csharp; title: ; notranslate">
Feature: Play a single round of Rock Paper Scissors
	As a player
	I want to play a round
	So that I can test my luck

Scenario: Computer chooses Rock and the player chooses Paper
	Given the computer makes a secret choice of Rock
	When I choose Paper
	Then the result should be &quot;Player Wins!&quot;
</pre>
<p>This contains a Feature and a single Scenario. The Feature is the user story. The Scenario forms a part of the specification, see <a href="http://en.wikipedia.org/wiki/Specification_by_example" target="_blank">specification by example</a>.</p>
<p>Next we map the feature file onto code. This is done by adding a SpecFlow step definition file. Add a step definition file to the steps folder and call it &#8216;PlayRoundSteps.cs&#8217;. Delete all the sample steps.</p>
<p>No we need to define steps in the step definition file that match the lines within the feature file. The SpecFlow plugin makes this easy for us. In the feature file, right click on  the line &#8220;Given the computer makes a secret code of rock&#8221;, then choose &#8216;go to step definition&#8217;. This will give you an option to copy the generated code to the clipboard. Select copy and then past this step into the &#8216;PlayRoundSteps.cs&#8217; file. Repeat this for other three lines in the feature file. At this stage the PlayRoundSteps.cs file should look as follows:</p>
<p>PlayRoundSteps.cs</p>
<pre class="brush: csharp; title: ; notranslate">
        [Given(@&quot;the computer makes a secret choice of Rock&quot;)]
        public void GivenTheComputerMakesASecretChoiceOfRock()
        {
            ScenarioContext.Current.Pending();
        }

        [When(@&quot;I choose Paper&quot;)]
        public void WhenIChoosePaper()
        {
            ScenarioContext.Current.Pending();
        }

        [Then(@&quot;the result shoussld be &quot;&quot;Player Wins!&quot;&quot;&quot;)]
        public void ThenTheResultShoussldBePlayerWins()
        {
            ScenarioContext.Current.Pending();
        }
</pre>
<p>It is possible to run the SpecFlow tests by right clicking on the feature file and selecting &#8216;Run SpecFlow Scenarios&#8217;.</p>
<p>When using Cucumber, the steps are generated with a comment similar to &#8220;Now enter the code you wish you had&#8221; &#8211; and that is exactly what we need to do.</p>
<p>To start we remove &#8216;ScenarioContext.Current.Pending();&#8217; from all steps and then implement the following code (which will not compile at this stage):</p>
<p>PlayRoundSteps.cs</p>
<pre class="brush: csharp; title: ; notranslate">
        [Given(@&quot;the computer makes a secret choice of Rock&quot;)]
        public void GivenTheComputerMakesASecretChoiceOfRock()
        {
            var game = new Game();
            ScenarioContext.Current.Add(&quot;Game&quot;, game);
        }

        [When(@&quot;I choose Paper&quot;)]
        public void WhenIChoosePaper()
        {

        }

        [Then(@&quot;the result should be &quot;&quot;Player Wins!&quot;&quot;&quot;)]
        public void ThenTheResultShouldBePlayerWins()
        {
            var game = ScenarioContext.Current.Get(&quot;Game&quot;);
            Assert.AreEqual(&quot;Player Wins!&quot;, game.Result());
        }
</pre>
<p>The ScenarioContext is used to share objects between steps. At this stage the code cannot compile as we don&#8217;t have a Game class. Next we create this class in the RockPaperScissors assembly. Next we add the required method.</p>
<p>Game.cs</p>
<pre class="brush: csharp; title: ; notranslate">
namespace RockPaperScissors
{
    public class Game
    {
        public string Result()
        {
            throw new NotImplementedException();
        }
    }
}
</pre>
<p>Now the code should compile and running the tests will throw a NotImplementedException. To fix this we drop down into unit testing.</p>
<p><strong>Adding Unit Tests</strong></p>
<p>In the Tests folder, create a unit test called GameTest.Add the following test:</p>
<p>GameTest.cs</p>
<pre class="brush: csharp; title: ; notranslate">
        [TestMethod]
        public void ComputerRock_PlayerPaper_PlayerWins()
        {
            var game = new Game();
            Assert.AreEqual(&quot;Player Wins!&quot;, game.Result());
        }
</pre>
<p>At this stage we are duplicating the SpecFlow test in the unit test.There is little benefit at this stage. We are simply following the BDD cycle. Experience has taught me that it is better to introduce unit testing sooner rather than later. It is easier to remove redundant tests than to introduce unit testing late in development.</p>
<p>We are only adding what we really need. You are welcome to go faster if you wish, however I would like to show very small steps in this tutorial. <em>Be patient,</em> w<em>e are changing our grip&#8230;</em></p>
<p>The unit test should fail. Then we make it pass by adding the simplest bit of code we can in the Game class.</p>
<p>Game.cs</p>
<pre class="brush: csharp; title: ; notranslate">
namespace RockPaperScissors
{
    public class Game
    {
        public string Result()
        {
            return &quot;Player Wins!&quot;;
        }
    }
}
</pre>
<p>That should make the unit test pass. We then run the SpecFlow test, and that should also turn green.</p>
<p>At this stage I am not that interested in a complete implementation of the games&#8217; rules, I am trying to flesh out the architecture. We know we are nowhere near a complete solution, but we do have our first scenario passing &#8211; progress!</p>
<p><strong>Test <span style="text-decoration:underline;"><em>Driven</em></span></strong></p>
<p>We want to use tests to drive out the logic. We should write a test that exposes our hard coded &#8220;Player Wins!&#8221; line in the Game class. The easiest way to do that is to write a test that expects the computer to win. We move back up to high level testing and append another Scenario to the SpecFlow feature file:</p>
<p>PlayRoundFeature.feature</p>
<pre class="brush: csharp; title: ; notranslate">
Feature: Play a single round of Rock Paper Scissors
	As a player
	I want to play a round
	So that I can test my luck

Scenario: Computer chooses Rock and the player chooses Paper
	Given the computer makes a secret choice of Rock
	When I choose Paper
	Then the result should be &quot;Player Wins!&quot;

Scenario: Computer chooses Rock and the player chooses Scissors
	Given the computer makes a secret choice of Rock
	When I choose Scissors
	Then the result should be &quot;Computer Wins!&quot;
</pre>
<p>We then add the two new step definitions:</p>
<p>PlayRoundSteps.cs</p>
<pre class="brush: csharp; title: ; notranslate">
        [Given(@&quot;the computer makes a secret choice of Rock&quot;)]
        public void GivenTheComputerMakesASecretChoiceOfRock()
        {
            var game = new Game();
            ScenarioContext.Current.Add(GameKey, game);
        }

        [When(@&quot;I choose Paper&quot;)]
        public void WhenIChoosePaper()
        {

        }

        // Added
        [When(@&quot;I choose scissors&quot;)]
        public void WhenIChooseScissors()
        {

        }

        [Then(@&quot;the result should be &quot;&quot;Player Wins!&quot;&quot;&quot;)]
        public void ThenTheResultShouldBePlayerWins()
        {
            var game = ScenarioContext.Current.Get(GameKey);
            Assert.AreEqual(&quot;Player Wins!&quot;, game.Result());
        }

        // Added
        [Then(@&quot;the result should be &quot;&quot;Computer Wins!&quot;&quot;&quot;)]
        public void ThenTheResultShouldBeComputerWins()
        {
            var game = ScenarioContext.Current.Get(GameKey);
            Assert.AreEqual(&quot;Computer Wins!&quot;, game.Result());
        }

</pre>
<p>The new test should fail with an appropriate error message e.g. Expected &#8220;Computer Wins!&#8221; actual &#8220;Player Wins!&#8221;. Now we drop back down into unit testing and replicate the test:</p>
<p>GameTest.cs</p>
<pre class="brush: csharp; title: ; notranslate">

        [TestMethod]
        public void ComputerRock_PlayerPaper_PlayerWins()
        {
            var game = new Game();
            Assert.AreEqual(&quot;Player Wins!&quot;, game.Result());
        }

        [TestMethod]
        public void ComputerRock_PlayerScissors_ComputerWins()
        {
            var game = new Game();
            Assert.AreEqual(&quot;Computer Wins!&quot;, game.Result());
        }
</pre>
<p>This unit test should fail, similarly to the integration test we wrote using SpecFlow.</p>
<p>With the intention of taking small steps, we look for ways of doing the least amount of work to get the unit tests to pass. The computer chooses Rock in both tests, it is only the player choice that changes. Therefore we use that in our logic. First we alter the unit tests as follows:</p>
<p>GameTest.cs</p>
<pre class="brush: csharp; title: ; notranslate">

        [TestMethod]
        public void ComputerRock_PlayerPaper_PlayerWins()
        {
            var game = new Game();
            game.PlayerMove = &quot;Paper&quot;;
            Assert.AreEqual(&quot;Player Wins!&quot;, game.Result());
        }

        [TestMethod]
        public void ComputerRock_PlayerScissors_ComputerWins()
        {
            var game = new Game();
            game.PlayerMove = &quot;Scissors&quot;;
            Assert.AreEqual(&quot;Computer Wins!&quot;, game.Result());
        }
</pre>
<p>Then we do the least amount of code in the Game class to make the tests pass. After refactoring, I ended up with:</p>
<p>Game.cs</p>
<pre class="brush: csharp; title: ; notranslate">
namespace RockPaperScissors
{
    public class Game
    {
        public string PlayerMove { private get; set; }

        public string Result()
        {
            return PlayerMove == &quot;Paper&quot; ? &quot;Player Wins!&quot; : &quot;Computer Wins!&quot;;
        }
    }
}
</pre>
<p>Later we will add more tests to drive out this rudimentary logic. At this stage we have the unit tests passing. We we still need to use the new PlayerMove property in the SpecFlow tests to get them passing. Before doing that it is a good idea to throw an exception if the PlayerMove property is used before it has been set. We drive this functionality out through tests:</p>
<p>GameTest.cs</p>
<pre class="brush: csharp; title: ; notranslate">

        [TestMethod]
        public void ComputerRock_PlayerPaper_PlayerWins()
        {
            var game = new Game();
            game.PlayerMove = &quot;Paper&quot;;
            Assert.AreEqual(&quot;Player Wins!&quot;, game.Result());
        }

        [TestMethod]
        public void ComputerRock_PlayerScissors_ComputerWins()
        {
            var game = new Game();
            game.PlayerMove = &quot;Scissors&quot;;
            Assert.AreEqual(&quot;Computer Wins!&quot;, game.Result());
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void ThrowsErrorIfPlayerMoveIsNotSet()
        {
            var game = new Game();
            game.Result();
        }
</pre>
<p>With the implementation being as follows:</p>
<p>Game.cs</p>
<pre class="brush: csharp; title: ; notranslate">
namespace RockPaperScissors
{
    public class Game
    {
        private string _playerMove;
        public string PlayerMove
        {
            private get
            {
                if (String.IsNullOrEmpty(_playerMove))
                    throw new ArgumentNullException(&quot;PlayerMove&quot;);
                return _playerMove;
            }
            set
            {
                _playerMove = value;
            }
        }

        public string Result()
        {
            return PlayerMove == &quot;Paper&quot; ? &quot;Player Wins!&quot; : &quot;Computer Wins!&quot;;
        }
    }
}
</pre>
<p>We then move onto the failing integration tests, they need to use the new property:</p>
<p>PlayRoundSteps.cs</p>
<pre class="brush: csharp; title: ; notranslate">
namespace RockPaperScissorsTest.Specs.Steps
{
    [Binding]
    public class PlayRoundSteps
    {
        private const string GameKey = &quot;Game&quot;;

        [Given(@&quot;the computer makes a secret choice of rock&quot;)]
        public void GivenTheComputerMakesASecretChoiceOfRock()
        {
            var game = new Game();
            ScenarioContext.Current.Add(GameKey, game);
        }

        [When(@&quot;I choose paper&quot;)]
        public void WhenIChoosePaper()
        {
            var game = ScenarioContext.Current.Get(GameKey);
            game.PlayerMove = &quot;Paper&quot;;
        }

        [When(@&quot;I choose scissors&quot;)]
        public void WhenIChooseScissors()
        {
            var game = ScenarioContext.Current.Get(GameKey);
            game.PlayerMove = &quot;Scissors&quot;;
        }

        [Then(@&quot;the result should be &quot;&quot;Player Wins!&quot;&quot;&quot;)]
        public void ThenTheResultShouldBePlayerWins()
        {
            var game = ScenarioContext.Current.Get(GameKey);
            Assert.AreEqual(&quot;Player Wins!&quot;, game.Result());
        }

        [Then(@&quot;the result should be &quot;&quot;Computer Wins!&quot;&quot;&quot;)]
        public void ThenTheResultShouldBeComputerWins()
        {
            var game = ScenarioContext.Current.Get(GameKey);
            Assert.AreEqual(&quot;Computer Wins!&quot;, game.Result());
        }

    }
}

</pre>
<p>We now have a total of 5 tests passing, three unit tests and two SpecFlow integration tests. There is still a lot more to be done, including refactoring the SpecFlow tests to use the table feature. In upcoming posts we will see more of SpecFlow and we will use dependency injection.</p>
<p>Please let me know of any mistakes I have made, and any topics you would like to have covered in the follow up posts.</p>
<br />Filed under: <a href='http://darynholmes.wordpress.com/category/agile/'>Agile</a>, <a href='http://darynholmes.wordpress.com/category/bdd/'>BDD</a>, <a href='http://darynholmes.wordpress.com/category/c/'>C#</a>, <a href='http://darynholmes.wordpress.com/category/extreme-programming/'>Extreme Programming</a>, <a href='http://darynholmes.wordpress.com/category/tdd/'>TDD</a>, <a href='http://darynholmes.wordpress.com/category/tutorials/'>Tutorials</a>, <a href='http://darynholmes.wordpress.com/category/xp/'>XP</a> Tagged: <a href='http://darynholmes.wordpress.com/tag/bdd/'>BDD</a>, <a href='http://darynholmes.wordpress.com/tag/csharp/'>csharp</a>, <a href='http://darynholmes.wordpress.com/tag/dependency-injection/'>dependency injection</a>, <a href='http://darynholmes.wordpress.com/tag/specflow/'>specflow</a>, <a href='http://darynholmes.wordpress.com/tag/unit-tests/'>unit tests</a>, <a href='http://darynholmes.wordpress.com/tag/xp/'>XP</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/darynholmes.wordpress.com/395/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/darynholmes.wordpress.com/395/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=darynholmes.wordpress.com&#038;blog=2505811&#038;post=395&#038;subd=darynholmes&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://darynholmes.wordpress.com/2012/04/12/tutorial-bdd-and-dependency-injection-in-net-1/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/be1f59e4118912d487c5330586f39b72?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Daryn</media:title>
		</media:content>

		<media:content url="http://darynholmes.files.wordpress.com/2012/04/bddcycle.jpg" medium="image">
			<media:title type="html">BDD Cycle</media:title>
		</media:content>

		<media:content url="http://darynholmes.files.wordpress.com/2012/04/solutionsetup.png" medium="image">
			<media:title type="html">SolutionSetup</media:title>
		</media:content>
	</item>
		<item>
		<title>In Theory and In Practice</title>
		<link>http://darynholmes.wordpress.com/2012/02/25/in-theory-and-in-practice/</link>
		<comments>http://darynholmes.wordpress.com/2012/02/25/in-theory-and-in-practice/#comments</comments>
		<pubDate>Sat, 25 Feb 2012 13:11:01 +0000</pubDate>
		<dc:creator>darynholmes</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Kanban]]></category>
		<category><![CDATA[Lean]]></category>
		<category><![CDATA[Presentations]]></category>
		<category><![CDATA[Scrum]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[chaos report]]></category>
		<category><![CDATA[lean software development]]></category>
		<category><![CDATA[software metrics]]></category>
		<category><![CDATA[software quality]]></category>

		<guid isPermaLink="false">http://darynholmes.wordpress.com/?p=377</guid>
		<description><![CDATA[We recently completed a small but interesting project at work. The team consisted of Tim Weeks, Lee Walton and I played a supporting role. We shared the lessons learned in an experience report at the Agile Practitioners group. The talk &#8230; <a href="http://darynholmes.wordpress.com/2012/02/25/in-theory-and-in-practice/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=darynholmes.wordpress.com&#038;blog=2505811&#038;post=377&#038;subd=darynholmes&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>We recently completed a small but interesting project at work. The team consisted of Tim Weeks, Lee Walton and I played a supporting role. We shared the lessons learned in an experience report at the <a title="Agile Practitioners" href="http://www.meetup.com/AgilePractitioners/" target="_blank">Agile Practitioners</a> group. The talk was filmed and can be seen below.</p>
<p>On this project, the developers tried a number of Agile and XP practices. BDD and Pair Programming were tried for the first time, in the video they explain what this was like.</p>
<p>In addition to the Agile aspects, the talk shows what Lean (kanban) principles we followed e.g. making decisions at the last responsible moment.</p>
<p>There is a large section on using code reviews and code metrics to help improve code quality.</p>
<p>I got off to a shaky start, but things seemed to improve as the video goes on.</p>
<p>Part 1:</p>
<ul>
<li>Overview of the project</li>
<li>Developers discuss how they felt on the project</li>
<li>Discussion on pair programming for the first time</li>
<li>The importance of putting people first</li>
<li>NUMMI case study (GM and Toyota)</li>
<li>Start of project &#8211; beginning with the end in mind</li>
<li>Re-writing stories, to remove implementation details</li>
<li>Simplicity &#8211; <em>the art of not doing work</em></li>
<li>Cost of defects</li>
<li>Concurrent development</li>
<li>Making decisions at the last responsible moment</li>
</ul>
<span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='584' height='359' src='http://www.youtube.com/embed/MdbgdhY7I0M?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span>
<p>Part 2:</p>
<ul>
<li>Burn down charts</li>
<li>Cumulative flow diagram</li>
<li>Walking skeleton or tracer bullet</li>
<li>Lean thinking &#8211; limiting work in process</li>
<li>Pull System</li>
<li>Dealing with blocked stories</li>
<li>Code Reviews (brief discussion)</li>
<li>Relationship with PO &#8211; developers having access to users</li>
<li>Task switching &#8211; cost of task switching on projects</li>
</ul>
<span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='584' height='359' src='http://www.youtube.com/embed/VZfLEdCJuvI?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span>
<p><span id="more-377"></span>Part 3:</p>
<ul>
<li>Pair programming and the &#8216;cardboard developer&#8217;</li>
<li>Code Review &#8211; full section</li>
<li>Code metrics e.g. cyclomatic complexity</li>
<li>Importance of code quality</li>
<li>Why do evelopers write better code at home?</li>
<li>What do developers spend their time on at work?</li>
<li>Check in frequency</li>
<li>TDD and BDD</li>
<li>Discussion on automated acceptance tests (cucumber, specflow etc)</li>
</ul>
<div><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='584' height='359' src='http://www.youtube.com/embed/rglF1fz4MUI?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span></div>
<div></div>
<div></div>
<div>Part 4:</div>
<div></div>
<ul>
<li>Re-factoring is important!</li>
<li>Architecture on an Agile project</li>
<li>OMA &#8211; buildings are designed incrementally and iteratively</li>
<li>Documentation</li>
<li>Scrum tools - <em>use the wall</em></li>
<li>Was this a waterfall project?</li>
<li>Was it an agile projects?</li>
<li>What could we have done better?</li>
<li>Was this project a success?</li>
</ul>
<span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='584' height='359' src='http://www.youtube.com/embed/f9Byep00ROg?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span>
<p>Thanks to <a href="http://www.zuehlke.com/en/contact.html" target="_blank">Zuhlke Engineering</a> for hosting the event, and to <a href="http://heldstab.wordpress.com/" target="_blank">Christian Heldstab</a> for recording the talk.</p>
<p>Feedback in the comments would be appreciated&#8230;</p>
<br />Filed under: <a href='http://darynholmes.wordpress.com/category/agile/'>Agile</a>, <a href='http://darynholmes.wordpress.com/category/c/'>C#</a>, <a href='http://darynholmes.wordpress.com/category/lean/kanban-lean/'>Kanban</a>, <a href='http://darynholmes.wordpress.com/category/lean/'>Lean</a>, <a href='http://darynholmes.wordpress.com/category/presentations/'>Presentations</a>, <a href='http://darynholmes.wordpress.com/category/scrum/'>Scrum</a>, <a href='http://darynholmes.wordpress.com/category/uncategorized/'>Uncategorized</a> Tagged: <a href='http://darynholmes.wordpress.com/tag/agile/'>Agile</a>, <a href='http://darynholmes.wordpress.com/tag/chaos-report/'>chaos report</a>, <a href='http://darynholmes.wordpress.com/tag/kanban/'>Kanban</a>, <a href='http://darynholmes.wordpress.com/tag/lean-software-development/'>lean software development</a>, <a href='http://darynholmes.wordpress.com/tag/scrum/'>Scrum</a>, <a href='http://darynholmes.wordpress.com/tag/software-metrics/'>software metrics</a>, <a href='http://darynholmes.wordpress.com/tag/software-quality/'>software quality</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/darynholmes.wordpress.com/377/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/darynholmes.wordpress.com/377/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=darynholmes.wordpress.com&#038;blog=2505811&#038;post=377&#038;subd=darynholmes&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://darynholmes.wordpress.com/2012/02/25/in-theory-and-in-practice/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/be1f59e4118912d487c5330586f39b72?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Daryn</media:title>
		</media:content>
	</item>
		<item>
		<title>Agile20x20</title>
		<link>http://darynholmes.wordpress.com/2011/09/29/agile20x20/</link>
		<comments>http://darynholmes.wordpress.com/2011/09/29/agile20x20/#comments</comments>
		<pubDate>Thu, 29 Sep 2011 14:26:33 +0000</pubDate>
		<dc:creator>darynholmes</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Lean]]></category>
		<category><![CDATA[Presentations]]></category>
		<category><![CDATA[Agile20x20]]></category>
		<category><![CDATA[lean software development]]></category>
		<category><![CDATA[Pecha Kucha]]></category>

		<guid isPermaLink="false">http://darynholmes.wordpress.com/?p=320</guid>
		<description><![CDATA[The Agile Practitioners group recently held a pecha-kucha event at Zuhlke Engineering. The talks were great! The content was intriguing and the Pecha Kucha format added an extra edge to the presentations. We learned a few lessons that will help improve the next Agile20x20 &#8230; <a href="http://darynholmes.wordpress.com/2011/09/29/agile20x20/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=darynholmes.wordpress.com&#038;blog=2505811&#038;post=320&#038;subd=darynholmes&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><span class="Apple-style-span" style="color:inherit;font:normal normal normal 15px/normal 'Helvetica Neue', Helvetica, Arial, sans-serif;font-style:inherit;font-weight:inherit;line-height:1.625;font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;"><a style="text-decoration:underline;" href="http://darynholmes.files.wordpress.com/2011/09/pecha-kucha.png"><img class="size-full wp-image-342 alignright" style="background-image:initial;background-attachment:initial;background-color:#eeeeee;border-color:initial;border-style:initial;" title="pecha-kucha" src="http://darynholmes.files.wordpress.com/2011/09/pecha-kucha.png?w=584" alt=""   /></a></span></p>
<p style="text-align:left;">The<a href="http://www.meetup.com/AgilePractitioners/"> Agile Practitioners</a> group recently held a <a href="http://www.pecha-kucha.org/">pecha-kucha</a> event at <a href="http://www.zuehlke.com/en/">Zuhlke</a><a href="http://www.zuehlke.com/en/"> Engineering</a>. The talks were great! The content was intriguing and the Pecha Kucha format added an extra edge to the presentations.</p>
<p style="text-align:left;">We learned a few lessons that will help improve the next Agile20x20 event.</p>
<p style="text-align:left;">Here are the talks</p>
<span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='584' height='359' src='http://www.youtube.com/embed/xZMG_6yZHok?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span>
<p>Christian Heldstab does a great job of presenting Getting Things Done</p>
<span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='584' height='359' src='http://www.youtube.com/embed/_WoSl94aLZc?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span>
<p><a href="http://www.linkedin.com/pub/abid-quereshi/6/51a/402">Abid Quereshi</a> exlapins the core values of Scrum</p>
<p><span id="more-320"></span></p>
<span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='584' height='359' src='http://www.youtube.com/embed/iPynQbXK6WM?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span>
<p><a href="http://twitter.com/#!/DarynHolmes">Daryn Holmes</a> gives a talked inspired by the phrase &#8220;we want to be more agile&#8221;</p>
<span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='584' height='359' src='http://www.youtube.com/embed/HHOvAqqGEh4?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span>
<p><a href="http://www.1011ltd.com/">Benjamin Nortier</a> discusses efficiency at the cost of robustness</p>
<span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='584' height='359' src='http://www.youtube.com/embed/Bu05h0IvL1c?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span>
<p><a href="http://twitter.com/#!/sleepyfox">Sleepyfox</a> warns about the dark side of metrics</p>
<p>Thanks to all the people who attended and thanks to the presenters for all the time and effort they put in to make it an interesting evening.</p>
<p>If you would like to be involved with these events in the future, please leave a comment below.</p>
<br />Filed under: <a href='http://darynholmes.wordpress.com/category/agile/'>Agile</a>, <a href='http://darynholmes.wordpress.com/category/general/'>General</a>, <a href='http://darynholmes.wordpress.com/category/lean/'>Lean</a>, <a href='http://darynholmes.wordpress.com/category/presentations/'>Presentations</a> Tagged: <a href='http://darynholmes.wordpress.com/tag/agile/'>Agile</a>, <a href='http://darynholmes.wordpress.com/tag/agile20x20/'>Agile20x20</a>, <a href='http://darynholmes.wordpress.com/tag/lean-software-development/'>lean software development</a>, <a href='http://darynholmes.wordpress.com/tag/pecha-kucha/'>Pecha Kucha</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/darynholmes.wordpress.com/320/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/darynholmes.wordpress.com/320/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=darynholmes.wordpress.com&#038;blog=2505811&#038;post=320&#038;subd=darynholmes&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://darynholmes.wordpress.com/2011/09/29/agile20x20/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/be1f59e4118912d487c5330586f39b72?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Daryn</media:title>
		</media:content>

		<media:content url="http://darynholmes.files.wordpress.com/2011/09/pecha-kucha.png" medium="image">
			<media:title type="html">pecha-kucha</media:title>
		</media:content>
	</item>
		<item>
		<title>The Buffering Law observed in Software Engineering</title>
		<link>http://darynholmes.wordpress.com/2011/08/18/the-buffering-law-observed-in-software-engineering/</link>
		<comments>http://darynholmes.wordpress.com/2011/08/18/the-buffering-law-observed-in-software-engineering/#comments</comments>
		<pubDate>Thu, 18 Aug 2011 17:20:34 +0000</pubDate>
		<dc:creator>darynholmes</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[Kanban]]></category>
		<category><![CDATA[Lean]]></category>
		<category><![CDATA[buffering law]]></category>
		<category><![CDATA[lean software development]]></category>
		<category><![CDATA[Scrum]]></category>

		<guid isPermaLink="false">http://darynholmes.wordpress.com/?p=260</guid>
		<description><![CDATA[There is an informative slide deck on the FactoryPhysics website entitled A Fast Cycle Time Story. This slide deck was created by two Intel Products employees namely Tim Skowronski and Joan Tafoya. The slides cover many aspects of lean manufacturing, one of the topics covered is &#8230; <a href="http://darynholmes.wordpress.com/2011/08/18/the-buffering-law-observed-in-software-engineering/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=darynholmes.wordpress.com&#038;blog=2505811&#038;post=260&#038;subd=darynholmes&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<div id="attachment_301" class="wp-caption alignright" style="width: 231px"><a href="http://www.flickr.com/photos/timpearcelosgatos/3498322771/"><img class="size-full wp-image-301   " title="train_buffer" src="http://darynholmes.files.wordpress.com/2011/08/train_buffer.jpg?w=584" alt=""   /></a><p class="wp-caption-text">Railway buffer at the top of Pikes Peak, Colorado Springs CO </p></div>
<p>There is an informative slide deck on the <a href="http://www.factoryphysics.com/index.cfm">FactoryPhysics</a> website entitled <a title="A Fast Cycle Time Story" href="http://www.factoryphysics.com/documents/Factory%20Physics%20Application%20at%20Intel.pdf">A Fast Cycle Time</a> <a title="A Fast Cycle Time Story" href="http://www.factoryphysics.com/documents/Factory%20Physics%20Application%20at%20Intel.pdf">Story</a>. This slide deck was created by two Intel Products employees namely Tim Skowronski and Joan Tafoya.</p>
<p>The slides cover many aspects of lean manufacturing, one of the topics covered is The Buffering Law</p>
<blockquote><p>Systems with variability must be buffered by some combination of:</p>
<ul>
<li><span class="Apple-style-span" style="font-family:Georgia, 'Bitstream Charter', serif;font-weight:normal;">Inventory</span></li>
<li><span class="Apple-style-span" style="font-family:Georgia, 'Bitstream Charter', serif;font-weight:normal;">Capacity</span></li>
<li><span class="Apple-style-span" style="font-family:Georgia, 'Bitstream Charter', serif;font-weight:normal;">Time</span></li>
</ul>
</blockquote>
<p>Tafoya and Skowronski explain the implication of this law</p>
<blockquote><p>If you cannot pay to reduce variability, you will pay in terms of high WIP, under-underutilized capacity, or reduced customer service i.e. lost sales, long lead times, and/or late deliveries.</p></blockquote>
<p>The following variability buffering examples are provided:</p>
<ul>
<li>Ballpoint Pens:</li>
<ul>
<li>can’t buffer with time (who will backorder a cheap pen?)</li>
<li>can’t buffer with capacity (too expensive, and slow)</li>
<li>must buffer with inventory</li>
</ul>
<li>Ambulance Service:</li>
<ul>
<li>can’t buffer with inventory (an inventory of trips to hospitals?)</li>
<li>can’t buffer with time (response time is the key measure)</li>
<li>must buffer with capacity</li>
</ul>
<li>Organ Transplants:</li>
<ul>
<li>can’t buffer with WIP (perishable &#8211; very short usable life)</li>
<li>can’t buffer with capacity (we cannot ethically increase capacity)</li>
<li>must buffer with time</li>
</ul>
</ul>
<p><span id="more-260"></span>In software engineering we experience variability due to a number of reasons, including policies and practices we put in place.  The prominent cause of variability considered here is changing requirements and the varying levels of demand for features.</p>
<p>This variably is due to a number of reasons e.g. a customer gaining insights after using the software, a new opportunity in the market, a change in regulation etc. This variability is largely due to external events. Iterative and incremental development practices help reduce the impact of this variability but this does not illuminate variablility. Therefore, according to the Buffering Law, we need to buffer with some combination of inventory, capacity or time.</p>
<p>We cannot buffer with inventory because we don&#8217;t know what the future requirements will be. If we did we would not have variability in the first place.</p>
<p>A teams capacity is their ability to produce features as and when the business needs them. There are a number of options teams can use to improve their capacity e.g. process improvements (Scrum\Kanban), technological improvements (automated acceptance tests), increasing or decreasing team size (<a title="Two Pizza Rule" href="http://www.learningapi.com/blog/archives/000079.html" target="_blank">two pizza rule</a>).</p>
<p>Due to the nature of software development most teams are continuously trying to catch up with a backlog of requirements. Many of these teams are continuously improving their velocity. With this in mind, it is naive to think that we can cause a huge increase capacity simply because we need to. That is like saying we only take the short cut when we are in a rush. The teams capacity is not like a tap that we can turn on and off. While all teams can (and should) incrementally improve, drastically increasing capacity in times of need it is not always feasible and it is not a trivial task.</p>
<p>In software development we need to buffer with time. Teams aim to deliver the requested features over a period of time. As Tafoya and Skowronski point out, when you buffer with time you pay with &#8220;reduced customer service i.e. lost sales, long lead times, and/or late deliveries&#8221;. Which reads like a <a href="http://www.urbandictionary.com/define.php?term=Readers%20Digest%20Version" target="_blank">readers digest version</a> of the history of software development.</p>
<p>Photo attributed to: <a href="http://www.flickr.com/photos/timpearcelosgatos/3498322771/" target="_blank">Tim Pearce</a></p>
<br />Filed under: <a href='http://darynholmes.wordpress.com/category/agile/'>Agile</a>, <a href='http://darynholmes.wordpress.com/category/lean/kanban-lean/'>Kanban</a>, <a href='http://darynholmes.wordpress.com/category/lean/'>Lean</a> Tagged: <a href='http://darynholmes.wordpress.com/tag/agile/'>Agile</a>, <a href='http://darynholmes.wordpress.com/tag/buffering-law/'>buffering law</a>, <a href='http://darynholmes.wordpress.com/tag/kanban/'>Kanban</a>, <a href='http://darynholmes.wordpress.com/tag/lean-software-development/'>lean software development</a>, <a href='http://darynholmes.wordpress.com/tag/scrum/'>Scrum</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/darynholmes.wordpress.com/260/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/darynholmes.wordpress.com/260/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=darynholmes.wordpress.com&#038;blog=2505811&#038;post=260&#038;subd=darynholmes&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://darynholmes.wordpress.com/2011/08/18/the-buffering-law-observed-in-software-engineering/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/be1f59e4118912d487c5330586f39b72?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Daryn</media:title>
		</media:content>

		<media:content url="http://darynholmes.files.wordpress.com/2011/08/train_buffer.jpg" medium="image">
			<media:title type="html">train_buffer</media:title>
		</media:content>
	</item>
		<item>
		<title>The X Penny Game</title>
		<link>http://darynholmes.wordpress.com/2011/08/02/the-x-penny-game/</link>
		<comments>http://darynholmes.wordpress.com/2011/08/02/the-x-penny-game/#comments</comments>
		<pubDate>Tue, 02 Aug 2011 15:00:22 +0000</pubDate>
		<dc:creator>darynholmes</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[Kanban]]></category>
		<category><![CDATA[Lean]]></category>
		<category><![CDATA[batching]]></category>
		<category><![CDATA[lean software development]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Scrum]]></category>
		<category><![CDATA[Teams]]></category>
		<category><![CDATA[WIP]]></category>

		<guid isPermaLink="false">http://darynholmes.wordpress.com/?p=160</guid>
		<description><![CDATA[The X Penny Game is a simulation game exploring the effects of WIP limits. It is a combination of Karen Greaves modified Scrum Penny game with Karl Scotland’s version of the Ball Flow Game. This game is geared to show the importance &#8230; <a href="http://darynholmes.wordpress.com/2011/08/02/the-x-penny-game/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=darynholmes.wordpress.com&#038;blog=2505811&#038;post=160&#038;subd=darynholmes&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>The X Penny Game is a simulation game exploring the effects of WIP limits. It is a combination of Karen Greaves <a href="http://scrumcoaching.wordpress.com/2010/04/19/the-scrum-penny-game-a-modification/">modified Scrum Penny game</a> with Karl Scotland’s version of the <a href="http://availagility.co.uk/2011/07/19/running-the-ball-flow-game/">Ball Flow Game</a>.</p>
<p>This game is geared to show the importance of limiting the work in progress and to explore the following formula (implied by <a href="http://www.factoryphysics.com/Principle/LittlesLaw.htm">Little&#8217;s Law</a>)</p>
<blockquote><p>Flow Time = WIP/Throughput</p></blockquote>
<ul>
<li>Flow Time (Cycle Time, Lead Time) – average amount of time it takes to fully complete a unit of work</li>
<li>WIP (Work In Process) – is the average amount of units in the system</li>
<li>Throughput – average number of units being completed within a given time frame</li>
</ul>
<p>The game is designed to work with 6 to 12 people – we had 8 players and 1 facilitator</p>
<p>The team divides into the following roles:</p>
<ul>
<li>1 – Customer</li>
<li>5 – Workers</li>
<li>The rest are efficiency experts</li>
</ul>
<p>We had a total of 8 players (6 workers, 2 efficiency experts).</p>
<p>The team organises themselves around a table. The image below shows how our team arranged themselves. Each worker has an empty area on the table directly in from of them referred to as a workspace.</p>
<p><a href="http://darynholmes.files.wordpress.com/2011/08/layout.png"><img class="size-medium wp-image-164 aligncenter" title="Layout" src="http://darynholmes.files.wordpress.com/2011/08/layout.png?w=300&#038;h=290" alt="" width="300" height="290" /></a><span id="more-160"></span><br />
<strong>The props</strong><br />
100 coins – I used 10 pence coins (GBP), all coins should be the same size<br />
1 table – large enough to have 3 people stand side-by-side on each side of the table<br />
A stopwatch for each efficiency expert – ones that can pause and resume<br />
A <a href="https://www.box.net/shared/opzx5pxyefrcdzsyipxf">spreadsheet</a> to record stats – discussed later</p>
<p><strong>The game</strong><br />
The customer takes a batch of coins (from 1 to 100) and passes them to a workspace. A worker turns over each coin one-by-one and then passes the batch to the next workspace where the process is repeated. A batch of coins are returned to the customer once they have been turned over once in each workspace. The facilitator records the time it took to process the coins. The team then decides how to improve the performance and tries again. It is recommended that you limit the game to 5 rounds to avoid fatigue.</p>
<p>The objective of the game: The team aims to turn over each coin once, in each workspace as fast as possible.</p>
<p>The objective should not be misinterpreted as “<em>each worker</em> turns over each coin once as fast as possible” . There is no 1 to 1 mapping between a worker and a workspace. This gives teams the opportunity to come up with a pairing or <a href="http://blog.brodzinski.com/2010/05/kanban-swarming.html">swarming</a> strategy that may improve performance e.g. near the end of the round all workers who have nothing to do can join a work station where there is still work to be done.</p>
<p><strong>The constraints</strong><br />
The game has soft constraints and hard constraints. The soft constraints are there for the team to change and to see the effect on performance. The hard constraints are there to make the game more challenging and to force certain behaviours. If you do change the hard constraints, change them after 4 or 5 rounds. The team can only make one change per round.</p>
<p><em>Soft Constraints</em><br />
These constraints are enforced on the first round, after that the team can start changing or removing them.</p>
<ul>
<li>The customer and product owner may only use their left hands</li>
<li>Batch sizes of 20 must be used</li>
</ul>
<p><em>Hard Constraints</em></p>
<ul>
<li>Only the customer can add coins to the system and removed them from the system</li>
<li>The complete batch must be processed before passing the batch on</li>
<li>Each batch must be the same size</li>
<li>The customer and workers may not pass batches to their neighbours sitting directly on the left or right, passing to the opposite neighbour is allowed. If you want to be cruel, don’t allow passing to opposite neighbours.</li>
<li>A worker can only turn one coin over at a time</li>
</ul>
<p><strong>Defects</strong><br />
A dropped coin is a defect, you can choose to collect the defects in a round or enforce a different penalty. If you would like to focus on the impact of defects you may want to use a higher penalty for defects  e.g. the worker needs to redo that batch. Obviously this introduces a new dimension to the game.</p>
<p><strong>Stats</strong><br />
The more stats you can collect the better. In our exercise each of the 2 efficiency experts chose a worker to monitor. They kept track of how much time the worker spent turning coins i.e. waiting time was not counted.</p>
<p>Karl Scotland was kind enough to provide a spreadsheet with the <a href="http://availagility.co.uk/2011/07/19/running-the-ball-flow-game/" target="_blank">Ball Flow Game</a>. I used a modified version of this spreadsheet in this X Penny Game. I needed to alter it as the ‘batches’ are different in this game. In the ball flow game the batch is the amount of balls in the system, in this game batches of coins are passed around. Thus 3 batches of 10 coins each could be in the system at once. This difference is reflected in the how the stats are collected. You can download the spreadsheet from the home page of this <a href="http://darynholmes.wordpress.com/">blog</a>, near the top right.</p>
<p>Whenever the customer added a batch to the system she yelled &#8220;in!&#8221;, when she received a processed batch she shouted &#8220;out!&#8221;. This helped me, the facilitator, to record when a batch went into or out of the system. The spreadsheet displays some interesting data and graphs.</p>
<p><a href="http://darynholmes.files.wordpress.com/2011/08/spreadsheet.png"><img class="aligncenter size-full wp-image-222" title="SpreadSheet" src="http://darynholmes.files.wordpress.com/2011/08/spreadsheet.png?w=584&#038;h=234" alt="" width="584" height="234" /></a></p>
<p><strong>The game in progress…</strong></p>
<p>The team gathered around the table, as per the image above. I explained the rules and gave them a few minutes to plan the routes for the batches of coins.</p>
<p>I had previously sketched out paths I thought the team would use to pass the coins and it looked similar to this:</p>
<p><a href="http://darynholmes.files.wordpress.com/2011/08/routes1.png"><img class="size-medium wp-image-165 aligncenter" title="Routes1" src="http://darynholmes.files.wordpress.com/2011/08/routes1.png?w=204&#038;h=300" alt="" width="204" height="300" /></a></p>
<p>I introduced the ‘neighbour constraint’ to create two troublesome intersections. The plan is for those intersections to cause delays and mishaps. The ‘X’ shape is the reason I called this the ‘X Penny Game’.</p>
<p>Interestingly the team did not come up with those paths, they opted for this strategy:</p>
<p><a href="http://darynholmes.files.wordpress.com/2011/08/routes2.png"><img class="size-medium wp-image-166 aligncenter" title="Routes2" src="http://darynholmes.files.wordpress.com/2011/08/routes2.png?w=206&#038;h=300" alt="" width="206" height="300" /></a><br />
Later I found out that I did not explain the rules clearly, the team thought they could not pass to opposite neighbours. This misunderstanding did not do any damage, it made things more challenging. You can choose which versions of the game you would like to try.</p>
<p><strong>Round 1</strong><br />
Batches of 20<br />
Left hand only<br />
All the hard rules in place</p>
<p><em>These are the initial set of constraints enforced in round 1.</em></p>
<p>The results:</p>
<p><a href="http://darynholmes.files.wordpress.com/2011/08/round1.png"><img class="aligncenter size-full wp-image-169" title="Round1" src="http://darynholmes.files.wordpress.com/2011/08/round1.png?w=584&#038;h=689" alt="" width="584" height="689" /></a></p>
<p>The first batch came back to the customer at 2:00 minutes. The total time was 3:45min. The first two batches went through the system the fastest. The batches were delivered at an average rate of every 30 seconds.</p>
<p>1 coin had dropped off the table and we noted this as a defect.</p>
<p>The efficiency experts said that worker X worked for 1:33min and worker Y was active for 1:35min.</p>
<p>The team said that they experienced major delays waiting for the first batch to arrive.</p>
<p><strong>Round 2</strong><br />
Left hand only<br />
All the hard rules in place<br />
Change: Batch size of 10</p>
<p><a href="http://darynholmes.files.wordpress.com/2011/08/round2.png"><img class="aligncenter size-full wp-image-170" title="Round2" src="http://darynholmes.files.wordpress.com/2011/08/round2.png?w=584&#038;h=686" alt="" width="584" height="686" /></a></p>
<div><span style="font-family:'Helvetica Neue', Helvetica, Arial, 'Nimbus Sans L', sans-serif;">The first batch was delivered at 1:04min, with a total time of 2:54. The average cycle time was about half of round 1. There were regular deliveries only 10 seconds apart. </span></div>
<div><span style="font-family:'Helvetica Neue', Helvetica, Arial, 'Nimbus Sans L', sans-serif;"><br />
</span></div>
<div><span style="font-family:'Helvetica Neue', Helvetica, Arial, 'Nimbus Sans L', sans-serif;">3 defects (dropped coins) occurred in this round.</span></div>
<div><span style="font-family:'Helvetica Neue', Helvetica, Arial, 'Nimbus Sans L', sans-serif;"><br />
</span></div>
<div><span style="font-family:'Helvetica Neue', Helvetica, Arial, 'Nimbus Sans L', sans-serif;">The efficiency experts recorded worker X had worked for 2:00min and worker Y was active for 1:25min. </span></div>
<div><span style="font-family:'Helvetica Neue', Helvetica, Arial, 'Nimbus Sans L', sans-serif;"><br />
</span></div>
<div><span style="font-family:'Helvetica Neue', Helvetica, Arial, 'Nimbus Sans L', sans-serif;">The team noted that the total time was half that of round 1, even though worker X worked for 30 seconds longer. </span></div>
<div><span style="font-family:'Helvetica Neue', Helvetica, Arial, 'Nimbus Sans L', sans-serif;"><br />
</span></div>
<div><span style="font-family:'Helvetica Neue', Helvetica, Arial, 'Nimbus Sans L', sans-serif;">While looking at the stats, one of the team members pointed out a WIP of 60 coins. We were doing batches of 10 with 5 workers. We came to the conclusion that a queue must have formed. The stats recorded a 60 WIP on 4 occasions.</span></div>
<div><span style="font-family:'Helvetica Neue', Helvetica, Arial, 'Nimbus Sans L', sans-serif;"><br />
</span></div>
<p><strong>Round 3</strong><br />
Keep: Batch of 10<br />
Left hand only<br />
All the hard rules in place<br />
Change: Don’t give coins to the next worker, unless they have an empty workspace</p>
<div>We discussed the new constraint “Don’t give coins to the next worker, unless they have an empty workspace”.  Some of us felt that this was now a pull system while others disagreed and felt more changes needed to be made before it was a true pull system. Personally I felt that it was a pull system as it looked like a Kanban system to me. We had WIP limits and the empty workspaces were visual indications that the worker required more coins.</div>
<p><a href="http://darynholmes.files.wordpress.com/2011/08/round3.png"><img class="aligncenter size-full wp-image-171" title="Round3" src="http://darynholmes.files.wordpress.com/2011/08/round3.png?w=584&#038;h=681" alt="" width="584" height="681" /></a></p>
<p>The first batch arrived at 0:56min, the total time was 2:45. This was 9 seconds faster than the previous round, interesting given the small change made in this round.</p>
<p>There were 2 defects in this round.</p>
<p>Worker X was busy for 1:45 minutes with worker Y working for 1:36 minutes.</p>
<p>The team felt that this round was more organised and that there was less waiting.</p>
<p>The following graph shows the WIP and the total time of the first 3 rounds:</p>
<p><a href="http://darynholmes.files.wordpress.com/2011/08/wipoffirst3rounds.png"><img class="aligncenter size-full wp-image-181" title="WIPOfFirst3Rounds" src="http://darynholmes.files.wordpress.com/2011/08/wipoffirst3rounds.png?w=584" alt=""   /></a></p>
<p>The throughput between round 2 and round 3 are intriguingly similar:</p>
<p><a href="http://darynholmes.files.wordpress.com/2011/08/throughput2and3.png"><img class="aligncenter size-full wp-image-179" title="Throughput2and3" src="http://darynholmes.files.wordpress.com/2011/08/throughput2and3.png?w=584" alt=""   /></a></p>
<p><strong>Round 4</strong><br />
Left hand only<br />
All the hard rules in place<br />
Keep: Don’t give coins to the next worker, unless they have an empty workspace<br />
Change: Batch of 5</p>
<p><a href="http://darynholmes.files.wordpress.com/2011/08/round4.png"><img class="aligncenter size-full wp-image-176" title="Round4" src="http://darynholmes.files.wordpress.com/2011/08/round4.png?w=584&#038;h=696" alt="" width="584" height="696" /></a></p>
<p>In this round, the first batch was delivered at 00:32min. The total time took ~2:50min. I don’t have the exact time, for some reason we only did 19 batches. None of us noticed this. The 19<sup>th</sup> batch was delivered at 2:43min. The throughput was impressive. On five occasions we had 2 batches coming through within the 10 second time span.</p>
<p>We encountered 4 defects.</p>
<p>The efficiency experts said worker X worked for 1:55, worker Y for 1:51.</p>
<p>The following graph overlays the WIP from round 3 with round 4:</p>
<p><a href="http://darynholmes.files.wordpress.com/2011/08/wip3and4.png"><img class="aligncenter size-full wp-image-180" title="WIP3and4" src="http://darynholmes.files.wordpress.com/2011/08/wip3and4.png?w=584" alt=""   /></a></p>
<p>In this case, moving from a batch of 10 to 5 seems counterproductive. Had we done all 100 coins, it may have taken longer than using batches of 10. This may have been due to the cost of moving coins from one workstation to the next. The team said this round felt more exhausting. This shows us that we don’t always benefit from reducing the batch size.</p>
<p><strong>Round 5</strong><br />
Left hand only<br />
All the hard rules in place<br />
Keep: Don’t give coins to the next worker, unless they have an empty workspace<br />
Change: Batch of 1</p>
<p>In this round the system ‘burst’. The first batch (coin) came in at 14 seconds. The throughput was about 4. By the time 8 coins had entered the system, we had recorded 7 defects. I could not keep up with the stats and called an end to this round.</p>
<p>The team noticed that while there was a high throughput, we also had a high defect rate and the pace was not sustainable. We could have made changes to make a batch of 1 more manageable e.g. limiting the number of batches\coins entering the system. Unfortunately we were not brave enough to try this batch size again.</p>
<p><strong>Round 6</strong><br />
Batch of 5<br />
Left hand only<br />
Keep: Don’t give coins to the next worker, unless they have an empty workspace<br />
Change: You can now pass to your direct left or right neighbour</p>
<p>This change allowed the team to simplify the routes the coins were passed along:</p>
<p><a href="http://darynholmes.files.wordpress.com/2011/08/routes3.png"><img class="aligncenter size-medium wp-image-167" title="Routes3" src="http://darynholmes.files.wordpress.com/2011/08/routes3.png?w=208&#038;h=300" alt="" width="208" height="300" /></a></p>
<p>This simplification reduced the time and disruption of passing a batch on. We remarked that this was similar to reducing the cost of moving work between stages. For example, when a development team passes work on to a separate testing team, the testing team would also need to learn about the requirements of these new features. If one team developed and tested the work we could avoid this duplication of effort.</p>
<p><a href="http://darynholmes.files.wordpress.com/2011/08/round6.png"><img class="aligncenter size-full wp-image-177" title="Round6" src="http://darynholmes.files.wordpress.com/2011/08/round6.png?w=584&#038;h=688" alt="" width="584" height="688" /></a></p>
<p>The first batch was delivered at 27 seconds and the total time was 2:18 minutes. No defects were recorded.</p>
<p>Worker X worked for 1.40 minutes and worker Y worked for 1.35 minutes. The team mentioned that worker Y was extremely consistent, almost always having a time of 1.35 minutes.  While we had a ‘new and faster’ system in place, there was no significant change in the average time spent working.</p>
<p>In this round the team felt that there was less waste in the system. They noted that they did better, even though people worked for the same period of time. One of the team members felt that they worked better in the first half of the round, the stats confirmed this.</p>
<p>A comment was made about the synchronicity that was achieved in this round. The team seemed to be working like clockwork. The team developed a natural rhythm or <a href="http://agile.dzone.com/news/introducing-kanban-flow-and">cadence</a>. This is reflected in the consistent cycle time:</p>
<p><a href="http://darynholmes.files.wordpress.com/2011/08/cycletime34and6.png"><img class="aligncenter size-full wp-image-183" title="CycleTime34and6" src="http://darynholmes.files.wordpress.com/2011/08/cycletime34and6.png?w=584" alt=""   /></a></p>
<p><strong>Round 7</strong><br />
Batch of 5<br />
Keep: Don’t give coins to the next worker, unless they have an empty workspace<br />
Keep: You can now pass to your direct left or right neighbour<br />
Change: Right hand only</p>
<p><a href="http://darynholmes.files.wordpress.com/2011/08/round7.png"><img class="aligncenter size-full wp-image-178" title="Round7" src="http://darynholmes.files.wordpress.com/2011/08/round7.png?w=584&#038;h=692" alt="" width="584" height="692" /></a></p>
<p>The first batch came in at 28 seconds, the total time was 2:19 min.</p>
<p>1 defect was recorded.</p>
<p>Worker X worked for 1.36 and worker Y worked for 1.35 minutes (again!).</p>
<p>We discussed why the team had done better with their left hands. The team said this was because they had now trained their left hands.</p>
<p><strong>Additional Discussions and Observations</strong></p>
<p>We have noticed that when we try to think of ways to improve performance, our ideas tend to involve increasing WIP e.g. introducing queues. Returning to this formula:</p>
<blockquote><p>Flow Time = WIP/Throughput</p></blockquote>
<p>Increasing the WIP may be counterproductive. We noticed this in round 2 and round 3. The only difference between the two round was that we waited for the next worker to have an empty workspace before passing on the batch. In round 2 there were times when we had a WIP of 60 while in round 3 the WIP did not exceed 50. Round 3 was completed 10 seconds faster than round 2.</p>
<p>The following graph shows the amount of time worked by worker X and worker Y mapped against the time it took to process all 100 coins in the different rounds:</p>
<p><a href="http://darynholmes.files.wordpress.com/2011/08/workertimes.png"><img class="aligncenter size-full wp-image-184" title="WorkerTimes" src="http://darynholmes.files.wordpress.com/2011/08/workertimes.png?w=584" alt=""   /></a></p>
<p>I have included this to show that performance was improved due to changes in the WIP and process. The individual workers did not perform their work any faster.</p>
<p><strong>What we didn’t try</strong></p>
<p>Some team members suggested a pairing strategy, another suggested converting the efficiency experts into workers to increase the size of the team.</p>
<p>We did not try a batch of 1, with fewer batches in the system.</p>
<p>There was a discussion about using queues, this would be interesting to try.</p>
<p>It may be possible to send batches around in opposite directions, it would take some organisation but it is possible.</p>
<p><em>Again. these ideas suggest increasing WIP therefore they may be counterproductive. </em></p>
<p><strong>Improvements</strong></p>
<p>We had a number of misunderstandings as I did not have the rules written down. Sometimes fuzzy rules lead to interesting results, sometimes they frustrate participants.</p>
<p>I would have liked to have spent more time gathering feedback from the participants. Next time I may hold less rounds to give more time for discussions.</p>
<p><strong>Your Turn</strong></p>
<p>You are welcome to try this with your team, I am keen to hear what results you observed&#8230;</p>
<br />Filed under: <a href='http://darynholmes.wordpress.com/category/agile/'>Agile</a>, <a href='http://darynholmes.wordpress.com/category/lean/kanban-lean/'>Kanban</a>, <a href='http://darynholmes.wordpress.com/category/lean/'>Lean</a> Tagged: <a href='http://darynholmes.wordpress.com/tag/agile/'>Agile</a>, <a href='http://darynholmes.wordpress.com/tag/batching/'>batching</a>, <a href='http://darynholmes.wordpress.com/tag/kanban/'>Kanban</a>, <a href='http://darynholmes.wordpress.com/tag/lean-software-development/'>lean software development</a>, <a href='http://darynholmes.wordpress.com/tag/performance/'>Performance</a>, <a href='http://darynholmes.wordpress.com/tag/scrum/'>Scrum</a>, <a href='http://darynholmes.wordpress.com/tag/teams/'>Teams</a>, <a href='http://darynholmes.wordpress.com/tag/wip/'>WIP</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/darynholmes.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/darynholmes.wordpress.com/160/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=darynholmes.wordpress.com&#038;blog=2505811&#038;post=160&#038;subd=darynholmes&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://darynholmes.wordpress.com/2011/08/02/the-x-penny-game/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/be1f59e4118912d487c5330586f39b72?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Daryn</media:title>
		</media:content>

		<media:content url="http://darynholmes.files.wordpress.com/2011/08/layout.png?w=300" medium="image">
			<media:title type="html">Layout</media:title>
		</media:content>

		<media:content url="http://darynholmes.files.wordpress.com/2011/08/spreadsheet.png" medium="image">
			<media:title type="html">SpreadSheet</media:title>
		</media:content>

		<media:content url="http://darynholmes.files.wordpress.com/2011/08/routes1.png?w=204" medium="image">
			<media:title type="html">Routes1</media:title>
		</media:content>

		<media:content url="http://darynholmes.files.wordpress.com/2011/08/routes2.png?w=206" medium="image">
			<media:title type="html">Routes2</media:title>
		</media:content>

		<media:content url="http://darynholmes.files.wordpress.com/2011/08/round1.png" medium="image">
			<media:title type="html">Round1</media:title>
		</media:content>

		<media:content url="http://darynholmes.files.wordpress.com/2011/08/round2.png" medium="image">
			<media:title type="html">Round2</media:title>
		</media:content>

		<media:content url="http://darynholmes.files.wordpress.com/2011/08/round3.png" medium="image">
			<media:title type="html">Round3</media:title>
		</media:content>

		<media:content url="http://darynholmes.files.wordpress.com/2011/08/wipoffirst3rounds.png" medium="image">
			<media:title type="html">WIPOfFirst3Rounds</media:title>
		</media:content>

		<media:content url="http://darynholmes.files.wordpress.com/2011/08/throughput2and3.png" medium="image">
			<media:title type="html">Throughput2and3</media:title>
		</media:content>

		<media:content url="http://darynholmes.files.wordpress.com/2011/08/round4.png" medium="image">
			<media:title type="html">Round4</media:title>
		</media:content>

		<media:content url="http://darynholmes.files.wordpress.com/2011/08/wip3and4.png" medium="image">
			<media:title type="html">WIP3and4</media:title>
		</media:content>

		<media:content url="http://darynholmes.files.wordpress.com/2011/08/routes3.png?w=208" medium="image">
			<media:title type="html">Routes3</media:title>
		</media:content>

		<media:content url="http://darynholmes.files.wordpress.com/2011/08/round6.png" medium="image">
			<media:title type="html">Round6</media:title>
		</media:content>

		<media:content url="http://darynholmes.files.wordpress.com/2011/08/cycletime34and6.png" medium="image">
			<media:title type="html">CycleTime34and6</media:title>
		</media:content>

		<media:content url="http://darynholmes.files.wordpress.com/2011/08/round7.png" medium="image">
			<media:title type="html">Round7</media:title>
		</media:content>

		<media:content url="http://darynholmes.files.wordpress.com/2011/08/workertimes.png" medium="image">
			<media:title type="html">WorkerTimes</media:title>
		</media:content>
	</item>
		<item>
		<title>Agile Practitioners</title>
		<link>http://darynholmes.wordpress.com/2011/07/27/agile-practitioners/</link>
		<comments>http://darynholmes.wordpress.com/2011/07/27/agile-practitioners/#comments</comments>
		<pubDate>Wed, 27 Jul 2011 10:52:58 +0000</pubDate>
		<dc:creator>darynholmes</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[Kanban]]></category>
		<category><![CDATA[lean software development]]></category>
		<category><![CDATA[Scrum]]></category>
		<category><![CDATA[ScrumMaster]]></category>
		<category><![CDATA[socialise]]></category>

		<guid isPermaLink="false">http://darynholmes.wordpress.com/?p=153</guid>
		<description><![CDATA[It is important to mingle with other members from our industry. This keeps us up to date and stops us getting too caught up in a closed off world. If you would like to have face to face discussions with other professionals &#8230; <a href="http://darynholmes.wordpress.com/2011/07/27/agile-practitioners/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=darynholmes.wordpress.com&#038;blog=2505811&#038;post=153&#038;subd=darynholmes&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.meetup.com/AgilePractitioners/"><img class="alignright size-medium wp-image-154" title="AgilePractitioners" src="http://darynholmes.files.wordpress.com/2011/07/agilepractitioners.png?w=245&#038;h=300" alt="" width="245" height="300" /></a>It is important to mingle with other members from our industry. This keeps us up to date and stops us getting too caught up in a closed off world. If you would like to have face to face discussions with other professionals you may wish to join us at one of the  <a href="http://www.meetup.com/AgilePractitioners/">Agile Practitioners</a> events. This London based group will be meeting at least once a month. We will be discussing a variety of topics. While we don&#8217;t plan to replace any of the existing Agile groups, we do intend to be intriguingly different.</p>
<br />Filed under: <a href='http://darynholmes.wordpress.com/category/agile/'>Agile</a> Tagged: <a href='http://darynholmes.wordpress.com/tag/agile/'>Agile</a>, <a href='http://darynholmes.wordpress.com/tag/kanban/'>Kanban</a>, <a href='http://darynholmes.wordpress.com/tag/lean-software-development/'>lean software development</a>, <a href='http://darynholmes.wordpress.com/tag/scrum/'>Scrum</a>, <a href='http://darynholmes.wordpress.com/tag/scrummaster/'>ScrumMaster</a>, <a href='http://darynholmes.wordpress.com/tag/socialise/'>socialise</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/darynholmes.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/darynholmes.wordpress.com/153/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=darynholmes.wordpress.com&#038;blog=2505811&#038;post=153&#038;subd=darynholmes&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://darynholmes.wordpress.com/2011/07/27/agile-practitioners/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/be1f59e4118912d487c5330586f39b72?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Daryn</media:title>
		</media:content>

		<media:content url="http://darynholmes.files.wordpress.com/2011/07/agilepractitioners.png?w=245" medium="image">
			<media:title type="html">AgilePractitioners</media:title>
		</media:content>
	</item>
		<item>
		<title>Avatars and not acting like a manager</title>
		<link>http://darynholmes.wordpress.com/2011/07/26/avatars-and-not-acting-like-a-manager/</link>
		<comments>http://darynholmes.wordpress.com/2011/07/26/avatars-and-not-acting-like-a-manager/#comments</comments>
		<pubDate>Tue, 26 Jul 2011 15:10:01 +0000</pubDate>
		<dc:creator>darynholmes</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[Kanban]]></category>
		<category><![CDATA[Lean]]></category>
		<category><![CDATA[lean software development]]></category>
		<category><![CDATA[Scrum]]></category>
		<category><![CDATA[ScrumMaster]]></category>
		<category><![CDATA[South Park]]></category>

		<guid isPermaLink="false">http://darynholmes.wordpress.com/?p=147</guid>
		<description><![CDATA[Recently we started using avatars on our Kanban board. We are certainly not the first to do this, however I was surprised by how excited and rejuvenated the team became. If you have never tried this I recommend you suggest it to your team &#8230; <a href="http://darynholmes.wordpress.com/2011/07/26/avatars-and-not-acting-like-a-manager/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=darynholmes.wordpress.com&#038;blog=2505811&#038;post=147&#038;subd=darynholmes&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Recently we started using avatars on our Kanban board. We are certainly not the first to do this, however I was surprised by how excited and rejuvenated the team became. If you have never tried this I recommend you suggest it to your team and see if they go for it.</p>
<p>Not only is it fun, but it is also practical. With one look at our board we can see exactly who is working on what and who they are working with. Each person has one avatar on the board, therefore they can only work on one task at a time. Occasionally someone will start work without updating the board, but this is very seldom.</p>
<p>We went for the classic <a title="South Park" href="http://www.sp-studio.de/">South Park characters</a>, each team member got to draw themselves, here is the result:</p>
<p><a href="http://darynholmes.files.wordpress.com/2011/07/stuffplanners.png"><img class="size-full wp-image-150 aligncenter" title="StuffPlanners" src="http://darynholmes.files.wordpress.com/2011/07/stuffplanners.png?w=584&#038;h=495" alt="" width="584" height="495" /></a></p>
<p>You may have noticed that my character (Daryn) is a bit stressed out. This is a reminder to myself, that as the ScrumMaster I should not get overly concerned about everything. I need to trust in the team and leave them alone to get the job done. I need to remember that a ScrumMaster is a facilitator and not a manager. For me, not acting like a manager is the most difficult part about being a ScrumMaster.</p>
<br />Filed under: <a href='http://darynholmes.wordpress.com/category/agile/'>Agile</a>, <a href='http://darynholmes.wordpress.com/category/lean/kanban-lean/'>Kanban</a>, <a href='http://darynholmes.wordpress.com/category/lean/'>Lean</a> Tagged: <a href='http://darynholmes.wordpress.com/tag/agile/'>Agile</a>, <a href='http://darynholmes.wordpress.com/tag/kanban/'>Kanban</a>, <a href='http://darynholmes.wordpress.com/tag/lean-software-development/'>lean software development</a>, <a href='http://darynholmes.wordpress.com/tag/scrum/'>Scrum</a>, <a href='http://darynholmes.wordpress.com/tag/scrummaster/'>ScrumMaster</a>, <a href='http://darynholmes.wordpress.com/tag/south-park/'>South Park</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/darynholmes.wordpress.com/147/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/darynholmes.wordpress.com/147/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=darynholmes.wordpress.com&#038;blog=2505811&#038;post=147&#038;subd=darynholmes&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://darynholmes.wordpress.com/2011/07/26/avatars-and-not-acting-like-a-manager/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/be1f59e4118912d487c5330586f39b72?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Daryn</media:title>
		</media:content>

		<media:content url="http://darynholmes.files.wordpress.com/2011/07/stuffplanners.png" medium="image">
			<media:title type="html">StuffPlanners</media:title>
		</media:content>
	</item>
	</channel>
</rss>
