<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" version="2.0"><channel><title>Sean Chambers</title><link>http://www.lostechies.com/blogs/sean_chambers/default.aspx</link><description>I am a Senior Software Development Engineer at Telligent Systems Inc. I enjoy programming, photography and spending time with my wonderful family.</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 (Build: 30929.2835)</generator><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/SeanChambers" type="application/rss+xml" /><item><title>‘Vice’ Testing</title><link>http://www.lostechies.com/blogs/sean_chambers/archive/2009/04/21/vice-testing.aspx</link><pubDate>Wed, 22 Apr 2009 03:55:00 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:20402</guid><dc:creator>schambers</dc:creator><slash:comments>4</slash:comments><wfw:commentRss>http://www.lostechies.com/blogs/sean_chambers/rsscomments.aspx?PostID=20402</wfw:commentRss><comments>http://www.lostechies.com/blogs/sean_chambers/archive/2009/04/21/vice-testing.aspx#comments</comments><description>&lt;p&gt;Refactoring to tests is no easy task. The largest problem that you run into is moving around code with no feedback as to whether you are breaking modules other than doing very high level user/functional testing directly against the UI. This makes the first step of refactoring to tests the most difficult to take.&lt;/p&gt;
&lt;p&gt;Before I begin describing the technique at hand I would like to prefix it with a disclaimer and a warning: &lt;strong&gt;DO NOT&lt;/strong&gt; use this to replace actual unit tests. This type of testing should &lt;strong&gt;ONLY&lt;/strong&gt; be used as a baseline so that you can start to do larger refactorings that could potentially break portions of code. This gives you the start of a safety net, albeit a pretty flimsy one.&lt;/p&gt;
&lt;p&gt;Awhile back &lt;a href="http://www.lostechies.com/blogs/joe_ocampo/default.aspx"&gt;Joe Ocampo&lt;/a&gt; mentioned a technique that Michael Feathers called &amp;lsquo;vice&amp;rsquo; testing. I recently came across an &lt;a href="http://www.infoq.com/articles/Utilizing-Logging"&gt;article on infoq where Ian Roughley calls it Logging Seam Testing&lt;/a&gt;. At the core, it&amp;rsquo;s the same thing just named a little differently. The article on infoq is in java, so I created a utility to do the same thing in c# that you can find in my &lt;a href="http://github.com/schambers/vice/tree/master"&gt;github repository here&lt;/a&gt;. Here is a &lt;a href="http://github.com/schambers/vice/zipball/master"&gt;direct download link to a zip archive&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This is quite the interesting technique. One thing to note: I have yet to use this technique myself, so please take it with a grain of salt. Seems like this could work well for extremely tightly coupled, monolithic code and wouldn&amp;rsquo;t necessarily fit for every scenario. I could see this being a good fit while trying to reduce cyclomatic complexity or breaking large methods/classes into smaller ones. That being said, let&amp;rsquo;s dive in.&lt;/p&gt;
&lt;p&gt;The basic idea here is you want to get some form of tests into your code, but it&amp;rsquo;s much too difficult to break dependencies and create seams to get unit tests in. That&amp;rsquo;s where vice testing comes in. It&amp;rsquo;s actually very simple and straightforward. The process goes like this.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Determine what it is that you want to test, in this sample its the amount of deductions and the amount paid to an employee via an Employee.Pay method&lt;/li&gt;
&lt;li&gt;Insert logging statements in your production code that simply log internal state of an object. In the example it is deduction total, salary and &amp;lsquo;completed&amp;rsquo;&lt;/li&gt;
&lt;li&gt;Write a test that sets up the class under test, intializes the log4net logger, sets the expectations to be met&lt;/li&gt;
&lt;li&gt;Execute the method on the class under test and assert that all expectations were met via the ViceAppender class&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;First let&amp;rsquo;s look at the actual test code that would do the work for us:   &lt;/p&gt;
&lt;div class="csharpcode-wrapper"&gt;
&lt;div class="csharpcode"&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:&lt;/span&gt; [TestFixture]&lt;/pre&gt;
&lt;pre class="alteven"&gt;&lt;span class="lnum"&gt;   2:&lt;/span&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; EmployeeTests&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre class="alteven"&gt;&lt;span class="lnum"&gt;   4:&lt;/span&gt;     &lt;span class="kwrd"&gt;private&lt;/span&gt; ViceAppender _viceAppender;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre class="alteven"&gt;&lt;span class="lnum"&gt;   6:&lt;/span&gt;     [TestFixtureSetUp]&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:&lt;/span&gt;     &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; TestFixtureSetUp()&lt;/pre&gt;
&lt;pre class="alteven"&gt;&lt;span class="lnum"&gt;   8:&lt;/span&gt;     {&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:&lt;/span&gt;         _viceAppender = &lt;span class="kwrd"&gt;new&lt;/span&gt; ViceAppender(&lt;span class="kwrd"&gt;new&lt;/span&gt; log4net.Layout.SimpleLayout());&lt;/pre&gt;
&lt;pre class="alteven"&gt;&lt;span class="lnum"&gt;  10:&lt;/span&gt;         log4net.Config.BasicConfigurator.Configure(_viceAppender);&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  11:&lt;/span&gt;     }&lt;/pre&gt;
&lt;pre class="alteven"&gt;&lt;span class="lnum"&gt;  12:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  13:&lt;/span&gt;     [Test]&lt;/pre&gt;
&lt;pre class="alteven"&gt;&lt;span class="lnum"&gt;  14:&lt;/span&gt;     &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; employee_is_paid_expected_amount()&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  15:&lt;/span&gt;     {&lt;/pre&gt;
&lt;pre class="alteven"&gt;&lt;span class="lnum"&gt;  16:&lt;/span&gt;         _viceAppender.AddVerification(&lt;span class="str"&gt;&amp;quot;deduction total=&amp;quot;&lt;/span&gt; + 70m);&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  17:&lt;/span&gt;         _viceAppender.AddVerification(&lt;span class="str"&gt;&amp;quot;salary=&amp;quot;&lt;/span&gt; + 330m);&lt;/pre&gt;
&lt;pre class="alteven"&gt;&lt;span class="lnum"&gt;  18:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  19:&lt;/span&gt;         IList&amp;lt;&lt;span class="kwrd"&gt;decimal&lt;/span&gt;&amp;gt; _deductions = &lt;span class="kwrd"&gt;new&lt;/span&gt; List&amp;lt;&lt;span class="kwrd"&gt;decimal&lt;/span&gt;&amp;gt;();&lt;/pre&gt;
&lt;pre class="alteven"&gt;&lt;span class="lnum"&gt;  20:&lt;/span&gt;         _deductions.Add(50m);&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  21:&lt;/span&gt;         _deductions.Add(20m);&lt;/pre&gt;
&lt;pre class="alteven"&gt;&lt;span class="lnum"&gt;  22:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  23:&lt;/span&gt;         var employee = &lt;span class="kwrd"&gt;new&lt;/span&gt; Employee(400m, _deductions);&lt;/pre&gt;
&lt;pre class="alteven"&gt;&lt;span class="lnum"&gt;  24:&lt;/span&gt;         employee.Pay();&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  25:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre class="alteven"&gt;&lt;span class="lnum"&gt;  26:&lt;/span&gt;         _viceAppender.PrintExpectations();&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  27:&lt;/span&gt;         Assert.IsTrue(_viceAppender.Verify(), &lt;span class="str"&gt;&amp;quot;Expectations not met&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;pre class="alteven"&gt;&lt;span class="lnum"&gt;  28:&lt;/span&gt;     }&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  29:&lt;/span&gt; }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
  &lt;br /&gt;In the example you can see that I am initializing a log4net logger and setting some configuration on it. Then you setup verifications on the ViceAppender class that matches expectations added to your class along with the expected internal state that will result from the input.&lt;/p&gt;
&lt;p&gt;Here is the Pay method from the Employee class:
  &lt;/p&gt;
&lt;div class="csharpcode-wrapper"&gt;
&lt;div class="csharpcode"&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:&lt;/span&gt; &lt;span class="kwrd"&gt;private&lt;/span&gt; ILog _log = LogManager.GetLogger(&lt;span class="kwrd"&gt;typeof&lt;/span&gt;(Employee));&lt;/pre&gt;
&lt;pre class="alteven"&gt;&lt;span class="lnum"&gt;   2:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:&lt;/span&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Pay()&lt;/pre&gt;
&lt;pre class="alteven"&gt;&lt;span class="lnum"&gt;   4:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:&lt;/span&gt;     &lt;span class="rem"&gt;// bunch of code outside the scope of this test&lt;/span&gt;&lt;/pre&gt;
&lt;pre class="alteven"&gt;&lt;span class="lnum"&gt;   6:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:&lt;/span&gt;     &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (var deduction &lt;span class="kwrd"&gt;in&lt;/span&gt; _deductions)&lt;/pre&gt;
&lt;pre class="alteven"&gt;&lt;span class="lnum"&gt;   8:&lt;/span&gt;         _salaryPerWeek -= deduction;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:&lt;/span&gt;         &lt;/pre&gt;
&lt;pre class="alteven"&gt;&lt;span class="lnum"&gt;  10:&lt;/span&gt;     _log.Info(&lt;span class="str"&gt;&amp;quot;deduction total=&amp;quot;&lt;/span&gt; + _deductions.Sum());&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  11:&lt;/span&gt;     _log.Info(&lt;span class="str"&gt;&amp;quot;salary=&amp;quot;&lt;/span&gt; + _salaryPerWeek);&lt;/pre&gt;
&lt;pre class="alteven"&gt;&lt;span class="lnum"&gt;  12:&lt;/span&gt;     _log.Info(&lt;span class="str"&gt;&amp;quot;completed&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  13:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre class="alteven"&gt;&lt;span class="lnum"&gt;  14:&lt;/span&gt;     &lt;span class="rem"&gt;// more code we don&amp;#39;t want to test right now&lt;/span&gt;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  15:&lt;/span&gt; }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Now that we have the expected output, you can now assert what was dumped to a log file and determine if your tests are passing or not. This is achieved pretty easily with a simple Expectation class and a derived Appender class that is called ViceAppender. We have a &amp;lsquo;Verify&amp;rsquo; method here that will iterate over the logging statements using the message as a key and see if the expected message is actually in the logger. The verify method returns a boolean to indicate if all expectations were met during the test run. The message is used as the key on a dictionary. Therefore the message needs to match exactly in order to match an expectation.&lt;/p&gt;
&lt;div class="csharpcode-wrapper"&gt;
&lt;div class="csharpcode"&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:&lt;/span&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; Verify()&lt;/pre&gt;
&lt;pre class="alteven"&gt;&lt;span class="lnum"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:&lt;/span&gt;     &lt;span class="kwrd"&gt;bool&lt;/span&gt; result = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;
&lt;pre class="alteven"&gt;&lt;span class="lnum"&gt;   4:&lt;/span&gt;     &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (&lt;span class="kwrd"&gt;string&lt;/span&gt; key &lt;span class="kwrd"&gt;in&lt;/span&gt; _verifications.Keys)&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:&lt;/span&gt;         &lt;span class="kwrd"&gt;if&lt;/span&gt; (!_verifications[key].WasCalled)&lt;/pre&gt;
&lt;pre class="alteven"&gt;&lt;span class="lnum"&gt;   6:&lt;/span&gt;             result = &lt;span class="kwrd"&gt;false&lt;/span&gt;;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre class="alteven"&gt;&lt;span class="lnum"&gt;   8:&lt;/span&gt;     &lt;span class="kwrd"&gt;return&lt;/span&gt; result;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:&lt;/span&gt; }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
  &lt;br /&gt;Also on the ViceAppender I have the PrintExpectations() method that outputs the expectations to the Console:
  &lt;/p&gt;
