<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://sourcesafe.codebetter.com/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><title type="html">Jeremy D. Miller -- The Shade Tree Developer</title><subtitle type="html">Under the hood and working with .Net, TDD, Software Design, and Agile Stuff

</subtitle><id>http://sourcesafe.codebetter.com/blogs/jeremy.miller/atom.aspx</id><link rel="alternate" type="text/html" href="http://sourcesafe.codebetter.com/blogs/jeremy.miller/default.aspx" /><link rel="self" type="application/atom+xml" href="http://sourcesafe.codebetter.com/blogs/jeremy.miller/atom.aspx" /><generator uri="http://communityserver.org" version="3.0.20416.853">Community Server</generator><updated>2008-12-04T16:14:00Z</updated><entry><title>Choosing the Constructor Function in StructureMap without Attributes</title><link rel="alternate" type="text/html" href="http://sourcesafe.codebetter.com/blogs/jeremy.miller/archive/2009/01/07/choosing-the-constructor-function-in-structuremap-without-attributes.aspx" /><id>http://sourcesafe.codebetter.com/blogs/jeremy.miller/archive/2009/01/07/choosing-the-constructor-function-in-structuremap-without-attributes.aspx</id><published>2009-01-08T04:47:00Z</published><updated>2009-01-08T04:47:00Z</updated><content type="html">&lt;p&gt;A longstanding complaint with StructureMap is that the way StructureMap selects a constructor function can only be overridden with an attribute.&amp;nbsp; Using attributes is now frowned upon, and other times is impossible.&amp;nbsp; StructureMap 2.5.2 (the version in the trunk that, knock on wood, I get released no later than Saturday) introduces a quick programmatic way to select the constructor function using the magic of Expressions.&amp;nbsp; This is an excerpt from the new StructureMap documentation I’m working up.&amp;nbsp; It will be much more readable on the website (next week hopefully):&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;StructureMap has always allowed you to override the constructor choice with an attribute, but increasingly, many people are unwilling to use attributes in their code for infrastructure concerns.&amp;nbsp; Other times you may want to override the constructor choice of a class that you don&amp;#39;t control.&amp;nbsp; Either way, it would be useful to select the constructor function used by StructureMap to build a concrete code in the Registry DSL.&amp;nbsp; The syntax to do just that is shown below:&lt;/p&gt;  &lt;p&gt;Let&amp;#39;s say that you have this class (from the unit tests):&lt;/p&gt;   &lt;div style="border:thin solid black;background:white none repeat scroll 0% 0%;font-size:10pt;-moz-background-clip:-moz-initial;-moz-background-origin:-moz-initial;-moz-background-inline-policy:-moz-initial;color:black;font-family:courier new;"&gt;   &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span&gt;ClassWithTwoConstructors&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; ClassWithTwoConstructors(&lt;span style="color:blue;"&gt;int&lt;/span&gt; age, &lt;span style="color:blue;"&gt;string&lt;/span&gt; name)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; ClassWithTwoConstructors(&lt;span style="color:blue;"&gt;int&lt;/span&gt; age)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;By default, StructureMap would choose the &amp;quot;greediest&amp;quot; constructor.&amp;nbsp; In this case, it would be the constructor that takes in &amp;quot;age&amp;quot; and &amp;quot;name.&amp;quot;&amp;nbsp; To force StructureMap into using the other constructor, use the SelectConstructor() method on the Registry:&lt;/p&gt;   &lt;div style="border:thin solid black;background:white none repeat scroll 0% 0%;font-size:10pt;-moz-background-clip:-moz-initial;-moz-background-origin:-moz-initial;-moz-background-inline-policy:-moz-initial;color:black;font-family:courier new;"&gt;   &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;var&lt;/span&gt; container = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span&gt;Container&lt;/span&gt;(x =&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x.SelectConstructor&amp;lt;&lt;span&gt;ClassWithTwoConstructors&lt;/span&gt;&amp;gt;(()=&amp;gt;&lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span&gt;ClassWithTwoConstructors&lt;/span&gt;(0));&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x.ForConcreteType&amp;lt;&lt;span&gt;ClassWithTwoConstructors&lt;/span&gt;&amp;gt;().Configure&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .WithCtorArg(&lt;span&gt;&amp;quot;age&amp;quot;&lt;/span&gt;).EqualTo(34);&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;The argument to the SelectConstructor is an Expression of type Expression&amp;lt;Func&amp;lt;T&amp;gt;&amp;gt; where T is the concrete class.&amp;nbsp; StructureMap parses the Expression to find the constructor function in the Expression object.&lt;/p&gt;&lt;img src="http://sourcesafe.codebetter.com/aggbug.aspx?PostID=187060" width="1" height="1"&gt;</content><author><name>jmiller</name><uri>http://sourcesafe.codebetter.com/members/jmiller.aspx</uri></author><category term="StructureMap" scheme="http://sourcesafe.codebetter.com/blogs/jeremy.miller/archive/tags/StructureMap/default.aspx" /></entry><entry><title>A Challenge to the VB.Net Community at Large on OSS</title><link rel="alternate" type="text/html" href="http://sourcesafe.codebetter.com/blogs/jeremy.miller/archive/2009/01/07/a-challenge-to-the-vb-net-community-at-large-on-oss.aspx" /><id>http://sourcesafe.codebetter.com/blogs/jeremy.miller/archive/2009/01/07/a-challenge-to-the-vb-net-community-at-large-on-oss.aspx</id><published>2009-01-08T01:21:00Z</published><updated>2009-01-08T01:21:00Z</updated><content type="html">&lt;p&gt;I had a 3-4 way Twitter conversation with &lt;a href="http://weblogs.asp.net/ROsherove/"&gt;Roy Osherove&lt;/a&gt; today that left me hot under the collar even several hours later.&amp;nbsp; The conversation basically played out like this:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;Roy:&amp;nbsp; Boo hoo, new .Net OSS projects are using advanced features in C# that might make those tools hard to use in VB.Net&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Me:&amp;nbsp; Maybe, but I&amp;#39;m optimizing the user experience of these tools for C#.&amp;nbsp; I&amp;#39;m not going to sacrifice user experience in favor of a little extra reach.&amp;nbsp; Besides, VB.Net devs are a very small percentage of OSS users.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Roy:&amp;nbsp; Jeremy is an anti-VB bigot!&amp;nbsp; Who&amp;#39;s with me VB guys?&amp;nbsp; VB guys can&amp;#39;t use or participate in OSS because they&amp;#39;re actively turned away by guys like Jeremy! &lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;and then Roy proceeded to present himself as the champion of all those poor dispossessed VB.Net developers with some cheap theatrics. &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;b&gt;To you Mr. VB.Net Dev:&lt;/b&gt;&lt;/p&gt;&lt;p&gt;Stand up if you don&amp;#39;t like the way things are.&amp;nbsp; I have never once gotten any kind of specific suggestion about how to make StructureMap more palatable for VB.Net usage.&amp;nbsp; I&amp;#39;ve gotten complaints, and some questions (which I have answered), but not one single specific suggestion or patch that I recall.&amp;nbsp; Mr. VB.Net developer, if there&amp;#39;s something you want or lack in an OSS framework that would make it easier/better to use that tool with idiomatic VB.Net, you know who&amp;#39;s probably most qualified and able to write that patch?&amp;nbsp; You are!&amp;nbsp; I don&amp;#39;t write software in VB.Net, and haven&amp;#39;t used VB.Net in anger since .Net was in and early beta.&amp;nbsp; I&amp;#39;m not going to get VB.Net idioms, and I don&amp;#39;t have visibility into VB specific issues.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;And you know what?&amp;nbsp; There isn&amp;#39;t a major OSS project on earth that doesn&amp;#39;t like getting patches.&amp;nbsp; I would love to get real, useful contribution from the VB.Net community in regards to an improved user experience with StructureMap -- but I&amp;#39;m not going to pay attention to empty complaints, and I&amp;#39;m certainly not putting up with vilification.&lt;/p&gt;&lt;p&gt;&lt;b&gt;I&amp;#39;ll go a step farther, give me a usable patch for StructureMap for better VB.Net usage, and I&amp;#39;ll have it released within 48 hours on Sourceforge&lt;/b&gt;. &lt;br /&gt;&lt;/p&gt;&lt;p&gt;Actually, now that I&amp;#39;m a bit calmer, take this to heart.&amp;nbsp; OSS projects are owned by the community -- meaning that you can pick up the reins and do something about a tool that lacks something you need or want.&amp;nbsp; Don&amp;#39;t be passive.&amp;nbsp; Heck, you could even write your own.&amp;nbsp; You don&amp;#39;t think that OSS projects are a friendly place for VB&amp;#39;ers?&amp;nbsp; Start your own and make the .Net ecosystem even richer.&amp;nbsp; Hell, it&amp;#39;s not rocket science after all.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;And p.s,. you really need to get the VB.Net team to give you multiline Lambda functions in the next version of VB.&amp;nbsp; Trust me, once you have them, you&amp;#39;ll never want to code in a language that lacks them ever again. &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://sourcesafe.codebetter.com/aggbug.aspx?PostID=187049" width="1" height="1"&gt;</content><author><name>jmiller</name><uri>http://sourcesafe.codebetter.com/members/jmiller.aspx</uri></author><category term="Ranting" scheme="http://sourcesafe.codebetter.com/blogs/jeremy.miller/archive/tags/Ranting/default.aspx" /></entry><entry><title>AutoWiring in StructureMap 2.5+</title><link rel="alternate" type="text/html" href="http://sourcesafe.codebetter.com/blogs/jeremy.miller/archive/2009/01/07/autowiring-in-structuremap-2-5.aspx" /><id>http://sourcesafe.codebetter.com/blogs/jeremy.miller/archive/2009/01/07/autowiring-in-structuremap-2-5.aspx</id><published>2009-01-07T18:06:00Z</published><updated>2009-01-07T18:06:00Z</updated><content type="html">&lt;p&gt;Getting the StructureMap docs a going.&amp;nbsp; Here’s an excerpt:&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;The best way to use an IoC container is to allow &amp;quot;Auto Wiring&amp;quot; to do most of the work for you.&amp;nbsp; IoC Containers like StructureMap are an infrastructure concern, and as such, should be isolated from as much of your code as possible.&amp;nbsp; Before examining Auto Wiring in depth, let&amp;#39;s look at a common anti pattern of IoC usage:&lt;/p&gt;  &lt;h2&gt;IoC Container Anti-Pattern&lt;/h2&gt;  &lt;p&gt;One of the worst, but sadly&amp;nbsp; most common, usages of an IoC container is shown below:&lt;/p&gt;   &lt;div style="border:thin solid black;background:white none repeat scroll 0% 0%;font-size:10pt;-moz-background-clip:-moz-initial;-moz-background-origin:-moz-initial;-moz-background-inline-policy:-moz-initial;color:black;font-family:courier new;"&gt;   &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:green;"&gt;// This is the way to write a Constructor Function with an IoC tool&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:green;"&gt;// Let the IoC container &amp;quot;inject&amp;quot; services from outside, and keep&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:green;"&gt;// ShippingScreenPresenter ignorant of the IoC infrastructure&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; ShippingScreenPresenter(&lt;span&gt;IShippingService&lt;/span&gt; service, &lt;span&gt;IRepository&lt;/span&gt; repository)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _service = service;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _repository = repository;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:green;"&gt;// FAIL!&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:green;"&gt;// This is the wrong way to use an IoC container.&amp;nbsp; Do NOT invoke the container from&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:green;"&gt;// the constructor function.&amp;nbsp; This tightly couples the ShippingScreenPresenter to&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:green;"&gt;// the IoC container in a harmful way.&amp;nbsp; This class cannot be used in either&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:green;"&gt;// production or testing without a valid IoC configuration.&amp;nbsp; Plus, you&amp;#39;re writing more&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:green;"&gt;// code&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; ShippingScreenPresenter()&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _service = &lt;span&gt;ObjectFactory&lt;/span&gt;.GetInstance&amp;lt;&lt;span&gt;IShippingService&lt;/span&gt;&amp;gt;();&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _repository = &lt;span&gt;ObjectFactory&lt;/span&gt;.GetInstance&amp;lt;&lt;span&gt;IRepository&lt;/span&gt;&amp;gt;();&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt; &lt;/div&gt;   &lt;hr /&gt;  &lt;h2&gt;Example&lt;/h2&gt;  &lt;p&gt;Typically, you’ll try to minimize the number of &lt;a href="http://codebetter.com/controlpanel/blogs/%20%20%20%20%20%20%20%20%20%20%20%20Typically,%20you%E2%80%99ll%20try%20to%20minimize%20the%20number%20of%20Service%20Locator%20usages%20in%20"&gt;Service Locator&lt;/a&gt; (Container.Get*****) usages in your system to a bare minimum (I found 8 in my current system, but I think I’ll find a way to prune half of those later).&amp;nbsp; Most of the value of an IoC tool is in automatically doing Dependency Injection.&amp;nbsp; I’m working with the new MVC framework at the moment, so it’s a handy sample.&amp;nbsp; Let’s say that we have a Controller class for a typical CRUD screen.&amp;nbsp; That Controller class will generally need to interact with both validation services and the data access functionality of the Repository.&amp;nbsp; Here’s a representative Controller class:&lt;/p&gt;  &lt;div class="code-sample"&gt;   &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span&gt;SomeScreenController&lt;/span&gt; : &lt;span&gt;IController&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color:blue;"&gt;readonly&lt;/span&gt; &lt;span&gt;IRepository&lt;/span&gt; _repository;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color:blue;"&gt;readonly&lt;/span&gt; &lt;span&gt;IValidator&lt;/span&gt; _validator;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:green;"&gt;// SomeScreenController depends on both IRepository and IValidator&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; SomeScreenController(&lt;span&gt;IRepository&lt;/span&gt; repository, &lt;span&gt;IValidator&lt;/span&gt; validator)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _repository = repository;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _validator = validator;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;So let’s get StructureMap set up for this SomeScreenController class:&lt;/p&gt;  &lt;div style="border:thin solid black;background:white none repeat scroll 0% 0%;overflow:scroll;font-size:10pt;-moz-background-clip:-moz-initial;-moz-background-origin:-moz-initial;-moz-background-inline-policy:-moz-initial;color:black;font-family:courier new;"&gt;   &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span&gt;ObjectFactory&lt;/span&gt;.Initialize(x =&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:green;"&gt;// Set up the IValidator&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x.ForRequestedType&amp;lt;&lt;span&gt;IValidator&lt;/span&gt;&amp;gt;().TheDefaultIsConcreteType&amp;lt;&lt;span&gt;Validator&lt;/span&gt;&amp;gt;();&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:green;"&gt;// Set up the IRepository&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x.ForRequestedType&amp;lt;&lt;span&gt;IRepository&lt;/span&gt;&amp;gt;().TheDefault.Is.OfConcreteType&amp;lt;&lt;span&gt;Repository&lt;/span&gt;&amp;gt;()&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .WithCtorArg(&lt;span&gt;&amp;quot;connectionString&amp;quot;&lt;/span&gt;).EqualToAppSetting(&lt;span&gt;&amp;quot;CONNECTION-STRING&amp;quot;&lt;/span&gt;);&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;You’ll notice that we didn’t make any explicit configuration for the SomeScreenController class, but yet we could now call:&lt;/p&gt;  &lt;div style="border:thin solid black;background:white none repeat scroll 0% 0%;overflow:scroll;font-size:10pt;-moz-background-clip:-moz-initial;-moz-background-origin:-moz-initial;-moz-background-inline-policy:-moz-initial;color:black;font-family:courier new;"&gt;   &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;var&lt;/span&gt; controller = &lt;span&gt;ObjectFactory&lt;/span&gt;.GetInstance&amp;lt;&lt;span&gt;SomeScreenController&lt;/span&gt;&amp;gt;();&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;and StructureMap will happily create a new instance of the SomeScreenController class by invoking its constructor and passing in a new Validator object and a new Repository object created with the connection string from the App.config file.&amp;nbsp; We didn’t need to tell StructureMap how to construct SomeScreenController because: &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;StructureMap can look at the constructor function of SomeScreenController and see that it depends on IValidator and IRepository &lt;/li&gt;    &lt;li&gt;StructureMap “knows” about the default way to create and return an IValidator and an IRepository &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;This feature is known as “auto wiring,” and all the mainstream IoC containers support this feature to some extent or another.&amp;nbsp; &lt;/p&gt;  &lt;hr /&gt;  &lt;h2&gt;StructureMap&amp;#39;s Policies for Auto Wiring&lt;/h2&gt;  &lt;p&gt;By default, as long as an object is being created by invoking its constructor function, StructureMap will try to create/resolve/find an object for each non-primitive dependency in the requested concrete type.&amp;nbsp; If StructureMap doesn&amp;#39;t &amp;quot;know&amp;quot; how to find a requested dependency, it will throw an exception.&amp;nbsp; By design, StructureMap cannot auto wire primitive arguments like strings and numbers.&amp;nbsp; The Auto Wiring can be overriden by explicit configuration (this might actually be easier with Xml configuration):&lt;/p&gt;   &lt;div style="border:thin solid black;background:white none repeat scroll 0% 0%;font-size:10pt;-moz-background-clip:-moz-initial;-moz-background-origin:-moz-initial;-moz-background-inline-policy:-moz-initial;color:black;font-family:courier new;"&gt;   &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; registry.InstanceOf&amp;lt;&lt;span&gt;Rule&lt;/span&gt;&amp;gt;()&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .Is.OfConcreteType&amp;lt;&lt;span&gt;WidgetRule&lt;/span&gt;&amp;gt;()&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .WithName(&lt;span&gt;&amp;quot;TheWidgetRule&amp;quot;&lt;/span&gt;)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .CtorDependency&amp;lt;&lt;span&gt;IWidget&lt;/span&gt;&amp;gt;().Is(i =&amp;gt; i.TheInstanceNamed(&lt;span&gt;&amp;quot;Yellow&amp;quot;&lt;/span&gt;));&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;In the example above, the IWidget dependency of the WidgetRule class is overriden.&lt;/p&gt;  &lt;hr /&gt;  &lt;h4&gt;Object Identity within a Single Request&lt;/h4&gt;  &lt;p&gt;Within a single object request, StructureMap will only create a single object for a single Instance configuration.&amp;nbsp; What that means in effect is that if two or more objects in a single request need the same dependency, those two objects will get the exact same instance of that dependency.&amp;nbsp; Let&amp;#39;s immediately jump into code to demonstrate this.&lt;/p&gt;  &lt;p&gt;This auto wiring policy was intended for objects that need to be shared by lots of other objects.&amp;nbsp; A common example of this is some sort of DataContext class:&lt;/p&gt;   &lt;div style="border:thin solid black;background:white none repeat scroll 0% 0%;font-size:10pt;-moz-background-clip:-moz-initial;-moz-background-origin:-moz-initial;-moz-background-inline-policy:-moz-initial;color:black;font-family:courier new;"&gt;   &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span&gt;DataContext&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span&gt;Guid&lt;/span&gt; _id = &lt;span&gt;Guid&lt;/span&gt;.NewGuid();&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;override&lt;/span&gt; &lt;span style="color:blue;"&gt;string&lt;/span&gt; ToString()&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;return&lt;/span&gt; &lt;span style="color:blue;"&gt;string&lt;/span&gt;.Format(&lt;span&gt;&amp;quot;Id: {0}&amp;quot;&lt;/span&gt;, _id);&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;Now, let&amp;#39;s say that I have a hierarchy of classes that all need to work on a DataContext:&lt;/p&gt;   &lt;div style="border:thin solid black;background:white none repeat scroll 0% 0%;font-size:10pt;-moz-background-clip:-moz-initial;-moz-background-origin:-moz-initial;-moz-background-inline-policy:-moz-initial;color:black;font-family:courier new;"&gt;   &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span&gt;Class1&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; Class1(&lt;span&gt;DataContext&lt;/span&gt; context){}&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;override&lt;/span&gt; &lt;span style="color:blue;"&gt;string&lt;/span&gt; ToString()&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;return&lt;/span&gt; &lt;span style="color:blue;"&gt;string&lt;/span&gt;.Format(&lt;span&gt;&amp;quot;Class1 has Context: {0}&amp;quot;&lt;/span&gt;, _context);&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span&gt;Class2&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; Class2(&lt;span&gt;Class1&lt;/span&gt; class1, &lt;span&gt;DataContext&lt;/span&gt; context) {}&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;override&lt;/span&gt; &lt;span style="color:blue;"&gt;string&lt;/span&gt; ToString()&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;return&lt;/span&gt; &lt;span style="color:blue;"&gt;string&lt;/span&gt;.Format(&lt;span&gt;&amp;quot;Class2 has Context: {0}\n{1}&amp;quot;&lt;/span&gt;, _context, _class1);&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span&gt;Class3&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; Class3(&lt;span&gt;Class2&lt;/span&gt; class2, &lt;span&gt;DataContext&lt;/span&gt; context) {}&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;override&lt;/span&gt; &lt;span style="color:blue;"&gt;string&lt;/span&gt; ToString()&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;return&lt;/span&gt; &lt;span style="color:blue;"&gt;string&lt;/span&gt;.Format(&lt;span&gt;&amp;quot;Class3 has Context: {0}\n{1}&amp;quot;&lt;/span&gt;, _context, _class2);&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;When you request an object of Class3 with a call to Container.GetInstance&amp;lt;Class3&amp;gt;() like this:&lt;/p&gt;   &lt;div style="border:thin solid black;background:white none repeat scroll 0% 0%;font-size:10pt;-moz-background-clip:-moz-initial;-moz-background-origin:-moz-initial;-moz-background-inline-policy:-moz-initial;color:black;font-family:courier new;"&gt;   &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span&gt;Test&lt;/span&gt;]&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; demonstrate_session_identity()&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;var&lt;/span&gt; class3 = container.GetInstance&amp;lt;&lt;span&gt;Class3&lt;/span&gt;&amp;gt;();&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span&gt;Debug&lt;/span&gt;.WriteLine(class3);&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;The output is:&lt;/p&gt;  &lt;pre&gt;Class3 has Context: Id: 3abe0330-e94f-48a3-b8c3-56d278eea07f&lt;br /&gt;Class2 has Context: Id: 3abe0330-e94f-48a3-b8c3-56d278eea07f&lt;br /&gt;Class1 has Context: Id: 3abe0330-e94f-48a3-b8c3-56d278eea07f&lt;/pre&gt;

