<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ORTHOcoders &#187; Presentations</title>
	<atom:link href="http://orthocoders.com/category/presentations/feed/" rel="self" type="application/rss+xml" />
	<link>http://orthocoders.com</link>
	<description>U can code it, we can help</description>
	<lastBuildDate>Fri, 13 Jan 2012 07:16:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Testing with random values: is it really dangerous?</title>
		<link>http://orthocoders.com/2011/03/06/testing-with-random-values-is-it-really-dangerous/</link>
		<comments>http://orthocoders.com/2011/03/06/testing-with-random-values-is-it-really-dangerous/#comments</comments>
		<pubDate>Mon, 07 Mar 2011 04:37:34 +0000</pubDate>
		<dc:creator>Amir Barylko</dc:creator>
				<category><![CDATA[BDD]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Presentations]]></category>
		<category><![CDATA[TDD]]></category>
		<category><![CDATA[Unit Testing]]></category>

		<guid isPermaLink="false">http://orthocoders.com/?p=254</guid>
		<description><![CDATA[Using random values can be a great tool when writing any kind of tests, however the word "random" sometimes scare developers and gives the idea that if we use unknown values how can we be sure the test is actually working? The key is to discover the tests scenarios, and the valid domain for each scenario...]]></description>
			<content:encoded><![CDATA[<p>Last Saturday I presented a session about automation at the Winnipeg Code Camp.</p>
<p>I&#8217;ve been doing presentations a the WPG CC for the past three years, and is always a blast! Great sessions, lots of networking and great food is an awesome combination!</p>
<p>After my session, some of the attendes approached me and started to talk about CI, their gotchas about testing and woes <img src='http://orthocoders.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>One of them mentioned that he wasn&#8217;t sure about the way they were using &#8220;hardcoded&#8221; values with the tests. He felt that probably should be a better way of defining valid inputs that could avoid the &#8220;smell&#8221;.</p>
<p>My suggestions was to consider using auto generated values. Random values are a great tool to avoid hardcoding inputs. Using &#8220;factories&#8221; to create valid test values helps us to make sure we have better coverage of the domain of valid inputs for our tests.</p>
<h2>How do I know what input is valid?</h2>
<p>You may wonder &#8220;But, if the values are random, the test may pass once and then fail at runtime, that&#8217;s really, really, dangerous!!!&#8221;.</p>
<p>The answer is <strong>No</strong>, not at all. The key is to identify the domain that makes your test pass and use the random generation tools to get values that are part of that domain. How to do that? Keep reading &#8230;</p>
<p>When you write a unit test you may have more than one scenario. For each scenario you need to find a set of inputs that make it pass.</p>
<p>For example, let&#8217;s use a method that verifies if a string is a <em>palindrome</em>. Definition of <em>palindrome</em> in wikipedia:</p>
<blockquote><p>A <strong>palindrome</strong> is a word, phrase, <a title="Palindromic number" href="http://en.wikipedia.org/wiki/Palindromic_number">number</a> or other sequence of units that can be read the same way in either direction</p></blockquote>
<p>Our method may look something like this in C#:</p>
<pre class="brush: csharp; title: ; notranslate">
bool IsPalindrome(string word)
</pre>
<p>So now, what should we do? Write one test that takes random strings as input, run it once and if we are lucky and passes then we are done? Woah, slow down your horses&#8230;.. take a deep breath&#8230; maybe two&#8230;.</p>
<h2>Preconditions, postconditions and domains</h2>
<p>The <em>precondition</em> of the method is the set of values that are valid in order to call the method. Valid means that we don&#8217;t get an exception when we use it, no matter what the result of the method is.</p>
<p>So, what are the values that are valid to use for <em>IsPalindrome</em>? It seems to me that any string should work, except <em>null</em>, therefore:</p>
<ul>
<li>Precondition: Any <strong>not</strong> <em>null</em> <em>string</em> instance.</li>
</ul>
<p>Great! Now let&#8217;s think about the <em>postcondition</em> and discover our scenarios. The <em>postcondition</em> defines what are the expected results and under what conditions are calculated.</p>
<p>Following our definition of what the method does, we can have two possible outputs:</p>
<ul>
<li><em>True: </em>if the input is <em>palindrome </em></li>
<li><em>False</em>: if the input is <strong>not</strong> <em>palindrome</em></li>
</ul>
<p>Thus, we have two scenarios:</p>
<ul>
<li>When the word is palindrome it should return true</li>
<li>When the word is not palindrome it should return false</li>
</ul>
<h2>Writing the test</h2>
<p>We need to test two scenarios and the best way of doing that is to write one test per scenario.</p>
<p>The first test should check the first part of the <em>postcondition</em>, I want to get <em>true </em>as result, and to do that the domain I need to use would be all the words that actually are <em>palindrome</em>. Let&#8217;s write the scenario:</p>
<blockquote><p><strong>Given</strong> I have a <em>palindrome</em> phrase</p>
<p><strong>When</strong> I check <em>IsPalindrome</em></p>
<p><strong>Then</strong> I should get <em>true</em></p></blockquote>
<p>I like to use the <a title="Using Given-When-Then (GWT) syntax" href="https://github.com/amirci/mt_testing/wiki/Given-When-Then">Given-When-Then</a> syntax, it&#8217;s very descriptive. I&#8217;m using the <a title="Maventhought Testing Framework" href="https://github.com/amirci/mt_testing">MT Testing</a> library that enforces GWT. Here is the scenario using C# and just one example:</p>
<pre class="brush: csharp; title: ; notranslate">
protected override void GivenThat()
{
    this._phrase = &quot;Madam Im adam&quot;;
}

protected override void WhenIRun()
{
   this.Actual = PalindromeChecker.IsPalindrome(this._phrase);
}

[It]
public void Should_validate_the_phrase_is_palindrome()
{
    this.Actual.Should().Be.True();
}
</pre>
<p>The test looks good, a bit of TDD and all green. Don&#8217;t worry about the implementation, you can <a title="MT Testing library with the example" href="https://github.com/amirci/mt_testing">download</a> all the source and check it out at the later <img src='http://orthocoders.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .</p>
<h2>Using Factories</h2>
<p>I&#8217;d like to make sure that for any <em>palindrome</em> phrase (that&#8217;s the domain we got from the pre and post condition) the test passes, no just for one example.</p>
<p>However, though generating all the <em>palindrome </em>words is a bit ambitious, we could settle for generating a collection of phrases that are <em>palindrome</em> and use that as input.</p>
<p><a title="MbUnit V3" href="http://gallio.org/">MbUnit</a> provides an attribute named &#8220;Factory&#8221; that allows a <em>static method</em> to define a collection of values to be passed to the test, let&#8217;s look at the code:</p>
<pre class="brush: csharp; title: ; notranslate">
        private readonly string _phrase;

        [Factory(&quot;PalindromeFactory&quot;)]
        public When_palindrome_checker_checks_a_palindrome_phrase(string phrase)
        {
            _phrase = phrase;
        }

        protected override void WhenIRun()
        {
            this.Actual = PalindromeChecker.IsPalindrome(this._phrase);
        }

        [It]
        public void Should_check_the_word_as_palindrome()
        {
            this.Actual.Should().Be.True();
        }

        protected static IEnumerable&lt;string&gt; PalindromeFactory()
        {
            yield return &quot;Madam I'm adam&quot;;
            yield return &quot;Draw pupil's lip upward&quot;;
            yield return ....
        }
</pre>
<p>Using the attribute, we indicate the runner that the test should be run for every value in the collection.</p>
<p>We run the test, and we can see in the result window something like:</p>
<p>### Step When_palindrome_checker_checks_a_palindrome_phrase(&quot;Madam I\&#8217;m adam&quot;): passed ###<br />
### Step When_palindrome_checker_checks_a_palindrome_phrase(&quot;Draw pupil\&#8217;s lip upward&quot;): passed ###<br />
### Step When_palindrome_checker_checks_a_palindrome_phrase(&quot;Gateman sees name, garageman sees name tag&quot;): passed ###<br />
### Step When_palindrome_checker_checks_a_palindrome_phrase(&quot;Go hang a salami; I\&#8217;m a lasagna hog&quot;): passed ###<br />
### Step When_palindrome_checker_checks_a_palindrome_phrase(&quot;I roamed under it as a tired, nude Maori&quot;): passed ###<br />
### Step When_palindrome_checker_checks_a_palindrome_phrase(&quot;Live not on evil&quot;): passed ###</p>
<h2>Using random strings</h2>
<p>One case covered, one to go.</p>
<p>The second test should verify the second part of the <em>postcondition</em>. I want to get <em>false</em> as result, so the domain I need to use is all the words that are <em>not palindrome</em>. Let&#8217;s write the scenario:</p>
<blockquote><p><strong>Given</strong> I don&#8217;t have palindrome phrase</p>
<p><strong>When</strong> I check IsPalindrome</p>
<p><strong>Then</strong> I should get false</p></blockquote>
<p>And the code:</p>
<pre class="brush: csharp; title: ; notranslate">
        private string _phrase;

        protected override void GivenThat()
        {
            this._phrase = &quot;This is not palindrome&quot;;
        }

        protected override void WhenIRun()
        {
            this.Actual = PalindromeChecker.IsPalindrome(this._phrase);
        }

        [It]
        public void Should_not_validate_the_phrase_as_palindrome()
        {
            this.Actual.Should().Be.False();
        }
</pre>
<p>The code works fine. However we have a similar situation as before, I&#8217;d like to have more values that belong to the domain that makes the method fail, that means any phrase that is <em>not palindrome</em>.</p>
<p>Factories are a good idea when we have a set of values that we want to use. In this case I don&#8217;t want to hardcode <em>non palindrome</em> phrases. I would prefer to have a way of creating those phrases without needing to enumerate all the examples.</p>
<p>Luckily MbUnit has another attribute that we can use to generate random strings. It&#8217;s called <em>RandomStrings</em> and it takes a regular expression to describe the string. Adding the attribute the code looks like this:</p>
<pre class="brush: csharp; title: ; notranslate">
        private readonly string _phrase;

        public When_palindrome_checker_checks_a_non_palindrome_phrase(
            [RandomStrings(Count=10, Pattern=@&quot;Weird [A-Z]{5,8} [0-9]{2}&quot;)]string phrase)
        {
            _phrase = phrase;
        }

        protected override void WhenIRun()
        {
            this.Actual = PalindromeChecker.IsPalindrome(this._phrase);
        }

        [It]
        public void Should_not_validate_the_phrase_as_palindrome()
        {
            this.Actual.Should().Be.False();
        }
</pre>
<p>I&#8217;m using a regular expression that <em>uses </em>numbers at the end to make sure the phrase is not <em>palindrome</em>.</p>
<p>We run the tests, and here is the output:</p>
<p>### Step When_palindrome_checker_checks_a_non_palindrome_phrase(&quot;Weird VGSKTTZ 64&quot;): passed ###<br />
### Step When_palindrome_checker_checks_a_non_palindrome_phrase(&quot;Weird VLMEWIJ 59&quot;): passed ###<br />
### Step When_palindrome_checker_checks_a_non_palindrome_phrase(&quot;Weird NDICJK 08&quot;): passed ###<br />
### Step When_palindrome_checker_checks_a_non_palindrome_phrase(&quot;Weird FEMBMSKK 88&quot;): passed ###<br />
### Step When_palindrome_checker_checks_a_non_palindrome_phrase(&quot;Weird IHOIOWN 38&quot;): passed ###<br />
### Step When_palindrome_checker_checks_a_non_palindrome_phrase(&quot;Weird ITIRCHAA 63&quot;): passed ###</p>
<h2>The moral of the story</h2>
<p>Random values are a powerful tool, not dangerous per se. They are part of our toolbox as developers. Can we use it wrong? Sure, but that&#8217;s a completely different story &#8230;.</p>
<p>If you want to get the full code, download it from the examples in <a title="MavenThought Testing Framework" href="https://github.com/amirci/mt_testing">MT Testing</a>. Check the <em>Palindrome</em> folder.</p>
<p>Do you have any other stories or comments about random values that you would like to share, please leave a comment, feedback is more than welcome.</p>
<p>Want to see an example with major complexity? Something that fits better your case? Tell me about it and I&#8217;ll add it to the MT Testing framework as an example of usage (and I&#8217;ll give you credit for it too!).</p>
]]></content:encoded>
			<wfw:commentRss>http://orthocoders.com/2011/03/06/testing-with-random-values-is-it-really-dangerous/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Presentation at Codemash</title>
		<link>http://orthocoders.com/2011/01/13/presentation-at-codemash/</link>
		<comments>http://orthocoders.com/2011/01/13/presentation-at-codemash/#comments</comments>
		<pubDate>Thu, 13 Jan 2011 18:36:19 +0000</pubDate>
		<dc:creator>Amir Barylko</dc:creator>
				<category><![CDATA[Presentations]]></category>

		<guid isPermaLink="false">http://orthocoders.com/?p=238</guid>
		<description><![CDATA[Wow, first day of CodeMash and so far it&#8217;s being great! It&#8217;s really an awesome conference! Yesterday at the precompiler, I went to the &#8221; Getting Published in an Evolving Industry: How to Survive and Even Thrive&#8221; with Jason Gilmore (@wjgilmore) and learnt a lot about writing books and how to publish, I&#8217;m really tempted [...]]]></description>
			<content:encoded><![CDATA[<p>Wow, first day of CodeMash and so far it&#8217;s being great! It&#8217;s really an awesome conference!</p>
<p>Yesterday at the precompiler, I went to the &#8221; Getting Published in an Evolving Industry:<br />
How to Survive and Even Thrive&#8221; with Jason Gilmore (@wjgilmore) and learnt a lot about writing books and how to publish, I&#8217;m really tempted to write an ebook!</p>
<p>Then in the afternoon I went to the &#8220;Git Immersion&#8221; session and was pretty interesting, is a tough call because for every session I go there is another four I can&#8217;t &#8230;</p>
<p>Today I&#8217;m going to do my presentation about IronRuby. I uploaded the slides and code to the <a title="Presentations page" href="/presentations" target="_blank">presentation</a> page, please feel free to download it and check it out before the conference.</p>
<p>In order to run ir u need to:<br />
* Install Iron Ruby from <a title="Iron Ruby at Codeplex" href="http://ironruby.codeplex.com/" target="_blank">http://ironruby.codeplex.com/</a></p>
<p>* Remember to put it in the path</p>
<p>* Install rake: igem install rake</p>
<p>* Install bundler: igem install bundler</p>
<p>* Check the tasks: rake -T</p>
<p>* Setup dependencies: rake setup</p>
<p>* Build: rake</p>
<p>* Run the tests: rake test</p>
<p>That&#8217;s it! Please contact me at @abarylko or amir@barylko.com if you have any issues.</p>
<p>Hope to see you at the session! Say hi if you are at codemash!</p>
<p>Now, in the afternoon, which session to go&#8230;. which session to go&#8230;..</p>
]]></content:encoded>
			<wfw:commentRss>http://orthocoders.com/2011/01/13/presentation-at-codemash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Microsoft Techdays 2010</title>
		<link>http://orthocoders.com/2010/12/07/microsoft-techdays-2010/</link>
		<comments>http://orthocoders.com/2010/12/07/microsoft-techdays-2010/#comments</comments>
		<pubDate>Wed, 08 Dec 2010 02:16:55 +0000</pubDate>
		<dc:creator>Amir Barylko</dc:creator>
				<category><![CDATA[Presentations]]></category>

		<guid isPermaLink="false">http://orthocoders.com/?p=233</guid>
		<description><![CDATA[Wow! First day of Techdays is gone and I&#8217;ve done both of my presentations: Test Driven Development Patterns Top 10 mistakes in unit testing The attendance was pretty good and all the attendees were great! Thank you everyone, I had a great time! I&#8217;ve uploaded to presentations the slides and a link to the source. [...]]]></description>
			<content:encoded><![CDATA[<p>Wow! First day of Techdays is gone and I&#8217;ve done both of my presentations:</p>
<ul>
<li>Test Driven Development Patterns</li>
<li>Top 10 mistakes in unit testing</li>
</ul>
<p>The attendance was pretty good and all the attendees were great! Thank you everyone, I had a great time!</p>
<p>I&#8217;ve uploaded to <a title="Presentation material for TechDays" href="/presentations" target="_blank">presentations</a> the slides and a link to the source. Both presentations using the same code.</p>
<p>Please follow each commit that mimics the steps I did in the presentation.</p>
<p>If u want to run the code please do the following:</p>
<ul>
<li>Download the code</li>
<li>Install ruby (if u don&#8217;t have it)</li>
<li>Install rake: gem install rake</li>
<li>Install bundler: gem install bundler</li>
<li>Then do setup: rake setup</li>
<li>Run the test to make sure: rake tests</li>
</ul>
<p>Please let me know if you have any issues or questions.</p>
]]></content:encoded>
			<wfw:commentRss>http://orthocoders.com/2010/12/07/microsoft-techdays-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Protegra SDEC 2010</title>
		<link>http://orthocoders.com/2010/10/13/protegra-sdec-2010/</link>
		<comments>http://orthocoders.com/2010/10/13/protegra-sdec-2010/#comments</comments>
		<pubDate>Wed, 13 Oct 2010 07:38:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[BDD]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Presentations]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[TDD]]></category>

		<guid isPermaLink="false">http://orthocoders.com/?p=220</guid>
		<description><![CDATA[I&#8217;m really excited about participating tomorrow of Protegra SDEC 2010! I&#8217;ll be doing two presentations, check the schedule! As usual all the presentation will be uploaded to the presentations page. Any comments or questions feel free to contact me!]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m really excited about participating tomorrow of <a href="http://www.sdec10.com">Protegra SDEC 2010</a>!</p>
<p>I&#8217;ll be doing two presentations, check the schedule!</p>
<p>As usual all the presentation will be uploaded to the <a href="/presentations">presentations</a> page.</p>
<p>Any comments or questions feel free to contact me!</p>
]]></content:encoded>
			<wfw:commentRss>http://orthocoders.com/2010/10/13/protegra-sdec-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Iron Ruby presentation at Dot Net User Group</title>
		<link>http://orthocoders.com/2010/09/21/iron-ruby-presentation-at-dot-net-user-group/</link>
		<comments>http://orthocoders.com/2010/09/21/iron-ruby-presentation-at-dot-net-user-group/#comments</comments>
		<pubDate>Tue, 21 Sep 2010 20:28:48 +0000</pubDate>
		<dc:creator>Amir Barylko</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Presentations]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://orthocoders.com/?p=207</guid>
		<description><![CDATA[Tonight at 6:00 PM I&#8217;ll be presenting a demo showing how to use Iron Ruby with .NET. Ruby is an awesome language that has lots of frameworks and tools that can be used to improve our day to day development. I uploaded the link to the code and the presentation to the presentations section in [...]]]></description>
			<content:encoded><![CDATA[<p>Tonight at 6:00 PM I&#8217;ll be presenting a demo showing how to use Iron Ruby with .NET.<br />
Ruby is an awesome language that has lots of frameworks and tools that can be used to improve our day to day development.<br />
I uploaded the link to the code and the presentation to the <a title="Presentations" href="/presentations">presentations</a> section in the blog.</p>
<p>See u there!</p>
]]></content:encoded>
			<wfw:commentRss>http://orthocoders.com/2010/09/21/iron-ruby-presentation-at-dot-net-user-group/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ASP.NET MVC CONF 2010</title>
		<link>http://orthocoders.com/2010/07/22/asp-net-mvc-conf-2010/</link>
		<comments>http://orthocoders.com/2010/07/22/asp-net-mvc-conf-2010/#comments</comments>
		<pubDate>Thu, 22 Jul 2010 20:14:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[BDD]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Presentations]]></category>
		<category><![CDATA[TDD]]></category>
		<category><![CDATA[Training]]></category>

		<guid isPermaLink="false">http://orthocoders.com/?p=194</guid>
		<description><![CDATA[Just finished my presentation about BDD for the ASP.NET MVC virtual conference! It was fun to have a virtual audience. I uploaded the code and slides to the presentations page. Any feedback would be appreciated! Feel free to ask any questions. Enjoy!]]></description>
			<content:encoded><![CDATA[<p>Just finished my presentation about BDD for the ASP.NET MVC virtual conference!</p>
<p>It was fun to have a virtual audience.</p>
<p>I uploaded the code and slides to the <a title="Presentations page" href="wordpress/presentations">presentations</a> page.</p>
<p>Any feedback would be appreciated! Feel free to ask any questions.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://orthocoders.com/2010/07/22/asp-net-mvc-conf-2010/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Real world BDD introduction</title>
		<link>http://orthocoders.com/2010/05/26/real-world-bdd-introduction/</link>
		<comments>http://orthocoders.com/2010/05/26/real-world-bdd-introduction/#comments</comments>
		<pubDate>Thu, 27 May 2010 02:58:40 +0000</pubDate>
		<dc:creator>Amir Barylko</dc:creator>
				<category><![CDATA[BDD]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Presentations]]></category>
		<category><![CDATA[TDD]]></category>
		<category><![CDATA[Training]]></category>
		<category><![CDATA[Unit Testing]]></category>
		<category><![CDATA[PrairieDevCon]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://orthocoders.com/?p=162</guid>
		<description><![CDATA[Getting ready for PrairieDevCon Next week I’ll be presenting at the PrairieDevCon in Regina and one of my presentations is about Behavior Driven Development, how to apply it using .NET tools like SpecFlow, Nunit, Watin, Cassini, MbUnit, etc. Because is a Dojo/Code with me presentation I’m planning to do a BDD exercise with all the [...]]]></description>
			<content:encoded><![CDATA[<h3>Getting ready for PrairieDevCon</h3>
<p>Next week I’ll be presenting at the <a href="http://www.prairiedevcon.com" target="_blank">PrairieDevCon</a> in Regina and one of my presentations is about Behavior Driven Development, how to apply it using .NET tools like SpecFlow, Nunit, Watin, Cassini, MbUnit, etc.</p>
<p>Because is a Dojo/Code with me presentation I’m planning to do a BDD exercise with all the attendees to show them how to describe a new feature using BDD and implement it together.</p>
<p>We will start with a project that has one feature implemented, and will code together the second feature using full BDD and TDD.</p>
<p>So, what should I use to illustrate BDD? No other than my old friend the MediaLibrary example that I used quite a few times, but now including a full BDD implementation.</p>
<h3>MediaLibrary</h3>
<p>The MediaLibrary project is a web application that  allows the user to register and catalog his collection of movies, books, games, etc.</p>
<p>I’m using GitHub to publish the code we are going to use in the Dojo. Right now the latest version represents the code that I’m going to start with.</p>
<p>If you would like to check out the code I’m going to use please go to the <a href="http://orthocoders.com/prairiedevcon/" target="_blank">PrairieDevCon page</a> on my blog and get the code from <a href="http://github.com/amirci/Media-Library-Demo-PrairieDevCon-2010" target="_blank">GitHub</a>, read the README file to verify you have the requirements installed and the application is working.</p>
<p>Do you have everything installed? Did you read the README file? Cool, open the solution and let’s move on!</p>
<h3>Using BDD</h3>
<p>Behavior Driven Development is a term used to describe (in our case) development that starts by writing the feature (or user story) that we want to implement. Once we have the feature, we will use a “story runner” that will run the feature we just wrote and show if the story is actually implemented as we wanted or not yet. If it is, good, everything should be “green”. If not, we get a “red”, and we have to add code and implement more functionality to make it pass.</p>
<p>To write the user story we are going to use a particular syntax from the Gherkin language. The Gherkin language has very few rules, please read the introduction for Cucumber from <a title="http://wiki.github.com/aslakhellesoy/cucumber/gherkin" href="http://wiki.github.com/aslakhellesoy/cucumber">Aslak Hellesoy</a>.</p>
<p>Let’s see the feature that it’s implemented in the code, <em>Browse Movies:</em></p>
<pre class="code"><span style="color: blue;">Feature: </span>Browse Movies
    As a User
    I want to Browse Movies
    So I can see the contents of the library

    <span style="color: blue;">Scenario: </span>Browse available movies
        <span style="color: blue;">Given </span><span style="color: green;">I have the following movies:
          </span>| title           |
          | Blazing Saddles |
          | Space Balls     |
        <span style="color: blue;">When </span><span style="color: green;">I go to </span><span style="color: red;">Movies
        </span><span style="color: blue;">Then </span><span style="color: green;">I should see in the listing:
          </span>| title             |
          | Blazing Saddles   |
          | Space Balls       |</pre>
<p>What is most important here is to look at the scenario. The scenario is describing that if you have movies A, B and C in the library, when you browse you should see the same movies on the <em>Movies</em> page.</p>
<p>Now if we want to check the feature manually, what would we do? Something like this:</p>
<ol>
<li>Add the movies to the storage</li>
<li>Start the web application</li>
<li>Launch the browser</li>
<li>Go to the movies page</li>
<li>Check that all the movies in the storage are listed in the browser</li>
</ol>
<p>The thing is that I don’t want to validate each feature (with many scenarios) manually, I’d like the scenario/feature runner to do that for me, add the movies, launch the browser and check, everything automated following the steps I wrote in my scenario.</p>
<p>Probable we could manage to write code that will do that for us, now, the question is how the scenario runner translates this feature into actual code? If we were using rails we could use <em>Cucumber, </em>but luckily for the .NET world we can use <a href="http://www.specflow.org">SpecFlow</a> (<em><a href="http://ironruby.net/download">IronRuby</a></em> too, but that’s another post).</p>
<h3>Given That I have the following movies</h3>
<p>Specflow is a tool that understands <a href="http://wiki.github.com/aslakhellesoy/cucumber/gherkin">Gherkin</a> and generates an <a href="http://nunit.org/">NUnit</a> test for every feature that we use. Being an NUnit test, simplifies how we going to run the specification. Just run the NUnit test with your favorite test runner: <a href="http://www.jetbrains.com/resharper/">ReSharper</a>, NUnit (console or GUI), <a href="http://www.gallio.org">MbUnit</a>, etc.</p>
<p>Each scenario is composed by a series of steps, each step is identified by a Gherkin keyword, in our feature we found <em>Given, When</em> and <em>Then.</em></p>
<p>The NUnit test has code for each scenario and will invoke the steps indicated in the scenario.</p>
<p>In order to do so, Specflow uses the text that we write in the step, to match the code.</p>
<p>Let’s look at our first step “Given I have the following movies:”. In order to implement the step, in the code, you will find a method that looks like:</p>
<pre class="code">[<span style="color: #2b91af;">Given</span>(<span style="color: #a31515;">@"I have the following movies:"</span>)]
<span style="color: blue;">public void </span>AddMovies(<span style="color: #2b91af;">Table </span>movies)
{
    movies.Rows.ForEach(row =&gt; AddMovieToStorage(row[<span style="color: #a31515;">"title"</span>]));
}</pre>
<p>The <em>Given</em> attribute is used to match the text we wrote in the scenario, to indicate the the method <em>AddMovies</em> should be called when the step is invoked.</p>
<p>The step in the scenario indicates that the method receives a series of rows should be passed as parameter (first row is the title, every column separated by “|”), that is why it receives a <em>Table</em>.</p>
<p>In the implementation for each movie in the table, the title will be added to the storage. Check the method <em>AddMoviesToStorage</em> for more details.</p>
<p>Now that we setup our storage we are ready to move on and launch the browser.</p>
<h3>When I go to Movies</h3>
<p>The next step to implement implies opening the browser and going to the <em>Movies </em>page to see the listing<em>.</em></p>
<p>Now, to do so we need two things, first the web application running and then to launch a browser to go the actual page.</p>
<p>To run the application I’m going to use <a href="http://www.asp.net/downloads/archived-v11/cassini">Cassini</a> web server. The setup of the features will start the web server and stop it when it’s not needed any more. We can see the implementation in the <em>Browser </em>class under Utililty.</p>
<pre class="code"><span style="color: blue;">static </span>Browser()
{
    WebServer = <span style="color: blue;">new </span><span style="color: #2b91af;">Server</span>(Port, <span style="color: #a31515;">"/"</span>, GetPhysicalPath());
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>With the server running, we now need to launch the browser and automate the checking for all the movies.</p>
<p>For that we are going to use<em> </em>Watin. <a href="http://watin.sourceforge.net/">Watin</a> (Web automation test in .NET) is a library that helps us to manipulate the browser (based on <a href="http://watir.com/">Watir</a>) and also give us all the HTML for the page we are visiting.</p>
<p>We can see the use of the <em>IE </em>instance in the <em>Browser</em> class:</p>
<pre class="code"><span style="color: blue;">public static void </span>InitializeBrowser()
{
    WebServer.Start();

    Instance = <span style="color: blue;">new </span><span style="color: #2b91af;">IE</span>(ApplicationURL);
}

<span style="color: blue;">public static void </span>ShutdownBrowser()
{
    Instance.Close();

    WebServer.Stop();
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Now that we have our server running, and our <em>IE</em> instance, we only need to go to the right path. In this case we want to go to “/Movies”. For that let’s look at the <em>NavigationSteps class:</em></p>
<pre class="code">[<span style="color: #2b91af;">When</span>(<span style="color: #a31515;">@"I go to (.*)"</span>)]
<span style="color: blue;">public void </span>WhenIGoToPage(<span style="color: blue;">string </span>pageName)
{
    <span style="color: #2b91af;">Browser</span>.GoTo(PathFor(pageName));
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>The step uses the browser to navigate to the right page. The page is passed as a parameter that we can see in the attribute as a regular expression.</p>
<p>So far, so good. Now, our last step is to check for the movies in the page to make sure that all of them are in the list.</p>
<h3>Then I should see in the listing</h3>
<p>To implement the last step in our scenario we are going to use the following implementation:</p>
<pre class="code">[<span style="color: #2b91af;">Then</span>(<span style="color: #a31515;">@"I should see in the listing:"</span>)]
<span style="color: blue;">public void </span>AssertListingContains(<span style="color: #2b91af;">Table </span>movies)
{
    <span style="color: blue;">var </span>expected = movies.Rows.Select(row =&gt; row[<span style="color: #a31515;">"title"</span>]);

    <span style="color: blue;">var </span>listing = <span style="color: blue;">this</span>.Page.Listing;

    listing.Should().Have.SameSequenceAs(expected);
}</pre>
<p>Again we are using a step that takes a table as parameter, so we iterate thru the table and get the titles of all the movies that should be in the page.</p>
<p>The code has no mysteries except the <em>Page</em> property.</p>
<pre class="code"><span style="color: blue;">public </span>ListingSteps()
{
    <span style="color: blue;">this</span>.Page = <span style="color: blue;">new </span><span style="color: #2b91af;">BrowseMoviesPage</span>();
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>The <em>Page</em> property is initialized in the constructor and the goal of the <em>BrowseMoviesPage</em> is to abstract the internals of how the movies are listed in the page. For example, right now the view that implements the listing of movies uses a table for each movie, however it could use a <em>DIV</em> or some other tag. Here is the implementation:</p>
<pre class="code"><span style="color: blue;">public </span><span style="color: #2b91af;">IEnumerable</span>&lt;<span style="color: blue;">string</span>&gt; Listing
{
    <span style="color: blue;">get
    </span>{
        <span style="color: blue;">var </span>elements = <span style="color: #2b91af;">Browser</span>.Instance.TableCells.Where(cell =&gt; cell.ClassName == <span style="color: #a31515;">"title"</span>);

        <span style="color: blue;">return </span>elements.Select(e =&gt; e.InnerHtml.Trim());
    }
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>As we can see, the code is getting all the table cells where the <em>CSS</em> class is <em>title</em> and then getting the inner html and trimming it.</p>
<p>If we would have to use this code every time we want to check the listing we would have code duplication, plus if the implementation of the view changes, we would have to modify each piece of code that refers to this page. Using the <em>PageObject</em> pattern we avoid code duplication and it’s easy to change the implementation.</p>
<p>And voila! We got all our steps implemented.</p>
<h3>What’s next?</h3>
<p>If you join me next week on the Prairie Dev Con, we will implement the next feature together “<em>Add Movies”.</em></p>
<p>What’s so cool about BDD? Please go ahead and run “rake test:features” on the command line, and you’ll see that the steps for the second feature are still pending, that means that they are not implemented yet.</p>
<p>Writing the feature first we manage to describe what we want, and implementing step by step we make sure that we are working towards make the feature pass. BDD on the outside and TDD on the inside.</p>
<p>Hope to see you all next week in the conference!</p>
]]></content:encoded>
			<wfw:commentRss>http://orthocoders.com/2010/05/26/real-world-bdd-introduction/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>RoR Course Content</title>
		<link>http://orthocoders.com/2010/05/08/ror-course-content-and-sessions/</link>
		<comments>http://orthocoders.com/2010/05/08/ror-course-content-and-sessions/#comments</comments>
		<pubDate>Sat, 08 May 2010 22:44:07 +0000</pubDate>
		<dc:creator>Amir Barylko</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Presentations]]></category>
		<category><![CDATA[Training]]></category>
		<category><![CDATA[RubyOnRails]]></category>
		<category><![CDATA[Unit Testing]]></category>

		<guid isPermaLink="false">http://orthocoders.com/2010/05/08/ror-course-content-and-sessions/</guid>
		<description><![CDATA[I'm giving a RoR training course at NMM on June 14th to 18th, the content includes...]]></description>
			<content:encoded><![CDATA[<p>Here is the content that I’m going to cover in the RoR course I’m giving on June 14th – to 18th at <a href="http://newmediamanitoba.com">NMM</a>:</p>
<h3>Ruby content</h3>
<ul>
<li>Introduction to scripting languages</li>
<li>Introduction to unit testing, functional testing, BDD</li>
<li>Great Ruby and Rails free resources</li>
<li>Basic git usage (distribute version control system), github</li>
<li>IRB, rubygems</li>
<li>Basic Ruby syntax</li>
<li>Classes and inheritance in Ruby</li>
<li>Ruby blocks, closures, iterators, examples of use</li>
<li>Basic usage of Ruby standard library</li>
<li>Modules, mixins, multiple inheritance in Ruby</li>
<li>RSpec, Cucumber</li>
</ul>
<h3>Ruby on Rails content</h3>
<ul>
<li>Introduction to MVC for web frameworks, Rails history, comparison with other frameworks</li>
<li>Serving static content</li>
<li>Rails ORM (ActiveRecord), migrations, database backends Joins, validations, associations, named_scopes</li>
<li>Controllers, information sharing, filters, permissions Helpers, idioms, code smells</li>
<li>Routing, REST, nested resources Login, logout, sessions, attachments</li>
<li>Gem management, plugins, git submodules</li>
<li>Advanced forms, custom form builders haml, sass will_paginate, paperclip, authlogic, formtastic</li>
<li>Rspec-rails, cucumber-rails, other test gems</li>
<li>Rails console, Rails runner Scripted deployment</li>
<li>Testing web applications, modern Rails testing</li>
</ul>
<p>Each day will consist of an explanation of the subjects, practical examples illustrating the concepts and hands on time to implement a series of exercises using the topics presented during the day.</p>
<p>Any questions please contact me!</p>
]]></content:encoded>
			<wfw:commentRss>http://orthocoders.com/2010/05/08/ror-course-content-and-sessions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Prairie Development Conference</title>
		<link>http://orthocoders.com/2010/05/03/prairie-development-conference/</link>
		<comments>http://orthocoders.com/2010/05/03/prairie-development-conference/#comments</comments>
		<pubDate>Tue, 04 May 2010 03:14:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[BDD]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Patterns]]></category>
		<category><![CDATA[Presentations]]></category>
		<category><![CDATA[TDD]]></category>
		<category><![CDATA[Unit Testing]]></category>
		<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Mocking]]></category>
		<category><![CDATA[SOLID]]></category>

		<guid isPermaLink="false">http://orthocoders.com/2010/05/03/prairie-development-conference/</guid>
		<description><![CDATA[On Jun 2nd and 3rd I’ll be speaking at the PrairieDevCon 2010 in Regina!!! You can read about it at http://www.prairiedevcon.com/. It would be two complete days of sessions with four tracks and many cool speakers!!!! I will do two presentations: Real World Behaviour Driven Development Behaviour Driven Development drives you process towards keeping the [...]]]></description>
			<content:encoded><![CDATA[<p>On Jun 2nd and 3rd I’ll be speaking at the <strong>PrairieDevCon</strong> 2010 in Regina!!!</p>
<p><a href="http://orthocoders.com/wp-content/uploads/2010/05/Prairie_Dev_Con_Presenter.gif"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Prairie_Dev_Con_Presenter" src="http://orthocoders.com/wp-content/uploads/2010/05/Prairie_Dev_Con_Presenter_thumb.gif" border="0" alt="Prairie_Dev_Con_Presenter" width="225" height="123" /></a></p>
<p>You can read about it at <a href="http://www.prairiedevcon.com/">http://www.prairiedevcon.com/</a>. It would be two complete days of sessions with four tracks and many cool speakers!!!!</p>
<p>I will do two presentations:</p>
<p><strong> </strong></p>
<h5>Real World Behaviour Driven Development</h5>
<p>Behaviour Driven Development drives you process towards keeping the focus on the stakeholder’s goals while discovering new features to achieve those goals.<br />
But&#8230; what does it mean in a .NET project to use BDD? What do I have to change? What tools are available? Can I use it for project with actual deadlines? How the quality will be improved?<br />
We are going to see a real world example from start to finish using BDD and TDD while answering all those questions. After the session you will have the foundation to apply BDD with confidence on any .NET project.<br />
<strong>Track:</strong> Developer Foundation<br />
<strong>Style:</strong> Dojo (Bring your laptop and code with me!)</p>
<h5>Test Driven Development Patterns for .NET Developers</h5>
<p>Test Driven Development is a methodology that will help us to discover our model while improving the quality of our software.<br />
We are going to see different patterns to help us deal with day to day problems like constructor initialization, exception testing, combinatorial tests, database testing, and many others.<br />
<strong>Track:</strong> Developer Foundation<br />
<strong>Style:</strong> Lecture</p>
<p>Hope to see you there!!!</p>
]]></content:encoded>
			<wfw:commentRss>http://orthocoders.com/2010/05/03/prairie-development-conference/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Microsoft TechDays Canada</title>
		<link>http://orthocoders.com/2009/09/16/microsoft-techdays-canada/</link>
		<comments>http://orthocoders.com/2009/09/16/microsoft-techdays-canada/#comments</comments>
		<pubDate>Thu, 17 Sep 2009 04:30:27 +0000</pubDate>
		<dc:creator>Amir Barylko</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Presentations]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[SOLID]]></category>

		<guid isPermaLink="false">http://orthocoders.com/?p=51</guid>
		<description><![CDATA[I&#8221;ll be presenting this year at Microsoft TechDays Canada. I&#8217;m super excited! Here is a brief description of my presentation: SOLIDify Your Microsoft ASP.NET MVC Applications Object-oriented programming makes it easier to manage complexity, but only if you do it right. The five SOLID principles of class design (one for each letter) help ensure that [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8221;ll be presenting this year at <span lang="EN-CA"><a href="http://techdays.ca/" target="_blank">Microsoft TechDays Canada</a>.</span> I&#8217;m super excited!</p>
<p>Here is a brief description of my presentation:</p>
<p style="margin-left: 0.5in;"><strong><span lang="EN-CA">SOLIDify Your Microsoft <a href="http://asp.net/" target="_blank">ASP.NET</a> MVC Applications</span></strong></p>
<p style="margin-left: 0.5in;"><span lang="EN-CA">Object-oriented programming makes it easier to manage complexity, but only if you do it right. The five SOLID principles of class design (one for each letter) help ensure that you’re writing applications that are flexible, comprehensible and maintainable, and we’ll explain and explore them in this session. We’ll start with a brittle <a href="http://asp.net/" target="_blank">ASP.NET</a> MVC application that’s badly in need of refactoring and fix it by applying the SOLID principles. This session is a good follow-up for Introducing <a href="http://asp.net/" target="_blank">ASP.NET</a> MVC, but it’s also good for developers of <a href="http://asp.net/" target="_blank">ASP.NET</a> MVC looking to improve their code – or even if you’re not planning to use <a href="http://asp.net/" target="_blank">ASP.NET</a> MVC. The SOLID principles apply to programming in any object-oriented language or framework.</span></p>
<p style="margin-left: 0.5in;"><em><span lang="EN-CA">December 15-16 at the Winnipeg Convention Centre</span></em></p>
<p>Hope u can make it!</p>
]]></content:encoded>
			<wfw:commentRss>http://orthocoders.com/2009/09/16/microsoft-techdays-canada/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