&lt;div class="csharpcode-wrapper"&gt;
&lt;div class="csharpcode"&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:&lt;/span&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; PrintExpectations()&lt;/pre&gt;
&lt;pre class="alteven"&gt;&lt;span class="lnum"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:&lt;/span&gt;     &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (&lt;span class="kwrd"&gt;string&lt;/span&gt; message &lt;span class="kwrd"&gt;in&lt;/span&gt; _verifications.Keys)&lt;/pre&gt;
&lt;pre class="alteven"&gt;&lt;span class="lnum"&gt;   4:&lt;/span&gt;     {&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:&lt;/span&gt;         var sb = &lt;span class="kwrd"&gt;new&lt;/span&gt; StringBuilder();&lt;/pre&gt;
&lt;pre class="alteven"&gt;&lt;span class="lnum"&gt;   6:&lt;/span&gt;         sb.Append(&lt;span class="str"&gt;&amp;quot;Logger called &amp;#39;&amp;quot;&lt;/span&gt;)&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:&lt;/span&gt;             .Append(message)&lt;/pre&gt;
&lt;pre class="alteven"&gt;&lt;span class="lnum"&gt;   8:&lt;/span&gt;             .Append(&lt;span class="str"&gt;&amp;quot;&amp;#39;. Was Called? &amp;#39;&amp;quot;&lt;/span&gt;)&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:&lt;/span&gt;             .Append(_verifications[message].WasCalled)&lt;/pre&gt;
&lt;pre class="alteven"&gt;&lt;span class="lnum"&gt;  10:&lt;/span&gt;             .Append(&lt;span class="str"&gt;&amp;quot;&amp;#39;&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  11:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre class="alteven"&gt;&lt;span class="lnum"&gt;  12:&lt;/span&gt;         Console.WriteLine(sb.ToString());&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  13:&lt;/span&gt;     }&lt;/pre&gt;
&lt;pre class="alteven"&gt;&lt;span class="lnum"&gt;  14:&lt;/span&gt; }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Produces the following output:&lt;/p&gt;
&lt;div class="csharpcode-wrapper"&gt;
&lt;div class="csharpcode"&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:&lt;/span&gt; Logger called &lt;span class="str"&gt;&amp;#39;deduction total=70&amp;#39;&lt;/span&gt;. Was Called? &lt;span class="str"&gt;&amp;#39;True&amp;#39;&lt;/span&gt;&lt;/pre&gt;
&lt;pre class="alteven"&gt;&lt;span class="lnum"&gt;   2:&lt;/span&gt; Logger called &lt;span class="str"&gt;&amp;#39;salary=330&amp;#39;&lt;/span&gt;. Was Called? &lt;span class="str"&gt;&amp;#39;True&amp;#39;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The benefit from doing this type of testing is no modification of the class under test needs to take place. All you need to add is logging statements and a field for getting at the ILog instance. This gives you a solid foundation to begin doing refactoring.&lt;/p&gt;
&lt;p&gt;This could be viewed as integration tests as well as unit testing because your class under test may leak into other portions of code. Make sure you make your scope of your test as narrow as possible to combat the problem. This is a good place to start, but use wisely. It&amp;rsquo;s not meant to be a long term solution and can be abused just like any other technique.&lt;/p&gt;
&lt;p&gt;After typing out some code and playing with it for awhile, You could get this to work without even using a logging utility and just make one yourself. The java example on infoq used the java equivalent of log4net so I did the same here. One other thing I left out was that Ian in his infoq article had the ability to assert on expectations that were called when not expected. While this is a good feature, I decided it was a little overkill for a simple example and left it out for brevity.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;a href="http://www.dotnetkicks.com/kick/?title=%e2%80%98Vice%e2%80%99+Testing&amp;url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fsean_chambers%2farchive%2f2009%2f04%2f21%2fvice-testing.aspx"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fsean_chambers%2farchive%2f2009%2f04%2f21%2fvice-testing.aspx" border="0" alt="Kick It on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=20402" width="1" height="1"&gt;</description></item><item><title>TDD Firestarter</title><link>http://www.lostechies.com/blogs/sean_chambers/archive/2009/01/18/tdd-firestarter.aspx</link><pubDate>Mon, 19 Jan 2009 02:26:00 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:14088</guid><dc:creator>schambers</dc:creator><slash:comments>2</slash:comments><wfw:commentRss>http://www.lostechies.com/blogs/sean_chambers/rsscomments.aspx?PostID=14088</wfw:commentRss><comments>http://www.lostechies.com/blogs/sean_chambers/archive/2009/01/18/tdd-firestarter.aspx#comments</comments><description>&lt;p&gt;I want to thank everyone for coming out to the TDD Firestarter event that we had in Tampa yesterday. We had an excellent turnout (about 80 people), and everyone was very interested in getting to know TDD/BDD.&lt;/p&gt;
&lt;p&gt;We are in the process of post-processing videos and getting the content together. We have complete videos of the entire presentation as well as presentations in breakout rooms after the main workshop. Expect the content to be posted later in the week.&lt;/p&gt;
&lt;p&gt;I also want to thank everyone that helped with directing the video, answering questions and doing presentations in the breakout sessions. We couldn&amp;#39;t have done it without your help!!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;a href="http://www.dotnetkicks.com/kick/?title=TDD+Firestarter&amp;url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fsean_chambers%2farchive%2f2009%2f01%2f18%2ftdd-firestarter.aspx"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fsean_chambers%2farchive%2f2009%2f01%2f18%2ftdd-firestarter.aspx" border="0" alt="Kick It on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=14088" width="1" height="1"&gt;</description></item><item><title>Starting with BDD vs. starting with TDD</title><link>http://www.lostechies.com/blogs/sean_chambers/archive/2008/12/07/starting-with-bdd-vs-starting-with-tdd.aspx</link><pubDate>Sun, 07 Dec 2008 14:37:00 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:8792</guid><dc:creator>schambers</dc:creator><slash:comments>20</slash:comments><wfw:commentRss>http://www.lostechies.com/blogs/sean_chambers/rsscomments.aspx?PostID=8792</wfw:commentRss><comments>http://www.lostechies.com/blogs/sean_chambers/archive/2008/12/07/starting-with-bdd-vs-starting-with-tdd.aspx#comments</comments><description>&lt;p&gt;Yesterday I did a presentation on TDD/BDD at the &lt;a href="http://www.tampacodecamp.com"&gt;Tamp Code Camp&lt;/a&gt;. I have done several TDD presentations in the past but this was the first time I also showed the attendees BDD at the same time. In actuality I didn&amp;#39;t even show them a traditional TDD test. Not to my surprise, newcomers seem to grasp BDD much quicker and easier than from a TDD perspective. I did touch on that some tests would still be driven from a technical aspect, but from a business requirements they should try to use BDD. Another thing I very briefly touched on was Mocks/Stubs. I try not to go too in depth as you can discuss mocks and stubs for an hour by themselves and isn’t worth it to dive into when all you have is an hour.&lt;/p&gt;  &lt;p&gt;The best description I came up with for what is &amp;quot;BDD&amp;quot;, it&amp;#39;s nothing more than two things:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;A language shift in traditional TDD&lt;/li&gt;    &lt;li&gt;Driving your tests from a domain/user story perspective rather than technical perspective&lt;/li&gt; &lt;/ol&gt;  &lt;div&gt;When this was explained to a group of people that have never even used TDD, their heads nodded and I saw about 30 lightbulbs come on in the room. They just seemed to &amp;quot;get it&amp;quot; right away.&lt;/div&gt;  &lt;div&gt;&lt;/div&gt;  &lt;div&gt;As I dive further into a description here. I should note that there is &lt;strong&gt;ALOT&lt;/strong&gt; of differing opinions on what the proper way to do BDD is and what the proper “language” is. Much like TDD, it comes down to personal preference. Using a simple BDD tool like &lt;a href="http://code.google.com/p/specunit-net/"&gt;SpecUnit&lt;/a&gt; helped me a lot to figure out how to structure my tests in the beginning. From there, It breaks down to what you find works.&lt;/div&gt;  &lt;div&gt;&amp;#160;&lt;/div&gt;  &lt;div&gt;SpecUnit lays a pretty good foundation on what your language is. Let’s take a look at the language real quick. We’ll compare traditional TDD test naming vs. BDD test naming. Here’s how you would layout a test class and test for an AddressBook application with traditional TDD:&lt;/div&gt;  &lt;div&gt;&amp;#160;&lt;/div&gt;  &lt;div class="csharpcode-wrapper"&gt;   &lt;div class="csharpcode"&gt;     &lt;pre class="alt"&gt;[TestFixture]&lt;/pre&gt;

    &lt;pre class="alteven"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; addressbook_tests&lt;/pre&gt;

    &lt;pre class="alt"&gt;{&lt;/pre&gt;

    &lt;pre class="alteven"&gt;    [SetUp]&lt;/pre&gt;

    &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SetUp()&lt;/pre&gt;

    &lt;pre class="alteven"&gt;    {&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;// setup code for test&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alteven"&gt;    }&lt;/pre&gt;

    &lt;pre class="alt"&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre class="alteven"&gt;    [Test]&lt;/pre&gt;

    &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; can_add_person_to_addressbook()&lt;/pre&gt;

    &lt;pre class="alteven"&gt;    {&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;// test assertions&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alteven"&gt;    }&lt;/pre&gt;

    &lt;pre class="alt"&gt;}&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;As you can see. We have TestFixture/Test attributes. This is pretty straightforward and if you’ve been doing TDD you know how it works. Now let’s look at the same test using SpecUnit and with BDD language adjustments:&lt;/p&gt;

&lt;div class="csharpcode-wrapper"&gt;
  &lt;div class="csharpcode"&gt;
    &lt;pre class="alt"&gt;[Concern(&lt;span class="str"&gt;&amp;quot;Address Book&amp;quot;&lt;/span&gt;), TestFixture]&lt;/pre&gt;

    &lt;pre class="alteven"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; when_adding_a_person_to_an_addressbook : ContextSpecification&lt;/pre&gt;

    &lt;pre class="alt"&gt;{&lt;/pre&gt;

    &lt;pre class="alteven"&gt;    [Context]&lt;/pre&gt;

    &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt;  Context()&lt;/pre&gt;

    &lt;pre class="alteven"&gt;    {&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;base&lt;/span&gt;.Context();&lt;/pre&gt;

    &lt;pre class="alteven"&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;// setup code for test&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alteven"&gt;    }&lt;/pre&gt;

    &lt;pre class="alt"&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre class="alteven"&gt;    [Observation, Test]&lt;/pre&gt;

    &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; addressbook_contains_person()&lt;/pre&gt;

    &lt;pre class="alteven"&gt;    {&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;// test assertions&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alteven"&gt;    }&lt;/pre&gt;

    &lt;pre class="alt"&gt;}&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div&gt;Its a minor shift but a couple of things are important here.&lt;/div&gt;

&lt;ol&gt;
  &lt;li&gt;I have both Concern/TestFixture and Observation/Test attributes on the class/method. This reason I am doing this is because I am using Resharper. At the moment, resharper doesn’t recognize that Concern/Observation derive from TestFixture/Test and thus needs to be added so the Resharper test runner recognizes the tests. I have filed a bug with JetBrains and this will be fixed on the next release. It also helps to show what was a testfixture and test in the first example&lt;/li&gt;

  &lt;li&gt;Instead of [SetUp] attribute you now have the [Context] attribute.&lt;/li&gt;

  &lt;li&gt;There are other methods you can override from ContextSpecification like “Context_BeforeAllSpecs”, “Context_AfterAllSpecs” and so on.&lt;/li&gt;

  &lt;li&gt;SpecUnit has a number of extremely useful extension methods that make for a much more readable assertions like: somevalue.ShouldEqual(“whatever”).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In BDD one of the biggest shifts is that your testfixture classes are now grouped together into “Concerns” and your classes are broken out into Contexts. So in the TDD example our individual tests defined the context, now we pull that context up to the class level and the tests then become the acceptance criteria for the context.&lt;/p&gt;

&lt;p&gt;BDD has a much better alignment with business concerns and allows us to create tests that are parallel with User Stories/Acceptance criteria. This allows us to write software that is directly inline with what our stakeholders want rather than writing code that may or may not be necessary.&lt;/p&gt;

&lt;p&gt;Moving on, lets look at another important part of BDD which has to do with reusing contexts in your tests. Ok, so lets say we are creating an addressbook in our “when_adding_a_person_to_an_addressbook” like so:&lt;/p&gt;

&lt;div class="csharpcode-wrapper"&gt;
  &lt;div class="csharpcode"&gt;
    &lt;pre class="alt"&gt;[Concern(&lt;span class="str"&gt;&amp;quot;Address Book&amp;quot;&lt;/span&gt;), TestFixture]&lt;/pre&gt;

    &lt;pre class="alteven"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; when_adding_a_person_to_an_addressbook : ContextSpecification&lt;/pre&gt;

    &lt;pre class="alt"&gt;{&lt;/pre&gt;

    &lt;pre class="alteven"&gt;    &lt;span class="kwrd"&gt;private&lt;/span&gt; AddressBook addressBook;&lt;/pre&gt;

    &lt;pre class="alt"&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre class="alteven"&gt;    [Context]&lt;/pre&gt;

    &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt;  Context()&lt;/pre&gt;

    &lt;pre class="alteven"&gt;    {&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;base&lt;/span&gt;.Context();&lt;/pre&gt;

    &lt;pre class="alteven"&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        addressBook = &lt;span class="kwrd"&gt;new&lt;/span&gt; AddressBook();&lt;/pre&gt;

    &lt;pre class="alteven"&gt;    }&lt;/pre&gt;

    &lt;pre class="alt"&gt;}&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div&gt;Now lets say we have another user story and we have to create another context for “when_searching_for_a_person_in_an_addressbook”. Instead of creating a class with a context setup that matches the one above, we want to enforce DRY and create a “behaves_like_addressbook” class that both test classes can utilize:&lt;/div&gt;

&lt;div&gt;&amp;#160;&lt;/div&gt;

&lt;div class="csharpcode-wrapper"&gt;
  &lt;div class="csharpcode"&gt;
    &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; behaves_like_addressbook : ContextSpecification&lt;/pre&gt;

    &lt;pre class="alteven"&gt;{&lt;/pre&gt;

    &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;protected&lt;/span&gt; AddressBook addressBook;&lt;/pre&gt;

    &lt;pre class="alteven"&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Context()&lt;/pre&gt;

    &lt;pre class="alteven"&gt;    {&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;base&lt;/span&gt;.Context();&lt;/pre&gt;

    &lt;pre class="alteven"&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        addressBook = &lt;span class="kwrd"&gt;new&lt;/span&gt; AddressBook();&lt;/pre&gt;

    &lt;pre class="alteven"&gt;    }&lt;/pre&gt;

    &lt;pre class="alt"&gt;}&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Now both of the context test classes can derive from this class like so:&lt;/p&gt;

&lt;div class="csharpcode-wrapper"&gt;
  &lt;div class="csharpcode"&gt;
    &lt;pre class="alt"&gt;[Concern(&lt;span class="str"&gt;&amp;quot;Address Book&amp;quot;&lt;/span&gt;), TestFixture]&lt;/pre&gt;

    &lt;pre class="alteven"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; when_adding_a_person_to_an_addressbook : behaves_like_addressbook&lt;/pre&gt;

    &lt;pre class="alt"&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre class="alteven"&gt;[Concern(&lt;span class="str"&gt;&amp;quot;Address Book&amp;quot;&lt;/span&gt;), TestFixture]&lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; when_searching_for_a_person_in_an_addressbook : behaves_like_addressbook&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;So now any setup of the context that our classes share can be placed in the behaves_like_addressbook “Context Base class”. This is a part of bdd that comes from rspec. The ruby guys reuse their contexts in exactly this way. Then if you have additional context base classes along the way if you have two or more contexts that share behavior/setup. For instance. lets say we had a shared context further down we can set it up like this:&lt;/p&gt;

&lt;div class="csharpcode-wrapper"&gt;
  &lt;div class="csharpcode"&gt;
    &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; behaves_like_address_book_with_some_other_context : behaves_like_addressbook&lt;/pre&gt;

    &lt;pre class="alteven"&gt;{&lt;/pre&gt;

    &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Context()&lt;/pre&gt;

    &lt;pre class="alteven"&gt;    {&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;base&lt;/span&gt;.Context();&lt;/pre&gt;

    &lt;pre class="alteven"&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;// modify our context that was&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alteven"&gt;        &lt;span class="rem"&gt;// created in behaves_like_addressbook&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;    }&lt;/pre&gt;

    &lt;pre class="alteven"&gt;}&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;This really helps to promote reuse among the context setups in your tests. Also take a look at the SpecUnit.report.exe in the specunit project. It allows you to generate an html document from the name of your tests to hand to stakeholders. Very useful form of documentation.&lt;/p&gt;

&lt;p&gt;Thats it for an introduction to bdd and to get the gist of it. Now heres a list of resources to get you started not only for the people that were in my presentation yesterday but also for any newcomers to BDD.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://code.google.com/p/specunit-net/"&gt;SpecUnit&lt;/a&gt; : BDD testing tool that was described in this post&lt;/p&gt;

&lt;p&gt;&lt;a href="http://schambers.googlecode.com/svn/"&gt;schambers googlecode&lt;/a&gt; : My google code repository with my resharper templates and AddresBook sample for BDD&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.autohotkey.com/download/"&gt;AutoHotKey&lt;/a&gt; : install this and execute the “TestNamingMode.ahk” from my google code repository, then you do crtl+shift+u to turn on test naming mode where spaces are turned into underscores for you. Thanks to jpboodhoo for this!&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blog.jpboodhoo.com/"&gt;Jean-Paul Boodhoo’s Blog&lt;/a&gt; : this guy is a BDD master. He has excellent posts on BDD and if your not already, you should definately read his blog.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.jetbrains.com/resharper/"&gt;JetBrains ReSharper&lt;/a&gt; : alot of the people in my presentation were blown away when I showed them what resharper was capable of. For anyone that is interested you can obtain a 30-day trial&lt;/p&gt;

&lt;p&gt;Any feedback would be greatly appreciated! till next time&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;a href="http://www.dotnetkicks.com/kick/?title=Starting+with+BDD+vs.+starting+with+TDD&amp;url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fsean_chambers%2farchive%2f2008%2f12%2f07%2fstarting-with-bdd-vs-starting-with-tdd.aspx"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fsean_chambers%2farchive%2f2008%2f12%2f07%2fstarting-with-bdd-vs-starting-with-tdd.aspx" border="0" alt="Kick It on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=8792" width="1" height="1"&gt;</description></item><item><title>PTOM: The Decorator Pattern</title><link>http://www.lostechies.com/blogs/sean_chambers/archive/2008/11/16/ptom-the-decorator-pattern.aspx</link><pubDate>Mon, 17 Nov 2008 04:23:00 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:6367</guid><dc:creator>schambers</dc:creator><slash:comments>14</slash:comments><wfw:commentRss>http://www.lostechies.com/blogs/sean_chambers/rsscomments.aspx?PostID=6367</wfw:commentRss><comments>http://www.lostechies.com/blogs/sean_chambers/archive/2008/11/16/ptom-the-decorator-pattern.aspx#comments</comments><description>&lt;p&gt;For the month of November, Pablo&amp;#39;s Topic of the Month is Design Patterns. I will be talking about the Decorator design pattern in this post.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.dofactory.com/Patterns/PatternDecorator.aspx"&gt;The Decorator Pattern&lt;/a&gt; was originally coined by The Gang Of Four (GoF). It is a commonly used pattern for extending functionality dynamically at runtime. This is in contrast to a common OOP technique that everyone knows called inheritance. At it&amp;#39;s most basic level, think of the Decorator pattern as a wrapper with the intent to modify/attach additional behavior to an underlying class.&lt;/p&gt;
&lt;p&gt;This is one of the easiest patterns to grasp and understand, as well as to put to use. We will use an example of a coffee shop, let&amp;#39;s start with a class that is used to represent a cup of coffee available in the shop. Here we have the ICoffee and Coffe interface and class:&lt;/p&gt;
&lt;div class="csharpcode-wrapper"&gt;
&lt;div class="csharpcode"&gt;
&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;interface&lt;/span&gt; ICoffee&lt;/pre&gt;
&lt;pre class="alteven"&gt;{&lt;/pre&gt;
&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;string&lt;/span&gt; Name { get; }&lt;/pre&gt;
&lt;pre class="alteven"&gt;    &lt;span class="kwrd"&gt;decimal&lt;/span&gt; Total { get; }&lt;/pre&gt;
&lt;pre class="alt"&gt;}&lt;/pre&gt;
&lt;pre class="alteven"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Coffee : ICoffee&lt;/pre&gt;
&lt;pre class="alteven"&gt;{&lt;/pre&gt;
&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Name&lt;/pre&gt;
&lt;pre class="alteven"&gt;    {&lt;/pre&gt;
&lt;pre class="alt"&gt;        get { &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="str"&gt;&amp;quot;Coffee&amp;quot;&lt;/span&gt;; }&lt;/pre&gt;
&lt;pre class="alteven"&gt;    }&lt;/pre&gt;
&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre class="alteven"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;decimal&lt;/span&gt; Total&lt;/pre&gt;
&lt;pre class="alt"&gt;    {&lt;/pre&gt;
&lt;pre class="alteven"&gt;        get { &lt;span class="kwrd"&gt;return&lt;/span&gt; 0.75m; }&lt;/pre&gt;
&lt;pre class="alt"&gt;    }&lt;/pre&gt;
&lt;pre class="alteven"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;br /&gt;We have an interface that defines behavior for a cup of Coffee, and then we have a concrete class that represents a Coffee. Something to take note of here is the fact that the GoF sample uses an abstract base class for Coffee instead of my ICoffee interface. The abstract base class is then also used when implementing the decorator pattern. In other samples, people use interfaces instead of ABC&amp;#39;s, I usually opt for interfaces to start and then refactor to ABC if it is warranted. Use your judgement here. This is a pretty basic example so an ABC isn&amp;#39;t really needed.&lt;/p&gt;
&lt;p&gt;Now let&amp;#39;s say we want to add the ability to have a customer add an extra shot of espresso to their latte. Normally you would do this with traditional inheritance like so:&lt;/p&gt;
&lt;div class="csharpcode-wrapper"&gt;
&lt;div class="csharpcode"&gt;
&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; CoffeePlusEspresso : Coffee&lt;/pre&gt;
&lt;pre class="alteven"&gt;{&lt;/pre&gt;
&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;decimal&lt;/span&gt; Total&lt;/pre&gt;
&lt;pre class="alteven"&gt;    {&lt;/pre&gt;
&lt;pre class="alt"&gt;        get { &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;base&lt;/span&gt;.Total + .5m; }&lt;/pre&gt;
&lt;pre class="alteven"&gt;    }&lt;/pre&gt;
&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Name&lt;/pre&gt;
&lt;pre class="alteven"&gt;    {&lt;/pre&gt;
&lt;pre class="alt"&gt;        get { &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt;.Format(&lt;span class="str"&gt;&amp;quot;{0} w/ Extra shot of espresso&amp;quot;&lt;/span&gt;, &lt;span class="kwrd"&gt;base&lt;/span&gt;.Name); }&lt;/pre&gt;
&lt;pre class="alteven"&gt;    }&lt;/pre&gt;
&lt;pre class="alt"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This would work, however it&amp;#39;s not very desirable. Eventually as you add more and more permutations, (Coffee w/ Espresso, Coffee w/ Espress and Whip cream, etc..) it would lead to a class explosion and you would have a new class for every new combination of ingredients someone could have for a cup of coffee. A better option would be if we could add or &amp;quot;decorate&amp;quot; the original cost and name with our added options. Enter the Decorator Pattern.&lt;/p&gt;
&lt;p&gt;The first step in implementing the decorator pattern is to define an abstract base class that all of your decorators can derive from. This helps enforce &lt;a target="_blank" href="http://en.wikipedia.org/wiki/Don&amp;#39;t_repeat_yourself"&gt;the DRY principle&lt;/a&gt; by having the code that implements the ICoffee interface. Commonly, this ABC will only be calling the passed in or &amp;quot;decorated&amp;quot; object. This way, you only need to extend the properties/methods you want in the decorators and eliminates the need to return the decorated properties/methods in each decorator.&lt;br /&gt;&lt;br /&gt;Here is our base class that I have called IngredientDecorator:&lt;/p&gt;
&lt;div class="csharpcode-wrapper"&gt;
&lt;div class="csharpcode"&gt;
&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;abstract&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; IngredientDecorator : ICoffee&lt;/pre&gt;
&lt;pre class="alteven"&gt;{&lt;/pre&gt;
&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;protected&lt;/span&gt; ICoffee _decoratedCoffee;&lt;/pre&gt;
&lt;pre class="alteven"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;protected&lt;/span&gt; IngredientDecorator(ICoffee decoratedCoffee)&lt;/pre&gt;
&lt;pre class="alteven"&gt;    {&lt;/pre&gt;
&lt;pre class="alt"&gt;        _decoratedCoffee = decoratedCoffee;&lt;/pre&gt;
&lt;pre class="alteven"&gt;    }&lt;/pre&gt;
&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre class="alteven"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;virtual&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Name&lt;/pre&gt;
&lt;pre class="alt"&gt;    {&lt;/pre&gt;
&lt;pre class="alteven"&gt;        get { &lt;span class="kwrd"&gt;return&lt;/span&gt; _decoratedCoffee.Name; }&lt;/pre&gt;
&lt;pre class="alt"&gt;    }&lt;/pre&gt;
&lt;pre class="alteven"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;virtual&lt;/span&gt; &lt;span class="kwrd"&gt;decimal&lt;/span&gt; Total&lt;/pre&gt;
&lt;pre class="alteven"&gt;    {&lt;/pre&gt;
&lt;pre class="alt"&gt;        get { &lt;span class="kwrd"&gt;return&lt;/span&gt; _decoratedCoffee.Total; }&lt;/pre&gt;
&lt;pre class="alteven"&gt;    }&lt;/pre&gt;
&lt;pre class="alt"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;As you can see here, our base decorator implements the ICoffee interface by just calling the underlying ICoffee properties that we passed in the constructor. Very simple and to the point. Now we can start to create our concrete decorators that will extend the behavior of our Coffee class. Lets start with our original Espresso example and create an EspressoShotDecorator class.&lt;/p&gt;
&lt;div class="csharpcode-wrapper"&gt;
&lt;div class="csharpcode"&gt;
&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; EspressoShotDecorator : IngredientDecorator&lt;/pre&gt;
&lt;pre class="alteven"&gt;{&lt;/pre&gt;
&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; EspressoShotDecorator(ICoffee decoratedCoffee) : &lt;span class="kwrd"&gt;base&lt;/span&gt;(decoratedCoffee)&lt;/pre&gt;
&lt;pre class="alteven"&gt;    {&lt;/pre&gt;
&lt;pre class="alt"&gt;    }&lt;/pre&gt;
&lt;pre class="alteven"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Name&lt;/pre&gt;
&lt;pre class="alteven"&gt;    {&lt;/pre&gt;
&lt;pre class="alt"&gt;        get { &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt;.Format(&lt;span class="str"&gt;&amp;quot;{0}, shot of espresso&amp;quot;&lt;/span&gt;, &lt;span class="kwrd"&gt;base&lt;/span&gt;.Name); }&lt;/pre&gt;
&lt;pre class="alteven"&gt;    }&lt;/pre&gt;
&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre class="alteven"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;decimal&lt;/span&gt; Total&lt;/pre&gt;
&lt;pre class="alt"&gt;    {&lt;/pre&gt;
&lt;pre class="alteven"&gt;        get { &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;base&lt;/span&gt;.Total + 0.50m; }&lt;/pre&gt;
&lt;pre class="alt"&gt;    }&lt;/pre&gt;
&lt;pre class="alteven"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;We can now create a Coffee instance, pass it to an EspressoShotDecorator and print out the grand total and modified name by calling EspressoShotDecorator.Name/EspressoShotDecorator.Total as shown here:&lt;/p&gt;
&lt;div class="csharpcode-wrapper"&gt;
&lt;div class="csharpcode"&gt;
&lt;pre class="alt"&gt;Coffee plainCoffee = &lt;span class="kwrd"&gt;new&lt;/span&gt; Coffee();&lt;/pre&gt;
&lt;pre class="alteven"&gt;EspressoShotDecorator espressoShotDecorator = &lt;span class="kwrd"&gt;new&lt;/span&gt; EspressoShotDecorator(plainCoffee);&lt;/pre&gt;
&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre class="alteven"&gt;Console.WriteLine(&lt;span class="str"&gt;&amp;quot;Name of your coffee: {0}&amp;quot;&lt;/span&gt;, espressoShotDecorator.Name);&lt;/pre&gt;
&lt;pre class="alt"&gt;Console.WriteLine(&lt;span class="str"&gt;&amp;quot;Cost: {0}&amp;quot;&lt;/span&gt;, espressoShotDecorator.Total);&lt;/pre&gt;
&lt;pre class="alteven"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="rem"&gt;// Name of your coffee: Coffee, shot of espresso&lt;/span&gt;&lt;/pre&gt;
&lt;pre class="alteven"&gt;&lt;span class="rem"&gt;// Cost: 1.25&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This is where it starts to become really flexible. Let&amp;#39;s say we also have a &amp;quot;Whip Cream&amp;quot; topping that we want to add as an ingredient. To add this functionality to our application, all we need to do is create a class that represents that single item and we can then begin to chain together the options when someone is asking for their cup of coffee with additional options. The options they have are now interchangable and dynamic. Here is the WhipCreamDecorator:&lt;/p&gt;
&lt;div class="csharpcode-wrapper"&gt;
&lt;div class="csharpcode"&gt;
&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; WhipCreamDecorator : IngredientDecorator&lt;/pre&gt;
&lt;pre class="alteven"&gt;{&lt;/pre&gt;
&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; WhipCreamDecorator(ICoffee decoratedCoffee) : &lt;span class="kwrd"&gt;base&lt;/span&gt;(decoratedCoffee)&lt;/pre&gt;
&lt;pre class="alteven"&gt;    {&lt;/pre&gt;
&lt;pre class="alt"&gt;    }&lt;/pre&gt;
&lt;pre class="alteven"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Name&lt;/pre&gt;
&lt;pre class="alteven"&gt;    {&lt;/pre&gt;
&lt;pre class="alt"&gt;        get { &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt;.Format(&lt;span class="str"&gt;&amp;quot;{0}, whip cream&amp;quot;&lt;/span&gt;, &lt;span class="kwrd"&gt;base&lt;/span&gt;.Name); }&lt;/pre&gt;
&lt;pre class="alteven"&gt;    }&lt;/pre&gt;
&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre class="alteven"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;decimal&lt;/span&gt; Total&lt;/pre&gt;
&lt;pre class="alt"&gt;    {&lt;/pre&gt;
&lt;pre class="alteven"&gt;        get { &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;base&lt;/span&gt;.Total + 0.25m; }&lt;/pre&gt;
&lt;pre class="alt"&gt;    }&lt;/pre&gt;
&lt;pre class="alteven"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Adding this to the mix and then chaining it on top of the EspressoShotDecorator would yield the following results:&lt;/p&gt;
&lt;div class="csharpcode-wrapper"&gt;
&lt;div class="csharpcode"&gt;
&lt;pre class="alt"&gt;WhipCreamDecorator whipCreamDecorator = &lt;span class="kwrd"&gt;new&lt;/span&gt; WhipCreamDecorator(espressoShotDecorator);&lt;/pre&gt;
&lt;pre class="alteven"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre class="alt"&gt;Console.WriteLine(&lt;span class="str"&gt;&amp;quot;Name of your coffee: {0}&amp;quot;&lt;/span&gt;, whipCreamDecorator.Name);&lt;/pre&gt;
&lt;pre class="alteven"&gt;Console.WriteLine(&lt;span class="str"&gt;&amp;quot;Cost: {0}&amp;quot;&lt;/span&gt;, whipCreamDecorator.Total);&lt;/pre&gt;
&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre class="alteven"&gt;&lt;span class="rem"&gt;// Name of your coffee: Coffee, shot of espresso, whip cream&lt;/span&gt;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="rem"&gt;// Cost: 1.50&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You can now see how this can be flexible in dynamically modifying and extending behavior at runtime. If you want to be really cool, you can hook up the classes to an IoC framework and chain together these objects through a configuration. This is even more flexible than the above approach because you could modify behavior by changing your configuration for the IoC framework. An excellent example of this was already posted by &lt;a target="_blank" href="http://blog.bittercoder.com/PermaLink,guid,4863e460-2985-475c-9266-80b4895e80de.aspx"&gt;Alex Henderson (a.k.a The Bitter Coder) in his series on Castle Windsor tutorials&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;As you can see the Decorator Pattern is a powerful, easy to use/implement, flexible design pattern that should be in everyones arsenal. Please post comments any derivations that you have found useful of the Decorator Pattern. Till next time!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;a href="http://www.dotnetkicks.com/kick/?title=PTOM%3a+The+Decorator+Pattern&amp;url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fsean_chambers%2farchive%2f2008%2f11%2f16%2fptom-the-decorator-pattern.aspx"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fsean_chambers%2farchive%2f2008%2f11%2f16%2fptom-the-decorator-pattern.aspx" border="0" alt="Kick It on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=6367" width="1" height="1"&gt;</description></item><item><title>LosTechies welcomes Colin Jack!</title><link>http://www.lostechies.com/blogs/sean_chambers/archive/2008/10/23/lostechies-welcomes-colin-jack.aspx</link><pubDate>Thu, 23 Oct 2008 10:49:00 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:5529</guid><dc:creator>schambers</dc:creator><slash:comments>4</slash:comments><wfw:commentRss>http://www.lostechies.com/blogs/sean_chambers/rsscomments.aspx?PostID=5529</wfw:commentRss><comments>http://www.lostechies.com/blogs/sean_chambers/archive/2008/10/23/lostechies-welcomes-colin-jack.aspx#comments</comments><description>Today the LosTechies family welcomes Colin Jack to the site.

Colin is a very active member in the ALT.NET and .NET Community. Colin resides in Edinburgh, UK.

So please take a moment and welcome Colin to the family! Welcome Colin! We look forward to insightful posts!&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;a href="http://www.dotnetkicks.com/kick/?title=LosTechies+welcomes+Colin+Jack!&amp;url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fsean_chambers%2farchive%2f2008%2f10%2f23%2flostechies-welcomes-colin-jack.aspx"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fsean_chambers%2farchive%2f2008%2f10%2f23%2flostechies-welcomes-colin-jack.aspx" border="0" alt="Kick It on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=5529" width="1" height="1"&gt;</description></item><item><title>New job, new opportunities at Telligent</title><link>http://www.lostechies.com/blogs/sean_chambers/archive/2008/09/15/working-with-telligent.aspx</link><pubDate>Mon, 15 Sep 2008 23:07:00 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:4967</guid><dc:creator>schambers</dc:creator><slash:comments>12</slash:comments><wfw:commentRss>http://www.lostechies.com/blogs/sean_chambers/rsscomments.aspx?PostID=4967</wfw:commentRss><comments>http://www.lostechies.com/blogs/sean_chambers/archive/2008/09/15/working-with-telligent.aspx#comments</comments><description>&lt;p&gt;Over the last couple of months I have been casually looking at the job market in the Jacksonville/Orlando area at various opportunities. None of the really interested me and had mediocre opportunities at best. I was comfortable in my current job, but was looking for more of a challenge. Eventually, I came to the conclusion that in order for me to continue to gain
knowledge and strive for more experience, I needed to seek a new position with a strong development background; among many other reasons at the time of making these considerations. I felt the stench of stagnation, and in the development community everyone knows that stagnating is not where you want to be as stagnation == dead in the programming world. &lt;/p&gt;&lt;p&gt;I saw that &lt;a href="http://kohari.org/2008/08/21/joining-the-telligenti/"&gt;Nate Kohari (author of Ninject) had just recently accepted a position&lt;/a&gt; from &lt;a href="http://www.telligent.com"&gt;Telligent&lt;/a&gt;, and one thing led to another, I sent off my resume to &lt;a href="http://simpable.com/"&gt;Scott Watermasysk&lt;/a&gt; and started the interview process at Telligent. After a very thorough interview process I accepted a position at Telligent as a Senior Software Development Engineer. I am extremely excited to start with a company on the rise like Telligent and eager work with a notable and knowledgable staff that is present at Telligent. I am looking forward to new challenges, new technologies and working in a new environment. I will be telecommuting from my home in Florida for this position which should present some new challenges in itself.&lt;/p&gt;&lt;p&gt;I will miss everyone that I have worked with at the School District over the years, and will stop in from time to time to say hello. Comfort zones are meant to be broken and any decent developer will always be striving for different challenges to overcome and new opportunities. Once you reach the top of one ladder, the only logical step is to look for the next one and continue climbing.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;a href="http://www.dotnetkicks.com/kick/?title=New+job%2c+new+opportunities+at+Telligent&amp;url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fsean_chambers%2farchive%2f2008%2f09%2f15%2fworking-with-telligent.aspx"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fsean_chambers%2farchive%2f2008%2f09%2f15%2fworking-with-telligent.aspx" border="0" alt="Kick It on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=4967" width="1" height="1"&gt;</description></item><item><title>Refactoring towards deeper insight</title><link>http://www.lostechies.com/blogs/sean_chambers/archive/2008/08/24/refactoring-towards-deeper-insight.aspx</link><pubDate>Sun, 24 Aug 2008 14:03:00 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:4599</guid><dc:creator>schambers</dc:creator><slash:comments>4</slash:comments><wfw:commentRss>http://www.lostechies.com/blogs/sean_chambers/rsscomments.aspx?PostID=4599</wfw:commentRss><comments>http://www.lostechies.com/blogs/sean_chambers/archive/2008/08/24/refactoring-towards-deeper-insight.aspx#comments</comments><description>&lt;p&gt;While giving my DDD presentation at the Jacksonville Code Camp, I felt that DDD refactoring was one area that I really didn&amp;#39;t touch on enough. I mentioned it briefly but I wanted to build on the discussion that we started to have in the presentation. I feel this is a very important practice of DDD and needs more explanation.&lt;/p&gt;
&lt;p&gt;When doing DDD, a very important concept is the fact that noone gets the model correct the first time. This is against the traditional waterfall&amp;nbsp;approach of BDUF (big design up front) and trying to set everything in stone from the beginning. Because of this reason, the domain model needs to be refactored throughout the development lifecycle. In order to support this constant refactoring, you need to use TDD in order to keep your model functioning as expected. Without the safety net of tests, you have no way of seeing how the changes impact other portions of the system.&lt;/p&gt;
&lt;p&gt;In my presentation I spoke about two areas of refactoring in relation to DDD, or refactoring in general. Timing and Intiation. There are other concepts surrounding refactoring that I won&amp;#39;t focus on here.&lt;/p&gt;
&lt;p&gt;Timing of refactoring deals with when refactoring should occur during the development. Refactor too early and you will spin your wheels, wait too long and it becomes difficult to change the model and more costly. There is a sweet spot for timing to perform refactoring. I would say its a fairly large window as you will start to get code smells, this is an indicator that refactoring needs to occur, along with the ubiquitous language changing. The refactoring timing is fairly easy to see and show take place once you see it coming. Don&amp;#39;t hesitate or put it off until later, it will hurt much more if you do.&lt;/p&gt;
&lt;p&gt;Initiation of refactoring is important as well. Once you notice that refactoring needs to take place the second step is actually initiating the refactoring. It&amp;#39;s extremely easy to start cowboy coding doing refactoring changes because you have the tests, but this shouldn&amp;#39;t be the case. It&amp;#39;s very tempting but try to avoid this. Instead, begin writing tests to drive the refactoring in the direction you wish to go. If you notice that an entity has been renamed in the language from Loan to LoanSomething, then start by renaming it in your tests, which will then drive you to rename it in the domain. This is how all refactorings should take place in general, not only in DDD. Choose portions to localize the refactorings, but at the same time to just take little nibbles off the model. Try to cover as much of the domain model as required without making huge refactoring changes. The idea here is to perform small incremented refactorings that increase the cohesiveness of the model while not make huge sweeping changes in the process.&lt;/p&gt;
&lt;p&gt;While not the most important or well documented aspect of DDD, Refactoring plays an integral role when performing DDD. It feels slow and sluggish at first, but once you get the hang of it, you can utilize your toolset to aid in the refactoring, such as CodeRush or ReSharper. These greatly speed up the refactoring process in various ways. Don&amp;#39;t be afraid or nervous to start&amp;nbsp;refactoring, you will introduce problems but quickly iron them out in the process. Do this often enough, with the correct methods and your domain model will become much more flexible and cohesive for future changes. The domain model is NEVER set in stone. No matter who you are, noone will get it correct the first time. I really want to stress that point. Be comfortable and accept that so you can refactor towards a better model. Do this on an often enough basis and you will drive the domain model to a deeper insight that better reflects what the core idea of the domain model is. Hence, refactoring towards deeper insight.&lt;/p&gt;
&lt;p&gt;I hope that clears up anything I may have left out of my presentation and further defines the role of refactoring in DDD. Comments, Questions?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;a href="http://www.dotnetkicks.com/kick/?title=Refactoring+towards+deeper+insight&amp;url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fsean_chambers%2farchive%2f2008%2f08%2f24%2frefactoring-towards-deeper-insight.aspx"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fsean_chambers%2farchive%2f2008%2f08%2f24%2frefactoring-towards-deeper-insight.aspx" border="0" alt="Kick It on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=4599" width="1" height="1"&gt;</description></item><item><title>Jacksonville Code Camp</title><link>http://www.lostechies.com/blogs/sean_chambers/archive/2008/08/24/jacksonville-code-camp.aspx</link><pubDate>Sun, 24 Aug 2008 13:56:00 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:4598</guid><dc:creator>schambers</dc:creator><slash:comments>1</slash:comments><wfw:commentRss>http://www.lostechies.com/blogs/sean_chambers/rsscomments.aspx?PostID=4598</wfw:commentRss><comments>http://www.lostechies.com/blogs/sean_chambers/archive/2008/08/24/jacksonville-code-camp.aspx#comments</comments><description>&lt;p&gt;Jacksonville Code Camp was a great success. Even with faced with changing the venue only 48 hours before the event due to Tropical Storm Fay, Jonathan Bates and the rest of the team was able to pull it off with flying colors! I have great respect for these guys, they did an excellent job.&lt;/p&gt;
&lt;p&gt;I will be posting the content on my blog here later this evening, for the time being in case you missed one of my sessions or are in need of some of the sample code I used in the TDD session, you can find the contact on the Google Code Repository here: &lt;a href="http://code.google.com/p/jaxcodecamp/"&gt;http://code.google.com/p/jaxcodecamp/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Thank you for everyone that attended. Scott Reynolds had two great presentations on Agile and NDepend as well.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;a href="http://www.dotnetkicks.com/kick/?title=Jacksonville+Code+Camp&amp;url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fsean_chambers%2farchive%2f2008%2f08%2f24%2fjacksonville-code-camp.aspx"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fsean_chambers%2farchive%2f2008%2f08%2f24%2fjacksonville-code-camp.aspx" border="0" alt="Kick It on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=4598" width="1" height="1"&gt;</description><category domain="http://www.lostechies.com/blogs/sean_chambers/archive/tags/community/default.aspx">community</category></item><item><title>Designing Controllers</title><link>http://www.lostechies.com/blogs/sean_chambers/archive/2008/06/24/designing-controllers.aspx</link><pubDate>Wed, 25 Jun 2008 02:01:46 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:3815</guid><dc:creator>schambers</dc:creator><slash:comments>3</slash:comments><wfw:commentRss>http://www.lostechies.com/blogs/sean_chambers/rsscomments.aspx?PostID=3815</wfw:commentRss><comments>http://www.lostechies.com/blogs/sean_chambers/archive/2008/06/24/designing-controllers.aspx#comments</comments><description>&lt;p&gt;&lt;font face="Trebuchet MS" size="2"&gt;Once you wrap your head around using MVC in your web apps you tend to look at other ways to make your Controllers more descriptive. Specifically the way you structure and document your controllers.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Trebuchet MS" size="2"&gt;I have noticed that a few portions of MVC design that I can highlight as to where you should pay extra attention and be more discrete in your decisions. These areas are:&lt;/font&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;font face="Trebuchet MS" size="2"&gt;Actions&lt;/font&gt;&lt;/li&gt; &lt;li&gt;&lt;font face="Trebuchet MS" size="2"&gt;View/PropertyBag variables&lt;/font&gt;&lt;/li&gt; &lt;li&gt;&lt;font face="Trebuchet MS" size="2"&gt;Controller/Action reuse&lt;/font&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;font face="Trebuchet MS" size="2"&gt;For this posting, I will be using MonoRail in any examples but these ideas are confined to any one MVC framework. You can apply it to your own custom MVC, ASP.NET MVC or anything other MVC framework for that matter.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;font face="Trebuchet MS" size="2"&gt;Actions&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Trebuchet MS" size="2"&gt;Action naming is one area that I think deserves the most attention. There are a couple of different implications of your choices here. You may say, well I can just rename my actions but this drags along some pains because then you have to repoint any hyperlinks you have referring to those actions and refactor any controller code that uses those actions. You can mitigate the hyperlink problem by adding a new Routing Rule to point to the new action, but this should only be used as a temporary fix and shouldn&amp;#39;t be a permanent solution.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Trebuchet MS" size="2"&gt;When naming my actions I always try to limit actions to one word. There are a couple of reasons for this. The less words the easier it is to convey intent of what the action is going to do. This is often hard to convey with one word so sometimes two words are necessary. I try to keep it to one and often cringe when I add that second word. Common action names I have on a controller are, View, List, Search, Find, New, Create so on and so forth. While using jQuery to do ajax calls I am considering prefixing all actions that are called via jQuery with &amp;quot;Ajax&amp;quot;. So if I want to perform a Get action that is called via ajax the action name would be AjaxGet, this way it reads like the jQuery methods for performing the calls to a remote page.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Trebuchet MS" size="2"&gt;Next, I try to steer away from overloading Actions. Sometimes there are exceptions but as a rule of thumb, if I am overloading my actions I take a second look at why I am needing to do this and usually gives me a hint that I need to refactor some code on the controller like break it up into two seperate controllers. This is often the case.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Trebuchet MS" size="2"&gt;Action names should always be performing that verb on the controller at hand. So for a Controller named UserController, any action should &amp;quot;usually&amp;quot; be working with a User. Some actions do turn out to be utility actions however so use your judgement as to when you can stray away from this idea.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;font face="Trebuchet MS" size="2"&gt;View/PropertyBag variables&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Trebuchet MS" size="2"&gt;When I refer to &amp;quot;View/PropertyBag variables&amp;quot;, I am referring to data that is sent to the view from the Controller so we are all on the same page.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Trebuchet MS" size="2"&gt;On naming of your ProperyBag variables, I always am careful to be consistent with my pluralizing here. If I am sending a collection of objects, be sure to make the variable plural so that you don&amp;#39;t mix yourself up. Other than that, I just remain consistent with entity/dto naming in my domain so that it is consistent across the board.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;font face="Trebuchet MS" size="2"&gt;Controller/Action Reuse&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Trebuchet MS" size="2"&gt;This is one area that is a struggle. The easiest and most commonly used approach is Controller inheritance which works without a hitch. In my experience this works well for small scenarios with minimal reuse. Once you get into more complex Actions it becomes cumbersome and undesirable to attempt to apply inheritance to your Controllers. There are a couple of things that can help once you outgrow inheritance.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Trebuchet MS" size="2"&gt;The first is MonoRails DynamicActions. DynamicActions are a way to create an action in it&amp;#39;s own class and then by using attributes, you can hook up the disconnected action to whichever Controllers you wish, passing in parameters that deal with the specific context the DynamicAction is being used in. This works extremely well if the code that needs to be reused is exactly the same except for the objects that it is working with. For instance, list and view actions.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Trebuchet MS" size="2"&gt; One area where I have found Controller inheritance to work very well is in the area of managing security in your Controllers. What I commonly do is make a &amp;quot;SecureControllerBase&amp;quot; that has an Authentication Filter applied to check if the current user context is authenticated or not, redirecting where appropriate. I commonly use these base controllers for applying filters/monorail attributes across all controllers. That comes in pretty handy.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Trebuchet MS" size="2"&gt;That concludes my little blurb on Controller design/layout. If you have something to add please add a comment.&lt;/font&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;a href="http://www.dotnetkicks.com/kick/?title=Designing+Controllers&amp;url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fsean_chambers%2farchive%2f2008%2f06%2f24%2fdesigning-controllers.aspx"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fsean_chambers%2farchive%2f2008%2f06%2f24%2fdesigning-controllers.aspx" border="0" alt="Kick It on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=3815" width="1" height="1"&gt;</description></item><item><title>Tour of MonoRail Series</title><link>http://www.lostechies.com/blogs/sean_chambers/archive/2008/06/22/monorail-best-practices-series.aspx</link><pubDate>Mon, 23 Jun 2008 01:00:00 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:1155</guid><dc:creator>schambers</dc:creator><slash:comments>2</slash:comments><wfw:commentRss>http://www.lostechies.com/blogs/sean_chambers/rsscomments.aspx?PostID=1155</wfw:commentRss><comments>http://www.lostechies.com/blogs/sean_chambers/archive/2008/06/22/monorail-best-practices-series.aspx#comments</comments><description>&lt;p&gt;&lt;font face="Trebuchet MS" size="2"&gt;Due to a spell of blogger&amp;#39;s block, I thought I would do a series postings to help me get past it. This post begins a series on highlighting various features of the Castle Project MonoRail. All series will be examples from the MonoRail trunk. Some of the features I will be discussing are only available on the trunk (specifically the new Routing Module). To start off the series. The first part will cover MonoRail helpers. The series will have the following topics: &lt;/font&gt;&lt;/p&gt;
&lt;div&gt;&lt;font face="Trebuchet MS" size="2"&gt;&lt;a href="http://www.lostechies.com/blogs/sean_chambers/archive/2008/06/22/monorail-best-practices-series.aspx"&gt;Part 1. Helpers&lt;/a&gt;&lt;br /&gt;Part 2. UI Basics (Layouts, Views and Shared Views, View Components)&lt;br /&gt;Part 3. Using the new Routing Module&lt;br /&gt;Part 4. Authentication/Security&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face="Trebuchet MS" size="2"&gt;Part 5. Dynamic Actions&lt;br /&gt;Part 6. Using JsonReturnBinder for serializing to JSON&lt;br /&gt;Part 7. Creating Wizards using IWizardController&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face="Trebuchet MS" size="2"&gt;&lt;/font&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;&lt;font face="Trebuchet MS" size="2"&gt;Helpers are classes that are created specifically for providing your view templates with a minimal amount of work to perform or some form of html generation. They should not be used for complex operations or domain logic except for some rare circumstance. They are amazingly simple. A prime example of a helper at work is the &lt;/font&gt;&lt;a class="" href="http://castleproject.org/monorail/documentation/trunk/helpers/form/index.html" target="_blank"&gt;&lt;font face="Trebuchet MS" size="2"&gt;FormHelper&lt;/font&gt;&lt;/a&gt;&lt;font face="Trebuchet MS" size="2"&gt;. This Helper generates various html tags for the purpose of easily using the DataBinder on your controllers. Let&amp;#39;s look at the code required to have the FormHelper generate a TextField for us:&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face="Trebuchet MS" size="2"&gt;&lt;/font&gt;&amp;nbsp;&lt;/div&gt;
&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;$FormHelper.TextField(&lt;span class="str"&gt;&amp;quot;blogpost.title&amp;quot;&lt;/span&gt;)&lt;/pre&gt;&lt;/div&gt;
&lt;div class="csharpcode"&gt;&amp;nbsp;&lt;/div&gt;
&lt;div class="csharpcode"&gt;&lt;font face="Trebuchet MS"&gt;This will generate the following code when rendered:&lt;/font&gt;&lt;/div&gt;
&lt;div class="csharpcode"&gt;&lt;font face="Trebuchet MS"&gt;&lt;/font&gt;&amp;nbsp;&lt;/div&gt;
&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&amp;lt;input type=&lt;span class="str"&gt;&amp;quot;text&amp;quot;&lt;/span&gt; id=&lt;span class="str"&gt;&amp;quot;blogpost_title&amp;quot;&lt;/span&gt; name=&lt;span class="str"&gt;&amp;quot;blogpost.title&amp;quot;&lt;/span&gt; /&amp;gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;font face="Trebuchet MS" size="2"&gt;What happens here is the FormHelper creates the requested form field and sets the id/name attributes properly so the data can be data bound on the controller action which would look something like this:&lt;/font&gt;&lt;/p&gt;
&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; CreateBlogPost([DataBind(&lt;span class="str"&gt;&amp;quot;blogpost&amp;quot;&lt;/span&gt;)] BlogPost blogpost) {}&lt;/pre&gt;&lt;/div&gt;&lt;font face="Trebuchet MS"&gt;
&lt;p&gt;&lt;br /&gt;&lt;font size="2"&gt;As long as you specify the correct id prefix as it appears in your template, MonoRail will do all the binding on the controller. Your controller must also derive from SmartDispatcherController otherwise you will get an exception at runtime. There are many more features that are provided with FormHelper that I will leave you to &lt;/font&gt;&lt;a href="http://castleproject.org/monorail/documentation/trunk/helpers/form/index.html"&gt;&lt;font size="2"&gt;explore here&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt;. There are a number of other helpers available such as &lt;/font&gt;&lt;a href="http://castleproject.org/monorail/documentation/trunk/helpers/ajax/index.html"&gt;&lt;font size="2"&gt;AjaxHelper&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt;, &lt;/font&gt;&lt;a href="http://castleproject.org/monorail/documentation/trunk/helpers/url/index.html"&gt;&lt;font size="2"&gt;UrlHelper&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt; and &lt;/font&gt;&lt;a href="http://castleproject.org/monorail/documentation/trunk/helpers/date/index.html"&gt;&lt;font size="2"&gt;DateFormatHelper&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt;.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;If you want to create your own Helper for whatever task you have at hand all you need to do is create a class and then add an attribute to any controllers that wish to use the helper. The code would look like so:&lt;/font&gt;&lt;/p&gt;
&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; MyCoolHelper&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;{&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; DoSomethingCool()&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;    {&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;        &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="str"&gt;&amp;quot;cool stuff&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;    }&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;}&lt;/pre&gt;&lt;/div&gt;
&lt;div class="csharpcode"&gt;&amp;nbsp;&lt;/div&gt;
&lt;div class="csharpcode"&gt;&lt;font face="Trebuchet MS"&gt;The controller that wishes to use the Helper would look like so:&lt;br /&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div class="csharpcode"&gt;&lt;font face="Trebuchet MS"&gt;&amp;nbsp;&lt;/div&gt;&lt;/font&gt;
&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;[Helper(&lt;span class="kwrd"&gt;typeof&lt;/span&gt;(MyCoolHelper))]&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; SomeController&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;{&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;}&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;It&amp;#39;s as easy as that. This first post is pretty basic. I wanted to start off simple and work up to some of the other topics such as Dynamic Actions and doing Ajax/JSON related data retrieval.&lt;/p&gt;
&lt;p&gt;Next time we will go over layouts, views and view components. Should be a fun time!&lt;/font&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;a href="http://www.dotnetkicks.com/kick/?title=Tour+of+MonoRail+Series&amp;url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fsean_chambers%2farchive%2f2008%2f06%2f22%2fmonorail-best-practices-series.aspx"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fsean_chambers%2farchive%2f2008%2f06%2f22%2fmonorail-best-practices-series.aspx" border="0" alt="Kick It on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=1155" width="1" height="1"&gt;</description></item><item><title>Refactoring an established Domain Model</title><link>http://www.lostechies.com/blogs/sean_chambers/archive/2008/06/22/refactoring-an-established-domain-language.aspx</link><pubDate>Sun, 22 Jun 2008 12:45:00 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:3439</guid><dc:creator>schambers</dc:creator><slash:comments>3</slash:comments><wfw:commentRss>http://www.lostechies.com/blogs/sean_chambers/rsscomments.aspx?PostID=3439</wfw:commentRss><comments>http://www.lostechies.com/blogs/sean_chambers/archive/2008/06/22/refactoring-an-established-domain-language.aspx#comments</comments><description>&lt;p&gt;Writing Domain models is by far one of the most difficult things to do. It takes years of practice, errors and learning to get&amp;nbsp;good at writing&amp;nbsp;halfway decent domain models. This becomes even more difficult when we attempt to add ideas like Domain Driven Design to the mix.&amp;nbsp;I am not proposing I am even remotely good at it, but I have had lots of practice.&lt;/p&gt;
&lt;p&gt;In the last two weeks my co-worker and I have begun a greenfield project. This project is a complete language re-write&amp;nbsp;due to the fact that the existing technology it is written in, is a dead end. There is no upgrade path and the staff running the software have become more ancy as time has progressed because they knew sooner or later they would have to leave the existing platform behind. The project is greenfield because of no technology constraints, that doesn&amp;#39;t mean however there isn&amp;#39;t domain language constraints.&lt;/p&gt;
&lt;p&gt;The problem with this project is only a handful of people are intimately familiar with the domain. Even then, the few people that were familiar&amp;nbsp;don&amp;#39;t agree often on how specific aspects should work. This adds an enormous amount of risk to the project as even though there is a functioning domain model, it is one without a solid foundation and thus weak model. &lt;/p&gt;
&lt;p&gt;Enter Domain Model Refactoring...&lt;/p&gt;
&lt;p&gt;A few words&amp;nbsp;before I begin. This is an extremely risky thing to do when using Agile/DDD concepts. You run the risk of alienating the client from the&amp;nbsp;domain language.&amp;nbsp;Not only are you going out on a limb here, but you are playing with the business language that the client&amp;nbsp;is using. If&amp;nbsp;I wasn&amp;#39;t&amp;nbsp;comfortable with the client enough to talk to them on a real level (my client is within my staff), then I wouldn&amp;#39;t attempt to&amp;nbsp;refactor the model for their benefit. Trust&amp;nbsp;is extremely important between the client and developers, as it normally is,&amp;nbsp;but more than usual. Couple that with the fact that in my instance there is no money changing hands, so there is little or no monetary cost involved, that doesn&amp;#39;t mean however that there isn&amp;#39;t cost in general involved. Cost in this sense is time and effort, not money, although in some instances, time and effort is proportional to money but not in my case.&lt;/p&gt;
&lt;p&gt;Usually you are working with a project where you are starting from day one and can work with the client on the domain model. In this instance, they have been using a model for years and I am attempting to change it to make it more effecient for them. Again, proceed with caution.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 1. Model the existing Domain&lt;/strong&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The first step we took is to model out the existing solution with aggregates/entities and value objects. This gives us a good idea of how the model &amp;quot;would&amp;quot; be modeled if it was in a pure DDD&amp;nbsp;type model&amp;nbsp;with all the bells and whistles. This allowed us to reveal holes and gaps in the model (and there was a lot of them). When we approached the client about this, they shrugged and claimed they didn&amp;#39;t know why functionality was like it was, just that it was that way. This allowed us to refactor parts of the model that were superfluous and began to make the model more lean.&lt;/p&gt;
&lt;p&gt;The existing domain was modeled after the technology it was based on. Because of performance constraints, specific things had to be done in a specific manner in order to salvage performance. After noticing this in the DDD model we created, we refactored the &amp;quot;performance features&amp;quot; into more logical operations with extra documentation. The original application was split into seperate databases that were converged on a daily basis in the morning. Because of this, each database was it&amp;#39;s own seperate bubble of transactions/processing. To minimize collisions when everything was merged together, the model was setup in such a way that extra processing was required on the actual users of the system to resolve these conflicts before they happened. We were able to again make the model more lean by removing these constraints as we were refactoring to a single database approach and could remove these constraints.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 2. Refactor to a more&amp;nbsp;logical model&lt;/strong&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Once we had this step complete we could then begin to refactor the model into a more logical manner. This should be done&amp;nbsp;with baby steps and each change be communicated to the client. As long as you have a good idea of what the model should be, then make appropriate changes to the model. All the while documenting what has been refactored into what. You will need to communicate these changes to the client, otherwise you will be the one translating the old model to the new model. This is to be expected at first, but once the client gets running on their own feet they should be able to do this themselves, if they are not then you need to provide more documentation and explanation as to why a particular portion of the model is setup a specific way. In this case, the client didn&amp;#39;t actually care what language we changed as long as it still served their purpose and we informed them of any definition changes and provided documentation on why a specific feature was dropped.&lt;/p&gt;
&lt;p&gt;Before we laid down a single line of code, we spoke with the client explaining exactly what was happening, why it was happening and then received feedback from them. This part is very important as it will uncover MORE gaps in the model as well as gaps in their understanding of the model. Have someone take notes and address the gaps accordingly in your refactored model. We did this step and realized that some of the changes we made didn&amp;#39;t need to be communicated to the client because they already took this for granted, however, we wouldn&amp;#39;t have known this unless we spoke with them about it.&lt;/p&gt;
&lt;p&gt;Looking back in this project, the key was communication and feedback. If you cut this portion out of the loop you increase risk very quickly. Don&amp;#39;t take anything for granted and leave out assumptions. It is better to ask 10 questions and get 9 dumb answers and one good one than to ask no questions at all.&lt;/p&gt;
&lt;p&gt;As I said in the beginning of the post, I am no expert on modeling but I have found that this approach has worked well for me and my team. Hopefully you can take something from it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;a href="http://www.dotnetkicks.com/kick/?title=Refactoring+an+established+Domain+Model&amp;url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fsean_chambers%2farchive%2f2008%2f06%2f22%2frefactoring-an-established-domain-language.aspx"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fsean_chambers%2farchive%2f2008%2f06%2f22%2frefactoring-an-established-domain-language.aspx" border="0" alt="Kick It on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=3439" width="1" height="1"&gt;</description></item><item><title>A call for Alt.Net Speakers</title><link>http://www.lostechies.com/blogs/sean_chambers/archive/2008/06/21/a-call-for-alt-net-speakers.aspx</link><pubDate>Sun, 22 Jun 2008 00:08:00 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:3774</guid><dc:creator>schambers</dc:creator><slash:comments>1</slash:comments><wfw:commentRss>http://www.lostechies.com/blogs/sean_chambers/rsscomments.aspx?PostID=3774</wfw:commentRss><comments>http://www.lostechies.com/blogs/sean_chambers/archive/2008/06/21/a-call-for-alt-net-speakers.aspx#comments</comments><description>&lt;p&gt;In an attempt to spread awareness in the North/Central Florida area on Alt.Net topics I am trying to gather speakers&amp;nbsp;familiar with Alt.Net topics to speak at the &lt;a class="" title="Jacksonville Code Camp" href="http://www.jaxcodecamp.com/" target="_blank"&gt;Jacksonville Code Camp&lt;/a&gt; that is coming up on August 23rd.&amp;nbsp;The&amp;nbsp;topics I am envisioning are Domain Driven&amp;nbsp;Design, TDD, BDD, NHibernate, ORM&amp;#39;s in general or any other topics that would be of interest in the alt.net space.&lt;/p&gt;
&lt;p&gt;If you live in the central/north florida area and are interested in speaking at the code camp please register at &lt;a class="" href="http://www.jaxcodecamp.com/" target="_blank"&gt;http://www.jaxcodecamp.com&lt;/a&gt; and please contact me at dkode8 at gmail dot com. This way I can&amp;nbsp;begin to organize an alt.net track at the event when I attend one of the planning meetings.&lt;/p&gt;
&lt;p&gt;Hoping to hear from you!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;a href="http://www.dotnetkicks.com/kick/?title=A+call+for+Alt.Net+Speakers&amp;url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fsean_chambers%2farchive%2f2008%2f06%2f21%2fa-call-for-alt-net-speakers.aspx"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fsean_chambers%2farchive%2f2008%2f06%2f21%2fa-call-for-alt-net-speakers.aspx" border="0" alt="Kick It on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=3774" width="1" height="1"&gt;</description></item><item><title>The strive to do better</title><link>http://www.lostechies.com/blogs/sean_chambers/archive/2008/06/17/the-strive-to-do-better.aspx</link><pubDate>Wed, 18 Jun 2008 01:58:00 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:3729</guid><dc:creator>schambers</dc:creator><slash:comments>3</slash:comments><wfw:commentRss>http://www.lostechies.com/blogs/sean_chambers/rsscomments.aspx?PostID=3729</wfw:commentRss><comments>http://www.lostechies.com/blogs/sean_chambers/archive/2008/06/17/the-strive-to-do-better.aspx#comments</comments><description>&lt;p&gt;Late night thoughts after a coding session before&amp;nbsp;going to sleep.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;One skill that I value above all others in software development and life in general&amp;nbsp;is the inner drive and motivation&amp;nbsp;to do better and to do more. It is a skill that can be honed over time. Once you begin to cultivate it, a snowball ensues getting faster and larger as time passes. I am&amp;nbsp;immensely more motivated and driven now than I was a year ago, and the year before that. This is from reading books, writing code, doing presentations at code camps and user groups, getting involved and giving back the community as much as I take out. As well as pushing myself to learn the next step, and the step after that.&lt;/p&gt;
&lt;p&gt;For me, it feels&amp;nbsp;almost like a struggle, if I feel myself slowing down or&amp;nbsp;reaching the pinnacle of a particular topic of knowledge, I find another&amp;nbsp;one to begin learning and transition. It&amp;#39;s a zone in between comfort and frustration. It&amp;#39;s very hard to describe and must be experienced by the inividual doing the exploring. Too much at once causes frustration, not enough precipitates laziness and comfort. There&amp;#39;s a balance in between that can be tailored and tuned to.&lt;/p&gt;
&lt;p&gt;This applies to all aspects of life, Continuous learning and improvement must always be on your mind. If you stagnate, then you go the way of the dinosaur. Especially in the software industry.&lt;/p&gt;
&lt;p&gt;This concept can go from extremes from the macrocosm of your life, all the way to each individual line of code you write. Everytime you look at&amp;nbsp;piece of your own code you should consider that it could possibly be written better at the same time you should be looking at your life and how you can be better to your surrounding environment and fellow beings.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;I may be getting a little too zen there however =)&amp;nbsp; Just a thought!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;a href="http://www.dotnetkicks.com/kick/?title=The+strive+to+do+better&amp;url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fsean_chambers%2farchive%2f2008%2f06%2f17%2fthe-strive-to-do-better.aspx"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fsean_chambers%2farchive%2f2008%2f06%2f17%2fthe-strive-to-do-better.aspx" border="0" alt="Kick It on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=3729" width="1" height="1"&gt;</description></item><item><title>Getting up to speed with the Castle.MonoRail trunk</title><link>http://www.lostechies.com/blogs/sean_chambers/archive/2008/06/06/getting-up-to-speed-with-the-castle-monorail-trunk.aspx</link><pubDate>Fri, 06 Jun 2008 11:40:00 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:3473</guid><dc:creator>schambers</dc:creator><slash:comments>4</slash:comments><wfw:commentRss>http://www.lostechies.com/blogs/sean_chambers/rsscomments.aspx?PostID=3473</wfw:commentRss><comments>http://www.lostechies.com/blogs/sean_chambers/archive/2008/06/06/getting-up-to-speed-with-the-castle-monorail-trunk.aspx#comments</comments><description>&lt;p&gt;Over the last couple of months there have been a slew of great refactorings done on the castle monorail trunk. Some of these refactorings were inspired by ASP.Net MVC changes such as the new routing module. I have just now started to play with monorail trunk so I am by no means an expert on the changes that were done there. If you are interested in getting up to speed as well. The best thing to do is get a fresh copy of the monorail trunk and start looking through the source code specifically on Controller, EngineContext, ControllerContext and IController. After looking at the changes for only an hour or so and updating a project up to the monorail trunk, I can already get a good idea of where things logically should belong now.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;General Changes&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;The controller class has been split up into Controller and ControllerContext. A good deal of Controller &amp;quot;metadata&amp;quot; has been moved to ControllerContext. In addition, an IController interface has been created that is now used within all the Castle services.&lt;/div&gt;
&lt;li&gt;
&lt;div&gt;RailsEngineContext has been renamed to simply EngineContext.&lt;/div&gt;
&lt;li&gt;
&lt;div&gt;The ExecuteEnum has been renamed to ExecuteWhen which makes more sense to me.&lt;/div&gt;
&lt;li&gt;
&lt;div&gt;Certain services have been removed from the Controller&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;The EngineContextModule has ceased to exist&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Routing Functionality&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This is the coolest part of the refactorings. Instead of relying on ugly xml configuration for our routes, we can now configure them within our HttpApplication class using the PatternRoute class. This was the hardest portion to find documentation on. There are some postings on the castle project google group that helped me along. You can find the &lt;a href="http://groups.google.com/group/castle-project-devel/browse_thread/thread/55c12e2fda84d999/7e01f48ca88d4ffd?#7e01f48ca88d4ffd"&gt;posting here&lt;/a&gt;. In addition to reading that, the best way to get familiar with the new routing functionality is to download the trunk and take a look at the Routing tests. They are pretty descriptive and allowed me to wrap my head around them. To outline some of the routing functionality I have an example of a route in one of my applications:&lt;/p&gt;
&lt;div&gt;
&lt;div style="PADDING-RIGHT:0px;PADDING-LEFT:0px;FONT-SIZE:8pt;PADDING-BOTTOM:0px;OVERFLOW:visible;WIDTH:100%;COLOR:black;BORDER-TOP-STYLE:none;LINE-HEIGHT:12pt;PADDING-TOP:0px;FONT-FAMILY:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;BORDER-RIGHT-STYLE:none;BORDER-LEFT-STYLE:none;BACKGROUND-COLOR:#f4f4f4;BORDER-BOTTOM-STYLE:none;"&gt;&lt;pre style="PADDING-RIGHT:0px;PADDING-LEFT:0px;FONT-SIZE:8pt;PADDING-BOTTOM:0px;MARGIN:0em;OVERFLOW:visible;WIDTH:100%;COLOR:black;BORDER-TOP-STYLE:none;LINE-HEIGHT:12pt;PADDING-TOP:0px;FONT-FAMILY:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;BORDER-RIGHT-STYLE:none;BORDER-LEFT-STYLE:none;BACKGROUND-COLOR:#f4f4f4;BORDER-BOTTOM-STYLE:none;"&gt;&lt;span style="COLOR:#606060;"&gt;   1:&lt;/span&gt; rules.Add(&lt;span style="COLOR:#0000ff;"&gt;new&lt;/span&gt; PatternRoute(&lt;span style="COLOR:#006080;"&gt;&amp;quot;/&amp;lt;controller&amp;gt;/&amp;lt;action&amp;gt;&amp;quot;&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="PADDING-RIGHT:0px;PADDING-LEFT:0px;FONT-SIZE:8pt;PADDING-BOTTOM:0px;MARGIN:0em;OVERFLOW:visible;WIDTH:100%;COLOR:black;BORDER-TOP-STYLE:none;LINE-HEIGHT:12pt;PADDING-TOP:0px;FONT-FAMILY:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;BORDER-RIGHT-STYLE:none;BORDER-LEFT-STYLE:none;BACKGROUND-COLOR:#f4f4f4;BORDER-BOTTOM-STYLE:none;"&gt;&lt;span style="COLOR:#606060;"&gt;   2:&lt;/span&gt;     .DefaultForAction().Is(&lt;span style="COLOR:#006080;"&gt;&amp;quot;index&amp;quot;&lt;/span&gt;));&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;The rules class is an instance of RoutingModuleEx.Engine that you can obtain in your global application. We then pass the Add method a new PatternRoute. This is where we define the route to match.&lt;/p&gt;
&lt;p&gt;This route will match anything followed by anything,&amp;nbsp;It will then map anything between &amp;lt;controller&amp;gt;, and pass it along as the controller parameter, and pass along &amp;lt;action&amp;gt; as the action parameter. If no action is passed, a default of &amp;quot;index&amp;quot; will be applied. Specifying a parameter as [something] makes it optional, while &amp;lt;something&amp;gt; is a required parameter. The thing that took me a minute to understand is, when constructing the route, anything you make as a parameter is passed along to the action at hand. This means that if you have a parameter to your action that is someThing, you can place it in your route and that part of the url will be passed along as that parameter. To display this I have another example:&lt;/p&gt;
&lt;div&gt;
&lt;div style="PADDING-RIGHT:0px;PADDING-LEFT:0px;FONT-SIZE:8pt;PADDING-BOTTOM:0px;OVERFLOW:visible;WIDTH:100%;COLOR:black;BORDER-TOP-STYLE:none;LINE-HEIGHT:12pt;PADDING-TOP:0px;FONT-FAMILY:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;BORDER-RIGHT-STYLE:none;BORDER-LEFT-STYLE:none;BACKGROUND-COLOR:#f4f4f4;BORDER-BOTTOM-STYLE:none;"&gt;&lt;pre style="PADDING-RIGHT:0px;PADDING-LEFT:0px;FONT-SIZE:8pt;PADDING-BOTTOM:0px;MARGIN:0em;OVERFLOW:visible;WIDTH:100%;COLOR:black;BORDER-TOP-STYLE:none;LINE-HEIGHT:12pt;PADDING-TOP:0px;FONT-FAMILY:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;BORDER-RIGHT-STYLE:none;BORDER-LEFT-STYLE:none;BACKGROUND-COLOR:#f4f4f4;BORDER-BOTTOM-STYLE:none;"&gt;&lt;span style="COLOR:#606060;"&gt;   1:&lt;/span&gt; rules.Add(&lt;span style="COLOR:#0000ff;"&gt;new&lt;/span&gt; PatternRoute(&lt;span style="COLOR:#006080;"&gt;&amp;quot;/something/&amp;lt;parent&amp;gt;/&amp;lt;param2&amp;gt;/&amp;lt;param3&amp;gt;/&amp;quot;&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="PADDING-RIGHT:0px;PADDING-LEFT:0px;FONT-SIZE:8pt;PADDING-BOTTOM:0px;MARGIN:0em;OVERFLOW:visible;WIDTH:100%;COLOR:black;BORDER-TOP-STYLE:none;LINE-HEIGHT:12pt;PADDING-TOP:0px;FONT-FAMILY:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;BORDER-RIGHT-STYLE:none;BORDER-LEFT-STYLE:none;BACKGROUND-COLOR:#f4f4f4;BORDER-BOTTOM-STYLE:none;"&gt;&lt;span style="COLOR:#606060;"&gt;   2:&lt;/span&gt;     .DefaultForController().Is(&lt;span style="COLOR:#006080;"&gt;&amp;quot;somecontroller&amp;quot;&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="PADDING-RIGHT:0px;PADDING-LEFT:0px;FONT-SIZE:8pt;PADDING-BOTTOM:0px;MARGIN:0em;OVERFLOW:visible;WIDTH:100%;COLOR:black;BORDER-TOP-STYLE:none;LINE-HEIGHT:12pt;PADDING-TOP:0px;FONT-FAMILY:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;BORDER-RIGHT-STYLE:none;BORDER-LEFT-STYLE:none;BACKGROUND-COLOR:#f4f4f4;BORDER-BOTTOM-STYLE:none;"&gt;&lt;span style="COLOR:#606060;"&gt;   3:&lt;/span&gt;     .DefaultForAction().Is(&lt;span style="COLOR:#006080;"&gt;&amp;quot;view&amp;quot;&lt;/span&gt;));&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&lt;br /&gt;This route is a little more complex. To get a better idea of how this works, take a look at the associated action signature:&lt;/p&gt;
&lt;div&gt;
&lt;div style="PADDING-RIGHT:0px;PADDING-LEFT:0px;FONT-SIZE:8pt;PADDING-BOTTOM:0px;OVERFLOW:visible;WIDTH:100%;COLOR:black;BORDER-TOP-STYLE:none;LINE-HEIGHT:12pt;PADDING-TOP:0px;FONT-FAMILY:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;BORDER-RIGHT-STYLE:none;BORDER-LEFT-STYLE:none;BACKGROUND-COLOR:#f4f4f4;BORDER-BOTTOM-STYLE:none;"&gt;&lt;pre style="PADDING-RIGHT:0px;PADDING-LEFT:0px;FONT-SIZE:8pt;PADDING-BOTTOM:0px;MARGIN:0em;OVERFLOW:visible;WIDTH:100%;COLOR:black;BORDER-TOP-STYLE:none;LINE-HEIGHT:12pt;PADDING-TOP:0px;FONT-FAMILY:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;BORDER-RIGHT-STYLE:none;BORDER-LEFT-STYLE:none;BACKGROUND-COLOR:#f4f4f4;BORDER-BOTTOM-STYLE:none;"&gt;&lt;span style="COLOR:#606060;"&gt;   1:&lt;/span&gt; &lt;span style="COLOR:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="COLOR:#0000ff;"&gt;void&lt;/span&gt; View(&lt;span style="COLOR:#0000ff;"&gt;string&lt;/span&gt; parent, &lt;span style="COLOR:#0000ff;"&gt;string&lt;/span&gt; param2, &lt;span style="COLOR:#0000ff;"&gt;string&lt;/span&gt; param3);&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&lt;br /&gt;As you can see from this example, you can name the parameters to pass along to the action. On that same note, you can specify parameters that aren&amp;#39;t included in the url like so:&lt;/p&gt;
&lt;div&gt;
&lt;div style="PADDING-RIGHT:0px;PADDING-LEFT:0px;FONT-SIZE:8pt;PADDING-BOTTOM:0px;OVERFLOW:visible;WIDTH:100%;COLOR:black;BORDER-TOP-STYLE:none;LINE-HEIGHT:12pt;PADDING-TOP:0px;FONT-FAMILY:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;BORDER-RIGHT-STYLE:none;BORDER-LEFT-STYLE:none;BACKGROUND-COLOR:#f4f4f4;BORDER-BOTTOM-STYLE:none;"&gt;&lt;pre style="PADDING-RIGHT:0px;PADDING-LEFT:0px;FONT-SIZE:8pt;PADDING-BOTTOM:0px;MARGIN:0em;OVERFLOW:visible;WIDTH:100%;COLOR:black;BORDER-TOP-STYLE:none;LINE-HEIGHT:12pt;PADDING-TOP:0px;FONT-FAMILY:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;BORDER-RIGHT-STYLE:none;BORDER-LEFT-STYLE:none;BACKGROUND-COLOR:#f4f4f4;BORDER-BOTTOM-STYLE:none;"&gt;&lt;span style="COLOR:#606060;"&gt;   1:&lt;/span&gt; rules.Add(&lt;span style="COLOR:#0000ff;"&gt;new&lt;/span&gt; PatternRoute(&lt;span style="COLOR:#006080;"&gt;&amp;quot;/area/&amp;lt;param1&amp;gt;&amp;quot;&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="PADDING-RIGHT:0px;PADDING-LEFT:0px;FONT-SIZE:8pt;PADDING-BOTTOM:0px;MARGIN:0em;OVERFLOW:visible;WIDTH:100%;COLOR:black;BORDER-TOP-STYLE:none;LINE-HEIGHT:12pt;PADDING-TOP:0px;FONT-FAMILY:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;BORDER-RIGHT-STYLE:none;BORDER-LEFT-STYLE:none;BACKGROUND-COLOR:#f4f4f4;BORDER-BOTTOM-STYLE:none;"&gt;&lt;span style="COLOR:#606060;"&gt;   2:&lt;/span&gt;     .DefaultForController().Is(&lt;span style="COLOR:#006080;"&gt;&amp;quot;someOthercontroller&amp;quot;&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="PADDING-RIGHT:0px;PADDING-LEFT:0px;FONT-SIZE:8pt;PADDING-BOTTOM:0px;MARGIN:0em;OVERFLOW:visible;WIDTH:100%;COLOR:black;BORDER-TOP-STYLE:none;LINE-HEIGHT:12pt;PADDING-TOP:0px;FONT-FAMILY:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;BORDER-RIGHT-STYLE:none;BORDER-LEFT-STYLE:none;BACKGROUND-COLOR:#f4f4f4;BORDER-BOTTOM-STYLE:none;"&gt;&lt;span style="COLOR:#606060;"&gt;   3:&lt;/span&gt;     .DefaultForAction().Is(&lt;span style="COLOR:#006080;"&gt;&amp;quot;view&amp;quot;&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="PADDING-RIGHT:0px;PADDING-LEFT:0px;FONT-SIZE:8pt;PADDING-BOTTOM:0px;MARGIN:0em;OVERFLOW:visible;WIDTH:100%;COLOR:black;BORDER-TOP-STYLE:none;LINE-HEIGHT:12pt;PADDING-TOP:0px;FONT-FAMILY:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;BORDER-RIGHT-STYLE:none;BORDER-LEFT-STYLE:none;BACKGROUND-COLOR:#f4f4f4;BORDER-BOTTOM-STYLE:none;"&gt;&lt;span style="COLOR:#606060;"&gt;   4:&lt;/span&gt;     .DefaultFor(&lt;span style="COLOR:#006080;"&gt;&amp;quot;someOtherParam&amp;quot;&lt;/span&gt;).Is(&lt;span style="COLOR:#006080;"&gt;&amp;quot;someValue&amp;quot;&lt;/span&gt;));&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&lt;br /&gt;In this example we are calling the view action on SomeOtherController that would take a signature as follows:&lt;/p&gt;
&lt;div&gt;
&lt;div style="PADDING-RIGHT:0px;PADDING-LEFT:0px;FONT-SIZE:8pt;PADDING-BOTTOM:0px;OVERFLOW:visible;WIDTH:100%;COLOR:black;BORDER-TOP-STYLE:none;LINE-HEIGHT:12pt;PADDING-TOP:0px;FONT-FAMILY:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;BORDER-RIGHT-STYLE:none;BORDER-LEFT-STYLE:none;BACKGROUND-COLOR:#f4f4f4;BORDER-BOTTOM-STYLE:none;"&gt;&lt;pre style="PADDING-RIGHT:0px;PADDING-LEFT:0px;FONT-SIZE:8pt;PADDING-BOTTOM:0px;MARGIN:0em;OVERFLOW:visible;WIDTH:100%;COLOR:black;BORDER-TOP-STYLE:none;LINE-HEIGHT:12pt;PADDING-TOP:0px;FONT-FAMILY:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;BORDER-RIGHT-STYLE:none;BORDER-LEFT-STYLE:none;BACKGROUND-COLOR:#f4f4f4;BORDER-BOTTOM-STYLE:none;"&gt;&lt;span style="COLOR:#606060;"&gt;   1:&lt;/span&gt; &lt;span style="COLOR:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="COLOR:#0000ff;"&gt;void&lt;/span&gt; View(&lt;span style="COLOR:#0000ff;"&gt;string&lt;/span&gt; param1, &lt;span style="COLOR:#0000ff;"&gt;string&lt;/span&gt; someOtherParam);&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&lt;br /&gt;As you can see, the someOtherParam will always have a static value that we define. Not sure if this would be useful to most people but I have already had a use for it when constructing dynamic routes.&lt;/p&gt;
&lt;p&gt;One of the more complex parts of the refactorings is definately the routing. There are quite a few posts on them on the Castle Project Users Group and the Development Group so do some searches there if you have more questions about the routes.&lt;/p&gt;
&lt;p&gt;That&amp;#39;s it for now. Next time we can dive more into the refactorings and changes on the trunk. Feel free to ask any questions!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;a href="http://www.dotnetkicks.com/kick/?title=Getting+up+to+speed+with+the+Castle.MonoRail+trunk&amp;url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fsean_chambers%2farchive%2f2008%2f06%2f06%2fgetting-up-to-speed-with-the-castle-monorail-trunk.aspx"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fsean_chambers%2farchive%2f2008%2f06%2f06%2fgetting-up-to-speed-with-the-castle-monorail-trunk.aspx" border="0" alt="Kick It on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=3473" width="1" height="1"&gt;</description></item><item><title>ReSharper 4.0 Release Candidate available</title><link>http://www.lostechies.com/blogs/sean_chambers/archive/2008/06/05/resharper-4-0-release-candidate-available.aspx</link><pubDate>Thu, 05 Jun 2008 11:38:00 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:3539</guid><dc:creator>schambers</dc:creator><slash:comments>3</slash:comments><wfw:commentRss>http://www.lostechies.com/blogs/sean_chambers/rsscomments.aspx?PostID=3539</wfw:commentRss><comments>http://www.lostechies.com/blogs/sean_chambers/archive/2008/06/05/resharper-4-0-release-candidate-available.aspx#comments</comments><description>&lt;p&gt;FYI, &lt;a class="" href="http://resharper.blogspot.com/2008/06/resharper-40-release-candidate.html" target="_blank"&gt;Just read this posting&lt;/a&gt;, good news! Resharper 4 Release Candidate is now available. The last time I udpated from the nightly build has been pretty stable. A couple of minor bugs but no biggies.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Good job guys!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;a href="http://www.dotnetkicks.com/kick/?title=ReSharper+4.0+Release+Candidate+available&amp;url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fsean_chambers%2farchive%2f2008%2f06%2f05%2fresharper-4-0-release-candidate-available.aspx"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fsean_chambers%2farchive%2f2008%2f06%2f05%2fresharper-4-0-release-candidate-available.aspx" border="0" alt="Kick It on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=3539" width="1" height="1"&gt;</description></item></channel></rss>