&lt;p&gt;In the sample above, when we write out the Class3, Class2, and Class1 objects to Debug.WriteLine, we find that each of these objects have a reference to the same DataContext. If we were to run this test again, the output might be:&lt;/p&gt;

&lt;pre&gt;Class3 has Context: Id: 109329ce-4058-4a35-9fd1-46d47c1e69e7&lt;br /&gt;Class2 has Context: Id: 109329ce-4058-4a35-9fd1-46d47c1e69e7&lt;br /&gt;Class1 has Context: Id: 109329ce-4058-4a35-9fd1-46d47c1e69e7&lt;br /&gt;        &lt;/pre&gt;

&lt;p&gt;We see the exact same behavior, but it was a different object instance of DataContext for the new object graph.&lt;/p&gt;

&lt;p&gt;This behavior also applies to objects passed in to the Container as an explicit argument:&lt;/p&gt;


&lt;div style="border:thin solid black;background:white none repeat scroll 0% 0%;font-size:10pt;-moz-background-clip:-moz-initial;-moz-background-origin:-moz-initial;-moz-background-inline-policy:-moz-initial;color:black;font-family:courier new;"&gt;
  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span&gt;Test&lt;/span&gt;]&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; demonstrate_session_identity_with_explicit_argument()&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span&gt;DataContext&lt;/span&gt; context = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span&gt;DataContext&lt;/span&gt;();&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span&gt;Debug&lt;/span&gt;.WriteLine(&lt;span&gt;&amp;quot;The context being passed in is &amp;quot;&lt;/span&gt; + context);&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;var&lt;/span&gt; class3 = container.With(context).GetInstance&amp;lt;&lt;span&gt;Class3&lt;/span&gt;&amp;gt;();&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span&gt;Debug&lt;/span&gt;.WriteLine(class3);&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;/div&gt;


