<?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>public abstract string[] Blog() &#187; TDD</title>
	<atom:link href="http://extractmethod.wordpress.com/tag/tdd/feed/" rel="self" type="application/rss+xml" />
	<link>http://extractmethod.wordpress.com</link>
	<description>Wandering the Internet is search of better code and coding techniques</description>
	<lastBuildDate>Sat, 21 Jun 2008 14:01:14 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='extractmethod.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/aa59efbf3eef34a86e290a03a0aeb4a1?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>public abstract string[] Blog() &#187; TDD</title>
		<link>http://extractmethod.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://extractmethod.wordpress.com/osd.xml" title="public abstract string[] Blog()" />
		<item>
		<title>I still say Regions are not useful&#8230;but&#8230;</title>
		<link>http://extractmethod.wordpress.com/2008/06/02/i-still-say-regions-are-not-usefulbut/</link>
		<comments>http://extractmethod.wordpress.com/2008/06/02/i-still-say-regions-are-not-usefulbut/#comments</comments>
		<pubDate>Mon, 02 Jun 2008 07:35:01 +0000</pubDate>
		<dc:creator>casademora</dc:creator>
				<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[regions]]></category>
		<category><![CDATA[TDD]]></category>

		<guid isPermaLink="false">http://extractmethod.wordpress.com/2008/06/02/i-still-say-regions-are-not-usefulbut/</guid>
		<description><![CDATA[There was quite a bit of uproar regarding my rant about C# regions. At the time, I was looking through a lot of really bad code, and I was pretty peeved at how all the pieces of complex code were hidden away by Visual Studio.&#160; However, some of the comments seemed to imply that there [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=extractmethod.wordpress.com&blog=2356552&post=21&subd=extractmethod&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>There was quite a bit of uproar regarding my rant about C# regions. At the time, I was looking through a lot of really bad code, and I was pretty peeved at how all the pieces of complex code were hidden away by Visual Studio.&nbsp; However, some of the comments seemed to imply that there is no such thing as &#8220;perfect&#8221; or &#8220;good&#8221; code when you refer to code written by someone other than yourself. And, to be honest, that is true: I like to think the code I write is better than most other developers. However, I want to qualify what better is:</p>
<p>Better code is:</p>
<ul>
<li>Code that is tested</li>
<li>Code that is maintainable</li>
<li>Code that is understandable by someone other than me</li>
<li>Code that is changeable by someone other than me</li>
</ul>
<p>Even with those guidelines, there is still some room to define more terms, but we have to stop at some point. Notice how none of these points really points to Lines of Code, the degree of algorithm obfuscation or how low the average cyclomatic complexity is for your codebase. These bullet points take a professional approach to the software development profession. That is, I and many others are professionals, and we should write our code as professionals. I hold myself to the same high standards as I hold others. Granted, I don&#8217;t meet those standards all the time either. I try not to beat myself up about it, because I would never win.</p>
<p>However, I wanted to be less emotional about why regions are really not that great. Just flat out, the main reason I see is that when you encapsulate code in region blocks, you miss an opportunity for one of many refactorings. In other words, you are knowingly violating principles of good software development by hiding the &#8220;bad&#8221; code under the rug.</p>
<p>Regions are simply comments preprocessor-style comments. As with normal comments, they are removed before the code is compiled, and are only there to help our non-digital brains cope with the mess we created in the first place.</p>
<p>I try my best to follow the TDD (and by extension, BDD) methodology, and so far, I have found no need for regions. Ever. I find that they clutter the code. I also find that TDD manages the mess I create much better than regions because they are like little pieces of thoughts that stick around to keep verifying my intentions several features back. TDD is by no means a do all methodology, but it has saved my butt several times, and does tend to make you write code that is neat, well tested, well organized and region free.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/extractmethod.wordpress.com/21/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/extractmethod.wordpress.com/21/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/extractmethod.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/extractmethod.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/extractmethod.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/extractmethod.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/extractmethod.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/extractmethod.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/extractmethod.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/extractmethod.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/extractmethod.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/extractmethod.wordpress.com/21/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=extractmethod.wordpress.com&blog=2356552&post=21&subd=extractmethod&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://extractmethod.wordpress.com/2008/06/02/i-still-say-regions-are-not-usefulbut/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4c5bc935da066bf73113e426f396ba60?s=96&#38;d=identicon" medium="image">
			<media:title type="html">casademora</media:title>
		</media:content>
	</item>
		<item>
		<title>Desert Code Camp, Tomorrow</title>
		<link>http://extractmethod.wordpress.com/2008/05/31/desert-code-camp-tomorrow/</link>
		<comments>http://extractmethod.wordpress.com/2008/05/31/desert-code-camp-tomorrow/#comments</comments>
		<pubDate>Sat, 31 May 2008 07:18:16 +0000</pubDate>
		<dc:creator>casademora</dc:creator>
				<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[BDD]]></category>
		<category><![CDATA[codecamp]]></category>
		<category><![CDATA[TDD]]></category>

		<guid isPermaLink="false">http://extractmethod.wordpress.com/2008/05/31/desert-code-camp-tomorrow/</guid>
		<description><![CDATA[This is so last minute notice, but tomorrow is the Desert Code Camp in Tempe, AZ. I&#8217;ve attended the last few code camps, and they&#8217;ve been loads of help to me and my career in software development. This year, I decided that I should try to give something back, so I&#8217;m presenting on a couple [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=extractmethod.wordpress.com&blog=2356552&post=20&subd=extractmethod&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>This is so last minute notice, but tomorrow is the <a href="http://www.desertcodecamp.com">Desert Code Camp</a> in Tempe, AZ. I&#8217;ve attended the last few code camps, and they&#8217;ve been loads of help to me and my career in software development. This year, I decided that I should try to give something back, so I&#8217;m presenting on a couple of topics: Test Driven Development, and Behavior Driven Development. I&#8217;ve been practicing and evangelizing TDD for a couple of years now, and this is yet another outlet to try to convince others that this is the path toward code enlightenment.</p>
<p><strong>Spoiler Alert:</strong> BDD on the other hand is somewhat new to me. However, as I&#8217;ve read many of the descriptions, and BDD testing frameworks, its really all about the way you look at tests, and the eventual evolution of what your firstly written unit tests eventually become: behavior specifications. I will be talking about the little I&#8217;ve learned about rspec, nspec, and nbehave tomorrow.</p>
<p>See you all tomorrow!</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/extractmethod.wordpress.com/20/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/extractmethod.wordpress.com/20/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/extractmethod.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/extractmethod.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/extractmethod.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/extractmethod.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/extractmethod.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/extractmethod.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/extractmethod.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/extractmethod.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/extractmethod.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/extractmethod.wordpress.com/20/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=extractmethod.wordpress.com&blog=2356552&post=20&subd=extractmethod&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://extractmethod.wordpress.com/2008/05/31/desert-code-camp-tomorrow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4c5bc935da066bf73113e426f396ba60?s=96&#38;d=identicon" medium="image">
			<media:title type="html">casademora</media:title>
		</media:content>
	</item>
		<item>
		<title>A Simple DataTable Constraint for RhinoMocks</title>
		<link>http://extractmethod.wordpress.com/2008/02/07/a-simple-datatable-constraint-for-rhinomocks/</link>
		<comments>http://extractmethod.wordpress.com/2008/02/07/a-simple-datatable-constraint-for-rhinomocks/#comments</comments>
		<pubDate>Thu, 07 Feb 2008 07:08:16 +0000</pubDate>
		<dc:creator>casademora</dc:creator>
				<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[TDD]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[constrain]]></category>
		<category><![CDATA[DataTable]]></category>
		<category><![CDATA[RhinoMocks]]></category>
		<category><![CDATA[tests]]></category>
		<category><![CDATA[unit]]></category>

		<guid isPermaLink="false">http://extractmethod.wordpress.com/2008/02/07/a-simple-datatable-constraint-for-rhinomocks/</guid>
		<description><![CDATA[I&#8217;ve been a huge fan of Rhino Mocks since I heard about it on a way-back-episode of Dot Net Rocks HanselMinutes. One of the more awesome features of Rhino Mocks is that it utilizes a Record/Playback semantic so that you can set up your mocks with actual calls to the mock objects, then play them [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=extractmethod.wordpress.com&blog=2356552&post=17&subd=extractmethod&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I&#8217;ve been a huge fan of <a href="http://www.ayende.com/projects/rhino-mocks.aspx">Rhino Mocks</a> since I heard about it on a way-back-episode of <strike><a href="http://www.dotnetrocks.com">Dot Net Rocks</a></strike> <a href="http://hanselminutes.com/default.aspx?showID=43">HanselMinutes</a>. One of the more awesome features of Rhino Mocks is that it utilizes a Record/Playback semantic so that you can set up your mocks with actual calls to the mock objects, then play them back in your tests. This is great if you rely on intellisense when calling your object instances, or if you use <a href="http://www.jetbrains.com/resharper">Resharper</a> or another code refactoring tool.</p>
<p>Recently, I trying to use Rhino Mocks with DataTables like so:</p>
<blockquote>
<pre>DataTable a = <span class="kwrd">new</span> DataTable();
DataTable b = <span class="kwrd">new</span> DataTable(); 

MockObject mock = mockRepository.CreateMock&lt;MockObject&gt;();

<span class="kwrd">using</span> (mockRepository.Record())
{
   Expect.Call(mock.CreateRecord(<span class="str">"TableName"</span>, a, b).Return(1);
}
<span class="kwrd">using</span> (mockRepository.Playback())
{
  MyObject obj = <span class="kwrd">new</span> MyObject(mock);
  obj.Save();
}</pre>
</blockquote>
<p>When I ran the test, Rhino Mocks says that a the DataTable created during the obj.Save() call wasn&#8217;t the same as the one expected. This was correct as there were now two instances, and it seems that the default check Rhino Mocks performs is an Object.Equals(). Since I needed to do some more deep comparisons of the Expected and Actual DataTables, a fellow developer and I started a very simple DataTableConstraint:</p>
<div class="csharpcode">
<pre>    <span class="kwrd">class</span> DataTableConstraint : AbstractConstraint
    {
        <span class="kwrd">private</span> <span class="kwrd">readonly</span> DataTable _expected;
        <span class="kwrd">private</span> <span class="kwrd">string</span> _errorMessage;

        <span class="kwrd">public</span> DataTableConstraint(DataTable expected)
        {
            _expected = expected;
        }

        <span class="kwrd">public</span> <span class="kwrd">override</span> <span class="kwrd">bool</span> Eval(<span class="kwrd">object</span> obj)
        {
            DataTable actual = obj <span class="kwrd">as</span> DataTable;
            <span class="kwrd">if</span> (actual == <span class="kwrd">null</span>)
                <span class="kwrd">return</span> <span class="kwrd">false</span>;

            <span class="kwrd">if</span> (!CheckColumns(actual))
            {
                <span class="kwrd">return</span> <span class="kwrd">false</span>;
            }
            <span class="kwrd">if</span> (!CheckData(actual))
            {
                <span class="kwrd">return</span> <span class="kwrd">false</span>;
            }
            <span class="kwrd">return</span> <span class="kwrd">true</span>;
        }

        <span class="kwrd">private</span> <span class="kwrd">bool</span> CheckData(DataTable actual)
        {
            <span class="kwrd">if</span> (actual.Rows.Count == 0)
            {
                _errorMessage = <span class="str">"Actual table has no data to compare"</span>;
                <span class="kwrd">return</span> <span class="kwrd">false</span>;
            }
            <span class="kwrd">try</span>
            {
                <span class="kwrd">for</span> (<span class="kwrd">int</span> i=0; i &lt; _expected.Rows.Count; i++)
                {
                    <span class="kwrd">foreach</span> (DataColumn column <span class="kwrd">in</span> _expected.Columns)
                    {
                        <span class="kwrd">object</span> expectedCell = _expected.Rows[i][column];
                        <span class="kwrd">object</span> actualCell = actual.Rows[i][column];

                        <span class="kwrd">if</span> (expectedCell != actualCell)
                        {
                            _errorMessage = <span class="kwrd">string</span>.Format(<span class="str">"Expected {0} in Row ({1}), Column ({2}), but was {3}"</span>, expectedCell, i, column.ColumnName, actualCell);
                            <span class="kwrd">return</span> <span class="kwrd">false</span>;
                        }
                    }
                }
                <span class="kwrd">return</span> <span class="kwrd">true</span>;
            }
            <span class="kwrd">catch</span> (System.Exception e)
            {
                _errorMessage = e.Message;
                <span class="kwrd">return</span> <span class="kwrd">false</span>;
            }
        }

        <span class="kwrd">private</span> <span class="kwrd">bool</span> CheckColumns(DataTable actual)
        {
            <span class="kwrd">foreach</span> (DataColumn column <span class="kwrd">in</span> _expected.Columns)
            {
                <span class="kwrd">if</span> (!actual.Columns.Contains(column.ColumnName))
                {
                    _errorMessage = <span class="kwrd">string</span>.Format(<span class="str">"Could not find column {0} in {1}"</span>, column, actual);
                    <span class="kwrd">return</span> <span class="kwrd">false</span>;
                }
            }
            <span class="kwrd">return</span> <span class="kwrd">true</span>;
        }

        <span class="kwrd">public</span> <span class="kwrd">override</span> <span class="kwrd">string</span> Message
        {
            get { <span class="kwrd">return</span> _errorMessage; }
        }
    }</pre>
</div>
<p>To use this using the above sample code, do</p>
<blockquote>
<pre>Expect.Call(mock.CreateRecord(<span class="kwrd">null</span>, <span class="kwrd">null</span>, <span class="kwrd">null</span>).Constraints
(
  Is.Anything(),
  <span class="kwrd">new</span> DataTableConstraint(a),
  <span class="kwrd">new</span> DataTableConstraint(b)
);</pre>
</blockquote>
<p>Now, this is just a start, and will probably evolve more as I start to get more into verifying the data in two tables. Perhaps <a href="http://www.ayende.com/default.aspx">Oren</a> will create a new Syntax Helper along the lines of Data.Equals(expectedDataTable) since using a new Constraint() call is a little awkward.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/extractmethod.wordpress.com/17/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/extractmethod.wordpress.com/17/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/extractmethod.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/extractmethod.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/extractmethod.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/extractmethod.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/extractmethod.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/extractmethod.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/extractmethod.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/extractmethod.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/extractmethod.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/extractmethod.wordpress.com/17/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=extractmethod.wordpress.com&blog=2356552&post=17&subd=extractmethod&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://extractmethod.wordpress.com/2008/02/07/a-simple-datatable-constraint-for-rhinomocks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4c5bc935da066bf73113e426f396ba60?s=96&#38;d=identicon" medium="image">
			<media:title type="html">casademora</media:title>
		</media:content>
	</item>
	</channel>
</rss>