<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>ploeh blog : Productivity</title><link>http://blogs.msdn.com/ploeh/archive/tags/Productivity/default.aspx</link><description>Tags: Productivity</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Test-Driven Properties</title><link>http://blogs.msdn.com/ploeh/archive/2009/01/12/test-driven-properties.aspx</link><pubDate>Mon, 12 Jan 2009 11:26:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9307262</guid><dc:creator>ploeh</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/ploeh/comments/9307262.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ploeh/commentrss.aspx?PostID=9307262</wfw:commentRss><wfw:comment>http://blogs.msdn.com/ploeh/rsscomments.aspx?PostID=9307262</wfw:comment><description>&lt;P&gt;&lt;A class="" href="http://blog.ploeh.dk/2009/01/28/ZeroFrictionTDD.aspx" mce_href="http://blog.ploeh.dk/2009/01/28/ZeroFrictionTDD.aspx"&gt;Zero-Friction TDD&lt;/A&gt; post #10:&lt;/P&gt;
&lt;P&gt;In principle, defining properties (or fields, for that matter) while TDD'ing should be no different than &lt;A href="http://blogs.msdn.com/ploeh/archive/2009/01/05/use-the-generate-method-stub-smart-tag-to-stay-in-the-zone.aspx" mce_href="http://blogs.msdn.com/ploeh/archive/2009/01/05/use-the-generate-method-stub-smart-tag-to-stay-in-the-zone.aspx"&gt;defining methods&lt;/A&gt;. Again, the important part is to stay focused on the test at hand, and not become bogged down by implementation details.&lt;/P&gt;
&lt;P&gt;Unfortunately, neither Visual Studio 2005 nor 2008 has a &lt;EM&gt;Generate property stub&lt;/EM&gt; smart tag, so until the day arrives when we get support for such in our IDE of choice (and for the record: I have no idea about when this is going to happen), we'll have to resort to more primitive means:&lt;/P&gt;
&lt;P&gt;Just reference the non-existing property and move on:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/ploeh/WindowsLiveWriter/TestDrivenProperties_1307E/UndefinedProperty_2.png" mce_href="http://blogs.msdn.com/blogfiles/ploeh/WindowsLiveWriter/TestDrivenProperties_1307E/UndefinedProperty_2.png"&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=139 alt=UndefinedProperty src="http://blogs.msdn.com/blogfiles/ploeh/WindowsLiveWriter/TestDrivenProperties_1307E/UndefinedProperty_thumb.png" width=502 border=0 mce_src="http://blogs.msdn.com/blogfiles/ploeh/WindowsLiveWriter/TestDrivenProperties_1307E/UndefinedProperty_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;As you can see from the picture, my test code gets squiggly lines under the MyProperty property because this property doesn't exist (yet).&lt;/P&gt;
&lt;P&gt;Once more, the important point is to move on and resist the urge to fix this immediately. Don't even waste memory (your own, that is) on the fact that you need to implement this soon; just forget about it right away. The compiler will remind you in due time.&lt;/P&gt;
&lt;P&gt;This technique is a essentially what &lt;A href="http://blog.objectmentor.com/articles/category/michaels-musings" mce_href="http://blog.objectmentor.com/articles/category/michaels-musings"&gt;Michael Feathers&lt;/A&gt; calls &lt;EM&gt;leaning on the compiler&lt;/EM&gt;, although the context is different&lt;EM&gt;.&lt;/EM&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9307262" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/ploeh/archive/tags/Unit+Testing/default.aspx">Unit Testing</category><category domain="http://blogs.msdn.com/ploeh/archive/tags/Productivity/default.aspx">Productivity</category></item><item><title>Use The Generate Method Stub Smart Tag To Stay In The Zone</title><link>http://blogs.msdn.com/ploeh/archive/2009/01/05/use-the-generate-method-stub-smart-tag-to-stay-in-the-zone.aspx</link><pubDate>Mon, 05 Jan 2009 11:53:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9278509</guid><dc:creator>ploeh</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/ploeh/comments/9278509.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ploeh/commentrss.aspx?PostID=9278509</wfw:commentRss><wfw:comment>http://blogs.msdn.com/ploeh/rsscomments.aspx?PostID=9278509</wfw:comment><description>&lt;P&gt;Yet Another &lt;A class="" href="http://blog.ploeh.dk/2009/01/28/ZeroFrictionTDD.aspx" mce_href="http://blog.ploeh.dk/2009/01/28/ZeroFrictionTDD.aspx"&gt;Zero-Friction TDD&lt;/A&gt; Article (YAZFTA):&lt;/P&gt;
&lt;P&gt;When writing unit tests in the TDD fashion, it's important to stay in the zone and not get side-tracked by irrelevant issues. You need to avoid what I call mental context switching. Focus on writing the test and postpone all else to later, but make sure that you do it in such a way that you don't have to waste brainpower on remembering what you postponed.&lt;/P&gt;
&lt;P&gt;One easy way to do this is by using the &lt;EM&gt;Generate method stub&lt;/EM&gt; smart tag in Visual Studio:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/ploeh/WindowsLiveWriter/UseTheCreateMethodStubSmartTagToStayInTh_E74B/GenerateMethodStubSmartTag_2.png" mce_href="http://blogs.msdn.com/blogfiles/ploeh/WindowsLiveWriter/UseTheCreateMethodStubSmartTagToStayInTh_E74B/GenerateMethodStubSmartTag_2.png"&gt;&lt;IMG height=125 alt=GenerateMethodStubSmartTag src="http://blogs.msdn.com/blogfiles/ploeh/WindowsLiveWriter/UseTheCreateMethodStubSmartTagToStayInTh_E74B/GenerateMethodStubSmartTag_thumb.png" width=515 border=0 mce_src="http://blogs.msdn.com/blogfiles/ploeh/WindowsLiveWriter/UseTheCreateMethodStubSmartTagToStayInTh_E74B/GenerateMethodStubSmartTag_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;As we all know, this will generate the following implementation in MyClass:&lt;/P&gt;&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red0\green0\blue0;\red43\green145\blue175;}??\fs20 \cf1 public\cf0  \cf1 void\cf0  MyMethod()\par ??\{\par ??    \cf1 throw\cf0  \cf1 new\cf0  \cf4 NotImplementedException\cf0 ();\par ??\}}
--&gt;
&lt;DIV style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: courier new"&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; MyMethod()&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;{&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;throw&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;NotImplementedException&lt;/SPAN&gt;();&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;}&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;but since you already know that, you don't have to go look at it, and you don't even need to commit to memory that you will have to implement the method. When you run the test, it's going to throw a NotImplementedException, and that's all the reminder you need.&lt;/P&gt;
&lt;P&gt;So just use the smart tag and move on. Right away, forget about the method you just created. Resist the temptation to go implement it immediately, no matter how simple it might be. Stay focused on writing the test.&lt;/P&gt;
&lt;P&gt;You can use the same technique when it comes to evolving &lt;A href="http://xunitpatterns.com/Test%20Utility%20Method.html#SUT%20API%20Encapsulation" mce_href="http://xunitpatterns.com/Test%20Utility%20Method.html#SUT%20API%20Encapsulation"&gt;SUT API Encapsulation&lt;/A&gt;: Sometimes, I know that I'd really like a test helper method that can do something for me, but I have only a vague idea about how to implement it. In such cases, I just write the name of the method, use the smart tag and move on. This helps me stay focused on writing the test, and I can always come back later and implement the helper method at a more convenient time.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9278509" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/ploeh/archive/tags/Unit+Testing/default.aspx">Unit Testing</category><category domain="http://blogs.msdn.com/ploeh/archive/tags/Productivity/default.aspx">Productivity</category></item><item><title>Assert Messages Are Not Optional</title><link>http://blogs.msdn.com/ploeh/archive/2008/12/17/assert-messages-are-not-optional.aspx</link><pubDate>Wed, 17 Dec 2008 15:08:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9230759</guid><dc:creator>ploeh</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/ploeh/comments/9230759.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ploeh/commentrss.aspx?PostID=9230759</wfw:commentRss><wfw:comment>http://blogs.msdn.com/ploeh/rsscomments.aspx?PostID=9230759</wfw:comment><description>&lt;P&gt;...and now, in this week's episode of &lt;A class="" href="http://blog.ploeh.dk/2009/01/28/ZeroFrictionTDD.aspx" mce_href="http://blog.ploeh.dk/2009/01/28/ZeroFrictionTDD.aspx"&gt;Zero-Friction TDD&lt;/A&gt;: Optional Assert messages that aren't optional anyway!&lt;/P&gt;
&lt;P&gt;Actually, this piece of advice comes almost directly from the &lt;A href="http://xunitpatterns.com/" mce_href="http://xunitpatterns.com/"&gt;xUnit Test Patterns&lt;/A&gt; book, so I was in doubt whether I should post it all, but it bears repeating, and I guess I still have a few things to add.&lt;/P&gt;
&lt;P&gt;The various &lt;A href="http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.assert.aspx" mce_href="http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.assert.aspx"&gt;Assert&lt;/A&gt; methods all have an overload that takes a message string that is basically just echoed to the Test Results list if the test fails, appended to the assertion's more generic message.&lt;/P&gt;
&lt;P&gt;For example, this assertion&lt;/P&gt;&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red43\green145\blue175;\red255\green255\blue255;\red0\green0\blue0;\red0\green0\blue255;\red163\green21\blue21;}??\fs20 \cf1 Assert\cf0 .AreEqual&amp;lt;\cf4 string\cf0 &amp;gt;(expectedResult, result, \cf5 "DoStuff"\cf0 );}
--&gt;
&lt;DIV style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: courier new"&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Assert&lt;/SPAN&gt;.AreEqual&amp;lt;&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt;&amp;gt;(expectedResult, result, &lt;SPAN style="COLOR: #a31515"&gt;"DoStuff"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;will produce this output:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Assert.AreEqual failed. Expected:&amp;lt;ploeh&amp;gt;. Actual:&amp;lt;&amp;gt;. DoStuff&lt;/EM&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As there are also overloads available that does &lt;EM&gt;not&lt;/EM&gt; take such a message string, it is tempting to treat it as optional. As far as the compiler is concerned, I might as well have written this:&lt;/P&gt;&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red43\green145\blue175;\red255\green255\blue255;\red0\green0\blue0;\red0\green0\blue255;}??\fs20 \cf1 Assert\cf0 .AreEqual&amp;lt;\cf4 string\cf0 &amp;gt;(expectedResult, result);}
--&gt;
&lt;DIV style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: courier new"&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Assert&lt;/SPAN&gt;.AreEqual&amp;lt;&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt;&amp;gt;(expectedResult, result);&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;which would have yielded this output:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Assert.AreEqual failed. Expected:&amp;lt;ploeh&amp;gt;. Actual:&amp;lt;&amp;gt;.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Not much of a difference, so it may seem quite redundant to supply this extra message.&lt;/P&gt;
&lt;P&gt;Well, not only will I argue that it provides value, I will even go so far as to insist that you should treat it as mandatory. Here's the reason:&lt;/P&gt;
&lt;P&gt;When one or more test failures appear in the Test Results window, my eyes naturally seek out the Error Message text, so it's very nice to have all the information I need present in the same context. All I really need is just a small hint that will jog my memory enough so that I know what I did wrong.&lt;/P&gt;
&lt;P&gt;Please note that I'm not really talking about using the message in the initial Red/Green/Refactor development cycle. In this phase, I rarely read the test failure text at all - I only register that there was a failure, which was expected, since the code isn't implemented yet.&lt;/P&gt;
&lt;P&gt;I'm talking about what happens when you refactor a code base with hundreds of tests. In such cases, I often inadvertently break existing tests, and my eyes immediately seek out the Error Message.&lt;/P&gt;
&lt;P&gt;Imagine that this is the error message:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Assert.AreEqual failed. Expected:&amp;lt;ploeh&amp;gt;. Actual:&amp;lt;&amp;gt;.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;All this really tells me is that in one of my tests (and I don't know which one yet), something was expected to have the value &lt;EM&gt;ploeh&lt;/EM&gt;, but ended up having no value. That's not a lot to go after, so I will probably have to open the test and read it through to get enough context to know what I broke.&lt;/P&gt;
&lt;P&gt;On the other hand, I've experienced that just a &lt;EM&gt;little&lt;/EM&gt; extra message often provides &lt;EM&gt;just enough&lt;/EM&gt; context that I &lt;EM&gt;immediately&lt;/EM&gt; realize what I broke:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Assert.AreEqual failed. Expected:&amp;lt;ploeh&amp;gt;. Actual:&amp;lt;&amp;gt;. DoStuff&lt;/EM&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this case, &lt;EM&gt;DoStuff&lt;/EM&gt; is the name of the method being tested. It may seem hard to believe, but in most cases, this is context enough to help my brain figuring out what went wrong. Keep in mind that the test failure was a result of a code change that &lt;EM&gt;I just implemented&lt;/EM&gt;, so my mind has a lot of context already, and it needs almost no help to make the final connection.&lt;/P&gt;
&lt;P&gt;When I first encountered this guidance, I was sceptic, but after having worked with it for some time, I'm not going back. It has increased my productivity while refactoring, because I don't need to investigate failure causes quite as often as I did before.&lt;/P&gt;
&lt;P&gt;Most developers dislike having to write this optional message because they feel that they ought to write a long piece of fluent prose. That's not the case: Just write a single cue that can trigger your brain at a later date. Normally, I just write the name of the method or property I'm testing - I find that I can easily do that and still stay in the zone when I'm writing my tests.&lt;/P&gt;
&lt;P&gt;You are probably still skeptical, but try it out for a couple of months and see what you think!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9230759" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/ploeh/archive/tags/Unit+Testing/default.aspx">Unit Testing</category><category domain="http://blogs.msdn.com/ploeh/archive/tags/Productivity/default.aspx">Productivity</category></item><item><title>Why Use AreEqual&lt;T&gt;?</title><link>http://blogs.msdn.com/ploeh/archive/2008/12/11/why-use-areequal-t.aspx</link><pubDate>Thu, 11 Dec 2008 11:55:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9195808</guid><dc:creator>ploeh</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/ploeh/comments/9195808.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ploeh/commentrss.aspx?PostID=9195808</wfw:commentRss><wfw:comment>http://blogs.msdn.com/ploeh/rsscomments.aspx?PostID=9195808</wfw:comment><description>&lt;P&gt;This is a post in my &lt;A class="" href="http://blog.ploeh.dk/2009/01/28/ZeroFrictionTDD.aspx" mce_href="http://blog.ploeh.dk/2009/01/28/ZeroFrictionTDD.aspx"&gt;Zero-Friction TDD&lt;/A&gt; series.&lt;/P&gt;
&lt;P&gt;One of my colleagues recently asked my why I prefer &lt;A href="http://msdn.microsoft.com/en-us/library/ms243446.aspx" mce_href="http://msdn.microsoft.com/en-us/library/ms243446.aspx"&gt;Assert.AreEqual&amp;lt;T&amp;gt;&lt;/A&gt; over one of the non-generic &lt;A href="http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.assert.areequal.aspx" mce_href="http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.assert.areequal.aspx"&gt;Assert.AreEqual&lt;/A&gt; overloads for primitive types.&lt;/P&gt;
&lt;P&gt;In most cases, I'm very happy with the C# compiler's ability to infer generic type arguments from the method call parameters, but this case is a little different.&lt;/P&gt;
&lt;P&gt;Let's say you want to compare two strings. I always do it like this:&lt;/P&gt;&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red43\green145\blue175;\red255\green255\blue255;\red0\green0\blue0;\red0\green0\blue255;\red163\green21\blue21;}??\fs20 \cf1 Assert\cf0 .AreEqual&amp;lt;\cf4 string\cf0 &amp;gt;(expectedResult, result, \cf5 "DoStuff"\cf0 );}
--&gt;
&lt;DIV style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: courier new"&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Assert&lt;/SPAN&gt;.AreEqual&amp;lt;&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt;&amp;gt;(expectedResult, result, &lt;SPAN style="COLOR: #a31515"&gt;"DoStuff"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;This statement explicitly tells the compiler to use AreEqual&amp;lt;string&amp;gt;. However, if I omit the type parameter, type inferencing is &lt;EM&gt;not&lt;/EM&gt; going to happen:&lt;/P&gt;&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red43\green145\blue175;\red255\green255\blue255;\red0\green0\blue0;\red163\green21\blue21;}??\fs20 \cf1 Assert\cf0 .AreEqual(expectedResult, result, \cf4 "DoStuff"\cf0 );}
--&gt;
&lt;DIV style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: courier new"&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Assert&lt;/SPAN&gt;.AreEqual(expectedResult, result, &lt;SPAN style="COLOR: #a31515"&gt;"DoStuff"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;Instead of inferring the type parameter from the parameters, the compiler (correctly) selects the best matching overload, in this case, &lt;A href="http://msdn.microsoft.com/en-us/library/ms243496.aspx" mce_href="http://msdn.microsoft.com/en-us/library/ms243496.aspx"&gt;AreEqual(object, object, string)&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;When both the &lt;EM&gt;expectedResult&lt;/EM&gt; and &lt;EM&gt;result&lt;/EM&gt; variables are strings, this will still compile and work, but you just lost static type checking.&lt;/P&gt;
&lt;P&gt;There are 18 overloads of AreEqual, but that still leaves many combinations where type inferencing will occur. Consider comparing two integers:&lt;/P&gt;&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red43\green145\blue175;\red255\green255\blue255;\red0\green0\blue0;\red0\green0\blue255;\red163\green21\blue21;}??\fs20 \cf1 Assert\cf0 .AreEqual&amp;lt;\cf4 int\cf0 &amp;gt;(expectedNumber, result, \cf5 "Explicit typing"\cf0 );}
--&gt;
&lt;DIV style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: courier new"&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Assert&lt;/SPAN&gt;.AreEqual&amp;lt;&lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt;&amp;gt;(expectedNumber, result, &lt;SPAN style="COLOR: #a31515"&gt;"Explicit typing"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;Since there's no non-generic overload that takes Int32 instances, you could omit the type parameter and still arrive at the AreEqual&amp;lt;int&amp;gt; overload:&lt;/P&gt;&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red43\green145\blue175;\red255\green255\blue255;\red0\green0\blue0;\red163\green21\blue21;}??\fs20 \cf1 Assert\cf0 .AreEqual(expectedNumber, result, \cf4 "Implicit typing"\cf0 );}
--&gt;
&lt;DIV style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: courier new"&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Assert&lt;/SPAN&gt;.AreEqual(expectedNumber, result, &lt;SPAN style="COLOR: #a31515"&gt;"Implicit typing"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;However, what happens if you change the type of &lt;EM&gt;result&lt;/EM&gt; to a string? In the first case, you will get a compilation error, but in the latter case, the compiler instead selects the AreEqual(object, object, string) overload!&lt;/P&gt;
&lt;P&gt;When you perform refactorings that change the type of one of the assertion variables, the tests will still compile if you rely on type inferencing, but may fail at run-time. With the refactoring support in Visual Studio, you may be changing the type of a property somewhere else in your code base without thinking about the test code at all. If you test directly against such a property in your AreEqual assertion, static type checking could protect you, but the non-generic overloads may introduce subtle errors in your tests.&lt;/P&gt;
&lt;P&gt;Since test suites should be executed often, you might argue that you'll discover errors like that soon enough, but I'm a strong believer in &lt;EM&gt;fail fast&lt;/EM&gt;, so I still rather prefer getting a compiler error than a run-time error in my test suite.&lt;/P&gt;
&lt;P&gt;The easiest strategy is to not think about this at all, and just always explicitly define the type, so that's what I do: I always use AreEqual&amp;lt;T&amp;gt; and &lt;A href="http://msdn.microsoft.com/en-us/library/ms243707.aspx" mce_href="http://msdn.microsoft.com/en-us/library/ms243707.aspx"&gt;AreNotEqual&amp;lt;T&amp;gt;&lt;/A&gt; (except in special cases, but more about that later).&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9195808" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/ploeh/archive/tags/Unit+Testing/default.aspx">Unit Testing</category><category domain="http://blogs.msdn.com/ploeh/archive/tags/Productivity/default.aspx">Productivity</category></item><item><title>3 Is Many</title><link>http://blogs.msdn.com/ploeh/archive/2008/12/08/3-is-many.aspx</link><pubDate>Mon, 08 Dec 2008 17:51:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9184791</guid><dc:creator>ploeh</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/ploeh/comments/9184791.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ploeh/commentrss.aspx?PostID=9184791</wfw:commentRss><wfw:comment>http://blogs.msdn.com/ploeh/rsscomments.aspx?PostID=9184791</wfw:comment><description>&lt;P&gt;This is an installment in my &lt;A class="" href="http://blog.ploeh.dk/2009/01/28/ZeroFrictionTDD.aspx" mce_href="http://blog.ploeh.dk/2009/01/28/ZeroFrictionTDD.aspx"&gt;Zero-Friction TDD&lt;/A&gt; series.&lt;/P&gt;
&lt;P&gt;When I was a kid, my parents taught me that &lt;EM&gt;many&lt;/EM&gt; is any number above &lt;STRIKE&gt;three&lt;/STRIKE&gt; two*; they used the simple counting sequence &lt;EM&gt;one, two, many&lt;/EM&gt;. This little story may make me seem like I was an incredibly dim-witted kid, but the point was obviously not that I couldn't count to more than three, but rather that, in many cases, unary and binary systems may be special, but as soon as you cross the threshold to three, you are dealing with a number that doesn't exhibit any particular characteristics.&lt;/P&gt;
&lt;P&gt;Note: I'm not talking about number theory here. I'm sure someone will be able to tell me about all sorts of special characteristics of the number 3. Incidentally, three also seems to be a magic number in many cults and religions. That's not what I'm talking about either.&lt;/P&gt;
&lt;P&gt;If you will allow me to further digress, studies have shown that some animals can count to both three and also higher numbers. This goes for humans as well: If I place a number of marbles/dice/glass beads/whatever in front of you, and you have to give me the number as fast as possible, you can probably do that &lt;EM&gt;without&lt;/EM&gt; counting up to perhaps five or six. For higher numbers, you will have to count the items. Three is an instantly recognizable number by the human mind, but I'm not talking about cognition either.&lt;/P&gt;
&lt;P&gt;As a colleague once told me: &lt;EM&gt;The hardest scale-out you can perform is going from one to two&lt;/EM&gt;. Nonetheless, if you look at concepts such as active/passive failover clustering, it would seem as though going from two to three is also non-trivial.&lt;/P&gt;
&lt;P&gt;However, once you have managed to deal with three of whatever it is you deal with, you are probably ready to deal with four, five, or even twenty-seven. To bring the topic back to code, at that point you are probably working with a list of some sort.&lt;/P&gt;
&lt;P&gt;When testing against lists, 3 is a good &lt;A href="http://xunitpatterns.com/equivalence%20class.html" mce_href="http://xunitpatterns.com/equivalence%20class.html"&gt;Equivalence Class&lt;/A&gt; for &lt;EM&gt;many&lt;/EM&gt;. If you have a list of three elements, you have distinct elements for the head, interior and tail of the list. You can perform meaningful sorts and filtering on such a list.&lt;/P&gt;
&lt;P&gt;In fact, I usually find that I can reproduce most scenarios (as well as most bugs) with lists of three elements.&lt;/P&gt;
&lt;P&gt;When writing unit tests, for maintainability the number 3 shouldn't just appear as a magic number in the test, so it makes more sense to define it as a constant somewhere, as in this, otherwise inane, example:&lt;/P&gt;&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red0\green0\blue0;\red43\green145\blue175;\red0\green128\blue0;\red163\green21\blue21;}??\fs20 \cf1 private\cf0  \cf1 const\cf0  \cf1 int\cf0  Many = 3;\par ??\par ??[\cf4 TestMethod\cf0 ]\par ??\cf1 public\cf0  \cf1 void\cf0  SumOfManyNumbersWillBeCorrect()\par ??\{\par ??    \cf5 // Fixture setup\par ??\cf0     \cf4 IEnumerable\cf0 &amp;lt;\cf1 int\cf0 &amp;gt; anonymousNumbers = \par ??        \cf4 Enumerable\cf0 .Range(0, \cf4 MyClassTest\cf0 .Many);\par ??    \cf1 int\cf0  expectedSum = anonymousNumbers.Sum();\par ??    \cf4 MyClass\cf0  sut = \cf1 new\cf0  \cf4 MyClass\cf0 ();\par ??    \cf5 // Exercise system\par ??\cf0     \cf1 int\cf0  result = sut.Sum(anonymousNumbers);\par ??    \cf5 // Verify outcome\par ??\cf0     \cf4 Assert\cf0 .AreEqual&amp;lt;\cf1 int\cf0 &amp;gt;(expectedSum, result, \cf6 "Sum"\cf0 );\par ??    \cf5 // Teardown\par ??\cf0 \}}
--&gt;
&lt;DIV style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: courier new"&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;const&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt; Many = 3;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;[&lt;SPAN style="COLOR: #2b91af"&gt;TestMethod&lt;/SPAN&gt;]&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; SumOfManyNumbersWillBeCorrect()&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;{&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Fixture setup&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: #2b91af"&gt;IEnumerable&lt;/SPAN&gt;&amp;lt;&lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt;&amp;gt; anonymousNumbers = &lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: #2b91af"&gt;Enumerable&lt;/SPAN&gt;.Range(0, &lt;SPAN style="COLOR: #2b91af"&gt;MyClassTest&lt;/SPAN&gt;.Many);&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt; expectedSum = anonymousNumbers.Sum();&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: #2b91af"&gt;MyClass&lt;/SPAN&gt; sut = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;MyClass&lt;/SPAN&gt;();&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Exercise system&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt; result = sut.Sum(anonymousNumbers);&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Verify outcome&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: #2b91af"&gt;Assert&lt;/SPAN&gt;.AreEqual&amp;lt;&lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt;&amp;gt;(expectedSum, result, &lt;SPAN style="COLOR: #a31515"&gt;"Sum"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Teardown&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;}&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;The only noticeable part of this piece of code is the Many constant, which is used in the test code itself. This is a good hint to the &lt;A href="http://xunitpatterns.com/test%20reader.html" mce_href="http://xunitpatterns.com/test%20reader.html"&gt;Test Reader&lt;/A&gt; that this test deals with many integers, without particularly caring about how many there are.&lt;/P&gt;
&lt;P&gt;* Edit 2009.01.20&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9184791" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/ploeh/archive/tags/Unit+Testing/default.aspx">Unit Testing</category><category domain="http://blogs.msdn.com/ploeh/archive/tags/Productivity/default.aspx">Productivity</category></item><item><title>testmethod Code Snippet</title><link>http://blogs.msdn.com/ploeh/archive/2008/12/01/testmethod-code-snippet.aspx</link><pubDate>Mon, 01 Dec 2008 16:32:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9160423</guid><dc:creator>ploeh</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/ploeh/comments/9160423.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ploeh/commentrss.aspx?PostID=9160423</wfw:commentRss><wfw:comment>http://blogs.msdn.com/ploeh/rsscomments.aspx?PostID=9160423</wfw:comment><description>&lt;P&gt;This is an installment in my &lt;A class="" href="http://blog.ploeh.dk/2009/01/28/ZeroFrictionTDD.aspx" mce_href="http://blog.ploeh.dk/2009/01/28/ZeroFrictionTDD.aspx"&gt;Zero-Friction TDD&lt;/A&gt; series.&lt;/P&gt;
&lt;P&gt;If you are a regular reader of this blog, you may have noticed a certain pattern in my unit test examples (like &lt;A href="http://blogs.msdn.com/ploeh/archive/2008/11/17/anonymous-variables.aspx" mce_href="http://blogs.msdn.com/ploeh/archive/2008/11/17/anonymous-variables.aspx"&gt;this one&lt;/A&gt;). This is because I always follow the &lt;A href="http://xunitpatterns.com/Four%20Phase%20Test.html" mce_href="http://xunitpatterns.com/Four%20Phase%20Test.html"&gt;Four-Phase Test&lt;/A&gt; pattern (which is a superset of the more well-know Triple-A (Arrange Act Assert) pattern), with a few code comments to denote the different phases (incidentally, in this case, I don't regard these code comments as &lt;A href="http://www.butunclebob.com/ArticleS.TimOttinger.ApologizeIncode" mce_href="http://www.butunclebob.com/ArticleS.TimOttinger.ApologizeIncode"&gt;Apologies&lt;/A&gt;).&lt;/P&gt;
&lt;P&gt;Writing the skeleton of such a test (the TestMethod attribute, the method declaration, the four comments) is very repetitious work, and I got tired of it around the third or fourth time I had to do it. Therefore, I wrote a code snippet that, in essence, just generates this template:&lt;/P&gt;&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red43\green145\blue175;\red0\green0\blue255;\red0\green128\blue0;}??\fs20 [\cf3 TestMethod\cf0 ]\par ??\cf4 public\cf0  \cf4 void\cf0  Test()\par ??\{\par ??    \cf5 // Fixture setup\par ??\cf0     \cf5 // Exercise system\par ??\cf0     \cf5 // Verify outcome\par ??\cf0     \cf3 Assert\cf0 .Inconclusive();\par ??    \cf5 // Teardown\par ??\cf0 \}}
--&gt;
&lt;DIV style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: courier new"&gt;&lt;PRE style="MARGIN: 0px"&gt;[&lt;SPAN style="COLOR: #2b91af"&gt;TestMethod&lt;/SPAN&gt;]&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; Test()&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;{&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Fixture setup&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Exercise system&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Verify outcome&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: #2b91af"&gt;Assert&lt;/SPAN&gt;.Inconclusive();&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Teardown&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;}&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;From there, you are ready to go ahead and fill in the blanks. It saves me a bit of typing for &lt;EM&gt;every&lt;/EM&gt; test I write and allows me to get started faster with formulating the actual value-adding code, while the structure reminds me to write good and maintainable tests.&lt;/P&gt;
&lt;P&gt;I've been using this code snippet for more than a year now, and although I've considered many enhancements to it, I've always felt comfortable with the versatility that this simple implementation provides.&lt;/P&gt;
&lt;P&gt;For your convenience, I've attached the code snippet to this post: Just download it and put it in your &amp;lt;Documents&amp;gt;\Visual Studio 2008\Code Snippets\Visual C#\My Code Snippets folder. Now you can just type &lt;EM&gt;testmethod&lt;/EM&gt; and expand the snippet, and you have a structured Four-Phase Test ready to be implemented.&lt;/P&gt;
&lt;P&gt;Once more, it saves you a bit of mental context switching, and you can focus on writing the test code that really matters.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9160423" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/ploeh/attachment/9160423.ashx" length="885" type="text/xml" /><category domain="http://blogs.msdn.com/ploeh/archive/tags/Unit+Testing/default.aspx">Unit Testing</category><category domain="http://blogs.msdn.com/ploeh/archive/tags/Productivity/default.aspx">Productivity</category></item><item><title>Ignore Irrelevant Return Values</title><link>http://blogs.msdn.com/ploeh/archive/2008/11/21/ignore-irrelevant-return-values.aspx</link><pubDate>Fri, 21 Nov 2008 15:56:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9131791</guid><dc:creator>ploeh</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/ploeh/comments/9131791.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ploeh/commentrss.aspx?PostID=9131791</wfw:commentRss><wfw:comment>http://blogs.msdn.com/ploeh/rsscomments.aspx?PostID=9131791</wfw:comment><description>&lt;P&gt;This is an installment in my &lt;A class="" href="http://blog.ploeh.dk/2009/01/28/ZeroFrictionTDD.aspx" mce_href="http://blog.ploeh.dk/2009/01/28/ZeroFrictionTDD.aspx"&gt;Zero-Friction TDD&lt;/A&gt; series.&lt;/P&gt;
&lt;P&gt;Sometimes, you don't care about the return value from a particular operation. The simplest example is if you want to check that creating a new instance of a specific type will throw an exception if supplied with wrong parameter values:&lt;/P&gt;&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red43\green145\blue175;\red0\green0\blue255;\red0\green128\blue0;}??\fs20 [\cf3 ExpectedException\cf0 (\cf4 typeof\cf0 (\cf3 ArgumentNullException\cf0 ))]\par ??[\cf3 TestMethod\cf0 ]\par ??\cf4 public\cf0  \cf4 void\cf0  CreateWithNullTextWillThrow()\par ??\{\par ??    \cf5 // Fixture setup\par ??\cf0     \cf4 int\cf0  anonymousNumber = 8;\par ??    \cf4 string\cf0  nullText = \cf4 null\cf0 ;\par ??    \cf5 // Exercise system\par ??\cf0     \cf4 new\cf0  \cf3 Plop\cf0 (anonymousNumber, nullText);\par ??    \cf5 // Verify outcome (expected exception)\par ??\cf0     \cf5 // Teardown\par ??\cf0 \}}
--&gt;
&lt;DIV style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: courier new"&gt;&lt;PRE style="MARGIN: 0px"&gt;[&lt;SPAN style="COLOR: #2b91af"&gt;ExpectedException&lt;/SPAN&gt;(&lt;SPAN style="COLOR: blue"&gt;typeof&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #2b91af"&gt;ArgumentNullException&lt;/SPAN&gt;))]&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;[&lt;SPAN style="COLOR: #2b91af"&gt;TestMethod&lt;/SPAN&gt;]&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; CreateWithNullTextWillThrow()&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;{&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Fixture setup&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt; anonymousNumber = 8;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; nullText = &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Exercise system&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Plop&lt;/SPAN&gt;(anonymousNumber, nullText);&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Verify outcome (expected exception)&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Teardown&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;}&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;In this example, even though the &lt;EM&gt;new&lt;/EM&gt; operation is supposed to return a value, we don't care about it, since we only want to test that the correct exception type is being thrown. To save myself from having to stop and think about a variable name (even though in this case, &lt;A href="http://blogs.msdn.com/ploeh/archive/2008/10/06/naming-sut-test-variables.aspx" mce_href="http://blogs.msdn.com/ploeh/archive/2008/10/06/naming-sut-test-variables.aspx"&gt;I'd just have used &lt;EM&gt;sut&lt;/EM&gt;&lt;/A&gt;), I prefer to not declare and assign the variable at all.&lt;/P&gt;
&lt;P&gt;In general, I believe that APIs should follow the principle of Command-Query Separation, but sometimes it makes sense to break this rule. When you have an operation that both return a value and have side-effects, testing the side-effect via state-based testing doesn't require the return value.&lt;/P&gt;
&lt;P&gt;Imaging that you have a method with this signature:&lt;/P&gt;&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red0\green0\blue0;}??\fs20 \cf1 public\cf0  \cf1 object\cf0  CommandQuery(\cf1 int\cf0  number)}
--&gt;
&lt;DIV style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: courier new"&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;object&lt;/SPAN&gt; CommandQuery(&lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt; number)&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;Testing the side-effect may look like this:&lt;/P&gt;&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red43\green145\blue175;\red0\green0\blue255;\red0\green128\blue0;\red163\green21\blue21;}??\fs20 [\cf3 TestMethod\cf0 ]\par ??\cf4 public\cf0  \cf4 void\cf0  CommandQueryWillUpdateNumberProperty()\par ??\{\par ??    \cf5 // Fixture setup\par ??\cf0     \cf4 int\cf0  expectedNumber = 89;\par ??    \cf4 int\cf0  anonymousNumber = 11;\par ??    \cf4 string\cf0  anonymousText = \cf6 "Anonymous text"\cf0 ;\par ??    \cf3 Plop\cf0  sut = \cf4 new\cf0  \cf3 Plop\cf0 (anonymousNumber, anonymousText);\par ??    \cf5 // Exercise system\par ??\cf0     sut.CommandQuery(expectedNumber);\par ??    \cf5 // Verify outcome\par ??\cf0     \cf3 Assert\cf0 .AreEqual&amp;lt;\cf4 int\cf0 &amp;gt;(expectedNumber, sut.Number, \cf6 "CommandQuery"\cf0 );\par ??    \cf5 // Teardown\par ??\cf0 \}}
--&gt;
&lt;DIV style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: courier new"&gt;&lt;PRE style="MARGIN: 0px"&gt;[&lt;SPAN style="COLOR: #2b91af"&gt;TestMethod&lt;/SPAN&gt;]&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; CommandQueryWillUpdateNumberProperty()&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;{&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Fixture setup&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt; expectedNumber = 89;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt; anonymousNumber = 11;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; anonymousText = &lt;SPAN style="COLOR: #a31515"&gt;"Anonymous text"&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: #2b91af"&gt;Plop&lt;/SPAN&gt; sut = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Plop&lt;/SPAN&gt;(anonymousNumber, anonymousText);&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Exercise system&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sut.CommandQuery(expectedNumber);&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Verify outcome&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: #2b91af"&gt;Assert&lt;/SPAN&gt;.AreEqual&amp;lt;&lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt;&amp;gt;(expectedNumber, sut.Number, &lt;SPAN style="COLOR: #a31515"&gt;"CommandQuery"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Teardown&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;}&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;Notice that I've ignored the return value of the CommandQuery method.&lt;/P&gt;
&lt;P&gt;Save yourself the time and effort it takes to declare and assign variables if you don't use them anyway.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9131791" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/ploeh/archive/tags/Unit+Testing/default.aspx">Unit Testing</category><category domain="http://blogs.msdn.com/ploeh/archive/tags/Productivity/default.aspx">Productivity</category></item><item><title>Anonymous Variables</title><link>http://blogs.msdn.com/ploeh/archive/2008/11/17/anonymous-variables.aspx</link><pubDate>Mon, 17 Nov 2008 15:32:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9109755</guid><dc:creator>ploeh</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/ploeh/comments/9109755.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ploeh/commentrss.aspx?PostID=9109755</wfw:commentRss><wfw:comment>http://blogs.msdn.com/ploeh/rsscomments.aspx?PostID=9109755</wfw:comment><description>&lt;P&gt;This post is an installment in my series on &lt;A class="" href="http://blog.ploeh.dk/2009/01/28/ZeroFrictionTDD.aspx" mce_href="http://blog.ploeh.dk/2009/01/28/ZeroFrictionTDD.aspx"&gt;Zero-Friction TDD&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;Often when writing a unit test, the &lt;A href="http://xunitpatterns.com/SUT.html" mce_href="http://xunitpatterns.com/SUT.html"&gt;SUT&lt;/A&gt;'s API will force you to create objects that you really don't care about. As an example, take a look at the signature of this constructor:&lt;/P&gt;&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red0\green0\blue0;}??\fs20 \cf1 public\cf0  Plop(\cf1 int\cf0  number, \cf1 string\cf0  text)}
--&gt;
&lt;DIV style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: courier new"&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; Plop(&lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt; number, &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; text)&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;To create an instance of the Plop class, you must supply both parameters, but you may not care about their values. You can't just pass in null as the text parameter, because the constructor checks for this and throws an ArgumentNullException if you do. In other words, you are forced to create some non-null text to pass to the constructor, even if its specific value is totally irrelevant to the test at hand.&lt;/P&gt;
&lt;P&gt;That sounds a lot like the description of a &lt;A href="http://xunitpatterns.com/Dummy%20Object.html" mce_href="http://xunitpatterns.com/Dummy%20Object.html"&gt;Dummy&lt;/A&gt;, except that such variables are taxonomically different because they aren't &lt;A href="http://xunitpatterns.com/Test%20Double.html" mce_href="http://xunitpatterns.com/Test%20Double.html"&gt;Test Doubles&lt;/A&gt;. In &lt;EM&gt;&lt;A href="http://xunitpatterns.com/index.html" mce_href="http://xunitpatterns.com/index.html"&gt;xUnit Test Patterns&lt;/A&gt;&lt;/EM&gt;, Gerard Meszaros also discusses &lt;A href="http://xunitpatterns.com/Creation%20Method.html#Anonymous%20Creation%20Method" mce_href="http://xunitpatterns.com/Creation%20Method.html#Anonymous%20Creation%20Method"&gt;Anonymous Creation Methods&lt;/A&gt; as one way of creating variables like these, so I've lifted this terminology to call them &lt;EM&gt;Anonymous Variables&lt;/EM&gt;.&lt;/P&gt;
&lt;P&gt;When naming such variables, I prefix the variable name with &lt;EM&gt;anonymous&lt;/EM&gt; to indicate that I don't really care about the value.&lt;/P&gt;&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red43\green145\blue175;\red0\green0\blue255;\red0\green128\blue0;\red163\green21\blue21;}??\fs20 [\cf3 TestMethod\cf0 ]\par ??\cf4 public\cf0  \cf4 void\cf0  CreateWillExposeNumberAsProperty()\par ??\{\par ??    \cf5 // Fixture setup\par ??\cf0     \cf4 int\cf0  expectedNumber = 4;\par ??    \cf4 string\cf0  anonymousText = \cf6 "Anonymous text"\cf0 ;\par ??    \cf3 Plop\cf0  sut = \cf4 new\cf0  \cf3 Plop\cf0 (expectedNumber, anonymousText);\par ??    \cf5 // Exercise system\par ??\cf0     \cf4 int\cf0  result = sut.Number;\par ??    \cf5 // Verify outcome\par ??\cf0     \cf3 Assert\cf0 .AreEqual&amp;lt;\cf4 int\cf0 &amp;gt;(expectedNumber, result, \cf6 "Number"\cf0 );\par ??    \cf5 // Teardown\par ??\cf0 \}}
--&gt;
&lt;DIV style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: courier new"&gt;&lt;PRE style="MARGIN: 0px"&gt;[&lt;SPAN style="COLOR: #2b91af"&gt;TestMethod&lt;/SPAN&gt;]&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; CreateWillExposeNumberAsProperty()&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;{&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Fixture setup&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt; expectedNumber = 4;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; anonymousText = &lt;SPAN style="COLOR: #a31515"&gt;"Anonymous text"&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: #2b91af"&gt;Plop&lt;/SPAN&gt; sut = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Plop&lt;/SPAN&gt;(expectedNumber, anonymousText);&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Exercise system&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt; result = sut.Number;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Verify outcome&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: #2b91af"&gt;Assert&lt;/SPAN&gt;.AreEqual&amp;lt;&lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt;&amp;gt;(expectedNumber, result, &lt;SPAN style="COLOR: #a31515"&gt;"Number"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Teardown&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;}&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;Naming the text variable &lt;EM&gt;anonymousText&lt;/EM&gt; instead of just &lt;EM&gt;text&lt;/EM&gt; or something similar probably doesn't save me much context switching, but it's a good help for the &lt;A href="http://xunitpatterns.com/test%20reader.html" mce_href="http://xunitpatterns.com/test%20reader.html"&gt;Test Reader&lt;/A&gt; because it clearly indicates that we don't really care about this value.&lt;/P&gt;
&lt;P&gt;Even though it's redundant, I also type in &lt;EM&gt;Anonymous text&lt;/EM&gt; as the string value, although this could really be anything. However, it saves me the trouble of coming up with something else.&lt;/P&gt;
&lt;P&gt;The same pattern can be used if we want to test the text instead of the number&lt;/P&gt;&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red43\green145\blue175;\red0\green0\blue255;\red0\green128\blue0;\red163\green21\blue21;}??\fs20 [\cf3 TestMethod\cf0 ]\par ??\cf4 public\cf0  \cf4 void\cf0  CreateWillExposeTextAsProperty()\par ??\{\par ??    \cf5 // Fixture setup\par ??\cf0     \cf4 int\cf0  anonymousNumber = 3;\par ??    \cf4 string\cf0  expectedText = \cf6 "Anonymous text"\cf0 ;\par ??    \cf3 Plop\cf0  sut = \cf4 new\cf0  \cf3 Plop\cf0 (anonymousNumber, expectedText);\par ??    \cf5 // Exercise system\par ??\cf0     \cf4 string\cf0  result = sut.Text;\par ??    \cf5 // Verify outcome\par ??\cf0     \cf3 Assert\cf0 .AreEqual&amp;lt;\cf4 string\cf0 &amp;gt;(expectedText, result, \cf6 "Text"\cf0 );\par ??    \cf5 // Teardown\par ??\cf0 \}}
--&gt;
&lt;DIV style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: courier new"&gt;&lt;PRE style="MARGIN: 0px"&gt;[&lt;SPAN style="COLOR: #2b91af"&gt;TestMethod&lt;/SPAN&gt;]&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; CreateWillExposeTextAsProperty()&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;{&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Fixture setup&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt; anonymousNumber = 3;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; expectedText = &lt;SPAN style="COLOR: #a31515"&gt;"Anonymous text"&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: #2b91af"&gt;Plop&lt;/SPAN&gt; sut = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Plop&lt;/SPAN&gt;(anonymousNumber, expectedText);&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Exercise system&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; result = sut.Text;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Verify outcome&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: #2b91af"&gt;Assert&lt;/SPAN&gt;.AreEqual&amp;lt;&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt;&amp;gt;(expectedText, result, &lt;SPAN style="COLOR: #a31515"&gt;"Text"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Teardown&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;}&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;With numbers, the value itself can contain no hint of its origin and usage (like a string can by saying &lt;EM&gt;I don't matter&lt;/EM&gt;), so the name &lt;EM&gt;anonymousNumber&lt;/EM&gt; is the only clear indicator of the number's purpose. It also helps clarify what may otherwise look like a magic number: Why is the value &lt;EM&gt;3&lt;/EM&gt;? The name gives us an indication that it doesn't matter, and it might as well have been some other value. Without that hint, the Test Reader might have to spend more time before determining whether or not the number &lt;EM&gt;3&lt;/EM&gt; carries any particular connotation in this context.&lt;/P&gt;
&lt;P&gt;Notice that even though the text variable isn't an Anonymous Variable any more, I've kept the text &lt;EM&gt;Anonymous text&lt;/EM&gt; as the string value, since I don't really care about the explicit value, but only about the relationship between input and output. Again, this is a help for the Test Reader - and remember: That may very well be you six months into the future.&lt;/P&gt;
&lt;P&gt;In terms of avoiding context switching when writing tests, this tip falls into the Almost-Not-Worth-It category, but if you combine it with the assistance it provides the Test Reader, it is certainly a valuable habit to pick up.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9109755" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/ploeh/archive/tags/Unit+Testing/default.aspx">Unit Testing</category><category domain="http://blogs.msdn.com/ploeh/archive/tags/Productivity/default.aspx">Productivity</category></item><item><title>Naming Direct Output Variables</title><link>http://blogs.msdn.com/ploeh/archive/2008/11/14/naming-direct-output-variables.aspx</link><pubDate>Fri, 14 Nov 2008 12:38:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9068903</guid><dc:creator>ploeh</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/ploeh/comments/9068903.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ploeh/commentrss.aspx?PostID=9068903</wfw:commentRss><wfw:comment>http://blogs.msdn.com/ploeh/rsscomments.aspx?PostID=9068903</wfw:comment><description>&lt;P&gt;In my series of &lt;A class="" href="http://blog.ploeh.dk/2009/01/28/ZeroFrictionTDD.aspx" mce_href="http://blog.ploeh.dk/2009/01/28/ZeroFrictionTDD.aspx"&gt;Zero-Friction TDD&lt;/A&gt; tips and tricks, it's time to look at naming &lt;A href="http://xunitpatterns.com/direct%20output.html" mce_href="http://xunitpatterns.com/direct%20output.html"&gt;Direct Output&lt;/A&gt; variables.&lt;/P&gt;&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red43\green145\blue175;\red0\green0\blue255;\red0\green128\blue0;\red163\green21\blue21;}??\fs20 [\cf3 TestMethod\cf0 ]\par ??\cf4 public\cf0  \cf4 void\cf0  DoStuffWillReturnMessage()\par ??\{\par ??    \cf5 // Fixture setup\par ??\cf0     \cf4 string\cf0  expectedResult = \cf6 "ploeh"\cf0 ;\par ??    \cf3 MyClass\cf0  sut = \cf4 new\cf0  \cf3 MyClass\cf0 ();\par ??    \cf5 // Exercise system\par ??\cf0     \cf4 string\cf0  result = sut.DoStuff(expectedResult);\par ??    \cf5 // Verify outcome\par ??\cf0     \cf3 Assert\cf0 .AreEqual&amp;lt;\cf4 string\cf0 &amp;gt;(expectedResult, result, \cf6 "DoStuff"\cf0 );\par ??    \cf5 // Teardown\par ??\cf0 \}}
--&gt;
&lt;DIV style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: courier new"&gt;&lt;PRE style="MARGIN: 0px"&gt;[&lt;SPAN style="COLOR: #2b91af"&gt;TestMethod&lt;/SPAN&gt;]&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; DoStuffWillReturnMessage()&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;{&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Fixture setup&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; expectedResult = &lt;SPAN style="COLOR: #a31515"&gt;"ploeh"&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: #2b91af"&gt;MyClass&lt;/SPAN&gt; sut = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;MyClass&lt;/SPAN&gt;();&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Exercise system&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; result = sut.DoStuff(expectedResult);&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Verify outcome&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: #2b91af"&gt;Assert&lt;/SPAN&gt;.AreEqual&amp;lt;&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt;&amp;gt;(expectedResult, result, &lt;SPAN style="COLOR: #a31515"&gt;"DoStuff"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Teardown&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;}&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;As you can see, I use the name &lt;EM&gt;result&lt;/EM&gt; for the return value of DoStuff, and I &lt;EM&gt;always&lt;/EM&gt; use that word, irrespective of its type or other circumstances. Whether you prefer &lt;EM&gt;result&lt;/EM&gt; or another word is not important; the salient point is that by always using the same word, you save a context switch (because you don't have to stop and think of a good name) and thereby incrementally increase your productivity.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9068903" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/ploeh/archive/tags/Unit+Testing/default.aspx">Unit Testing</category><category domain="http://blogs.msdn.com/ploeh/archive/tags/Productivity/default.aspx">Productivity</category></item><item><title>Zero-Friction TDD</title><link>http://blogs.msdn.com/ploeh/archive/2008/11/13/zero-friction-tdd.aspx</link><pubDate>Thu, 13 Nov 2008 14:52:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9065972</guid><dc:creator>ploeh</dc:creator><slash:comments>8</slash:comments><comments>http://blogs.msdn.com/ploeh/comments/9065972.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ploeh/commentrss.aspx?PostID=9065972</wfw:commentRss><wfw:comment>http://blogs.msdn.com/ploeh/rsscomments.aspx?PostID=9065972</wfw:comment><description>&lt;P&gt;Writing good code is difficult. Unit tests are written as code, so a corollary to the first sentence is that writing good unit tests is also difficult.&lt;/P&gt;
&lt;P&gt;TDD (particularly if you interpret the last &lt;EM&gt;D&lt;/EM&gt; as &lt;EM&gt;Design&lt;/EM&gt;) carries this challenge in abundance, since you &lt;EM&gt;ought&lt;/EM&gt; to be focusing on designing your &lt;A href="http://xunitpatterns.com/SUT.html" mce_href="http://xunitpatterns.com/SUT.html"&gt;SUT&lt;/A&gt;, but you &lt;EM&gt;might&lt;/EM&gt; end up spending a lot of energy on ensuring the readability and maintainability of the tests themselves.&lt;/P&gt;
&lt;P&gt;The goal is Zero-Friction TDD. To me, this means that you should be able to focus entirely on designing the SUT. Writing the test should present as little productivity friction as possible.&lt;/P&gt;
&lt;P&gt;Writing a test will always require some attention to the test itself, but &lt;EM&gt;any&lt;/EM&gt; trick you can use to take your mind off the test will enable you to better focus on the SUT. Every time you have to think about how to write the test instead of how to design the SUT, you make a context switch, and each of these cost you productivity.&lt;/P&gt;
&lt;P&gt;This means that even if a given optimization strategy may seem insignificant in itself, a lot of these can go a long way towards keeping you in the zone.&lt;/P&gt;
&lt;P&gt;I've already posted one example, where I describe a few arguments for &lt;A href="http://blogs.msdn.com/ploeh/archive/2008/10/06/naming-sut-test-variables.aspx" mce_href="http://blogs.msdn.com/ploeh/archive/2008/10/06/naming-sut-test-variables.aspx"&gt;naming SUT test variables&lt;/A&gt; &lt;EM&gt;sut&lt;/EM&gt;. The argument I &lt;EM&gt;didn't&lt;/EM&gt; present is that it frees you from thinking about a good name for the variable. In the context of that post, such an argument would have seemed trifling, but in the broader context, it saves you from &lt;EM&gt;one&lt;/EM&gt; context switch and enables you to move on with writing the test.&lt;/P&gt;
&lt;P&gt;In future posts, I will share other tricks you can use to focus your mental energy on designing the SUT, while still writing good unit tests.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Update:&lt;/STRONG&gt; Posts in the series:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A class="" href="http://blogs.msdn.com/ploeh/archive/2008/10/06/naming-sut-test-variables.aspx" mce_href="http://blogs.msdn.com/ploeh/archive/2008/10/06/naming-sut-test-variables.aspx"&gt;Naming SUT Test Variables&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A class="" href="http://blogs.msdn.com/ploeh/archive/2008/11/14/naming-direct-output-variables.aspx" mce_href="http://blogs.msdn.com/ploeh/archive/2008/11/14/naming-direct-output-variables.aspx"&gt;Naming Direct Output Variables&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A class="" href="http://blogs.msdn.com/ploeh/archive/2008/11/17/anonymous-variables.aspx" mce_href="http://blogs.msdn.com/ploeh/archive/2008/11/17/anonymous-variables.aspx"&gt;Anonymous Variables&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A class="" href="http://blogs.msdn.com/ploeh/archive/2008/11/21/ignore-irrelevant-return-values.aspx" mce_href="http://blogs.msdn.com/ploeh/archive/2008/11/21/ignore-irrelevant-return-values.aspx"&gt;Ignore Irrelevant Return Values&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A class="" href="http://blogs.msdn.com/ploeh/archive/2008/12/01/testmethod-code-snippet.aspx" mce_href="http://blogs.msdn.com/ploeh/archive/2008/12/01/testmethod-code-snippet.aspx"&gt;testmethod Code Snippet&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A class="" href="http://blogs.msdn.com/ploeh/archive/2008/12/08/3-is-many.aspx" mce_href="http://blogs.msdn.com/ploeh/archive/2008/12/08/3-is-many.aspx"&gt;3 Is Many&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A class="" href="http://blogs.msdn.com/ploeh/archive/2008/12/11/why-use-areequal-t.aspx" mce_href="http://blogs.msdn.com/ploeh/archive/2008/12/11/why-use-areequal-t.aspx"&gt;Why Use AreEqual&amp;lt;T&amp;gt;?&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A class="" href="http://blogs.msdn.com/ploeh/archive/2008/12/17/assert-messages-are-not-optional.aspx" mce_href="http://blogs.msdn.com/ploeh/archive/2008/12/17/assert-messages-are-not-optional.aspx"&gt;Assert Messages Are Not Optional&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A class="" href="http://blogs.msdn.com/ploeh/archive/2009/01/05/use-the-generate-method-stub-smart-tag-to-stay-in-the-zone.aspx" mce_href="http://blogs.msdn.com/ploeh/archive/2009/01/05/use-the-generate-method-stub-smart-tag-to-stay-in-the-zone.aspx"&gt;Use The Generate Method Stub Smart Tag To Stay In The Zone&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A class="" href="http://blogs.msdn.com/ploeh/archive/2009/01/12/test-driven-properties.aspx" mce_href="http://blogs.msdn.com/ploeh/archive/2009/01/12/test-driven-properties.aspx"&gt;Test-Driven Properties&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;Update:&lt;/STRONG&gt; While I was publishing this series of posts, &lt;A class="" href="http://blog.ploeh.dk/2009/01/28/LivingInInterestingTimes.aspx" mce_href="http://blog.ploeh.dk/2009/01/28/LivingInInterestingTimes.aspx"&gt;my employment at Microsoft came to an end&lt;/A&gt;. Please see my &lt;A class="" href="http://blog.ploeh.dk/" mce_href="http://blog.ploeh.dk/"&gt;new blog&lt;/A&gt; for an &lt;A class="" href="http://blog.ploeh.dk/2009/01/28/ZeroFrictionTDD.aspx" mce_href="http://blog.ploeh.dk/2009/01/28/ZeroFrictionTDD.aspx"&gt;updated list of Zero-Friction TDD posts&lt;/A&gt;.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9065972" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/ploeh/archive/tags/Unit+Testing/default.aspx">Unit Testing</category><category domain="http://blogs.msdn.com/ploeh/archive/tags/Productivity/default.aspx">Productivity</category></item><item><title>Vote For Better TDD Support in Visual Studio 2008</title><link>http://blogs.msdn.com/ploeh/archive/2008/04/18/VoteForBetterTDDSupportInVisualStudio2008.aspx</link><pubDate>Fri, 18 Apr 2008 11:13:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8406936</guid><dc:creator>ploeh</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/ploeh/comments/8406936.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ploeh/commentrss.aspx?PostID=8406936</wfw:commentRss><wfw:comment>http://blogs.msdn.com/ploeh/rsscomments.aspx?PostID=8406936</wfw:comment><description>&lt;A class="" href="http://betterbits.blogspot.com/" mce_href="http://betterbits.blogspot.com/"&gt;Eric Jorgensen&lt;/A&gt; has created a &lt;A class="" href="https://connect.microsoft.com/default.aspx" mce_href="https://connect.microsoft.com/default.aspx"&gt;Microsoft Connect&lt;/A&gt; item asking for &lt;A class="" href="https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=338783" mce_href="https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=338783"&gt;better TDD support in Visual Studio 2008&lt;/A&gt;. If you also miss the green (sometimes red) progress bar and other UI elements of NUnit and similar tools, and think that Visual Studio should have a UI that supports TDD better than it currently does, please &lt;A class="" href="https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=338783" mce_href="https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=338783"&gt;go to the item&lt;/A&gt; and give it a favorable vote!&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8406936" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/ploeh/archive/tags/Productivity/default.aspx">Productivity</category></item><item><title>Automatically Generating LINQ To SQL Models From T-SQL</title><link>http://blogs.msdn.com/ploeh/archive/2008/04/10/AutomaticallyGeneratingLINQToSQLModelsFromTSQL.aspx</link><pubDate>Fri, 11 Apr 2008 00:13:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8374684</guid><dc:creator>ploeh</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/ploeh/comments/8374684.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ploeh/commentrss.aspx?PostID=8374684</wfw:commentRss><wfw:comment>http://blogs.msdn.com/ploeh/rsscomments.aspx?PostID=8374684</wfw:comment><description>&lt;P&gt;With LINQ to SQL, a couple of questions quickly arise:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Since you can create a data model directly in Visual Studio, where's your authoritative definition of the database?&lt;/LI&gt;
&lt;LI&gt;If you generate a data model from your database, how do you maintain the model if you have to tweak it?&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;The first question is pretty easy to answer: Since T-SQL can express a lot more about your database than&amp;nbsp;can a LINQ data model, T-SQL should be your authoritative definition. For example, you can define clustered and non-clustered indexes in T-SQL, but not in LINQ to SQL (as far as I know).&lt;/P&gt;
&lt;P&gt;Since T-SQL should be your authoritative database definition, you can generate a LINQ to SQL data model from your database. Unfortunately, there's no tool that I'm aware of that you can point directly at a set of T-SQL scripts and have it generate a .dbml directly, so you have to have a SQL database your tool can use.&lt;/P&gt;
&lt;P&gt;The next question that pops up, then, is how do you ensure that this particular&amp;nbsp;database instance&amp;nbsp;reflects your T-SQL script?&lt;/P&gt;
&lt;P&gt;The answer to that question is to create the database &lt;EM&gt;just&lt;/EM&gt; before you run your tool. If you've been following my posts on &lt;A class="" href="http://blogs.msdn.com/ploeh/archive/2008/01/31/DataAccessComponentTestingRedux.aspx" mce_href="http://blogs.msdn.com/ploeh/archive/2008/01/31/DataAccessComponentTestingRedux.aspx"&gt;data access testing&lt;/A&gt;, you will know that I'm not in the habit of having specific databases on my machine -&amp;nbsp;I have a database engine (SQL Server) on my machine, but no databases. When I run a test suite,&amp;nbsp;it first creates a completely new test-specific, temporary database, runs all the tests, and finally deletes the database again.&lt;/P&gt;
&lt;P&gt;When generating or updating the .dbml file, you can follow the same approach, and you can automate the whole thing in a script. The script&amp;nbsp;should perform the following steps:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Create the database based on the authoritative T-SQL scripts.&lt;/LI&gt;
&lt;LI&gt;Generate the data model using Sqlmetal.exe.&lt;/LI&gt;
&lt;LI&gt;Modify the .dbml file if you need to customize it (such as changing generated property names, etc.)&lt;/LI&gt;
&lt;LI&gt;Delete the database.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Using my &lt;A class="" href="http://blogs.msdn.com/ploeh/archive/2008/01/31/DataAccessComponentTestingRedux.aspx" mce_href="http://blogs.msdn.com/ploeh/archive/2008/01/31/DataAccessComponentTestingRedux.aspx"&gt;HoneySqlAccess&lt;/A&gt; project as an example, let's have a look at how to accomplish this. I'll use a &lt;A class="" href="http://blogs.msdn.com/ploeh/archive/2008/04/09/VisualStudio2008PowerShell.aspx" mce_href="http://blogs.msdn.com/ploeh/archive/2008/04/09/VisualStudio2008PowerShell.aspx"&gt;Visual Studio 2008 PowerShell&lt;/A&gt; to script this, but you can also do it in a Command prompt if you can find&amp;nbsp;a command-line XSLT processor.&lt;/P&gt;
&lt;P&gt;The first step is to create the database itself, complete with schema. Since I &lt;A class="" href="http://blogs.msdn.com/ploeh/archive/2007/11/28/FixtureSetupWithInstallers.aspx" mce_href="http://blogs.msdn.com/ploeh/archive/2007/11/28/FixtureSetupWithInstallers.aspx"&gt;use an Installer&lt;/A&gt; for this, I do it with InstallUtil, but you could also execute a set of T-SQL scripts by using SqlCmd:&lt;/P&gt;
&lt;DIV style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;&lt;PRE style="MARGIN: 0px"&gt;InstallUtil /ConnectionString="Data Source=localhost;Initial Catalog=HoneyTemp;Integrated Security=True" bin\Debug\Ploeh.Samples.HoneySqlAccess.dll /LogFile=&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;The main thing to notice here is that I create a new database called &lt;EM&gt;HoneyTemp&lt;/EM&gt;.&lt;/P&gt;
&lt;P&gt;The next step is to create the LINQ to SQL data model. For that purpose, we can use a tool called Sqlmetal:&lt;/P&gt;
&lt;DIV style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;&lt;PRE style="MARGIN: 0px"&gt;SqlMetal /server:localhost /database:HoneyTemp /dbml:OriginalHoneyDB.dbml /namespace:Ploeh.Samples.HoneySqlAccess /pluralize&lt;/PRE&gt;&lt;/DIV&gt;&lt;!--EndFragment--&gt;
&lt;P&gt;This creates the file &lt;EM&gt;OriginalHoneyDB.dmbl&lt;/EM&gt; from the database &lt;EM&gt;HoneyTemp&lt;/EM&gt; that was just created in the step before.&lt;/P&gt;
&lt;P&gt;If you are inclined to accept the generated data model &lt;EM&gt;as is&lt;/EM&gt;, you can just include the file in your project and go ahead and use it. When you add a .dbml file to Visual Studio 2008, it will automatically set it up with the MSLinqToSQLGenerator custom tool, which will cause it to autogenerate .NET code for you.&lt;/P&gt;
&lt;P&gt;In many cases, however, you will want to tweak the model a bit (I'll get back to that later). Since a .dbml file is just an XML file, the most flexible approach is to apply an XSL transformation. Since this is PowerShell, I can just use .NET objects directly:&lt;/P&gt;
&lt;DIV style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;&lt;PRE style="MARGIN: 0px"&gt;$transformation = [System.IO.Path]::Combine((Get-Location).Path, "ModifyDataModel.xslt")&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;$originalDbml = [System.IO.Path]::Combine((Get-Location).Path, "OriginalHoneyDB.dbml")&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;$dbml = [System.IO.Path]::Combine((Get-Location).Path, "HoneyDB.dbml")&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;$xslt = New-Object System.Xml.Xsl.XslCompiledTransform&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;$xslt.Load($transformation)&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;$xslt.Transform($originalDbml, $dbml)&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;This part of the script uses the ModifyDataModel.xslt transformation to create the HoneyDB.dbml file that I can then go ahead and include in my Visual Studio project.&lt;/P&gt;
&lt;P&gt;Left is only a bit of clean-up:&lt;/P&gt;
&lt;DIV style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;&lt;PRE style="MARGIN: 0px"&gt;del $originalDbml&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;InstallUtil /u /ConnectionString="Data Source=localhost;Initial Catalog=HoneyTemp;Integrated Security=True" bin\Debug\Ploeh.Samples.HoneySqlAccess.dll /LogFile=&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;The OriginalHoneyDB.dbml file is just for transitory use, so can be deleted. The last line is just my (Installer-based) way of removing the database from my system again (notice the /u switch to uninstall).&lt;/P&gt;
&lt;P&gt;Most of this script just calls .NET SDK command-line utilities, or, if you want to use SqlCmd for executing T-SQL scripts, tools from the SQL Server Client Tools installation. The only part that isn't going to work in cmd.exe is the XSLT processing part, but if you can find a suitable command-line XSLT processor (there are several free ones available), you can mimic this script in a .bat file as well.&lt;/P&gt;
&lt;P&gt;The last thing I want to show you is a couple of&amp;nbsp;snippets&amp;nbsp;from the XSL transformation.&lt;/P&gt;
&lt;P&gt;Since the transitory database was called &lt;EM&gt;HoneyTemp&lt;/EM&gt;, Sqlmetal creates a &lt;A class="" href="http://msdn2.microsoft.com/en-us/library/system.data.linq.datacontext.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/system.data.linq.datacontext.aspx"&gt;DataContext&lt;/A&gt; called &lt;EM&gt;HoneyTemp&lt;/EM&gt;. That is obviously not an acceptable name, so it should be renamed to something better, like &lt;EM&gt;HoneyContext&lt;/EM&gt;:&lt;/P&gt;
&lt;DIV style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;xsl:template&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;match&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;dbml:Database&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;xsl:copy&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;xsl:copy-of&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;select&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;@*&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; /&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;xsl:attribute&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Name&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;HoneyContext&lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;xsl:attribute&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;xsl:apply-templates&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;select&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;node()&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; /&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp; &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;xsl:copy&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;xsl:template&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;Another modification I wanted to do was to rename Bee.ID to Bee.Id, since Code Analysis would otherwise complain about the naming of the ID property. On the other hand, I didn't want to change the column name in the database from &lt;EM&gt;ID&lt;/EM&gt; to &lt;EM&gt;Id&lt;/EM&gt;, so a mapping is in order. LINQ to SQL supports that scenario by adding a Member attribute to the appropriate Column element, so that's what's going on here:&lt;/P&gt;
&lt;DIV style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;xsl:template&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;match&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;dbml:Database/dbml:Table/dbml:Type[@Name = 'Bee']/dbml:Column[@Name = 'ID']&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;xsl:copy&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;xsl:apply-templates&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;select&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;@* | node()&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; /&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;xsl:attribute&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Member&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;Id&lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;xsl:attribute&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp; &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;xsl:copy&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;xsl:template&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;Although this recipe may seem complex, it's fully automated and sure beats having to do a series of manual steps. Whenever I need to change the database schema, I can just edit my T-SQL scripts and then run my PowerShell script to automatically update my LINQ to SQL data model. If I wish to do some customization of the model, I can add or edit those in the XSL transformation. Each schema item is defined in one, and only one, place.&lt;/P&gt;
&lt;P&gt;Since the files involved in the example are a bit complex, I've attached a downloadable&amp;nbsp;sample to this post. As always, this is only sample code and is provided &lt;EM&gt;as is&lt;/EM&gt;, etc.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8374684" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/ploeh/attachment/8374684.ashx" length="41862" type="application/x-zip-compressed" /><category domain="http://blogs.msdn.com/ploeh/archive/tags/Productivity/default.aspx">Productivity</category></item><item><title>Visual Studio 2008 PowerShell</title><link>http://blogs.msdn.com/ploeh/archive/2008/04/09/VisualStudio2008PowerShell.aspx</link><pubDate>Wed, 09 Apr 2008 22:24:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8372993</guid><dc:creator>ploeh</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/ploeh/comments/8372993.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ploeh/commentrss.aspx?PostID=8372993</wfw:commentRss><wfw:comment>http://blogs.msdn.com/ploeh/rsscomments.aspx?PostID=8372993</wfw:comment><description>&lt;P&gt;Ever since I first&amp;nbsp;saw a demo of&amp;nbsp;&lt;A class="" href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx" mce_href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx"&gt;PowerShell&lt;/A&gt;&amp;nbsp;some five years ago, I've been wanting&amp;nbsp;to use it for development work; such as automating code generation or whatever other task for which small scripts are needed. It's such a powerful environment, and I simply love the fact that it's based on .NET and that you can easily create new Cmdlets! What's been holding me back so far is that none of the tools I regularly use (SvcUtil, InstallUtil, etc.) are available in the default shell.&lt;/P&gt;
&lt;P&gt;Sure, I could manually add the necessary directories to the shell's path, but since there's always been a Visual Studio Command Prompt (driven by vsvars32.bat), that seemed to me like unnecessary duplication of effort. Luckily, &lt;A class="" href="http://www.tavaresstudios.com/Blog/" mce_href="http://www.tavaresstudios.com/Blog/"&gt;Chris Tavares&lt;/A&gt; has &lt;A class="" href="http://www.tavaresstudios.com/Blog/post/The-last-vsvars32ps1-Ill-ever-need.aspx" mce_href="http://www.tavaresstudios.com/Blog/post/The-last-vsvars32ps1-Ill-ever-need.aspx"&gt;a solution&lt;/A&gt;! ...or, that's at least what I thought when I first read his post.&lt;/P&gt;
&lt;P&gt;Unfortunately, it didn't work for me. While I'm sure that Chris tested his solution, my registry simply doesn't contain the InstallDir node that he uses. Whether that's because I'm running on Vista x64 (which causes many funky issues from time to time), or my Visual Studio installation is just plain weird, I don't know... At least, Chris' post solved the most difficult problem for me: Getting the vsvars32.bat path and other environment variables into PowerShell.&lt;/P&gt;
&lt;P&gt;On every machine that I've ever had Visual Studio installed, there's always been an environment variable called VS90COMNTOOLS that points to exactly the folder containing vsvars32.bat, so why not use that instead of the registry approach?&lt;/P&gt;
&lt;P&gt;While I kept Chris' Get-BatchFile function unmodified, I reimplemented the VsVars32 function as:&lt;/P&gt;
&lt;DIV style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;&lt;PRE style="MARGIN: 0px"&gt;function VsVars32()&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;{&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $vs90comntools = (Get-ChildItem env:VS90COMNTOOLS).Value&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $batchFile = [System.IO.Path]::Combine($vs90comntools, "vsvars32.bat")&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Get-Batchfile $BatchFile&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [System.Console]::Title = "Visual Studio 2008 Windows PowerShell"&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;}&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;As you can see, getting the correct path to vsvars32.bat is as simple as extracting the VS90COMNTOOLS environment variable and then using &lt;A class="" href="http://msdn2.microsoft.com/en-us/library/system.io.path.combine.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/system.io.path.combine.aspx"&gt;Path.Combine&lt;/A&gt; to construct the full path to the file.&lt;/P&gt;
&lt;P&gt;To get a &lt;EM&gt;Visual Studio 2008 PowerShell&lt;/EM&gt; (as an equivalent to the Visual Studio 2008 Command Prompt), I combined it all in a vsvars32.ps1 file. To run the script file and keep the shell open, you need to open it like this, since double-clicking a .ps1 file will just open it in Notepad:&lt;/P&gt;
&lt;DIV style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;&lt;PRE style="MARGIN: 0px"&gt;powershell.exe -noexit &amp;lt;path&amp;gt;\vsvars32.ps1&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;where &amp;lt;path&amp;gt; indicates the path to the vsvars32.ps1 file. To make it easier to quickly&amp;nbsp;open a Visual Studio 2008 PowerShell, I created a shortcut with this command, and added the shortcut to my Start menu. Now I can simply type &lt;EM&gt;Visual Power&lt;/EM&gt; in my Vista Start menu search box, and I then have instant access to my Visual Studio 2008 PowerShell.&lt;/P&gt;
&lt;P&gt;As a convenience to you, my dear reader, I'm attaching the script file for your reuse - use at your own peril.&lt;/P&gt;
&lt;P&gt;If you are new to PowerShell, note that you must change your execution policy to &lt;EM&gt;RemoteSigned&lt;/EM&gt; or less (or sign my script with a certificate you trust) to be able to run scripts at all, and that you probably also need to go to the file's properties and unblock it, since you downloaded it from the internet.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Update:&lt;/STRONG&gt; You can also move the VsVars32&amp;nbsp;(and corresponding Get-BatchFile) function&amp;nbsp;into your profile.ps1, and just call VsVars32 from your vsvars32.ps1 file. That enables you to use VsVars32 from other scripts without having to explicitly open a Visual Studio 2008 PowerShell.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8372993" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/ploeh/attachment/8372993.ashx" length="518" type="text/plain" /><category domain="http://blogs.msdn.com/ploeh/archive/tags/Productivity/default.aspx">Productivity</category></item><item><title>Race Troubleshooting Using The Console Output In VSTS</title><link>http://blogs.msdn.com/ploeh/archive/2007/10/06/RaceTroubleshootingUsingTheConsoleOutputInVSTS.aspx</link><pubDate>Sat, 06 Oct 2007 22:13:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5319858</guid><dc:creator>ploeh</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/ploeh/comments/5319858.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ploeh/commentrss.aspx?PostID=5319858</wfw:commentRss><wfw:comment>http://blogs.msdn.com/ploeh/rsscomments.aspx?PostID=5319858</wfw:comment><description>&lt;P&gt;It must be my week of &lt;A class="" href="http://blogs.msdn.com/ploeh/archive/2007/10/02/TroubleshootingWCFInProductionEnvironments.aspx" mce_href="http://blogs.msdn.com/ploeh/archive/2007/10/02/TroubleshootingWCFInProductionEnvironments.aspx"&gt;discovering the obvious&lt;/A&gt;. The other day I was troubleshooting a race condition in my code. I had a unit test that faithfully reproduced the error, but just looking at the code involved didn't&amp;nbsp;produce any sudden insights into its reasons. The nasty thing about race conditions (and multi-threaded code in general) is that you can't debug them, since the debuger influences the race.&lt;/P&gt;
&lt;P&gt;Sometimes, you can troubleshoot race conditions by tracing strategic points in the code, and sometimes it doesn't work, since even tracing statements influence the race. In my particular case, tracing didn't disrupt my&amp;nbsp;race condition, so the only problem left was how I could view that output as easily as possible. Since I was using VSTS unit tests from within Visual Studio 2005, I was hoping my Console output would be in the Output window, but no such luck. Then, in a rare case of inspiration, I double-clicked on the test in the Test Results window and got a window similar to this one (which is a mock-up, I admit):&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://blogs.msdn.com/photos/ploeh/images/5319396/original.aspx" border=0 mce_src="http://blogs.msdn.com/photos/ploeh/images/5319396/original.aspx"&gt;&lt;/P&gt;
&lt;P&gt;Notice the highlighted Standard Console Output.&lt;/P&gt;
&lt;P&gt;It's so simple that I wonder I never discovered this feature before, but now that I know it exists, I know how to troubleshoot race conditions reproduced in unit tests the next time I have to deal with multi-dreaded code&amp;nbsp;:)&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=5319858" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/ploeh/archive/tags/Unit+Testing/default.aspx">Unit Testing</category><category domain="http://blogs.msdn.com/ploeh/archive/tags/Productivity/default.aspx">Productivity</category></item><item><title>Agile Proves Effective Once More</title><link>http://blogs.msdn.com/ploeh/archive/2007/08/31/AgileProvesEffectiveOnceMore.aspx</link><pubDate>Fri, 31 Aug 2007 11:14:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4663066</guid><dc:creator>ploeh</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/ploeh/comments/4663066.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ploeh/commentrss.aspx?PostID=4663066</wfw:commentRss><wfw:comment>http://blogs.msdn.com/ploeh/rsscomments.aspx?PostID=4663066</wfw:comment><description>&lt;P&gt;&lt;A class="" href="http://blogs.msdn.com/christj/default.aspx" mce_href="http://blogs.msdn.com/christj/default.aspx"&gt;Christian&lt;/A&gt;, one of my old (and present) collegues, has just posted about his &lt;A class="" href="http://blogs.msdn.com/christj/archive/2007/08/30/announcing-microsoft-dynamics-ax-mobile-sales-and-microsoft-dynamics-mobile-development-tools.aspx" mce_href="http://blogs.msdn.com/christj/archive/2007/08/30/announcing-microsoft-dynamics-ax-mobile-sales-and-microsoft-dynamics-mobile-development-tools.aspx"&gt;team's latest accomplishment&lt;/A&gt;, shipping six months ahead of time! I'm sure that the team consists of a bunch of very talented people, but I'd also venture a guess that their adoption of agile methodologies has a lot to do with it.&lt;/P&gt;
&lt;P&gt;If only more development organizations would adopt agile methodologies... At least, such a result as shippng six months earlier should make some people stop and think&amp;nbsp;about their current way of creating software&amp;nbsp;:)&lt;/P&gt;
&lt;P&gt;Let's have more of that, and congratulations to Christian and his team!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=4663066" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/ploeh/archive/tags/Productivity/default.aspx">Productivity</category></item></channel></rss>