&lt;p&gt;The output of this unit test is:&lt;/p&gt;

&lt;pre&gt;The context being passed in is Id: 87ddccfd-a441-41fd-a86d-3f32987496ba&lt;br /&gt;Class3 has Context: Id: 87ddccfd-a441-41fd-a86d-3f32987496ba&lt;br /&gt;Class2 has Context: Id: 87ddccfd-a441-41fd-a86d-3f32987496ba&lt;br /&gt;Class1 has Context: Id: 87ddccfd-a441-41fd-a86d-3f32987496ba&lt;br /&gt;        &lt;/pre&gt;

&lt;p&gt;The point of the sample above is just to show that the object instance of DataContext passed into the Container is used to create the Class3, Class2, and Class1 objects.&lt;/p&gt;


&lt;hr /&gt;

&lt;h4&gt;Injecting Arrays of Services&lt;/h4&gt;

&lt;p&gt;StructureMap has always supported Dependency Injection of arrays of dependency objects.&amp;nbsp; New in StructureMap 2.5+ is a policy that if any array of dependencies is not explicitly specified, StructureMap will inject all possible instances of that dependency type.&amp;nbsp; The sample below illustrates this auto wiring policy.&amp;nbsp; I have a class called &amp;quot;ClassThatUsesValidators&amp;quot; that needs an array of IValidator objects.&amp;nbsp; Below, I&amp;#39;ve configured two different Instances of ClassThatUsesValidator, one that explicitly configures its children IValidator and another Instance that is just going to let auto wiring inject the IValidator&amp;#39;s.&lt;/p&gt;


&lt;div style="border:thin solid black;background:white none repeat scroll 0% 0%;font-size:10pt;-moz-background-clip:-moz-initial;-moz-background-origin:-moz-initial;-moz-background-inline-policy:-moz-initial;color:black;font-family:courier new;"&gt;
  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;interface&lt;/span&gt; &lt;span&gt;IValidator&lt;/span&gt;&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span&gt;Validator&lt;/span&gt; : &lt;span&gt;IValidator&lt;/span&gt;&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color:blue;"&gt;readonly&lt;/span&gt; &lt;span style="color:blue;"&gt;string&lt;/span&gt; _name;&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; Validator(&lt;span style="color:blue;"&gt;string&lt;/span&gt; name)&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _name = name;&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;override&lt;/span&gt; &lt;span style="color:blue;"&gt;string&lt;/span&gt; ToString()&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;return&lt;/span&gt; &lt;span style="color:blue;"&gt;string&lt;/span&gt;.Format(&lt;span&gt;&amp;quot;Name: {0}&amp;quot;&lt;/span&gt;, _name);&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span&gt;ClassThatUsesValidators&lt;/span&gt;&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color:blue;"&gt;readonly&lt;/span&gt; &lt;span&gt;IValidator&lt;/span&gt;[] _validators;&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; ClassThatUsesValidators(&lt;span&gt;IValidator&lt;/span&gt;[] validators)&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _validators = validators;&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; Write()&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;foreach&lt;/span&gt; (&lt;span&gt;IValidator&lt;/span&gt; validator &lt;span style="color:blue;"&gt;in&lt;/span&gt; _validators)&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span&gt;Debug&lt;/span&gt;.WriteLine(validator);&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span&gt;TestFixture&lt;/span&gt;]&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span&gt;ValidatorExamples&lt;/span&gt;&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span&gt;Container&lt;/span&gt; container;&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span&gt;SetUp&lt;/span&gt;]&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; SetUp()&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; container = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span&gt;Container&lt;/span&gt;(x =&amp;gt;&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x.ForRequestedType&amp;lt;&lt;span&gt;IValidator&lt;/span&gt;&amp;gt;().AddInstances(o =&amp;gt;&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; o.OfConcreteType&amp;lt;&lt;span&gt;Validator&lt;/span&gt;&amp;gt;().WithCtorArg(&lt;span&gt;&amp;quot;name&amp;quot;&lt;/span&gt;).EqualTo(&lt;span&gt;&amp;quot;Red&amp;quot;&lt;/span&gt;).WithName(&lt;span&gt;&amp;quot;Red&amp;quot;&lt;/span&gt;);&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; o.OfConcreteType&amp;lt;&lt;span&gt;Validator&lt;/span&gt;&amp;gt;().WithCtorArg(&lt;span&gt;&amp;quot;name&amp;quot;&lt;/span&gt;).EqualTo(&lt;span&gt;&amp;quot;Blue&amp;quot;&lt;/span&gt;).WithName(&lt;span&gt;&amp;quot;Blue&amp;quot;&lt;/span&gt;);&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; o.OfConcreteType&amp;lt;&lt;span&gt;Validator&lt;/span&gt;&amp;gt;().WithCtorArg(&lt;span&gt;&amp;quot;name&amp;quot;&lt;/span&gt;).EqualTo(&lt;span&gt;&amp;quot;Purple&amp;quot;&lt;/span&gt;).WithName(&lt;span&gt;&amp;quot;Purple&amp;quot;&lt;/span&gt;);&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; o.OfConcreteType&amp;lt;&lt;span&gt;Validator&lt;/span&gt;&amp;gt;().WithCtorArg(&lt;span&gt;&amp;quot;name&amp;quot;&lt;/span&gt;).EqualTo(&lt;span&gt;&amp;quot;Green&amp;quot;&lt;/span&gt;).WithName(&lt;span&gt;&amp;quot;Green&amp;quot;&lt;/span&gt;);&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x.ForRequestedType&amp;lt;&lt;span&gt;ClassThatUsesValidators&lt;/span&gt;&amp;gt;().AddInstances(o =&amp;gt;&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:green;"&gt;// Define an Instance of ClassThatUsesValidators that depends on AutoWiring&lt;/span&gt;&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; o.OfConcreteType&amp;lt;&lt;span&gt;ClassThatUsesValidators&lt;/span&gt;&amp;gt;().WithName(&lt;span&gt;&amp;quot;WithAutoWiring&amp;quot;&lt;/span&gt;);&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:green;"&gt;// Define an Instance of ClassThatUsesValidators that overrides AutoWiring&lt;/span&gt;&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; o.OfConcreteType&amp;lt;&lt;span&gt;ClassThatUsesValidators&lt;/span&gt;&amp;gt;().WithName(&lt;span&gt;&amp;quot;ExplicitArray&amp;quot;&lt;/span&gt;)&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .TheArrayOf&amp;lt;&lt;span&gt;IValidator&lt;/span&gt;&amp;gt;().Contains(y =&amp;gt;&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y.TheInstanceNamed(&lt;span&gt;&amp;quot;Red&amp;quot;&lt;/span&gt;);&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y.TheInstanceNamed(&lt;span&gt;&amp;quot;Green&amp;quot;&lt;/span&gt;);&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span&gt;Test&lt;/span&gt;]&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; what_are_the_validators()&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span&gt;Debug&lt;/span&gt;.WriteLine(&lt;span&gt;&amp;quot;With Auto Wiring&amp;quot;&lt;/span&gt;);&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; container.GetInstance&amp;lt;&lt;span&gt;ClassThatUsesValidators&lt;/span&gt;&amp;gt;(&lt;span&gt;&amp;quot;WithAutoWiring&amp;quot;&lt;/span&gt;).Write();&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span&gt;Debug&lt;/span&gt;.WriteLine(&lt;span&gt;&amp;quot;=================================&amp;quot;&lt;/span&gt;);&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span&gt;Debug&lt;/span&gt;.WriteLine(&lt;span&gt;&amp;quot;With Explicit Configuration&amp;quot;&lt;/span&gt;);&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; container.GetInstance&amp;lt;&lt;span&gt;ClassThatUsesValidators&lt;/span&gt;&amp;gt;(&lt;span&gt;&amp;quot;ExplicitArray&amp;quot;&lt;/span&gt;).Write();&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;

  &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;/div&gt;


&lt;p&gt;The output of what_are_the_validators() is:&lt;/p&gt;

&lt;pre&gt;With Auto Wiring&lt;br /&gt;Name: Red&lt;br /&gt;Name: Blue&lt;br /&gt;Name: Purple&lt;br /&gt;Name: Green&lt;br /&gt;=================================&lt;br /&gt;With Explicit Configuration&lt;br /&gt;Name: Red&lt;br /&gt;Name: Green&lt;/pre&gt;

&lt;hr /&gt;&lt;img src="http://sourcesafe.codebetter.com/aggbug.aspx?PostID=187026" width="1" height="1"&gt;</content><author><name>jmiller</name><uri>http://sourcesafe.codebetter.com/members/jmiller.aspx</uri></author><category term="StructureMap" scheme="http://sourcesafe.codebetter.com/blogs/jeremy.miller/archive/tags/StructureMap/default.aspx" /></entry><entry><title>It’s been years since I’ve gone on an Anti-Singleton rant</title><link rel="alternate" type="text/html" href="http://sourcesafe.codebetter.com/blogs/jeremy.miller/archive/2009/01/06/it-s-been-years-since-i-ve-gone-on-an-anti-singleton-rant.aspx" /><id>http://sourcesafe.codebetter.com/blogs/jeremy.miller/archive/2009/01/06/it-s-been-years-since-i-ve-gone-on-an-anti-singleton-rant.aspx</id><published>2009-01-06T21:52:49Z</published><updated>2009-01-06T21:52:49Z</updated><content type="html">&lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;So apparently it’s time again:&lt;/p&gt;  &lt;p&gt;&lt;img src="http://imagebin.ca/img/LHYFxh64.jpg" alt="" /&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;See:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://codebetter.com/blogs/jeremy.miller/pages/129545.aspx"&gt;TDD Design Starter Kit - Static Methods and Singletons May Be Harmful&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;and&lt;/p&gt;  &lt;p&gt;&lt;a href="http://codebetter.com/blogs/jeremy.miller/archive/2005/08/04/130302.aspx"&gt;Chill out on the Singleton Fetish&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;TypeMock will make singletons and statics “testable” now, but you’ll still get screwed over with very tight coupling.&amp;#160; &lt;/p&gt;&lt;img src="http://sourcesafe.codebetter.com/aggbug.aspx?PostID=186987" width="1" height="1"&gt;</content><author><name>jmiller</name><uri>http://sourcesafe.codebetter.com/members/jmiller.aspx</uri></author></entry><entry><title>Quickie StructureMap Update for Jan ‘09</title><link rel="alternate" type="text/html" href="http://sourcesafe.codebetter.com/blogs/jeremy.miller/archive/2009/01/04/quickie-structuremap-update-for-jan-09.aspx" /><id>http://sourcesafe.codebetter.com/blogs/jeremy.miller/archive/2009/01/04/quickie-structuremap-update-for-jan-09.aspx</id><published>2009-01-05T04:42:00Z</published><updated>2009-01-05T04:42:00Z</updated><content type="html">&lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;Before the holidays &lt;a href="http://codebetter.com/blogs/jeremy.miller/archive/2008/12/22/structuremap-2-5-1-is-released.aspx"&gt;I more or less promised&lt;/a&gt; the stuff below (and status in bold red).&amp;nbsp; The short status is that I’m going to post a completely new StructureMap website with *complete* documentation and examples by the end of the week.&amp;nbsp; I will also be making a small 2.5.2 release by Friday the 9th (I just want to finish the documentation and do more dogfooding at work first).&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;A Silverlight ready version (i.e. a cutdown StructureMap) &lt;b&gt;&lt;font color="#ff0000"&gt;Not started.&amp;nbsp; Targeting late January&lt;/font&gt;&lt;/b&gt;&lt;/li&gt;    &lt;li&gt;Finish the Mono support.&amp;nbsp; It&amp;#39;s very close, but I want to make sure. &lt;a href="http://www.e-tobi.net/blog/"&gt;&lt;b&gt;&lt;font color="#ff0000"&gt;Tobias Grimm&lt;/font&gt;&lt;/b&gt;&lt;/a&gt;&lt;b&gt;&lt;font color="#ff0000"&gt; has sent me several patches for this to me and says that StructureMap is compiling, running, and passing all unit tests on Mono.&lt;/font&gt;&lt;/b&gt;&lt;/li&gt;    &lt;li&gt;The *#%$ &amp;quot;BuildUp&amp;quot; functionality that allows you to do setter injection on an object that&amp;#39;s created somewhere else.&amp;nbsp; Thank you ASP.Net. &lt;b&gt;&lt;font color="#ff0000"&gt;Done in Trunk (will release in 2.5.2)&lt;/font&gt;&lt;/b&gt;&lt;/li&gt;    &lt;li&gt;Convention based setter injection (low hanging fruit) &lt;b&gt;&lt;font color="#ff0000"&gt;Done in Trunk (will release in 2.5.2).&amp;nbsp; Shamelessly stole this idea from Ninject.&lt;/font&gt;&lt;/b&gt;&lt;/li&gt;    &lt;li&gt;A guarantee that StructureMap will function in partially trusted environments, or at least real guidance on what it can and cannot do&amp;nbsp; &lt;b&gt;&lt;font color="#ff0000"&gt;Not Started.&amp;nbsp; I’m going to put my current project into Medium Trust and just see what happens.&lt;/font&gt;&lt;/b&gt;&lt;/li&gt;    &lt;li&gt;&amp;quot;Missing Instance&amp;quot; handlers &lt;b&gt;&lt;font color="#ff0000"&gt;Done in Trunk (will release in 2.5.2)&lt;/font&gt;&lt;/b&gt;&lt;/li&gt;    &lt;li&gt;A &amp;quot;ConditionalInstance&amp;quot; that will give you easier ways to do conditional construction &lt;b&gt;&lt;font color="#ff0000"&gt;Done in Trunk (will release in 2.5.2)&lt;/font&gt;&lt;/b&gt;&lt;/li&gt;    &lt;li&gt;Improved diagnostics.&amp;nbsp; The error output and the output from StructureMapDoctor and ObjectFactory.AssertConfigurationIsValid() could be a lot better &lt;b&gt;&lt;font color="#ff0000"&gt;Putting off to a 2.5.3 release &lt;/font&gt;&lt;/b&gt;&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;Plus:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;&lt;b&gt;Idiomatic&lt;/b&gt; StructureMap Prism Bootstrapper &lt;b&gt;&lt;font color="#ff0000"&gt;I have preliminary notes on this, and it isn’t big.&amp;nbsp; I expect to have this released by 1/9/09 in 2.5.2.&amp;nbsp; &lt;/font&gt;&lt;/b&gt;&lt;/li&gt;    &lt;li&gt;Complete Documentation &lt;b&gt;&lt;font color="#ff0000"&gt;75% done.&amp;nbsp; &lt;a href="https://structuremap.svn.sourceforge.net/svnroot/structuremap/trunk/Source/HTML/"&gt;See here for the docs in Subversion&lt;/a&gt;&lt;/font&gt;&lt;/b&gt;.&amp;nbsp; Feedback on the docs would be much appreciated.&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;For the record, I typed ‘09 the first time I had to write down a date this year.&amp;nbsp; First time ever to get it right.&lt;/p&gt;&lt;img src="http://sourcesafe.codebetter.com/aggbug.aspx?PostID=186930" width="1" height="1"&gt;</content><author><name>jmiller</name><uri>http://sourcesafe.codebetter.com/members/jmiller.aspx</uri></author><category term="StructureMap" scheme="http://sourcesafe.codebetter.com/blogs/jeremy.miller/archive/tags/StructureMap/default.aspx" /></entry><entry><title>Happy New Year!</title><link rel="alternate" type="text/html" href="http://sourcesafe.codebetter.com/blogs/jeremy.miller/archive/2009/01/04/happy-new-year.aspx" /><id>http://sourcesafe.codebetter.com/blogs/jeremy.miller/archive/2009/01/04/happy-new-year.aspx</id><published>2009-01-05T03:10:00Z</published><updated>2009-01-05T03:10:00Z</updated><content type="html">&lt;p&gt;Everyone else is doing a 2008 to 2009 post, so why not.&amp;nbsp; 2008 was a very rough year for me personally, but I learned some good life lessons last year:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;One door closing might just lead to another door opening.&amp;nbsp; I started what I thought was going to be my dream job in January and was unemployed by the first week of April.&amp;nbsp; Dejected and discouraged, I took the job at Dovetail because I knew Chad and some of the other crew there and figured it would be stable.&amp;nbsp; A half year later I can easily say that this is the best job I’ve ever had in terms of my job satisfaction.&amp;nbsp; I love the people I work with, I love the environment, and the work has been interesting.&amp;nbsp; I’m even charged up for a couple upcoming months of crunch time.&lt;/li&gt;    &lt;li&gt;If you know you need to make a life change, get over the fear and do it.&amp;nbsp; Said life change basically ruined my 2008, but it gives me some reason to look forward to ‘09 and beyond.&amp;nbsp; In retrospect, I should have done it years earlier.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;h4&gt;My Software Development Plans for 2009&lt;/h4&gt;  &lt;ul&gt;   &lt;li&gt;I just got renewed as an MVP for C# &lt;/li&gt;    &lt;li&gt;I’m planning on cranking out a couple more little releases of StructureMap by the end of January.&amp;nbsp; Between creating (75% done) full documentation, getting StructureMap running on all major .Net Frameworks (3.5, Mobile/Compact, Silverlight, Mono), and adding some requested features, I’m hoping to get StructureMap into more or less a maintenance mode for the rest of the year.&amp;nbsp; &lt;/li&gt;    &lt;li&gt;Write my Presentation Patterns book for Addison Wesley.&amp;nbsp; It’s been 2 years in the making, and it’ll be almost 3 before it’s published.&amp;nbsp; I hope to blog about it as I go much the way Ayende did with his Boo DSL book.&amp;nbsp; &lt;/li&gt;    &lt;li&gt;Make an initial release of the rebooted StoryTeller.&amp;nbsp; My team is dogfooding it now, so the engine is in good shape.&amp;nbsp; I’m going to rewrite the UI from scratch in WPF and use a lot of the UI infrastructure as sample code for my book. &lt;/li&gt;    &lt;li&gt;Continue writing the Patterns in Practice column in MSDN Magazine.&amp;nbsp; I’m enjoying it so far (and it’s paying for my new car ;-) );&amp;nbsp; Please send me any subject requests or article ideas!&lt;/li&gt;    &lt;li&gt;Contribute a little tiny bit to other OSS projects like Fluent NHibernate, FubuMVC, and MassTransit&lt;/li&gt;    &lt;li&gt;I’m committed to speaking at the &lt;a href="http://ndc2009.no/en/"&gt;Norwegian Developers Conference&lt;/a&gt; in Oslo (the city, not the DSL tool) in June, and I’m pretty excited about it.&amp;nbsp; Assuming it’s ok with work, I’ll be at the Seattle ALT.Net Open Spaces in March, but I just can’t miss a week of work this spring to attend the MVP Summit this time around.&amp;nbsp; Other than that, I’m hoping to do one more conference in the fall and maybe another Open Spaces event here and there.&lt;/li&gt;    &lt;li&gt;Blogging?&amp;nbsp; Well, not so much.&amp;nbsp; I’d like to finish the “First Causes” series I started last year.&amp;nbsp; Other than that, it’ll probably just be StructureMap, StoryTeller, and Presentation Patterns stuff.&amp;nbsp; I’d like to stay away from any new “Vote of No Confidence” / Oxite / “Billy Hollis doesn’t like Agile” arguments and focus on doing my own things first.&amp;nbsp; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;h4&gt;Personal Plans and Resolutions&lt;br /&gt;&lt;/h4&gt;  &lt;ul&gt;   &lt;li&gt;Respond to email correspondence and StructureMap questions much quicker&lt;br /&gt;&lt;/li&gt;&lt;li&gt;I just turned 35, so this is just about the last chance for me to get in shape, lose some weight, and have a couple more good years on the basketball court (plus take some weight off of my reconstructed knees)&lt;/li&gt;    &lt;li&gt;Cook more at home&lt;/li&gt;    &lt;li&gt;Get out of the house more often.&amp;nbsp; See Toni Price play this year before she retires altogether.&lt;/li&gt;    &lt;li&gt;Catch a bass bigger than 1lb this year&lt;/li&gt;    &lt;li&gt;Finish my book with enough time to spare so that I can reread the entire Wheel of Time series before A Memory of Light comes out!&lt;/li&gt; &lt;/ul&gt;&lt;img src="http://sourcesafe.codebetter.com/aggbug.aspx?PostID=186927" width="1" height="1"&gt;</content><author><name>jmiller</name><uri>http://sourcesafe.codebetter.com/members/jmiller.aspx</uri></author></entry><entry><title>StructureMap 2.5.1 is Released</title><link rel="alternate" type="text/html" href="http://sourcesafe.codebetter.com/blogs/jeremy.miller/archive/2008/12/22/structuremap-2-5-1-is-released.aspx" /><id>http://sourcesafe.codebetter.com/blogs/jeremy.miller/archive/2008/12/22/structuremap-2-5-1-is-released.aspx</id><published>2008-12-22T15:41:00Z</published><updated>2008-12-22T15:41:00Z</updated><content type="html">&lt;p&gt;I just uploaded a new incremental release of StructureMap with a bunch of bugfixes and a few new features.&amp;nbsp; &lt;a href="https://sourceforge.net/projects/structuremap/"&gt;Download it here&lt;/a&gt;. &lt;/p&gt;&lt;p&gt;From the release notes:&lt;/p&gt;&lt;p&gt;* Fixed issue with With&amp;lt;T&amp;gt;(object).GetInstance&amp;lt;U&amp;gt;() functionality.&amp;nbsp; This is now much more robust.&lt;br /&gt;* Bug fix for Hybrid scoping&lt;br /&gt;* TryGetInstance() and TryGetNamedInstance().&amp;nbsp; &lt;br /&gt;* Ignore setter emitting for indexer properties -- fixed a bug reported on the forum&lt;br /&gt;* Multithreading lock problem fixed by Josh&lt;br /&gt;* Patch for session lifetime.&amp;nbsp; There is now an option for &amp;quot;CacheBy(InstanceScope.HttpSession)&amp;quot;&lt;br /&gt;* Fixed Public IDictionary setter injection in xml : http://groups.google.com/group/structuremap-users/browse_thread/thread/21265544d73cd395?hl=en&lt;br /&gt;* Pete Johnson&amp;#39;s fix for ObjectFactory.Configure() setting policy.&amp;nbsp; You can now set the scoping/lifecycle of a PluginType from Configure()&lt;br /&gt;* EjectAllInstances&amp;lt;T&amp;gt;() clears out Singleton objects now (and calls Dispose() if appropriate)&lt;br /&gt;* Josh has added an experimental debugger visualizer for StructureMap Container&amp;#39;s &lt;/p&gt;&lt;p&gt;* The AutoMocker isn&amp;#39;t as whiny about RhinoMocks versions.&amp;nbsp; There is also an AutoMocker strategy for Moq now as well&amp;nbsp; &lt;br /&gt;&lt;/p&gt;&lt;p&gt;* A minor performance enhancement that stops StructureMap from doing a scan of all types on the StructureMap assembly itself. &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Please send all questions to the &lt;a href="http://groups.google.com/group/structuremap-users?hl=en"&gt;StructureMap Google list&lt;/a&gt;. &lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;b&gt;The Future &lt;/b&gt;&lt;/p&gt;&lt;p&gt;I&amp;#39;m hoping to complete the new StructureMap website and documentation over the holidays, and that&amp;#39;s the next priority.&amp;nbsp; After that, I&amp;#39;d like to get a new 2.6 release out in the early quarter of &amp;#39;09.&amp;nbsp; Here&amp;#39;s what I&amp;#39;m thinking about in no particular order:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;A Silverlight ready version (i.e. a cutdown StructureMap)&lt;/li&gt;&lt;li&gt;Finish the Mono support.&amp;nbsp; It&amp;#39;s very close, but I want to make sure&lt;/li&gt;&lt;li&gt;The *#%$ &amp;quot;BuildUp&amp;quot; functionality that allows you to do setter injection on an object that&amp;#39;s created somewhere else.&amp;nbsp; Thank you ASP.Net.&lt;/li&gt;&lt;li&gt;Convention based setter injection (low hanging fruit)&lt;/li&gt;&lt;li&gt;A guarantee that StructureMap will function in partially trusted environments, or at least real guidance on what it can and cannot do&lt;/li&gt;&lt;li&gt;&amp;quot;Missing Instance&amp;quot; handlers&lt;/li&gt;&lt;li&gt;A &amp;quot;ConditionalInstance&amp;quot; that will give you easier ways to do conditional construction&lt;/li&gt;&lt;li&gt;Improved diagnostics.&amp;nbsp; The error output and the output from StructureMapDoctor and ObjectFactory.AssertConfigurationIsValid() could be a lot better&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;Now&amp;#39;s a good time to ask for things.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Ok, that&amp;#39;s it for me this year.&amp;nbsp; Merry Christmas and Happy Holidays, and I&amp;#39;ll see you in January. &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://sourcesafe.codebetter.com/aggbug.aspx?PostID=186573" width="1" height="1"&gt;</content><author><name>jmiller</name><uri>http://sourcesafe.codebetter.com/members/jmiller.aspx</uri></author><category term="StructureMap" scheme="http://sourcesafe.codebetter.com/blogs/jeremy.miller/archive/tags/StructureMap/default.aspx" /></entry><entry><title>In case you didn't already know this...</title><link rel="alternate" type="text/html" href="http://sourcesafe.codebetter.com/blogs/jeremy.miller/archive/2008/12/20/in-case-you-didn-t-already-know-this.aspx" /><id>http://sourcesafe.codebetter.com/blogs/jeremy.miller/archive/2008/12/20/in-case-you-didn-t-already-know-this.aspx</id><published>2008-12-21T00:03:00Z</published><updated>2008-12-21T00:03:00Z</updated><content type="html">&lt;p&gt;If TestDriven.Net or the ReSharper test runner crater violently, you need to think about where you could be getting a StackOverflowException. &lt;br /&gt;&lt;/p&gt;&lt;img src="http://sourcesafe.codebetter.com/aggbug.aspx?PostID=186485" width="1" height="1"&gt;</content><author><name>jmiller</name><uri>http://sourcesafe.codebetter.com/members/jmiller.aspx</uri></author></entry><entry><title>Improvements in the StructureMap AutoMocker</title><link rel="alternate" type="text/html" href="http://sourcesafe.codebetter.com/blogs/jeremy.miller/archive/2008/12/19/improvements-in-the-structuremap-automocker.aspx" /><id>http://sourcesafe.codebetter.com/blogs/jeremy.miller/archive/2008/12/19/improvements-in-the-structuremap-automocker.aspx</id><published>2008-12-19T15:38:00Z</published><updated>2008-12-19T15:38:00Z</updated><content type="html">&lt;p&gt;&lt;a href="http://www.lostechies.com/blogs/joshuaflanagan/default.aspx"&gt;Josh&lt;/a&gt; just &lt;a href="http://groups.google.com/group/structuremap-users/browse_thread/thread/22f877ca3b5249a3?hl=en"&gt;checked some stuff into the trunk&lt;/a&gt; last night to address some versioning conflict issues we&amp;#39;ve had with RhinoMocks.&amp;nbsp; There is also an AutoMocker strategy for &lt;a href="http://code.google.com/p/moq/"&gt;Moq&lt;/a&gt; as well. &lt;br /&gt;&lt;/p&gt;&lt;img src="http://sourcesafe.codebetter.com/aggbug.aspx?PostID=186453" width="1" height="1"&gt;</content><author><name>jmiller</name><uri>http://sourcesafe.codebetter.com/members/jmiller.aspx</uri></author></entry><entry><title>My “Best Of” for 2008</title><link rel="alternate" type="text/html" href="http://sourcesafe.codebetter.com/blogs/jeremy.miller/archive/2008/12/17/my-best-of-for-2008.aspx" /><id>http://sourcesafe.codebetter.com/blogs/jeremy.miller/archive/2008/12/17/my-best-of-for-2008.aspx</id><published>2008-12-18T02:05:42Z</published><updated>2008-12-18T02:05:42Z</updated><content type="html">&lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;I haven’t been nearly as prolific a blogger as I used to be this year, so this one is going to be short.&amp;#160; Below is a list of my blog posts from the last year and change that I thought were the best.&amp;#160; Also check out:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://codebetter.com/blogs/jeremy.miller/archive/2006/08/07/Best-of-the-Shade-Tree-Developer-_2800_with-actual-links_21002900_.aspx"&gt;Best of The Shade Tree Developer&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://codebetter.com/blogs/jeremy.miller/archive/2007/10/18/best-of-the-shade-tree-developer-part-ii.aspx"&gt;Best of The Shade Tree Developer II&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;&lt;strong&gt;Oct. ‘07 – Dec ‘08&lt;/strong&gt;&lt;/h4&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://codebetter.com/blogs/jeremy.miller/archive/2007/10/31/be-not-afraid-of-the-visitor-the-big-bad-composite-or-their-little-friend-double-dispatch.aspx"&gt;Be not afraid of the Visitor, the big, bad Composite, or their little friend Double Dispatch&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://codebetter.com/blogs/jeremy.miller/archive/2007/10/31/development-trivial-pursuit-the-difference-between-mvc-and-the-different-flavors-of-mvp.aspx"&gt;Development Trivial Pursuit: The difference between MVC and the different flavors of MVP&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://codebetter.com/blogs/jeremy.miller/archive/2007/11/08/don-t-think-you-know-more-than-you-do.aspx"&gt;Don&amp;#39;t think you know more than you do&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://codebetter.com/blogs/jeremy.miller/archive/2007/12/04/a-microcosm-of-agile-design.aspx"&gt;A Microcosm of Agile Design&lt;/a&gt; (this one was controversial, but that was more or less the point)&lt;/li&gt;    &lt;li&gt;&lt;a href="http://codebetter.com/blogs/jeremy.miller/archive/2008/01/25/should-i-blog.aspx"&gt;Should I Blog?&lt;/a&gt; (yes)      &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://codebetter.com/blogs/jeremy.miller/archive/2008/02/02/how-do-i-know-descartes-rationalism-versus-hume-s-empiricism.aspx"&gt;How do I know?: Descartes&amp;#39; Rationalism versus Hume&amp;#39;s Empiricism&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://codebetter.com/blogs/jeremy.miller/archive/2008/02/05/first-causes-in-software-development-how-do-i-decide-what-is-good.aspx"&gt;First Causes in Software Development: How do I decide what is good?&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://codebetter.com/blogs/jeremy.miller/archive/2008/02/10/first-causes-reversibility.aspx"&gt;First Causes:&amp;#160; Reversibility&lt;/a&gt; (I got distracted by moving across country before I finished this series.&amp;#160; I’ve had the draft for the next part and my notes reference something on a project from two years ago.&amp;#160; I will do more)      &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://codebetter.com/blogs/jeremy.miller/archive/2008/03/03/unit-testing-playing-tennis-and-the-lack-of-absolutes-in-tdd.aspx"&gt;Unit testing, playing tennis, and the lack of absolutes in TDD&lt;/a&gt; (I still hold that the folks that go to extreme measures to avoid using a mock object are doing themselves a disfavor)&lt;/li&gt;    &lt;li&gt;&lt;a href="http://codebetter.com/blogs/jeremy.miller/archive/2008/04/22/rightsizing-your-approach.aspx"&gt;Rightsizing Your Approach&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://codebetter.com/blogs/jeremy.miller/archive/2008/05/15/why-do-we-refactor.aspx"&gt;Why do we Refactor?&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://codebetter.com/blogs/jeremy.miller/archive/2008/10/23/our-opinions-on-the-asp-net-mvc-introducing-the-thunderdome-principle.aspx"&gt;Our “Opinions” on the ASP.NET MVC (Introducing the Thunderdome Principle)&lt;/a&gt; (the ASP.Net MVC framework is much more efficient when you add your own special sauce to your project)&lt;/li&gt;    &lt;li&gt;&lt;a href="http://codebetter.com/blogs/jeremy.miller/archive/2008/10/17/test-automation-brain-dump.aspx"&gt;Test Automation Braindump&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://codebetter.com/blogs/jeremy.miller/archive/2008/11/11/evolution-of-a-developer-in-regards-to-di-ioc.aspx"&gt;Evolution of a Developer&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;&lt;img src="http://sourcesafe.codebetter.com/aggbug.aspx?PostID=186226" width="1" height="1"&gt;</content><author><name>jmiller</name><uri>http://sourcesafe.codebetter.com/members/jmiller.aspx</uri></author></entry><entry><title>Design and Testability</title><link rel="alternate" type="text/html" href="http://sourcesafe.codebetter.com/blogs/jeremy.miller/archive/2008/12/10/design-and-testability.aspx" /><id>http://sourcesafe.codebetter.com/blogs/jeremy.miller/archive/2008/12/10/design-and-testability.aspx</id><published>2008-12-10T05:25:00Z</published><updated>2008-12-10T05:25:00Z</updated><content type="html">&lt;p&gt;&lt;b&gt;EDIT 12/23/2008:&amp;nbsp; I believe this post has been massively misconstrued in the comments.&amp;nbsp; Apparently, my analogy here was terrible from the way so many people are distorting what I was trying to say.&amp;nbsp; For the record,&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;I DID NOT SAY DON&amp;#39;T WRITE TESTS&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;I DID NOT SAY YOU MUST BE A MASTER OF ALL DESIGN LORE BEFORE YOU GET TO WRITE A TEST&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;I DID NOT SAY THAT YOU MUST HAVE A PERFECT, PURIST DESIGN FIRST&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;I DID NOT SAY DO NOT WRITE TESTS FOR LEGACY CODE&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;I said, or attempted to say, that testing and testability cannot be decoupled from design, and any effort towards automated testing / unit testing / TDD is probably not going to be successful until the team has a good understanding of the basics ( and I did say basics here) of fundamental software design. &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;My most recent Patterns in Practice article entitled &lt;a href="http://msdn.microsoft.com/en-us/magazine/dd263069.aspx"&gt;Design for Testability&lt;/a&gt; is available in this month&amp;#39;s issue of MSDN Magazine. This time around, I tried to tackle some of the design issues around supporting testability.&amp;nbsp; I’ve written four articles so far for MSDN on design fundamentals.&amp;nbsp; If you look at the whole body of work, there’s a very common theme:&amp;nbsp; good, fundamental design is being able to do one thing at a time.&amp;nbsp; I want to decompose the system so that I can change one thing at a time with less risk of destabilizing other parts of the system.&amp;nbsp; I want to be able to understand one element of the system at a time.&amp;nbsp; I want to solve one little problem at a time instead of tackling the whole mess in one try.&amp;nbsp; &lt;/p&gt;  &lt;p&gt;Testability as a design concept is right in line with this kind of thinking.&amp;nbsp; Testability means being able to easily create rapid, effective, and focused feedback cycles against your code with automated tests.&amp;nbsp; Testability isn’t some strange and unnatural new way to shape code.&amp;nbsp; For the most part (ok, it might be if you cut your programming teeth with Microsoft’s RAD tools), Testability goes hand in hand with the same structural qualities like &lt;a href="http://msdn.microsoft.com/en-us/magazine/cc947917.aspx"&gt;cohesion and coupling&lt;/a&gt; that we use to create code that’s easier to write, change, and understand.&amp;nbsp; On the other hand, we can use Testability within design techniques like Test Driven Development and/or Behavioral Driven Development to inform and help guide our design decisions.&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;h4&gt;&lt;b&gt;Unit Testing – Solid Design == PAIN!&lt;/b&gt;&lt;/h4&gt;  &lt;p&gt;A couple months back &lt;a href="http://weblogs.asp.net/rosherove"&gt;Roy Osherove&lt;/a&gt; wrote a post entitled &lt;a href="http://weblogs.asp.net/rosherove/archive/2008/09/26/unit-testing-decoupled-from-design-adoption.aspx"&gt;Unit Testing decoupled from Design == Adoption&lt;/a&gt; that posited the theory that things will work out better for the larger community if we drop all this hard design theory and TDD discipline and just get developers to write unit tests first.&amp;nbsp; The theory being that more developers would be more likely to adopt some sort of unit testing, fail, then naturally circle back to learning about design or try out TDD after they get started.&amp;nbsp; &lt;/p&gt;  &lt;p&gt;I couldn’t possibly disagree more with Roy on this.&amp;nbsp; I would describe Roy’s suggestion as akin to telling an out of shape 30 something with no prior athletic experience to start playing competitive basketball by just walking onto the court and getting into a pickup game.&amp;nbsp; That out of shape 30 something fellow isn’t going to be able to compete, and he’s likely to limp off too discouraged and humiliated to continue.&amp;nbsp; After all, why would the average person sign up for another beating?&amp;nbsp; Likewise, a developer with little foundational knowledge about good design principles will be very unlikely to succeed in any way with unit testing because it’ll be just too hard with poorly structured code (and no, I don’t think any “Isolation” framework will change that).&amp;nbsp; I would tell the 30 something to work on his cardiovascular conditioning (and his jumpshot) before he steps onto that basketball court for the first time.&amp;nbsp; I’d tell that developer to focus on his understanding (not rote knowledge, but understanding) of good design first and be ready to succeed upfront.&amp;nbsp; &lt;/p&gt;  &lt;p&gt;I guess to summarize and beat the analogy into the ground, cardiovascular health is beneficial for more than just playing pickup basketball after work and good design is valuable for more things than making unit testing and acceptance testing easier.&amp;nbsp; In short, &lt;b&gt;good design is far more beneficial and important than the practice of unit testing&lt;/b&gt;.&amp;nbsp; However, good design + TDD/Behavioral Driven Development/Acceptance Test Driven Development?&amp;nbsp; That’s where the real rewards happen.&amp;nbsp; Don’t settle for mediocre efforts.&amp;nbsp; Do both and reap the rewards.&lt;/p&gt;  &lt;p&gt;A couple years ago I was reading some writing from older guys like Steve McConnell and Robert Glass that stated that Test Driven Development couldn’t work because unit testing was proven to be only marginal cost effective – and they based those statements on studies that dated back to COBOL developers in the ‘70s and ‘80s writing purely procedural code.&amp;nbsp; TDD with well factored OOP or Functional code compared to unit testing tightly coupled structured programming is apples and oranges.&amp;nbsp; I have consistently found that the cost effectiveness of unit testing and Test Driven Development is almost entirely based on the structural design of the class structure of the system being built.&amp;nbsp; &lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;h4&gt;&lt;b&gt;Other Reading&lt;/b&gt;&lt;/h4&gt;  &lt;p&gt;I think this is a huge topic, and one measly 3500 word article isn’t going to cover the topic adequately.&amp;nbsp; Learning xUnit tools and even mock object frameworks is a piece of cake compared to learning how to design and write code that enables efficient testing.&amp;nbsp; Here are some of my older writings from the time when I had just gotten over the hump and started to figure out how to compose code to enable Test Driven Development.&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;li&gt;&lt;a href="http://codebetter.com/blogs/jeremy.miller/articles/131726.aspx"&gt;TDD Design Starter Kit: It’s All about Assigning Responsibilities&lt;/a&gt; &lt;/li&gt;  &lt;li&gt;&lt;a href="http://codebetter.com/blogs/jeremy.miller/articles/129544.aspx"&gt;TDD Design Starter Kit - State vs. Interaction Testing&lt;/a&gt; &lt;/li&gt;  &lt;li&gt;&lt;a href="http://codebetter.com/blogs/jeremy.miller/articles/129543.aspx"&gt;TDD Design Starter Kit - Dependency Inversion Principle&lt;/a&gt; &lt;/li&gt;  &lt;li&gt;&lt;a href="http://codebetter.com/blogs/jeremy.miller/articles/129542.aspx"&gt;TDD Design Starter Kit – Responsibilities, Cohesion, and Coupling&lt;/a&gt; &lt;/li&gt;  &lt;li&gt;&lt;a href="http://codebetter.com/blogs/jeremy.miller/articles/129545.aspx"&gt;TDD Design Starter Kit - Static Methods and Singletons May Be Harmful&lt;/a&gt; &lt;/li&gt;  &lt;li&gt;&lt;a href="http://codebetter.com/blogs/jeremy.miller/archive/2005/07/20/129540.aspx"&gt;Succeed with TDD by designing with TDD&lt;/a&gt; &lt;/li&gt;  &lt;li&gt;&lt;a href="http://codebetter.com/blogs/jeremy.miller/archive/2005/10/12/133017.aspx"&gt;Unit Testing Business Logic without Tripping Over the Database&lt;/a&gt;     &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;/li&gt;  &lt;li&gt;&lt;a href="http://codebetter.com/blogs/jeremy.miller/archive/2005/10/20/133437.aspx"&gt;Jeremy&amp;#39;s First Rule of TDD&lt;/a&gt; &lt;/li&gt;  &lt;li&gt;&lt;a href="http://codebetter.com/blogs/jeremy.miller/archive/2006/03/09/140465.aspx"&gt;Jeremy&amp;#39;s Second Law of TDD: Push, Don&amp;#39;t Pull&lt;/a&gt; &lt;/li&gt;  &lt;li&gt;&lt;a href="http://codebetter.com/blogs/jeremy.miller/archive/2006/05/30/145752.aspx"&gt;Achieve Better Results by following Jeremy&amp;#39;s Third Law of TDD: Test Small Before Testing Big&lt;/a&gt; - I think this is the most important lesson for making TDD work for you &lt;/li&gt;  &lt;li&gt;&lt;a href="http://codebetter.com/blogs/jeremy.miller/archive/2007/04/27/Jeremy_2700_s-Fourth-Law-of-Test-Driven-Development_3A00_-Keep-Your-Tail-Short.aspx"&gt;Jeremy&amp;#39;s Fourth Law of Test Driven Development: Keep Your Tail Short&lt;/a&gt;     &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;/li&gt;  &lt;li&gt;&lt;a href="http://codebetter.com/blogs/jeremy.miller/archive/2005/12/19/135757.aspx"&gt;Mock Objects and Stubs: The Bottle Brush of TDD&lt;/a&gt; &lt;/li&gt;  &lt;li&gt;&lt;a href="http://codebetter.com/blogs/jeremy.miller/archive/2005/12/20/135800.aspx"&gt;Why and When to Use Mock Objects&lt;/a&gt; &lt;/li&gt;  &lt;li&gt;&lt;a href="http://codebetter.com/blogs/jeremy.miller/archive/2006/01/10/136407.aspx"&gt;Best and Worst Practices for Mock Objects&lt;/a&gt; &lt;/li&gt;  &lt;li&gt;&lt;a href="http://codebetter.com/blogs/jeremy.miller/archive/2006/07/03/147075.aspx"&gt;Mock Objects are your Friend&lt;/a&gt;     &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;/li&gt;  &lt;li&gt;&lt;a href="http://codebetter.com/blogs/jeremy.miller/archive/2005/08/17/130864.aspx"&gt;Testing Granularity, Feedback Cycles, and Holistic Development&lt;/a&gt;     &lt;p&gt;&amp;nbsp;&lt;/p&gt;    &lt;h4&gt;&lt;b&gt;The Future&lt;/b&gt;&lt;/h4&gt;    &lt;p&gt;The next article is already in editing.&amp;nbsp; For February I’m discussing Ruby on Rails inspired design ideas like convention over configuration, opinionated software, sensible defaults, and once and only once.&amp;nbsp; For April I’m going to write about data access and persistence patterns to fit in with the theme of that month’s issue.&amp;nbsp; After that?&lt;/p&gt;    &lt;ul&gt;     &lt;li&gt;Patterns for Testability – I missed a lot of important topics in this month’s article.&amp;nbsp; I’d like to hit separated presentation patterns and Inversion of Control as a design pattern maybe. &lt;/li&gt;      &lt;li&gt;Designing an Internal DSL &lt;/li&gt;      &lt;li&gt;Some kind of post on Composition and IoC &lt;/li&gt;      &lt;li&gt;Patterns for Client/Server Communication &lt;/li&gt;   &lt;/ul&gt;    &lt;p&gt;Any requests?&amp;nbsp; Thoughts?&amp;nbsp; I’m bypassing (D)DDD for the most part because there are articles on the way on those very topics from more qualified folks (Don’t tell anyone, but I’m not entirely sure I completely buy off on DDD).&lt;/p&gt;    &lt;p&gt;&amp;nbsp;&lt;/p&gt;    &lt;h4&gt;&lt;b&gt;Self Reflection&lt;/b&gt;&lt;/h4&gt;    &lt;p&gt;The first three articles in this series are effectively tributes to my software design heroes (Fowler, Rebecca Wirfs-Brock, Uncle Bob Martin, and the Pragmatic Programmers).&amp;nbsp; This last one was largely based on my own prior writings on testability and design.&amp;nbsp; It’s also the one I’m least happy with.&amp;nbsp; Back to hero tributes after this;)&lt;/p&gt;    &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;/li&gt;&lt;img src="http://sourcesafe.codebetter.com/aggbug.aspx?PostID=185891" width="1" height="1"&gt;</content><author><name>jmiller</name><uri>http://sourcesafe.codebetter.com/members/jmiller.aspx</uri></author></entry><entry><title>I'm demo-ing StoryTeller online tomorrow night (10/10/08)</title><link rel="alternate" type="text/html" href="http://sourcesafe.codebetter.com/blogs/jeremy.miller/archive/2008/12/09/i-m-demo-ing-storyteller-online-tomorrow-night-10-10-08.aspx" /><id>http://sourcesafe.codebetter.com/blogs/jeremy.miller/archive/2008/12/09/i-m-demo-ing-storyteller-online-tomorrow-night-10-10-08.aspx</id><published>2008-12-09T22:22:00Z</published><updated>2008-12-09T22:22:00Z</updated><content type="html">&lt;p&gt;&lt;a href="http://www.lostechies.com/blogs/chad_myers/archive/2008/12/09/alt-net-online-open-meeting-10-dec-featuring-jeremy-miller.aspx"&gt;Since Chad is putting me on the spot for this&lt;/a&gt;, I&amp;#39;ll be doing a demo and leading a discussion on the &lt;a href="http://storyteller.tigris.org"&gt;StoryTeller&lt;/a&gt; reboot for the ALT.NET Online Open meeting tomorrow night.&lt;/p&gt;&lt;p&gt;StoryTeller is my attempt at creating a new FIT analog for automated acceptance testing.&amp;nbsp; At this point, it&amp;#39;s just the engine without any UI.&amp;nbsp; I will show how we&amp;#39;re using StoryTeller so far at Dovetail.&amp;nbsp; Chad is recording the session for later as well.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Here&amp;#39;s a bit of example usage:&amp;nbsp; &lt;a href="http://codebetter.com/blogs/jeremy.miller/archive/2008/10/27/a-quick-storyteller-update.aspx"&gt;http://codebetter.com/blogs/jeremy.miller/archive/2008/10/27/a-quick-storyteller-update.aspx &lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;img src="http://sourcesafe.codebetter.com/aggbug.aspx?PostID=185875" width="1" height="1"&gt;</content><author><name>jmiller</name><uri>http://sourcesafe.codebetter.com/members/jmiller.aspx</uri></author><category term="StoryTeller" scheme="http://sourcesafe.codebetter.com/blogs/jeremy.miller/archive/tags/StoryTeller/default.aspx" /></entry><entry><title>I can respect a good riposte</title><link rel="alternate" type="text/html" href="http://sourcesafe.codebetter.com/blogs/jeremy.miller/archive/2008/12/09/i-can-respect-a-good-riposte.aspx" /><id>http://sourcesafe.codebetter.com/blogs/jeremy.miller/archive/2008/12/09/i-can-respect-a-good-riposte.aspx</id><published>2008-12-09T20:21:00Z</published><updated>2008-12-09T20:21:00Z</updated><content type="html">&lt;p&gt;&lt;a href="http://davesbox.com/archive/2008/12/09/quot-i-can-t-believe-microsoft-didn-t-make-enter-api-name-here-public-quot.aspx"&gt;http://davesbox.com/archive/2008/12/09/quot-i-can-t-believe-microsoft-didn-t-make-enter-api-name-here-public-quot.aspx &lt;/a&gt;&lt;/p&gt;&lt;p&gt;A.)&amp;nbsp; I&amp;#39;m a bit embarrassed by the backwards compatibility issue in StructureMap 2.5, but then again, breaking backwards compatibility cleaned a lot of crap up and made for a better user experience.&amp;nbsp; Most of the things I eliminated were features that probably did more harm than good. &lt;/p&gt;&lt;p&gt;B.)&amp;nbsp; The ExpressionVisitor thing would be a very handy thing to have in the public with solid documentation.&amp;nbsp; How &amp;#39;bout we just make that a feature request for the BCL team? &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://sourcesafe.codebetter.com/aggbug.aspx?PostID=185873" width="1" height="1"&gt;</content><author><name>jmiller</name><uri>http://sourcesafe.codebetter.com/members/jmiller.aspx</uri></author></entry><entry><title>Stuff I do like</title><link rel="alternate" type="text/html" href="http://sourcesafe.codebetter.com/blogs/jeremy.miller/archive/2008/12/04/stuff-i-do-like.aspx" /><id>http://sourcesafe.codebetter.com/blogs/jeremy.miller/archive/2008/12/04/stuff-i-do-like.aspx</id><published>2008-12-04T22:17:00Z</published><updated>2008-12-04T22:17:00Z</updated><content type="html">&lt;p&gt;So &lt;a href="http://bradwilson.typepad.com/"&gt;Brad Wilson&lt;/a&gt; basically said on Twitter today that I was being too negative.&amp;nbsp; Since that&amp;#39;s like Debbie Downer asking you to be a little more upbeat, I thought I&amp;#39;d balance that with some stuff that I do like:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;The new architectural guidance coming from Patterns and Practices.&amp;nbsp; I raised one huge objection and they quickly changed it .&amp;nbsp; &lt;br /&gt;&lt;/li&gt;&lt;li&gt;The general direction of xUnit.Net in regards to the no SetUp/TearDown thing, and that&amp;#39;s not just a sop to Brad &lt;br /&gt;&lt;/li&gt;&lt;li&gt;The new AAA syntax and mocking style in both Rhino Mocks and Moq&lt;/li&gt;&lt;li&gt;Nate Kohari&amp;#39;s approach to convention based setter injection in Ninject (I&amp;#39;m going to copy the idea into StructureMap)&lt;/li&gt;&lt;li&gt;Autofac&amp;#39;s extensibility model (also going to copy some of that)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;I really, really like getting patches for StructureMap, and I&amp;#39;ve got a couple to incorporate this week&lt;/li&gt;&lt;li&gt;Love the new language features in .Net 3.5.&amp;nbsp; I bitch about generics a lot, but that comes from pushing the envelope on usage and banging into edge cases.&amp;nbsp; It&amp;#39;s really generics within Fluent Interface code that gives me the most heartburn, and that&amp;#39;s not typical usage.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;The magic of expressions, and &lt;a href="http://www.clariusconsulting.net/blogs/kzu/archive/2006/07/06/TypedReflection.aspx"&gt;Daniel Cazzulino for blazing a trail on using Expressions&lt;/a&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;The jQuery ecosystem.&amp;nbsp; And I thought Microsoft&amp;#39;s official blessing and support for jQuery was huge&lt;br /&gt;&lt;/li&gt;&lt;li&gt;MassTransit (I think the new service bus tools like nServiceBus &amp;amp; MassTransit basically become a sort of a &amp;quot;Distributed IoC&amp;quot; tool&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Linq to NHibernate and Linq in general of course&lt;br /&gt;&lt;/li&gt;&lt;li&gt;The more powerful auto mapping and convention support in Fluent NHibernate (I didn&amp;#39;t write that part)&lt;/li&gt;&lt;li&gt;Bellware&amp;#39;s SpecUnit assertion extensions&lt;/li&gt;&lt;li&gt;The fluent fixture stuff we stole from the Eleutian guys&lt;/li&gt;&lt;li&gt;The way P&amp;amp;P did the Prism project out in the open&lt;/li&gt;&lt;li&gt;The common service locator initiative&lt;br /&gt;&lt;/li&gt;&lt;li&gt;The way MS is doing the MVC project out in the open&lt;/li&gt;&lt;li&gt;The fact that MS does much more to acknowledge the value of Separated Presentation patterns and encourage their usage than they did just a few years ago&lt;br /&gt;&lt;/li&gt;&lt;li&gt;The fact that MEF is open sourced&lt;/li&gt;&lt;li&gt;The fact that MEF exists I think will help open up and decouple the BCL in some advantageous ways.&amp;nbsp; I think DI-friendly code will make it easier for us to use better composition based design instead of nasty inheritance structures&lt;/li&gt;&lt;li&gt;Yes, I gripe about some details of the MVC, but I made some huge, valuable customizations to our MVC pipeline in the past two days that were possible because the MVC classes are pretty cohesive and well structured&lt;/li&gt;&lt;li&gt;Basically any tool written by JetBrains&lt;/li&gt;&lt;li&gt;JP&amp;#39;s keyboard macro stuff for BDD&lt;br /&gt;&lt;/li&gt;&lt;li&gt;I do like the general concept behind StackOverflow, I&amp;#39;m just dubious about the veracity and wisdom of some of its content&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Auto Mockers and InteractionContext base classes that make interaction style unit tests much easier than a few years ago&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Rake as a build tool&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Rob Conery&amp;#39;s MVC Storefront podcasts&lt;/li&gt;&lt;li&gt;The HerdingCode podcasts&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Elegant Code and Los Techies as blogging communities&lt;/li&gt;&lt;li&gt;You have to look for it a bit, but the fact that many more .Net authors/INETA speakers/gurus from &lt;b&gt;outside&lt;/b&gt; the little ALT.NET echo chamber are addressing design fundamentals and unit testing concerns in their writing and speaking.&amp;nbsp; Don&amp;#39;t read any sarcasm or anything negative into that, I really do think it&amp;#39;s a good thing because those folks have much more reach.&amp;nbsp; I&amp;#39;m thinking specifically about some recent MSDN articles &lt;br /&gt;&lt;/li&gt;&lt;li&gt;The fact that we&amp;#39;re finally getting some well supported alternative languages for .Net.&amp;nbsp; VB.Net and C# are essentially Country and Western.&amp;nbsp; F#, IronRuby, and IronPython gives us Jazz, Blues, and Opera. &lt;br /&gt;&lt;/li&gt;&lt;li&gt;I was surprisingly impressed with &lt;a href="http://www.amazon.com/Microsoft%C2%AE-NET-Architecting-Applications-PRO-Developer/dp/073562609X/ref=sr_1_1?ie=UTF8&amp;amp;s=books&amp;amp;qid=1228430912&amp;amp;sr=1-1"&gt;Dino Esposito&amp;#39;s latest book on .Net architecture&lt;br /&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;The DotNetRocks guest list.&amp;nbsp; Yes, I tend to grumble at some of things that get said on DNR a fair amount, but it&amp;#39;s astounding that they&amp;#39;ve gotten so many of my heros to come onto the show in the last couple months&lt;/li&gt;&lt;li&gt;Ben Scheirman&amp;#39;s new fluent API for testing routes in MVC&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;img src="http://sourcesafe.codebetter.com/aggbug.aspx?PostID=185738" width="1" height="1"&gt;</content><author><name>jmiller</name><uri>http://sourcesafe.codebetter.com/members/jmiller.aspx</uri></author></entry><entry><title>I love Ayende (and OSS)</title><link rel="alternate" type="text/html" href="http://sourcesafe.codebetter.com/blogs/jeremy.miller/archive/2008/12/04/i-love-ayende-and-oss.aspx" /><id>http://sourcesafe.codebetter.com/blogs/jeremy.miller/archive/2008/12/04/i-love-ayende-and-oss.aspx</id><published>2008-12-04T21:14:00Z</published><updated>2008-12-04T21:14:00Z</updated><content type="html">
&lt;p&gt;&amp;nbsp;From one of &lt;a href="http://ayende.com/blog"&gt;Ayende&lt;/a&gt;&amp;#39;s many OSS projects.

&lt;/p&gt;
&lt;div style="border:thin solid black;background:white none repeat scroll 0% 0%;overflow:scroll;font-family:Courier New;font-size:10pt;color:black;-moz-background-clip:-moz-initial;-moz-background-origin:-moz-initial;-moz-background-inline-policy:-moz-initial;"&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; This class actually already exists in the System.Core assembly...as an internal class.&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; I can only speculate as to why it is internal, but it is obviously much too dangerous&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; for anyone outside of Microsoft to be using...&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;And dear MS BCL team, since so many people are already using Reflector to go get the ExpressionVisitor code, would you just make this public?&amp;nbsp; &amp;#39;K, thx.&lt;br /&gt;&lt;/p&gt;&lt;img src="http://sourcesafe.codebetter.com/aggbug.aspx?PostID=185733" width="1" height="1"&gt;</content><author><name>jmiller</name><uri>http://sourcesafe.codebetter.com/members/jmiller.aspx</uri></author></entry></feed>