<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Object Mentor Blog</title>
    <link>http://blog.objectmentor.com</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>What's your favorite Kata?</title>
      <description>&lt;p&gt;I&amp;#8217;m looking to collect several katas for the &lt;a href="http://okccoco.com/"&gt;OkC CoCo&lt;/a&gt; Dojo to make sure we have plenty of future practice sessions already in place. Ultimately I want it to be at least bi-weekly (or weekly) and self sustaining. Along those lines, I&amp;#8217;d like to hear what are your favorite katas.&lt;/p&gt;


	&lt;p&gt;I&amp;#8217;d prefer you mention things you&amp;#8217;ve tried yourself. Please post links and your impressions in response to the blog. &lt;a href="http://schuchert.wikispaces.com/Katas"&gt;I&amp;#8217;ll collect them here&lt;/a&gt;, and let me know if you&amp;#8217;d like me to credit you with pointing me to the idea (or for the idea itself if you created it).&lt;/p&gt;


	&lt;p&gt;&lt;span class="caps"&gt;FWIW&lt;/span&gt;, after a little thinking, my favorite kata based on the number of times I&amp;#8217;ve used it in one manner or another is &lt;a href="http://schuchert.wikispaces.com/Katas.MonopolyTheGame%28r%29"&gt;Monopoly&amp;#174;&lt;/a&gt;.&lt;/p&gt;</description>
      <pubDate>Tue, 30 Jun 2009 15:22:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:bb9513d9-ceaa-4b1a-a4e9-f1ca8f09c418</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2009/06/30/whats-your-favorite-kata</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>kata</category>
      <category>dojo</category>
    </item>
    <item>
      <title>Another Kata: Expression Tokenizer</title>
      <description>&lt;p&gt;I continue to work on some examples for upcoming kata&amp;#8217;s at the &lt;a href="http://okccoco.com/"&gt;OkC CoCo&lt;/a&gt;. The next problem (&lt;a href="http://blog.objectmentor.com/articles/2009/06/24/shunting-yard-algorithm-kata"&gt;previously mentioned here&lt;/a&gt;) is an implementation of the &lt;a href="http://en.wikipedia.org/wiki/Shunting_yard_algorithm"&gt;Shunting Yard Algorithm&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;This past week I used that with a group in North Carolina and I discovered that it was much easier to tokenize the expression as I worked my way through it rather than attempt to make it easy to split into tokens up front.&lt;/p&gt;


	&lt;p&gt;I worked through just this smaller problem of converting an expression into tokens using the iterator pattern a few times and eventually got what I thought was a pretty good solution. I was wrong, I got it even tighter by making more appropriate use of the regular expression libraries in Java. (This is an example of where my regex mental model &amp;#8211; based primarily on grep, vi and &lt;span class="caps"&gt;AWK&lt;/span&gt; &amp;#8211; was inadequate when taking into consideration typical implementations of regex libraries with classes like Pattern and Matcher.)&lt;/p&gt;


	&lt;p&gt;Anyway, here&amp;#8217;s a writeup for that Kata: &lt;a href="http://schuchert.wikispaces.com/Katas.ExpressionTokenizer"&gt;http://schuchert.wikispaces.com/Katas.ExpressionTokenizer&lt;/a&gt;.&lt;/p&gt;


My final version turned into something crazy-short. I&lt;i&gt; &lt;b&gt;did not&lt;/b&gt;&lt;/i&gt; anticipate the final version. Part of it, as mentioned above, had to do with how I previously envisioned using regular expressions. Part of it might have been that it just took a few times for the patterns naturally occurring to become evident to me. In any case, working through this problem three times resulted in the following revelations:
	&lt;ul&gt;
	&lt;li&gt;Initially I though it would be hard, it was not and in fact much less work than what I was doing in the original problem. And it took a lot less time than I expected.&lt;/li&gt;
		&lt;li&gt;The second time around I was looking to duplicate the experience, which I did. But I saw quite a bit of improvement.&lt;/li&gt;
		&lt;li&gt;The final version was really an a-ah for me. Initially it was just like the second version. Then, once I had the tests in the kata written, I started messing around, looking for additional improvements (and heavily applying the &lt;span class="caps"&gt;DRY&lt;/span&gt; principle). I found them, exploited commonality and finally I got to the point where there was one thing I did not like, and fixing that led to a huge improvement, which led to a few more significant improvements.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Ultimately, I&amp;#8217;ll have several useful take-aways from working on the problem several times.&lt;/p&gt;


	&lt;p&gt;If you&amp;#8217;d like to see the &amp;#8220;latest final version&amp;#8221; of this, ping me. I&amp;#8217;ll consider posting it to the blog, but I&amp;#8217;d rather not give anything away without a specific request.&lt;/p&gt;</description>
      <pubDate>Mon, 29 Jun 2009 01:49:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:0f979834-b53e-47c3-b633-efa371bad5ad</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2009/06/29/another-kata-expression-tokenizer</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>kata</category>
      <category>practice</category>
      <category>regex</category>
    </item>
    <item>
      <title>The Rush</title>
      <description>&lt;p&gt;There&amp;#8217;s nothing like the feeling of achievement when you get a complex software system working.  It&amp;#8217;s the feeling of the hunter making a hard fought kill.  By the sheer power of your intellect you have imposed your will upon inanimate nature, and forced it to do your bidding.  You feel the &lt;em&gt;rush&lt;/em&gt; of power, the satisfaction of victory.  You are the master!&lt;/p&gt;


	&lt;p&gt;That&amp;#8217;s the good news.&lt;/p&gt;


	&lt;p&gt;The bad news is that you&amp;#8217;ve made a mess of things along the way.&lt;/p&gt;


	&lt;p&gt;This is inevitable.  It takes a great deal of focus and endurance to get a system working just right.  While you are consumed by that focus, you have little room for niceties like small functions, nice names, decoupling, and cleanliness.&lt;/p&gt;


	&lt;p&gt;My apprentice and I just finished achieving a major milestone in FitNesse.  It used to be that each new release of FitNesse was contained in a zip file that had all the files and directories laid out just perfectly.  This is great for a brand new installation, but doesn&amp;#8217;t work so well when you are upgrading.  What we managed to get working last night was the ability for FitNesse to self-install from it&amp;#8217;s jar file.  Now, whether you are installing for the first time, or just upgrading, FitNesse will install itself into your environment appropriately.&lt;/p&gt;


	&lt;p&gt;If you&amp;#8217;ve ever written a self-install like this, you know there are lots of niggling little details to attend to.  While the problem is conceptually simple, the realization is a maze of complexity.&lt;/p&gt;


	&lt;p&gt;Last night, with dinner waiting on the table and getting cold, we got the last little problem licked, and saw the whole self-installation work as we wanted.  We congratulated each other with a high-five, and then went upstairs to eat a well-deserved meal.  Later that evening I went down to the office and checked in the code.&lt;/p&gt;


	&lt;p&gt;This morning I woke up, and while in the shower, I realized that we had a lot of work left to do.  We need to go back over all that code and clean it up.  I&amp;#8217;m sure we left a swath of detritus while on the hunt.&lt;/p&gt;


	&lt;p&gt;The rush of victory should never be confused with the cold and crystalline concept of &lt;em&gt;done&lt;/em&gt;.  Once you get your systems to work, you still have to go back and clean up the wreckage left behind by the victorious battle.  You are not &lt;em&gt;done&lt;/em&gt; until the victorious code has been cleaned, polished, and oiled.&lt;/p&gt;</description>
      <pubDate>Fri, 26 Jun 2009 08:40:13 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:ff86f7eb-465c-43d7-8584-e9f35b3dc900</guid>
      <author>Uncle Bob</author>
      <link>http://blog.objectmentor.com/articles/2009/06/26/the-rush</link>
      <category>Uncle Bob's Blatherings</category>
      <category>Software Craftsmanship</category>
      <category>Clean Code</category>
    </item>
    <item>
      <title>Shunting Yard Algorithm Kata</title>
      <description>&lt;p&gt;Next week (end of June 2009) I hoping to schedule the second &lt;a href="http://okccoco.com/"&gt;OkC CoCo&lt;/a&gt; Dojo. The first Dojo was fun with a decent turnout. However, it was a bit &amp;#8220;loose&amp;#8221; (my fault). Loose is fine, but this time around I want to try a different approach and see how that works out.&lt;/p&gt;


	&lt;p&gt;The problem for this second Dojo is: &lt;a href="http://schuchert.wikispaces.com/Katas.ShuntingYardAlgorithm"&gt;http://schuchert.wikispaces.com/Katas.ShuntingYardAlgorithm&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;In this second Dojo, we will start with several examples with their expected results already written, as well as a link to an algorithm. The goal is to make it through as many examples as possible (in the order listed) in the time allotted.&lt;/p&gt;


	&lt;p&gt;Unlike the first Dojo where there was a brief problem description and I sort of served as a customer, in this case we have a documented algorithm and a series of examples that:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;Explicitly define desired results&lt;/li&gt;
		&lt;li&gt;Are written in a particular order to make it easy to grow the algorithm without having to take large steps&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;If you want to give this a try, &lt;a href="http://schuchert.wikispaces.com/Katas.ShuntingYardAlgorithm"&gt;the link above&lt;/a&gt; has the description I&amp;#8217;ll be starting with.&lt;/p&gt;


	&lt;p&gt;Comments welcome!&lt;/p&gt;</description>
      <pubDate>Wed, 24 Jun 2009 21:36:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:ddd711bf-9d48-48ef-9f18-48535fe9f528</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2009/06/24/shunting-yard-algorithm-kata</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>kata</category>
      <category>dojo</category>
      <category>infix</category>
      <category>postfix</category>
      <category>shunting</category>
      <category>yard</category>
    </item>
    <item>
      <title>Remote Ping-Pong Challenge: Your turn, who's next? (Java)</title>
      <description>&lt;p&gt;So I want to try a form of &lt;span class="caps"&gt;TDD&lt;/span&gt; using Ping-Pong. Problem is, you are not where I can pair with you directly. So I figured we&amp;#8217;d try a slower-form. I&amp;#8217;ll post the beginning of a problem. First person to post the next response &amp;#8220;wins&amp;#8221; &amp;#8211; that&amp;#8217;s where the next person should pick up from. We&amp;#8217;ll continue until the problem is &amp;#8220;finished.&amp;#8221;&lt;/p&gt;


	&lt;p&gt;Interested? First the ground rules, then the problem and the starting code. This is Java. However, if someone responds in another language, that&amp;#8217;s cool. I might try and follow up, but you&amp;#8217;re welcome to do so yourself. I can imagine having multiple threads going on at the same time. (If you&amp;#8217;d like your own language thread, ask and I&amp;#8217;ll post another blog entry for that particular language.)&lt;/p&gt;


&lt;h2&gt;Ground Rules&lt;/h2&gt;

	&lt;ul&gt;
	&lt;li&gt;Follow the three rules of &lt;span class="caps"&gt;TDD&lt;/span&gt; + Refactoring.&lt;/li&gt;
		&lt;li&gt;Fix the one failing test.&lt;/li&gt;
		&lt;li&gt;Add one to three more tests before posting.&lt;/li&gt;
		&lt;li&gt;Make sure you leave one and only one failing test for the next person to fix. (Meaning you can add two passing tests but leave a third test failing, or you can just add one failing test).&lt;/li&gt;
		&lt;li&gt;You can/should refactor the test code and the production code&lt;/li&gt;
		&lt;li&gt;If you feel a test is wrong, you may change it, but be prepared to justify it.&lt;/li&gt;
		&lt;li&gt;I&amp;#8217;ll serve as the customer, so I get to define what is &amp;#8220;correct&amp;#8221; &amp;#8211; however, I can be argued with and I can lose arguments (see some of my other blog postings for evidence).&lt;/li&gt;
		&lt;li&gt;Feel free to respond with comments/suggestions rather than additional tests.&lt;/li&gt;
		&lt;li&gt;Feel free to apply refactorings like extract method, rename, split loop, ... Keep the code clean!&lt;/li&gt;
	&lt;/ul&gt;


&lt;h2&gt;The Problem&lt;/h2&gt;
Translate infix notation to postfix notation. Consider reviewing &lt;a href="http://en.wikipedia.org/wiki/Shunting_yard_algorithm"&gt;The Shunting Yard Algorithm&lt;/a&gt;. But that&amp;#8217;s a guideline.&lt;p/&gt;

&lt;h2&gt;The Start&lt;/h2&gt;
Here is the test and production code. Note, when you respond, surround your code with one of the following pairs of &lt;span class="caps"&gt;HTML&lt;/span&gt; tags:

	&lt;ul&gt;
	&lt;li&gt;&amp;lt;typo:code&amp;gt;, and &amp;lt;/typo:code&amp;gt;&lt;/li&gt;
		&lt;li&gt;&amp;lt;pre&amp;gt;, and &amp;lt;/pre&amp;gt;&lt;/li&gt;
	&lt;/ul&gt;


&lt;h3&gt;InfixToPostfixConverterTest&lt;/h3&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_Java "&gt;package com.om.example;

import static org.junit.Assert.assertEquals;

import java.util.ArrayList;
import java.util.Collection;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

@RunWith(Parameterized.class)
public class InfixToPostfixConverterTest {
   private final String infix;
   private final String expectedPostfix;

   @Parameters
   public static Collection&amp;lt;String[]&amp;gt; data() {
      ArrayList&amp;lt;String[]&amp;gt; values = new ArrayList&amp;lt;String[]&amp;gt;();

      addTestCase(values, null, &amp;quot;&amp;quot;);
      addTestCase(values, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;);
      addTestCase(values, &amp;quot;45&amp;quot;, &amp;quot;45&amp;quot;);
      addTestCase(values, &amp;quot;+&amp;quot;, &amp;quot;+&amp;quot;);
      addTestCase(values, &amp;quot;3 + 8&amp;quot;, &amp;quot;3 8 +&amp;quot;);

      return values;
   }

   private static void addTestCase(ArrayList&amp;lt;String[]&amp;gt; values, String infix,
         String expectedPostfix) {
      values.add(new String[] { infix, expectedPostfix });
   }

   public InfixToPostfixConverterTest(String infix, String expectedPostfix) {
      this.infix = infix;
      this.expectedPostfix = expectedPostfix;
   }

   @Test
   public void checkTranslation() {
      InfixToPostfixConverter converter = new InfixToPostfixConverter();
      String result = converter.translate(infix);

      assertEquals(expectedPostfix, result);
   }
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3&gt;InfixToPostfixConverter&lt;/h3&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_java "&gt;package com.om.example;

public class InfixToPostfixConverter {
   public String translate(String string) {
      if(null == string)
         return &amp;quot;&amp;quot;;

      return string;
   }
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
      <pubDate>Fri, 19 Jun 2009 01:11:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:8b0dd6cc-9121-43aa-be27-dd0c502402cf</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2009/06/19/remote-ping-pong-challenge-your-turn-whos-next-java</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>ping</category>
      <category>pong</category>
      <category>pairing</category>
      <category>remote</category>
      <category>TDD</category>
    </item>
    <item>
      <title>&amp;lt;a href=&amp;quot;http://infinitest.org/web/guest/home&amp;quot;&amp;gt;Infinitest&amp;lt;/A&amp;gt; for Java, have you tried it?</title>
      <description>&lt;h2&gt;Background&lt;/h2&gt;
About 2 years ago, I was working with &lt;a href="http://twitter.com/benrady"&gt;Ben Rady&lt;/a&gt; and he demonstrated something he was working on at the time: &lt;a href="http://infinitest.org/web/guest/home"&gt;Infinitest&lt;/A&gt;. As often I am, I was a little interested but mostly skeptical &amp;#8211; don&amp;#8217;t know if that came across or not.

	&lt;p&gt;Since then he and others (e.g., &lt;a href="http://twitter.com/rcoffin"&gt;Rod Coffin&lt;/a&gt; have made amazing strides and created plugins for both Eclipse and IntelliJ.&lt;/p&gt;


&lt;h2&gt;Taking it for a test run&lt;/h2&gt;
Earlier this month, I finally decided to give it a test drive. When I made that announcement, &lt;a href="http://twitter.com/benrady"&gt;Ben&lt;/a&gt; made the following (bold?) statement:
&lt;blockquote&gt;
For me, using Infinitest is as different from &lt;span class="caps"&gt;TDD&lt;/span&gt; as &lt;span class="caps"&gt;TDD&lt;/span&gt; is from not testing
&lt;/blockquote&gt;

	&lt;p&gt;So is that true? Is using a continuous test execution tool as different from not using one as using &lt;span class="caps"&gt;TDD&lt;/span&gt; is from not testing? I&amp;#8217;m not sure I&amp;#8217;m there yet. However, I will say my brain is having some difficulty getting used to the cool feedback.&lt;/p&gt;


	&lt;p&gt;Here are two recent experiences I had using it.&lt;/p&gt;


&lt;h2&gt;Classpath Issues&lt;/h2&gt;
Back at the end of 2006 I wrote a &lt;a href="http://schuchert.wikispaces.com/EJB+3+and+Java+Persistence+API"&gt;class on using &lt;span class="caps"&gt;JPA&lt;/span&gt; and &lt;span class="caps"&gt;EJB 3&lt;/span&gt;&lt;/a&gt;. I&amp;#8217;ve not really done much to update that material in some years but recently I had an email from someone trying to work through the first tutorial with little success. Over the past few years there&amp;#8217;s been some bit-rot. The embeddable container is not really up to date, &lt;span class="caps"&gt;EJB 3&lt;/span&gt;.1 includes an embeddable container as part of its spec, Hibernate has been updated, etc. 

So I spent a few hours tracking down updated jar files and building my classpath. I had already installed &lt;a href="http://infinitest.org/web/guest/home"&gt;Infinitest&lt;/A&gt; and I noticed as added I something to my classpath, &lt;a href="http://infinitest.org/web/guest/home"&gt;Infinitest&lt;/A&gt; would kick off and show a stack trace (my code was doing that in a @Before method). So I sped up what I was doing:
	&lt;ul&gt;
	&lt;li&gt;I directly edited the .classpath file in Eclipse&lt;/li&gt;
		&lt;li&gt;Saved what I was doing&lt;/li&gt;
		&lt;li&gt;Waited about a second&lt;/li&gt;
		&lt;li&gt;Noticed the new stack trace&lt;/li&gt;
		&lt;li&gt;Found the next jar file I needed to add&lt;/li&gt;
		&lt;li&gt;Repeat until tests passed.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Might sound like a bit of overkill, but in the end I built a classpath from scratch and I ended up adding 13 jar files. So it saved some time.&lt;/p&gt;


	&lt;p&gt;Note, I wasn&amp;#8217;t looking for this. I had only installed &lt;a href="http://infinitest.org/web/guest/home"&gt;Infinitest&lt;/A&gt; the day before so this was unexpected and welcome! Oh, and before my @Before method was handling the exception properly, &lt;a href="http://infinitest.org/web/guest/home"&gt;Infinitest&lt;/A&gt; showed that the code had a problem (it was in the @After with a null pointer exception), which it indicated as an error like a syntax error or a validation error. Nice!&lt;/p&gt;


&lt;h2&gt;Using &lt;a href="http://mockito.org/"&gt;Mockito&lt;/a&gt;&lt;/h2&gt;
I&amp;#8217;ve recently been using &lt;a href="http://mockito.org/"&gt;Mockito&lt;/a&gt;. You can review &lt;a href="http://blog.objectmentor.com/articles/2009/05/27/mockito-example-java-mocking-framework"&gt;a previous blog entry&lt;/a&gt; for that example. Today we&amp;#8217;re holding the first &lt;a href="http://codingdojo.org/"&gt;coding dojo&lt;/a&gt; at the recently opened &lt;a href="http://okccoco.com/"&gt;OkC CoCo&lt;/a&gt;. Last night I started working on the next problem I want to use for the next dojo. It involves practicing using a &lt;a href="http://www.martinfowler.com/articles/mocksArentStubs.html#ClassicalAndMockistTesting"&gt;mockist approach&lt;/a&gt;. I set up my classpath, started writing tests and immediately I noticed what looked like a syntax error on the verification step of my first unit test. I was confused thinking I had an actual syntax error since I&amp;#8217;m not quite to the point of touch-typing &lt;a href="http://mockito.org/"&gt;Mockito&lt;/a&gt; based tests (I did update Eclipse so I could &lt;a href="http://jdcarlflip.blogspot.com/2008/07/eclipse-tip-static-imports.html"&gt;more easily find the static imports&lt;/a&gt;).&lt;p/&gt;

	&lt;p&gt;Next, I updated my test to use the @Mock annotation. I removed the hand-written initialization and immediately I noticed a &amp;#8220;syntax&amp;#8221; error &amp;#8211; null pointer exception. I was immediately (OK 1 second later) showed the impact of removing a single line of code. I added the missing line to auto-initialize the @Mock annotated fields but I did it incorrectly, so the error remained. I finally got the line correct and the &amp;#8220;syntax error&amp;#8221; went away.&lt;/p&gt;


&lt;h2&gt;Observations&lt;/h2&gt;
Wow. That&amp;#8217;s what I have to say so far. I&amp;#8217;m not entirely sure the before and after of using &lt;a href="http://infinitest.org/web/guest/home"&gt;Infinitest&lt;/A&gt; is the same size as moving from not testing to using &lt;span class="caps"&gt;TDD&lt;/span&gt;. Maybe it&amp;#8217;s the same as moving from being &lt;a href="http://c2.com/cgi/wiki?TestInfected"&gt;Test Infected&lt;/a&gt; to practicing &lt;span class="caps"&gt;TDD&lt;/span&gt;. I was &lt;a href="http://c2.com/cgi/wiki?TestInfected"&gt;Test Infected&lt;/a&gt; several years before I practiced &lt;span class="caps"&gt;TDD&lt;/span&gt;. 

	&lt;p&gt;I was also about as skeptical that moving to &lt;span class="caps"&gt;TDD&lt;/span&gt; from being &lt;a href="http://c2.com/cgi/wiki?TestInfected"&gt;Test Infected&lt;/a&gt; was useful. I was wrong. History tends to repeat itself, so I&amp;#8217;m guessing, based on my initial resistance, that this is the future.&lt;/p&gt;


	&lt;p&gt;Embrace it.&lt;/p&gt;</description>
      <pubDate>Thu, 18 Jun 2009 11:35:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:e0b1e630-9d3c-4830-a1c9-87cfb0cea6d3</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2009/06/18/infinitest-for-java-have-you-tried-it</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>infinitest</category>
      <category>TDD</category>
      <category>test</category>
      <category>infected</category>
      <category>mock</category>
      <category>mockito</category>
      <category>ejb</category>
      <category>3</category>
      <category>jpa</category>
    </item>
    <item>
      <title>Challenge: How would you start this problem?</title>
      <description>&lt;p&gt;On Thursday, we&amp;#8217;re holding our first &lt;a href="http://codingdojo.org/"&gt;Coding Dojo&lt;/a&gt; at the recently opened &lt;a href="http://okccoco.com/"&gt;OkC CoCo&lt;/a&gt;. This isn&amp;#8217;t the first Coding Dojo to happen in Oklahoma City. Some time back, &lt;a href="http://davenicolette.wikispaces.com/"&gt;Dave Nicolette&lt;/a&gt; held a &lt;a href="http://davenicolette.wikispaces.com/TDD+Randori+and+Fishbowl"&gt;Randori with a Fishbowl&lt;/a&gt; at the OkC Java User&amp;#8217;s Group, and that&amp;#8217;s the format I&amp;#8217;ll be using for &lt;a href="http://schuchert.wikispaces.com/Rpn+Calculator+High+Level+Description"&gt;this problem&lt;/a&gt;. It was a blast then and I&amp;#8217;m hoping it&amp;#8217;ll be the same this time around.&lt;/p&gt;


	&lt;p&gt;This first DoJo is with C#, though I hope we manage to use several languages over time. I&amp;#8217;d like to sneak in Smalltalk as soon as we have enough of a critical mass so we don&amp;#8217;t lose people. I also plan to slowly introduce &lt;span class="caps"&gt;BDD&lt;/span&gt; (maybe not so slowly, who knows &amp;#8211; depends on the group).&lt;/p&gt;


	&lt;p&gt;The recent refactoring exercises (&lt;a href="http://blog.objectmentor.com/articles/2009/06/09/another-refactoring-exercise-design-patterns-recommended"&gt;here&lt;/a&gt; and &lt;a href="http://blog.objectmentor.com/articles/2009/06/04/refactoring-exercise"&gt;here&lt;/a&gt;), they come from &lt;a href="http://schuchert.wikispaces.com/Rpn+Calculator+High+Level+Description"&gt;this problem&lt;/a&gt;. We&amp;#8217;ll be starting from scratch, so you can probably imagine that those refactoring examples are not going to come up right away (actually probably not at all given the time).&lt;/p&gt;


	&lt;p&gt;So your challenge this time is not one of refactoring but rather one of an initial value problem. Given &lt;a href="http://schuchert.wikispaces.com/Rpn+Calculator+High+Level+Description"&gt;the problem statement&lt;/a&gt;, how would&lt;i&gt; &lt;b&gt;you&lt;/b&gt;&lt;/i&gt; go about starting it? I&amp;#8217;m assuming &lt;span class="caps"&gt;TDD&lt;/span&gt;, do you make that same assumption? If so, what&amp;#8217;s your first test? Your first few tests? What features do you try to tackle first? What questions do you ask yourself about the problem?&lt;/p&gt;


I&amp;#8217;ve used this problem several times and it&amp;#8217;s a great problem to practice many things including:
	&lt;ul&gt;
	&lt;li&gt;Test Driven Development&lt;/li&gt;
		&lt;li&gt;refactoring (lower case r deliberate &amp;#8211; can you guess why?)&lt;/li&gt;
		&lt;li&gt;Refactoring to Design Patterns&lt;/li&gt;
		&lt;li&gt;Most of the &lt;span class="caps"&gt;SOLID&lt;/span&gt; principles&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Anyway, how would you go about starting this problem? Or better yet, give it a try and post your first few tests (in the order you create them).&lt;/p&gt;


	&lt;p&gt;I&amp;#8217;ll be interested in seeing how people start and I&amp;#8217;ll compare it to what I&amp;#8217;ve done (hint, I use this as a class-driven thing, so I&amp;#8217;m pretty flexible on how to start it).&lt;/p&gt;


	&lt;p&gt;p.s. As a result of studying the &lt;a href="http://h10032.www1.hp.com/ctg/Manual/bpia5305.pdf"&gt;manual for my &lt;span class="caps"&gt;HP 32SII&lt;/span&gt;&lt;/a&gt;, I have a much better understanding of just how its stack works. I have a EE and CS background, so the stack implementation makes sense, but I left some of its details out of the problem.&lt;/p&gt;</description>
      <pubDate>Wed, 17 Jun 2009 00:16:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:cd259101-5576-45c4-99b6-866ae4207d25</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2009/06/17/challenge-how-would-you-start-this-problem</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>TDD</category>
      <category>randori</category>
      <category>dojo</category>
      <category>okccoco</category>
    </item>
    <item>
      <title>Hiding global methods, a C++ example</title>
      <description>&lt;h2&gt;Background&lt;/h2&gt;
This is a continuation of &lt;a href="http://blog.objectmentor.com/articles/2009/06/08/tdding-an-interface-a-twitter-influenced-discussion"&gt;this discussion&lt;/a&gt;. A few of the postings by GBGames have been swallowed so the context is somewhat lost. What follows is an excerpt from an email he sent me and some example C++ code that demonstrates making global methods &amp;#8220;testable&amp;#8221; in a sense. Or rather, making your code not use global methods during test.
&lt;h3&gt;The Offending Method&lt;/h3&gt;
Here is a method that GBGames has under test:
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;void SDLHardwareLayer::initializeHardware()
{
    const SDL_version * sdlVersion = SDL_Linked_Version();
    if (sdlVersion-&amp;gt;minor &amp;lt; 2 &amp;amp;&amp;amp; sdlVersion-&amp;gt;major &amp;lt; 2)
    {
        //Error message
    }
    else if (SDL_Init(SDL_INIT_VIDEO |
            SDL_INIT_AUDIO |
            SDL_INIT_NOPARACHUTE) &amp;lt; 0)
    {
        //Error message
    }
    else
    {
        m_screen = SDL_SetVideoMode(m_x, m_y, m_bitDepth, SDL_DOUBLEBUF);
        if (NULL != m_screen)
        {
            SDL_WM_SetCaption(m_title.c_str(), 0);
        }
    }
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;This is how this code is organized:&lt;p/&gt;
&lt;img src="http://yuml.me/diagram/scruffy/class/%5BSDLHardwareLayer%5D-%3E%5B...%20global%20methods%20...%5D"/&gt;&lt;/p&gt;


&lt;h3&gt;So What&amp;#8217;s Wrong?&lt;/h3&gt;
One problem he notes is that the test code driving this production code causes windows to pop up during testing. Is this a problem? If it works, then it may be OK. However, you can remove that and also make test-ability a bit easier. You&amp;#8217;ll be testing interactions and responses rather than directly using the library through its global functions.

&lt;h2&gt;Global Functions Considered Harmful&lt;/h2&gt;
First off, this code as written directly uses global functions. If you leave this code unchanged, then the only option you have to &amp;#8220;fix&amp;#8221; the problem of windows popping up is a link-seam (see &lt;a href="http://www.amazon.com/Working-Effectively-Legacy-Robert-Martin/dp/0131177052/ref=sr_1_1?ie=UTF8&amp;#38;s=books&amp;#38;qid=1244820344&amp;#38;sr=8-1"&gt;Working Effective with Legacy Code&lt;/a&gt;, page 233-234. In a nutshell, a link seam will link different versions of a library, one for testing, one for actual execution. So you&amp;#8217;ll need some &amp;#8220;make fu&amp;#8221; to get the link seam working in a manner that easily allows building for testing versus building for execution.

Since we&amp;#8217;re using C++ and&lt;i&gt; &lt;b&gt;we own this code&lt;/b&gt;&lt;/i&gt;, I chose a different route:
	&lt;ul&gt;
	&lt;li&gt;Change this code to use an object that uses the library&lt;/li&gt;
		&lt;li&gt;That object implements an interface (a base class with all pure virtual methods)&lt;/li&gt;
		&lt;li&gt;Change this code so that it acquires this object through a factory (I could have simply used constructor injection, but I&amp;#8217;ve already written it using a configurable factory [really singleton] &amp;#8211; but it would have been simpler if I had injected the interface)&lt;/li&gt;
		&lt;li&gt;Created a test double that can be used when writing new test doubles making code maintenance a bit easier (mentioned in the other blog posting).&lt;/li&gt;
		&lt;li&gt;Write test-method specific test doubles&lt;/li&gt;
	&lt;/ul&gt;


&lt;h3&gt;Changing Code to Use Factory + Object w/virtual Methods&lt;/h3&gt;
Rather than directly calling the various global &lt;span class="caps"&gt;SDL&lt;/span&gt;_* methods, e.g.:
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;const SDL_version * sdlVersion = SDL_Linked_Version();&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
I instead use a factory to get an instance and call 
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;const SDL_version * sdlVersion = SdlLayerFactory::getInstance()-&amp;gt;SDL_Linked_Version();&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Base Interface&lt;/h3&gt;
To make this work, I created a base interface representing all of the methods needed by the &lt;b&gt;SDLHardwareLayer::initializeHardware&lt;/b&gt;:
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;#pragma once

struct SDL_version;

class SdlLayerInstanceDelegator {
public:
  virtual ~SdlLayerInstanceDelegator(void) = 0;

  virtual const SDL_version *SDL_Linked_Version() = 0;
  virtual int SDL_Init(int bitMask) = 0;
  virtual void *SDL_SetVideoMode(int x, int y, int bitDepth, int mode) = 0;
  virtual void SDL_WM_SetCaption(const char *title, int someIntValue) = 0;

protected:
  SdlLayerInstanceDelegator();

private:
  SdlLayerInstanceDelegator(const SdlLayerInstanceDelegator &amp;amp;rhs);
  SdlLayerInstanceDelegator &amp;amp;operator = (const SdlLayerInstanceDelegator &amp;amp;);
};&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Real Calls Global Methods&lt;/h3&gt;
Getting rid of the direct call to the global method makes this work. However, you still need to call those global methods somewhere. That&amp;#8217;s where the &amp;#8220;real&amp;#8221; version of the interface comes in. The real version of this class simply calls the global methods (code only, not showing header file right now):
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;const SDL_version *RealSdlLayerInstanceDelegator::SDL_Linked_Version() {
  return ::SDL_Linked_Version();
}

int RealSdlLayerInstanceDelegator::SDL_Init(int bitMask) {
  return ::SDL_Init(bitMask);
}

void *RealSdlLayerInstanceDelegator::SDL_SetVideoMode(int x, int y, int bitDepth, int mode) {
  return ::SDL_SetVideoMode(x, y, bitDepth, mode);
}

void RealSdlLayerInstanceDelegator::SDL_WM_SetCaption(const char *title, int someIntValue) {
  ::SDL_WM_SetCaption(title, someIntValue);
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;The Factory: Inversion of Control&lt;/h3&gt;
The original code directly used global methods. We need to invert this relationship so that rather than depending directly on those methods, it depends on an interface. Then if it happens that it uses a &amp;#8220;real&amp;#8221; version, the underlying code will call the actual library. If, however, it is instead using a test double, it will not. It will do whatever the test double dictates. 

	&lt;p&gt;We cannot leave the decision of which object to talk to in the SdlHardwareLayer class. Instead, I&amp;#8217;ve used a configurable factory (singleton). A test can configure the factory, call the method under test, and then reset the factory back after the test.&lt;/p&gt;


The SdlLayerFactory allows such use(again, code only, no header file):
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;SdlLayerInstanceDelegator *SdlLayerFactory::instance = 0;

SdlLayerInstanceDelegator *SdlLayerFactory::getInstance() {
  return instance;
}

SdlLayerInstanceDelegator *SdlLayerFactory::replaceInstance(SdlLayerInstanceDelegator *replacement) {
  SdlLayerInstanceDelegator *original = instance;
  instance = replacement;
  return original;
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Handling Growing Interfaces&lt;/h3&gt;
One problem with &amp;#8220;interfaces&amp;#8221; in any language is that as you add methods to them, their implementations need to be updated. Since the SdlLayerInstanceDelegator class is not complete yet, this will case problems with test doubles. There are three ways to handle this problem:
* Deal with it, as you add new methods to the interface, update all existing classes
* Use a mocking library &amp;#8211; I have not used any for C++, but if this were Java I&amp;#8217;d use Mockito and if this were .Net I&amp;#8217;d use Moq.
* Create a base test double that implements all of the methods. All test doubles derive from that and only implement the methods needed for test.

	&lt;p&gt;The last option does not fix the problem, it controls it. When new methods are added, you update one test double class and all other classes still work.&lt;/p&gt;


	&lt;p&gt;This may not sound like much of an issue, but in general you&amp;#8217;ll have many small test doubles rather than a few large test doubles (or at least that&amp;#8217;s the standard recommendation). Why? Because a small, focused test double is less likely to be broken. It also better expressed your intention.&lt;/p&gt;


	&lt;p&gt;Here is that test double (header file excluded again):
&lt;b&gt;TestDoubleSdlLayerInstanceDelegator.h&lt;/b&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;#pragma once
#include &amp;quot;SdlLayerInstanceDelegator.h&amp;quot;

class TestDoubleSdlLayerInstanceDelegator: public SdlLayerInstanceDelegator {
public:
  TestDoubleSdlLayerInstanceDelegator();
  virtual ~TestDoubleSdlLayerInstanceDelegator();

  const SDL_version *SDL_Linked_Version();
  int SDL_Init(int bitMask);
  void *SDL_SetVideoMode(int x, int y, int bitDepth, int mode);
  void SDL_WM_SetCaption(const char *title, int someIntValue);
};&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;


	&lt;p&gt;&lt;b&gt;TestDoubleSdlLayerInstanceDelegator.cpp&lt;/b&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;#include &amp;quot;TestDoubleSdlLayerInstanceDelegator.h&amp;quot;

TestDoubleSdlLayerInstanceDelegator::TestDoubleSdlLayerInstanceDelegator(){}

TestDoubleSdlLayerInstanceDelegator::~TestDoubleSdlLayerInstanceDelegator(){}

const SDL_version *TestDoubleSdlLayerInstanceDelegator::SDL_Linked_Version() {
  return 0;
}

int TestDoubleSdlLayerInstanceDelegator::SDL_Init(int bitMask) {
  return 0;
}

void *TestDoubleSdlLayerInstanceDelegator::SDL_SetVideoMode(int x, int y, int bitDepth, int mode) {
  return 0;
}

void TestDoubleSdlLayerInstanceDelegator::SDL_WM_SetCaption(const char *title, int someIntValue){}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;A Test&lt;/h3&gt;
Finally, we need some tests and some test-specific test-doubles:
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;#include &amp;lt;CppUTest/TestHarness.h&amp;gt;

#include &amp;quot;sdl.h&amp;quot;
#include &amp;quot;SdlLayerFactory.h&amp;quot;
#include &amp;quot;SdlHardwareLayer.h&amp;quot;
#include &amp;quot;TestDoubleSdlLayerInstanceDelegator.h&amp;quot;

TEST_GROUP(SdlHardwareLayerTest) {
  virtual void setup() {
    original = SdlLayerFactory::getInstance();
    layer = new SdlHardwareLayer;
  }

  virtual void teardown() {
    if(SdlLayerFactory::getInstance() != original)
      delete SdlLayerFactory::getInstance();

    SdlLayerFactory::replaceInstance(original);
    delete layer;
  }

  SdlLayerInstanceDelegator *original;
  SdlHardwareLayer *layer;
};

struct MajorMinorSdlhardwareLayer : public TestDoubleSdlLayerInstanceDelegator {
  struct SDL_version v;

  MajorMinorSdlhardwareLayer() {
    v.major = 0;
    v.minor = 0;
  }

  const SDL_version *SDL_Linked_Version() {
    return &amp;amp;v;
  }
};

TEST(SdlHardwareLayerTest, ItGeneratsErrorWithLowMajorMinorVersionNumber) {
  SdlLayerFactory::replaceInstance(new MajorMinorSdlhardwareLayer);
  try {
    layer-&amp;gt;initializeHardware();
    FAIL(&amp;quot;Should have thrown int value&amp;quot;);
  } catch (int value) {
    LONGS_EQUAL(1, value);
  }
}

struct InitFailingSdlHardwareLayer : public MajorMinorSdlhardwareLayer {
  InitFailingSdlHardwareLayer () {
    v.major = 3;
    v.minor = 3;
  }

  int SDL_Init(int bitMask) {
    return -1;
  }
};

TEST(SdlHardwareLayerTest, ItGeneratesErrorWhenInitReturnsLessThan0) {
  SdlLayerFactory::replaceInstance(new InitFailingSdlHardwareLayer);
  try {
    layer-&amp;gt;initializeHardware();
    FAIL(&amp;quot;Should have thrown int value&amp;quot;);
  } catch (int value) {
    LONGS_EQUAL(2, value);
  }
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;


	&lt;p&gt;Notice that there are two test doubles. Also notice that I create them as full (implicitly) inlined classes. Virtual methods and inline methods do not interact well. C++ will make a copy of the method bodies in every .o and increase link times. However, these test classes are only used in one place, so this really does not cause any problems.&lt;/p&gt;


In lieu of a mocking library, this is how I&amp;#8217;d really write this code.
&lt;h2&gt;The Final Big Picture&lt;/h2&gt;
Here&amp;#8217;s an image of the completed product:
&lt;img src="http://yuml.me/diagram/scruffy;scale:80/class/%5BSdlLayerHardwareTest%5D-%3E%5BTestDoubleSdlLayerInstanceDelegator%5D,%20%5BSdlLayerHardwareTest%5D-%3E%5BSdlLayerHardware%5D,%20%5BSdlLayerHardwareTest%5D-%3E%5BSdlLayerFactory%5D,%20%5BSdlLayerHardware%5D-%3E%5BSdlLayerFactory%5D,%20%5BSdlLayerHardware%5D-%3E%5BSdlLayerInstanceDelegator%5D,%20%5BSdlLayerInstanceDelegator%5D%5E%5BRealSdlLayerInstanceDelegator%5D,%20%5BRealSdlLayerInstanceDelegator%5D-%3E%5B...%20global%20methods%20...%5D,%20%5BSdlLayerInstanceDelegator%5D%5E%5BTestDoubleSdlLayerInstanceDelegator%5D,%20%5BTestDoubleSdlLayerInstanceDelegator%5D%5E%5BMajorMinorSdlhardwareLayer%5D,%20%5BTestDoubleSdlLayerInstanceDelegator%5D%5E%5BInitFailingSdlHardwareLayer%5D,%20%5BSdlLayerFactory%5D-%3E%5BSdlLayerInstanceDelegator%5D"/&gt;
&lt;h2&gt;Summary&lt;/h2&gt;
So is this overkill? Is using the actual &lt;span class="caps"&gt;SDL&lt;/span&gt; library causing problems? Is it OK for windows to appear during test? I&amp;#8217;m neutral on that subject. The question I want to know is: are the tests working?&lt;p/&gt;
&lt;ul&gt;&lt;li&gt;Do they add value or are they busy work.&lt;/li&gt;
&lt;li&gt;Do they allow me to make small, incremental steps towards a complete, working implementation&lt;/li&gt;
&lt;li&gt;Do they run fast enough?&lt;/li&gt;
&lt;li&gt;Will they run in any environment? (Can I run on a headless system?)&lt;/li&gt;
&lt;li&gt;Can I run multiple tests at the same time? (Not generally an issue, but it can be.)&lt;/li&gt;&lt;/ul&gt;

	&lt;p&gt;If the &lt;span class="caps"&gt;SDL&lt;/span&gt; library is not causing a problem, then this might be overkill. However, on a long-lived project, this little amount of extra work will pay big dividends.&lt;/p&gt;


Oh, how long did this really take? Around 1.5 hours. But that included:
	&lt;ul&gt;
	&lt;li&gt;Starting a Windows &lt;span class="caps"&gt;XP VM&lt;/span&gt;&lt;/li&gt;
		&lt;li&gt;Creating a new projec&lt;/li&gt;
		&lt;li&gt;Setting up the link paths and include paths&lt;/li&gt;
		&lt;li&gt;Creating the initial file and the necessary support to get it to compile&lt;/li&gt;
		&lt;li&gt;Writing the additional classes&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;In fact, the actual work was probably &amp;lt; 30 minutes total. So while this might look big, in fact it is not. It&amp;#8217;s nearly an idiom, so it&amp;#8217;s mostly a matter of putting the hooks in place. So is full isolation from &lt;span class="caps"&gt;SDL&lt;/span&gt; worth 30 minutes?&lt;/p&gt;


&lt;p style="font-size:40px;text-align:center"&gt;Yes!&lt;/p&gt;
&lt;h2&gt;All your source files are belong to us&lt;/h2&gt;
If this looks like a complete example, it is. I have this building and running in Visual Studio 2008. I took GBGame&amp;#8217;s original method and got it to compile and link with a minimal set of additional source files. Then I made the structural changes to support test. And here&amp;#8217;s all of the source code, file by file:&lt;p/&gt;
&lt;b&gt;sdl.h&lt;/b&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;#pragma once

extern &amp;quot;C&amp;quot; {
  const int SDL_INIT_VIDEO = 1;
  const int SDL_INIT_AUDIO = 2;
  const int SDL_INIT_NOPARACHUTE = 4;
  const int SDL_DOUBLEBUF = 8;

  struct SDL_version {
    int major;
    int minor;
  };

  const SDL_version *SDL_Linked_Version();
  int SDL_Init(int bitMask);
  void *SDL_SetVideoMode(int x, int y, int bitDepth, int mode);
  void SDL_WM_SetCaption(const char *title, int someIntValue);
};&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;&lt;b&gt;sdl_implementation.cpp&lt;/b&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;#include &amp;quot;sdl.h&amp;quot;

const SDL_version *SDL_Linked_Version() {
  return 0;
}

int SDL_Init(int bitMask) {
  return  - 1;
}

void *SDL_SetVideoMode(int x, int y, int bitDepth, int mode) {
  return 0;
}

void SDL_WM_SetCaption(const char *title, int someIntValue){}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;hr/&gt;
&lt;b&gt;SdlHardwareLayer.h&lt;/b&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;#pragma once

#include &amp;lt;string&amp;gt;

class SdlHardwareLayer {
public:
  SdlHardwareLayer();
  virtual ~SdlHardwareLayer();
  void initializeHardware();

private:
  int m_x;
  int m_y;
  int m_bitDepth;
  std::string m_title;
  void *m_screen;
};&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;


	&lt;p&gt;&lt;b&gt;SdlHardwarelayer.cpp&lt;/b&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;#include &amp;quot;SdlHardwareLayer.h&amp;quot;

#include &amp;quot;sdl.h&amp;quot;
#include &amp;quot;SdlLayerFactory.h&amp;quot;
#include &amp;quot;SdlLayerInstanceDelegator.h&amp;quot;

SdlHardwareLayer::SdlHardwareLayer() {
}

SdlHardwareLayer::~SdlHardwareLayer() {
}

void SdlHardwareLayer::initializeHardware() {
    const SDL_version * sdlVersion = SdlLayerFactory::getInstance()-&amp;gt;SDL_Linked_Version();
    if (sdlVersion-&amp;gt;minor &amp;lt; 2 &amp;amp;&amp;amp; sdlVersion-&amp;gt;major &amp;lt; 2) {
      throw 1;
    }
    else if (SdlLayerFactory::getInstance()-&amp;gt;SDL_Init(SDL_INIT_VIDEO |
            SDL_INIT_AUDIO |
            SDL_INIT_NOPARACHUTE) &amp;lt; 0) {
              throw 2;
    }
    else {
        m_screen = SDL_SetVideoMode(m_x, m_y, m_bitDepth, SDL_DOUBLEBUF);
        if (0 != m_screen) {
            SDL_WM_SetCaption(m_title.c_str(), 0);
        }
    }
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;hr/&gt;
&lt;b&gt;SdlLayerFactory.h&lt;/b&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;#pragma once

class SdlLayerInstanceDelegator;

class SdlLayerFactory
{
public:
  static SdlLayerInstanceDelegator *getInstance();
  static SdlLayerInstanceDelegator *replaceInstance(SdlLayerInstanceDelegator *replacement);

private:
  static SdlLayerInstanceDelegator *instance;

  SdlLayerFactory();
  ~SdlLayerFactory();
};&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;


	&lt;p&gt;&lt;b&gt;SdlLayerFactory.cpp&lt;/b&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;#include &amp;quot;SdlLayerFactory.h&amp;quot;

SdlLayerInstanceDelegator *SdlLayerFactory::instance = 0;

SdlLayerFactory::SdlLayerFactory(){}

SdlLayerFactory::~SdlLayerFactory(){}

SdlLayerInstanceDelegator *SdlLayerFactory::getInstance() {
  return instance;
}

SdlLayerInstanceDelegator *SdlLayerFactory::replaceInstance(SdlLayerInstanceDelegator *replacement) {
  SdlLayerInstanceDelegator *original = instance;
  instance = replacement;
  return original;
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;hr/&gt;
&lt;b&gt;SdlLayerInstanceDelegator.h&lt;/b&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;#pragma once

struct SDL_version;

class SdlLayerInstanceDelegator {
public:
  virtual ~SdlLayerInstanceDelegator(void) = 0;

  virtual const SDL_version *SDL_Linked_Version() = 0;
  virtual int SDL_Init(int bitMask) = 0;
  virtual void *SDL_SetVideoMode(int x, int y, int bitDepth, int mode) = 0;
  virtual void SDL_WM_SetCaption(const char *title, int someIntValue) = 0;

protected:
  SdlLayerInstanceDelegator();

private:
  SdlLayerInstanceDelegator(const SdlLayerInstanceDelegator &amp;amp;rhs);
  SdlLayerInstanceDelegator &amp;amp;operator = (const SdlLayerInstanceDelegator &amp;amp;);
};&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;


	&lt;p&gt;&lt;b&gt;SdlLayerInstanceDelegator.cpp&lt;/b&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;#include &amp;quot;SdlLayerInstanceDelegator.h&amp;quot;

SdlLayerInstanceDelegator::SdlLayerInstanceDelegator(){}

SdlLayerInstanceDelegator::~SdlLayerInstanceDelegator(){}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;hr/&gt;
&lt;b&gt;TestDoubleSdlLayerInstanceDelegator.h&lt;/b&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;#pragma once
#include &amp;quot;SdlLayerInstanceDelegator.h&amp;quot;

class TestDoubleSdlLayerInstanceDelegator: public SdlLayerInstanceDelegator {
public:
  TestDoubleSdlLayerInstanceDelegator();
  virtual ~TestDoubleSdlLayerInstanceDelegator();

  const SDL_version *SDL_Linked_Version();
  int SDL_Init(int bitMask);
  void *SDL_SetVideoMode(int x, int y, int bitDepth, int mode);
  void SDL_WM_SetCaption(const char *title, int someIntValue);
};&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;


	&lt;p&gt;&lt;b&gt;TestDoubleSdlLayerInstanceDelegator.cpp&lt;/b&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;#include &amp;quot;TestDoubleSdlLayerInstanceDelegator.h&amp;quot;

TestDoubleSdlLayerInstanceDelegator::TestDoubleSdlLayerInstanceDelegator(){}

TestDoubleSdlLayerInstanceDelegator::~TestDoubleSdlLayerInstanceDelegator(){}

const SDL_version *TestDoubleSdlLayerInstanceDelegator::SDL_Linked_Version() {
  return 0;
}

int TestDoubleSdlLayerInstanceDelegator::SDL_Init(int bitMask) {
  return 0;
}

void *TestDoubleSdlLayerInstanceDelegator::SDL_SetVideoMode(int x, int y, int bitDepth, int mode) {
  return 0;
}

void TestDoubleSdlLayerInstanceDelegator::SDL_WM_SetCaption(const char *title, int someIntValue){}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;hr/&gt;
&lt;b&gt;RealSdlLayerInstanceDelegator.h&lt;/b&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;#pragma once
#include &amp;quot;SdlLayerInstanceDelegator.h&amp;quot;

class RealSdlLayerInstanceDelegator : public SdlLayerInstanceDelegator
{
public:
  RealSdlLayerInstanceDelegator();
  virtual ~RealSdlLayerInstanceDelegator();

  const SDL_version *SDL_Linked_Version();
  int SDL_Init(int bitMask);
  void *SDL_SetVideoMode(int x, int y, int bitDepth, int mode);
  void SDL_WM_SetCaption(const char *title, int someIntValue);
};&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;


	&lt;p&gt;&lt;b&gt;RealSdlLayerInstanceDelegator.cpp&lt;/b&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;#include &amp;quot;RealSdlLayerInstanceDelegator.h&amp;quot;
#include &amp;quot;sdl.h&amp;quot;

RealSdlLayerInstanceDelegator::RealSdlLayerInstanceDelegator(){}

RealSdlLayerInstanceDelegator::~RealSdlLayerInstanceDelegator(){}

const SDL_version *RealSdlLayerInstanceDelegator::SDL_Linked_Version() {
  return ::SDL_Linked_Version();
}

int RealSdlLayerInstanceDelegator::SDL_Init(int bitMask) {
  return ::SDL_Init(bitMask);
}

void *RealSdlLayerInstanceDelegator::SDL_SetVideoMode(int x, int y, int bitDepth, int mode) {
  return ::SDL_SetVideoMode(x, y, bitDepth, mode);
}

void RealSdlLayerInstanceDelegator::SDL_WM_SetCaption(const char *title, int someIntValue) {
  ::SDL_WM_SetCaption(title, someIntValue);
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;hr/&gt;
&lt;b&gt;SdlHardwareLayerTest.h&lt;/b&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;#include &amp;lt;CppUTest/TestHarness.h&amp;gt;

#include &amp;quot;sdl.h&amp;quot;
#include &amp;quot;SdlLayerFactory.h&amp;quot;
#include &amp;quot;SdlHardwareLayer.h&amp;quot;
#include &amp;quot;TestDoubleSdlLayerInstanceDelegator.h&amp;quot;

TEST_GROUP(SdlHardwareLayerTest) {
  virtual void setup() {
    original = SdlLayerFactory::getInstance();
    layer = new SdlHardwareLayer;
  }

  virtual void teardown() {
    if(SdlLayerFactory::getInstance() != original)
      delete SdlLayerFactory::getInstance();

    SdlLayerFactory::replaceInstance(original);
    delete layer;
  }

  SdlLayerInstanceDelegator *original;
  SdlHardwareLayer *layer;
};

struct MajorMinorSdlhardwareLayer : public TestDoubleSdlLayerInstanceDelegator {
  struct SDL_version v;

  MajorMinorSdlhardwareLayer() {
    v.major = 0;
    v.minor = 0;
  }

  const SDL_version *SDL_Linked_Version() {
    return &amp;amp;v;
  }
};

TEST(SdlHardwareLayerTest, ItGeneratsErrorWithLowMajorMinorVersionNumber) {
  SdlLayerFactory::replaceInstance(new MajorMinorSdlhardwareLayer);
  try {
    layer-&amp;gt;initializeHardware();
    FAIL(&amp;quot;Should have thrown int value&amp;quot;);
  } catch (int value) {
    LONGS_EQUAL(1, value);
  }
}

struct InitFailingSdlHardwareLayer : public MajorMinorSdlhardwareLayer {
  InitFailingSdlHardwareLayer () {
    v.major = 3;
    v.minor = 3;
  }

  int SDL_Init(int bitMask) {
    return -1;
  }
};

TEST(SdlHardwareLayerTest, ItGeneratesErrorWhenInitReturnsLessThan0) {
  SdlLayerFactory::replaceInstance(new InitFailingSdlHardwareLayer);
  try {
    layer-&amp;gt;initializeHardware();
    FAIL(&amp;quot;Should have thrown int value&amp;quot;);
  } catch (int value) {
    LONGS_EQUAL(2, value);
  }
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;hr/&gt;
&lt;b&gt;RunAllTests.cpp&lt;/b&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;#include &amp;lt;CppUTest/CommandLineTestRunner.h&amp;gt;

int main(int ac, char **av) {
  return CommandLineTestRunner::RunAllTests(ac, av);
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;</description>
      <pubDate>Fri, 12 Jun 2009 10:13:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:543cf808-17c0-48cd-ba07-6c4ac936f152</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2009/06/12/hiding-global-methods-a-c-example</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>c</category>
      <category>global</category>
      <category>methods</category>
      <category>wrapping</category>
      <category>testing</category>
      <category>test</category>
      <category>isolation</category>
    </item>
    <item>
      <title>Another Refactoring Exercise: Design Patterns Recommended!-)</title>
      <description>&lt;p&gt;Well the previous exercise was fun so here&amp;#8217;s another one. The following code is taken from the same problem, an &lt;span class="caps"&gt;RPN&lt;/span&gt; calculator. Originally, the interface of the calculator was &amp;#8220;wide&amp;#8221;; there was a method for each operator. E.g., plus(), minus(), factorial(). In an effort to fix this, a new method, perform(String operatorName) was added and ultimately the interface was fixed gradually to remove those methods.&lt;/p&gt;


	&lt;p&gt;Changing he calculator &lt;span class="caps"&gt;API&lt;/span&gt; in this way is an example of applying the open/closed principle. However, the resulting code is just a touch ugly (I made it a little extra ugly just for the hack [sic] of it). This code as written does pass all of my unit tests.&lt;/p&gt;


Before the code, however, let me give you a little additional information:
	&lt;ul&gt;
	&lt;li&gt;I changed the calculator to use BigDecimal instead of int&lt;/li&gt;
		&lt;li&gt;Right now the calculator has three operators, +, &amp;#8211; !&lt;/li&gt;
		&lt;li&gt;Eventually, there will be many operators (50 ish)&lt;/li&gt;
		&lt;li&gt;Right now there are only binary and unary operators, however there will be other kinds: ternary, quaternary, and others such as sum the stack and replace just the sum on the stack or calculate the prime factors of the top of the stack so take one value but push many values&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;So have a look at the following code and then either suggest changes or provide something better. There&amp;#8217;s a lot that can be done to this code to make it clearer and make the system easier to extend.&lt;/p&gt;


&lt;h3&gt;The Perform Method&lt;/h3&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_Java "&gt;   public void perform(String operatorName) {
      BigDecimal op1 = stack.pop();

      if (&amp;quot;+&amp;quot;.equals(operatorName)) {
         BigDecimal op2 = stack.pop();
         stack.push(op1.add(op2));
         currentMode = Mode.inserting;
      } else if (&amp;quot;-&amp;quot;.equals(operatorName)) {
         BigDecimal op2 = stack.pop();
         stack.push(op2.subtract(op1));
         currentMode = Mode.inserting;
      } else if (&amp;quot;!&amp;quot;.equals(operatorName)) {
         op1 = op1.round(MathContext.UNLIMITED);
         BigDecimal result = BigDecimal.ONE;
         while (op1.compareTo(BigDecimal.ONE) &amp;gt; 0) {
            result = result.multiply(op1);
            op1 = op1.subtract(BigDecimal.ONE);
         }
         stack.push(result);
      } else {
         throw new MathOperatorNotFoundException();
      }
   }&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;Unlike the last example, I&amp;#8217;ll provide the entire class. Feel free to make changes to this class as well. However, for now focus on the&lt;i&gt; &lt;b&gt;perform(...)&lt;/b&gt;&lt;/i&gt; method.&lt;/p&gt;


	&lt;p&gt;One note, Philip Schwarz recommended a change to what I proposed to avoid the command/query separation violation. I applied his recommendation before posting this updated version.&lt;/p&gt;


&lt;h3&gt;The Whole Class&lt;/h3&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_Java "&gt;package com.scrippsnetworks.calculator;

import java.math.BigDecimal;
import java.math.MathContext;

public class RpnCalculator {
   private OperandStack stack = new OperandStack();
   private Mode currentMode = Mode.accumulating;

   enum Mode {
      accumulating, replacing, inserting
   };

   public RpnCalculator() {
   }

   public void take(BigDecimal value) {
      if (currentMode == Mode.accumulating)
         value = determineNewTop(stack.pop(), value);

      if (currentMode == Mode.replacing)
         stack.pop();

      stack.push(value);
      currentMode = Mode.accumulating;
   }

   private BigDecimal determineNewTop(BigDecimal currentTop, BigDecimal value) {
      BigDecimal newTopValue = currentTop;
      String digits = value.toString();
      while (digits.length() &amp;gt; 0) {
         newTopValue = newTopValue.multiply(BigDecimal.TEN);
         newTopValue = newTopValue.add(new BigDecimal(Integer.parseInt(digits
               .substring(0, 1))));
         digits = digits.substring(1);
      }

      return newTopValue;
   }

   public void enter() {
      stack.dup();
      currentMode = Mode.replacing;
   }

   public void perform(String operatorName) {
      BigDecimal op1 = stack.pop();

      if (&amp;quot;+&amp;quot;.equals(operatorName)) {
         BigDecimal op2 = stack.pop();
         stack.push(op1.add(op2));
         currentMode = Mode.inserting;
      } else if (&amp;quot;-&amp;quot;.equals(operatorName)) {
         BigDecimal op2 = stack.pop();
         stack.push(op2.subtract(op1));
         currentMode = Mode.inserting;
      } else if (&amp;quot;!&amp;quot;.equals(operatorName)) {
         op1 = op1.round(MathContext.UNLIMITED);

         BigDecimal result = BigDecimal.ONE;
         while (op1.compareTo(BigDecimal.ONE) &amp;gt; 0) {
            result = result.multiply(op1);
            op1 = op1.subtract(BigDecimal.ONE);
         }
         stack.push(result);
      } else {
         throw new MathOperatorNotFoundException();
      }
   }

   public BigDecimal getX() {
      return stack.x();
   }

   public BigDecimal getY() {
      return stack.y();
   }

   public BigDecimal getZ() {
      return stack.z();
   }

   public BigDecimal getT() {
      return stack.t();
   }
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
      <pubDate>Tue, 09 Jun 2009 20:57:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:9a050400-2d6e-4f85-a4a5-f4081b39f1e5</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2009/06/09/another-refactoring-exercise-design-patterns-recommended</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>refactoring</category>
      <category>exercise</category>
      <category>design</category>
      <category>patterns</category>
      <category>abstract</category>
      <category>factory</category>
      <category>strategy</category>
      <category>template</category>
      <category>method</category>
    </item>
    <item>
      <title>Slim table examples with fixtures in C#</title>
      <description>&lt;p&gt;There was not a lot of interest in a series of tutorials. Some, yes, but not very much. So I&amp;#8217;m not going to be spending much time right now writing FitNesse.Slim tutorials for C#.&lt;/p&gt;


	&lt;p&gt;However, I think it&amp;#8217;s a good idea to at least have some examples of each of the tables so those few that are so inclined, have something from which to start.&lt;/p&gt;


	&lt;p&gt;Have a look: &lt;a href="http://schuchert.wikispaces.com/FitNesse.Tutorials.CSharp.Slim.EachTable"&gt;C# Slim Examples&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Mon, 08 Jun 2009 23:15:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:a44fd087-a7c9-45db-9de3-504bdfcd1b8c</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2009/06/08/slim-table-examples-with-fixtures-in-c</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>FitNesse</category>
      <category>slim</category>
      <category>c</category>
    </item>
    <item>
      <title>Metrics of Moment</title>
      <description>&lt;p&gt;There are two metrics that I think are quite useful in the pursuit of clean code.  One is &lt;a href="http://www.crap4j.org/faq.html"&gt;Crap&lt;/a&gt;, and the other is &lt;a href="http://peripateticaxiom.blogspot.com/2006/05/complexity-and-test-first-0.html"&gt;The Braithwaite Correlation&lt;/a&gt;.  The first is a pragmatic call to action, the second is a measure of overall care.&lt;/p&gt;


	&lt;h2&gt;&lt;span class="caps"&gt;CRAP&lt;/span&gt;&lt;/h2&gt;


	&lt;p&gt;I&amp;#8217;ve written about Crap &lt;a href="http://blog.objectmentor.com/articles/2009/05/20/clean-code-and-battle-scarred-architecture"&gt;before&lt;/a&gt;.  It&amp;#8217;s a very clever metric that combines test coverage and cyclomatic complexity.  You want to keep this metric low.  (FitNesse is currently at &lt;a href="http://internal.objectmentor.com:9090/job/fitnesse/"&gt;0.07&lt;/a&gt;).  Crap will skyrocket if you have a method with high CC and no coverage.  You can bring it down if you 1) split the method up into a group of low CC methods or 2) cover the method with tests or 3) both.&lt;/p&gt;


	&lt;p&gt;One of the more useful elements of &lt;span class="caps"&gt;CRAP&lt;/span&gt; is that it measures the &amp;#8220;crappiness&amp;#8221; of individual methods, and provides you with a list of the worst.  (Fitnesse has &lt;a href="http://internal.objectmentor.com:9090/job/fitnesse/crap/"&gt;very few&lt;/a&gt; crappy methods at the moment.)  This list of crappy methods gives you targets to attack.  You see a method whose &lt;span class="caps"&gt;CRAP&lt;/span&gt; metric is 30, or 50, you target it for decomposition and coverage.  In this way you can engage in a program to bring the &amp;#8220;Crappyness Trend&amp;#8221; (i.e. the ratio of crappy methods to total methods.) down.&lt;/p&gt;


	&lt;p&gt;What is the benefit of brining crappiness down?  Apparently there is a &lt;a href="http://www.enerjy.com/blog/?p=198"&gt;strong correlation&lt;/a&gt; between CC and defects.  So an effort to either reduce CC or increase coverage in high CC modules seems an appropriate way of reducing defects.  Of course the &lt;em&gt;real&lt;/em&gt; reason to target crappy modules is that &lt;span class="caps"&gt;CRAP&lt;/span&gt; is a measure of care&amp;#8212;or rather it&amp;#8217;s lack.&lt;/p&gt;


	&lt;p&gt;If you have high &lt;span class="caps"&gt;CRAP&lt;/span&gt; numbers it simply means that you have been careless with your code.  Big &lt;span class="caps"&gt;CRAP&lt;/span&gt; means that your methods are long, complicated, and untested.  And that&amp;#8217;s just slovenly behavior.  Sorry, that&amp;#8217;s just the way it is.&lt;/p&gt;


	&lt;h2&gt;The Braithwaite Correlation&lt;/h2&gt;


	&lt;p&gt;Despite the fact that this metric sounds like a movie title, this metric  &lt;em&gt;excites&lt;/em&gt; me.  The creator, Keith Braithwaite is duly humble about it; but I think it&amp;#8217;s a significant discovery.  The math behind the metric may be a bit hi-falutin for some folks, but the logic is &lt;em&gt;very&lt;/em&gt; compelling.  If you don&amp;#8217;t know what the terms &amp;#8220;scale-free&amp;#8221;, &amp;#8220;power-law&amp;#8221;, and/or &amp;#8220;log-log&amp;#8221; mean, don&amp;#8217;t worry.  It wouldn&amp;#8217;t hurt you to learn these concepts, but the bottom line is very simple.&lt;/p&gt;


	&lt;p&gt;The Braithwaite Correlation is simply a measure of how many methods have high Cyclomatic-complexity.  Well, OK, that&amp;#8217;s not precisely true.  It&amp;#8217;s actually a measure of how CC is distributed amongst all the methods.  Suffice it to say that if this number is &lt;em&gt;small&lt;/em&gt;, then many methods have a &lt;em&gt;high&lt;/em&gt; CC.  (notice the inversion.)&lt;/p&gt;


	&lt;p&gt;Now here&amp;#8217;s the interesting bit.  BC is not dependent upon the size of the program being measured.  Two different programs that have the same BC, have the same distribution of CC amongst their methods.  One program may have a thousand methods, and the other may have only 20, but the &lt;em&gt;distribution&lt;/em&gt; is the same.  Therefore BC can be viewed in an absolute sense.  For example, we can say that we want our programs to have a BC &amp;gt; 2.&lt;/p&gt;


	&lt;p&gt;Actually the number 2 seems to have a special significance.  Keith&amp;#8217;s research so far shows that programs developed with &lt;span class="caps"&gt;TDD&lt;/span&gt; almost always have a BC greater than 2.  Whereas programs developed without &lt;span class="caps"&gt;TDD&lt;/span&gt; almost always have a BC less than 2.  (FitNesse currently has a BC ~= 2.88)&lt;/p&gt;


	&lt;p&gt;What is the value of measuring BC in your code?  If BC is high it means that your methods are generally small and simple, and that very few are large and complex.  If BC is low, it means that more of your methods are larger and more complicated.  And since we know that CC is strongly correlated with defects, we can surmise that high BC correlates with low defects.&lt;/p&gt;


	&lt;p&gt;But again, the &lt;em&gt;real&lt;/em&gt; reason to keep BC high is that it simply reflects a greater amount of care.&lt;/p&gt;


	&lt;h2&gt;Conclusion&lt;/h2&gt;


	&lt;p&gt;The conclusion is simple.  These metrics are easy to measure&lt;sup&gt;&lt;a href="#fn1"&gt;1&lt;/a&gt;&lt;/sup&gt; and so you should be measuring them &lt;em&gt;now&lt;/em&gt;.  What&amp;#8217;s more, these metrics (especially &lt;span class="caps"&gt;CRAP&lt;/span&gt;) tell you where to focus your energies.  You can take &lt;em&gt;action&lt;/em&gt; that will have an immediate and direct effect on the quality of your code that correlates to defect rate.&lt;/p&gt;


	&lt;p&gt;So what are you waiting for?&lt;/p&gt;


	&lt;p id="fn1"&gt;&lt;sup&gt;1&lt;/sup&gt; For java programmers the tools already exist to measure these metrics, and they are very simple to use.   For everyone else, the tools that calculate CC and coverage are readily available.  Combining them to calculate these two metrics just isn&amp;#8217;t that hard.&lt;/p&gt;</description>
      <pubDate>Mon, 08 Jun 2009 11:26:51 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:8c11168a-cf2d-454c-bb15-e41f0de8d1be</guid>
      <author>Uncle Bob</author>
      <link>http://blog.objectmentor.com/articles/2009/06/08/metrics-of-moment</link>
    </item>
    <item>
      <title>TDDing an Interface - a Twitter influenced discussion</title>
      <description>&lt;h2&gt;Background&lt;/h2&gt;
I&amp;#8217;ve collected a few quick notes regarding &lt;span class="caps"&gt;TDD&lt;/span&gt; and interfaces (as in Java/C# or C++ classes with all pure virtual methods). You dynamic-language-using-types (near irony intentional) can read and laugh to yourselves! You don&amp;#8217;t need stinking interfaces, right?
&lt;p/&gt;
Note, these are based on a few questions from someone I follow on twitter. I considered leaving out the original poster, but since it&amp;#8217;s on twitter, I guess that&amp;#8217;s not really going to stay hidden. And, quite frankly, his questions are pretty good and quite common.

	&lt;p&gt;I&amp;#8217;m interested in seeing what other people have to say about this.&lt;/p&gt;


Here&amp;#8217;s the original question from &lt;a href="http://twitter.com/GBGames"&gt;@GBGames&lt;/a&gt;:
&lt;blockquote&gt;
When TDDing, I see info on using interfaces, but how do interfaces get created through &lt;span class="caps"&gt;TDD&lt;/span&gt;? How do you unit test your way to an interface?
&lt;/blockquote&gt;

&lt;h2&gt;Interfaces and &lt;span class="caps"&gt;TDD&lt;/span&gt;&lt;/h2&gt;
There are several reasons an interface comes up while practicing &lt;span class="caps"&gt;TDD&lt;/span&gt;, here are two:
&lt;ul&gt;&lt;li&gt;You have some existing code that has a concrete dependency on something and you want to remove that relationship.&lt;/li&gt;
&lt;li&gt;You are working on new production code, taking a &lt;a href="http://martinfowler.com/articles/mocksArentStubs.html#SoShouldIBeAClassicistOrAMockist"&gt;mockist&lt;/a&gt; approach and you want to create an object, inject dependencies represented by test-doubles that implement interfaces that do not yet exist.&lt;/li&gt;&lt;/ul&gt;

	&lt;p&gt;&lt;a href="http://twitter.com/GBGames"&gt;@GBGames&lt;/a&gt; goes on to write (remember, this was in Twitter, so I left the abbreviations and such as is):
&lt;blockquote&gt;
Game uses HardwareLayer. HL used libSDL but don&amp;#8217;t need &lt;span class="caps"&gt;SDL&lt;/span&gt; for unit tests so I wanted &lt;span class="caps"&gt;IHL&lt;/span&gt; for a mockHL. But how to get &lt;span class="caps"&gt;IHL&lt;/span&gt;? Most info I find assumes interface exists or class exists to extract interface. I feel like I&amp;#8217;m trying to do 2 things at once.
&lt;/blockquote&gt;&lt;/p&gt;


This additional information suggests something like the following:
&lt;p/&gt;
&lt;img src="http://yuml.me/diagram/scale:50;scruffy/class/%5BGame%5D-%3E%5BHardwareLayer%5D,%20%5BHardwareLayer%5D-%3E%5BLibSDL%5D.jpg" border="0" /&gt;
&lt;p/&gt;

&lt;p/&gt;&lt;a href="http://twitter.com/GBGames"&gt;@GBGames&lt;/a&gt; suggests using an IHardwareLayer to fully get rid of libSDL, which is a fine approach. Another approach is testing the HardwareLayer directly (with unit tests on the HardwareLayer) and passing in an adapter to libSDL (basically an ILibSdl):
&lt;img src="http://yuml.me/diagram/scale:50;scruffy;dir:lr/class/%5BHardwareLayer%5D-%3E%5BILibSDL%5D,%20%5BILibSDL%5D%5E%5BRealLibSdl%5D,%20%5BILibSDL%5D%5E%5BTestDoubleLibSdl%5D,%20%5BRealLibSdl%5D-%3E%5BLibSDL%5D.jpg" border="0" /&gt;
&lt;h2&gt;What are we Testing?&lt;/h2&gt;
If the goal is to test responsibility/functionality that belongs in the Game, then creating the IHardwareLayer is the right thing to do. The game only cares about the hardware layer and not the libSDL. If the goal is to test responsibility/functionality that belongs to the Hardware Layer, then that&amp;#8217;s where we should start.

However, this decision is academic. Why? &lt;a href="http://twitter.com/GBGames"&gt;@GBGames&lt;/a&gt;&amp;#8217;s original question was, in a nutshell:
&lt;blockquote&gt;
When using &lt;span class="caps"&gt;TDD&lt;/span&gt; to test a class that depends on an interface that does not yet exist, how do you go about doing that?
&lt;/blockquote&gt;

He observed, correctly, that it seems like you are doing two things at the same time, and you are:
	&lt;ul&gt;
	&lt;li&gt;What methods exist in the interface&lt;/li&gt;
		&lt;li&gt;How will the class under test use that interface.&lt;/li&gt;
	&lt;/ul&gt;


So how to proceed? &lt;a href="http://schuchert.wikispaces.com/Mockito.LoginServiceExample"&gt;Here&amp;#8217;s an example&lt;/a&gt; I posted a little while back that demonstrates the use of Mockito. My original intent was to demonstrate Mockito. However, that example also shows how, over a series of tests, I:
	&lt;ul&gt;
	&lt;li&gt;Create interfaces&lt;/li&gt;
		&lt;li&gt;Add methods to those interfaces needed to add functionality&lt;/li&gt;
		&lt;li&gt;Set expectations on the use of those interfaces&lt;/li&gt;
	&lt;/ul&gt;


There are a few important points from the original question:
	&lt;ul&gt;
	&lt;li&gt;The Hardware layer, apparently, does not yet exist.&lt;/li&gt;
		&lt;li&gt;By extension, the interface does not yet exist.&lt;/li&gt;
		&lt;li&gt;When writing the real hardware layer class, it will ultimately have to implement all of the methods in the interface created while TDDing the game class&lt;/li&gt;
		&lt;li&gt;Writing the actual hardware layer class will require TDDing it, and passing in an ILibSDL class. This is not strictly necessary, but if you want to test the HardwareLayer without using the real lib &lt;span class="caps"&gt;SDL&lt;/span&gt;, that&amp;#8217;s your best option.&lt;/li&gt;
	&lt;/ul&gt;


&lt;h2&gt;Now to get more concrete&lt;/h2&gt;
So let&amp;#8217;s assume that in fact we are starting from scratch on a game and we want to develop it without requiring a real hardware layer. Is it reasonable to assume the use of a hardware layer before we&amp;#8217;ve even started writing the game? I say yes. What do you say?

So I&amp;#8217;d need to come up with some tests (test categories) to get started (I&amp;#8217;m just making this up, I don&amp;#8217;t have any idea what GBGames is actually working on right now):
	&lt;ul&gt;
	&lt;li&gt;Creating a game properly initializes the hardware layer&lt;/li&gt;
		&lt;li&gt;Creating a game properly acquires some kind of game configuration information, which is used to configure the hardware layer (e.g., preferred resolution, color depth, anti-aliasing, ...)
(Do you see that even these two test categories actually suggest more than just two classes if you consider the single responsibility principle.)&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;This is enough to start to express my intent. Almost time to start with something.&lt;/p&gt;


One final set of questions before I get really started: 
	&lt;ul&gt;
	&lt;li&gt;One assertion per test?&lt;/li&gt;
		&lt;li&gt;&lt;span class="caps"&gt;TDD&lt;/span&gt; or &lt;span class="caps"&gt;BDD&lt;/span&gt; (At the very lest, looks like we&amp;#8217;re staring outside in)&lt;/li&gt;
		&lt;li&gt;...&lt;/li&gt;
	&lt;/ul&gt;


&lt;h3&gt;Test 1: Initializing&lt;/h3&gt;
How about when I create a game, I want to make sure that it sends some basic initialization to the HardwareLayer:
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;package com.om.example.gameandhw;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

import org.junit.Test;

public class GameTest {
  @Test
  public void itShouldInitializeHardwareLayerDringGameConstruction() {
    IHardwareLayer layer = mock(IHardwareLayer.class);
    new Game(layer);
    verify(layer, times(1)).setResolution(1024, 768);
    verify(layer, times(1)).setColorDepth(8);
  }
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

Note that this is the final test. I had to stop on each of the four lines:
	&lt;ul&gt;
	&lt;li&gt;On the first line, I had to create and interface IHardwareLayer, no methods.&lt;/li&gt;
		&lt;li&gt;On the first line, I also had to stop to statically import the mock method.&lt;/li&gt;
		&lt;li&gt;On the second line I had to stop and create the Game class.&lt;/li&gt;
		&lt;li&gt;On the second line I had to stop and add a constructor with a parameter (the injected IHardwareLayer, for which I use the Mockito library to create a test-double, which I am using as a Spy)&lt;/li&gt;
		&lt;li&gt;On the third line I had to stop to add the method setResolution to the IHardwareLayer interface.&lt;/li&gt;
		&lt;li&gt;On the third line I had to stop to add the static import of the verify method.&lt;/li&gt;
		&lt;li&gt;On the fourth line I had to stop to add the setColorDepth method to the IHardwareLayer interface.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;(Trust me, it too&lt;i&gt; &lt;b&gt;much&lt;/b&gt;&lt;/i&gt; longer to type that list than to do the work. The actual work was well under 30 seconds to do all of that.)&lt;/p&gt;


After this test compiled, but did not pass, I had to write the method for Game. Here are the other two java files I created as a result of this single test (getting the test to pass the first time was included in that 30 seconds above):
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;package com.om.example.gameandhw;

public interface IHardwareLayer {
  void setResolution(int widthInBits, int heightInBits);
  void setColorDepth(int bitsPerChannel);
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;package com.om.example.gameandhw;

public class Game {
  public Game(IHardwareLayer layer) {
    layer.setResolution(1024, 768);
    layer.setColorDepth(8);
  }
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;Now I have&lt;i&gt; &lt;b&gt;no&lt;/b&gt;&lt;/i&gt; idea if this is even beginning to make any sense for the original problem. This is where having a pair partner with expertise on the game requirements (and maybe some idea about this libSDL) would greatly help.&lt;/p&gt;


	&lt;p&gt;Notice, however, that as I try to write the Game class, I am adding methods to the IHardwareLayer class &lt;span class="caps"&gt;AND&lt;/span&gt; figuring out how the game will interact with those methods.&lt;/p&gt;


	&lt;p&gt;Hope this helps GBGames. I also hope to see some discussion in the comments section.&lt;/p&gt;


	&lt;p&gt;Brett&lt;/p&gt;</description>
      <pubDate>Mon, 08 Jun 2009 00:26:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:f9cbb22e-044a-4ca9-bc67-908d2e23944f</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2009/06/08/tdding-an-interface-a-twitter-influenced-discussion</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>interface</category>
      <category>TDD</category>
    </item>
    <item>
      <title>Calling C# and FitNesse Users</title>
      <description>&lt;p&gt;Are you using C# and FitNesse? Considering moving to FitNesse.Slim?&lt;/p&gt;


	&lt;p&gt;I eventually plan to port &lt;a href="http://schuchert.wikispaces.com/FitNesse.Tutorials"&gt;several FitNesse.Slim tutorials written in Java&lt;/a&gt; to C#. It&amp;#8217;s a bit of work so I want to make sure there&amp;#8217;s enough interest now (this is about&lt;i&gt; &lt;b&gt;when&lt;/i&gt;&lt;/b&gt; not if). Given that C# and Java are similar languages, I&amp;#8217;m not convinced it&amp;#8217;s really necessary right now. I&amp;#8217;m under the impression that the user base for FitNesse.Slim + C# is small, but I&amp;#8217;m often wrong. I have other things I want to get around to writing, so I&amp;#8217;m trying to get a temperature reading to know what might be useful next.&lt;/p&gt;


If this would help you or your team, what would you like to see?
	&lt;ul&gt;
	&lt;li&gt;Just the basics, all the tables and an example of each (quick to do)&lt;/li&gt;
		&lt;li&gt;Something more comprehensive, building story tests and working through to &lt;span class="caps"&gt;TDD&lt;/span&gt; to build a system from the ground up?&lt;/li&gt;
		&lt;li&gt;A full porting of the existing tutorials as is?&lt;/li&gt;
		&lt;li&gt;...&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;I&amp;#8217;m really looking for some user stories from some actual candidate users. If that&amp;#8217;s you or you know someone and you like being a proxy, please respond.&lt;/p&gt;


	&lt;p&gt;Thanks!&lt;/p&gt;


	&lt;p&gt;Brett&lt;/p&gt;</description>
      <pubDate>Sat, 06 Jun 2009 00:43:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:5d83d538-e622-4f71-919b-d3639a4853c5</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2009/06/06/calling-c-and-fitnesse-users</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>FitNesse</category>
      <category>slim</category>
      <category>c</category>
    </item>
    <item>
      <title>Rich Hickey on Testing</title>
      <description>&lt;p&gt;It was an interesting week at JavaOne, with lots of talks and hallway discussions about new languages on the &lt;span class="caps"&gt;JVM&lt;/span&gt;. One of those languages is Clojure.&lt;/p&gt;


	&lt;p&gt;Rich Hickey, the creator of Clojure, gave a talk at the Bay Area Clojure User Group Wednesday evening. During the Q&amp;#38;A part, he said that he&amp;#8217;s not big on writing tests, although he always runs the tests that other people have written before he commits changes.&lt;/p&gt;


	&lt;p&gt;Of course, there are many people, including us Object Mentors, who consider &lt;span class="caps"&gt;TDD&lt;/span&gt; to be an essential part of professional software development. Obviously not everyone agrees. James Coplien has been another critic of this view.&lt;/p&gt;


	&lt;p&gt;We should never accept any dogma. Why is &lt;span class="caps"&gt;TDD&lt;/span&gt; considered important? What does it purport to do? &lt;span class="caps"&gt;TDD&lt;/span&gt; provides two important benefits.&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;Driving the design.&lt;/li&gt;
		&lt;li&gt;Building a suite of automated regression tests.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;So, if you can satisfy both requirements without &lt;span class="caps"&gt;TDD&lt;/span&gt;, then technically you don&amp;#8217;t need it. In Rich&amp;#8217;s case, he said he spends a lot of time thinking about what he&amp;#8217;s going to do before he does it. In this way, he satisfies the first requirement, driving the design. I had a spirited discussion with some Thoughtworkers afterwards and Ola Bini said what a lot of us think, &amp;#8220;I do that thinking by writing tests.&amp;#8221; I&amp;#8217;ll freely admit that when I am really experimenting with ideas, I might just write code, but once I know how to proceed, I return to the beginning and test drive the &amp;#8220;production&amp;#8221; code.&lt;/p&gt;


	&lt;p&gt;Rich also made an off-hand comment that if he screws something up, he&amp;#8217;s got thousands of users who will let him know! That &lt;em&gt;ex post facto&lt;/em&gt; testing, along with the Rich&amp;#8217;s own devotion to doing high-quality work, does a good job of handling regressions.&lt;/p&gt;


	&lt;p&gt;But Rich mentioned something else that is also very important. In a functional language, where values are immutability and mutable state is handled in specific, principled ways, regressions don&amp;#8217;t happen nearly as often. Clojure has one of the most deeply thought out approaches for handling state, which is the genius of Clojure.&lt;/p&gt;


	&lt;p&gt;I asked Rich how long he worked on Clojure before releasing it to the world. He spent about 2 1/2 years, much of that time working exclusively on Clojure (and eating through his savings). When he finally &amp;#8220;announced&amp;#8221; it, his &amp;#8220;marketing&amp;#8221; consisted of one email to some friends in the Common Lisp community. The rest was viral, a testament to the justified excitement Clojure has generated.&lt;/p&gt;


	&lt;p&gt;For me, I&amp;#8217;ll probably always do my design thinking through tests, especially when I&amp;#8217;m writing code in imperative languages, like Java and Ruby. I&amp;#8217;ll continue to encourage my clients to use &lt;span class="caps"&gt;TDD&lt;/span&gt;, because I find that &lt;span class="caps"&gt;TDD&lt;/span&gt; is the most productive way to achieve high quality. I want the safety net of a good test suite. I&amp;#8217;m also writing more and more of my code in a functional style, with minimal side effects and mutable data. You should, too.&lt;/p&gt;</description>
      <pubDate>Fri, 05 Jun 2009 12:40:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:1af0ef13-e2af-4bbe-aa1a-158f3813eeaa</guid>
      <author>Dean Wampler</author>
      <link>http://blog.objectmentor.com/articles/2009/06/05/rich-hickey-on-testing</link>
      <category>Dean's Deprecations</category>
      <category>Software Craftsmanship</category>
      <category>Design Principles</category>
      <category>clojure</category>
      <category>TDD</category>
      <category>testing</category>
    </item>
    <item>
      <title>Bay-Area Scala Enthusiasts (BASE) Meeting: What's New In Scala 2.8</title>
      <description>&lt;p&gt;This week is JavaOne in San Francisco. The Bay-Area Scala Enthusiasts (BASE) held their monthly meeting. Martin Odersky, the creator of Scala, was the special guest. He discussed what&amp;#8217;s new In Scala 2.8, followed by Q&amp;#38;A. We met at Twitter HQ.&lt;/p&gt;


	&lt;p&gt;These are my notes, focusing primarily on Martin&amp;#8217;s presentation, and filled in afterwards with additional details. Any transcription errors or erroneous extrapolations are my own fault. It&amp;#8217;s also late in the day&amp;#8230;&lt;/p&gt;


	&lt;p&gt;Some of the features are not yet in the &lt;span class="caps"&gt;SVN&lt;/span&gt; trunk, so don&amp;#8217;t assume my examples actually work! See the &lt;a href="http://scala-lang.org"&gt;scala-lang.org&lt;/a&gt; for more details on Scala 2.8 features.&lt;/p&gt;


	&lt;p&gt;There are a few more months before it is released. A preview is planned for July, followed by the final release in September or October.&lt;/p&gt;


	&lt;h2&gt;New Features&lt;/h2&gt;


	&lt;p&gt;Here are the new features for this release.&lt;/p&gt;


	&lt;h3&gt;Named and Default Arguments&lt;/h3&gt;


	&lt;p&gt;Scala method parameters can be declared to with default values, so callers don&amp;#8217;t have to specify a value and the &lt;code&gt;implicit&lt;/code&gt; convention doesn&amp;#8217;t have to be used. The default &amp;#8220;values&amp;#8221; aren&amp;#8217;t limited to constants. Any valid expression can be used. Here is an example that I made up (not in Martin&amp;#8217;s slides) that illustrates both specifying and using one default argument and using named arguments.&lt;/p&gt;


&lt;pre&gt;
    &lt;code&gt;
def joiner(strings: List[String], separator: String = " ") = strings.mkString(separator)

val strs = List("Now", "is", "the", "time", "for", "all", "good", "men", "...")
println(joiner(strs))
println(joiner(strs, "|"))
println(joiner(strings = strs, separator = "-"))
    &lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;Named and default arguments enable an elegant enhancement to case classes. It&amp;#8217;s great that I can declare a succinct value class like this.&lt;/p&gt;


&lt;pre&gt;
    &lt;code&gt;
case class Person(firstName: String, lastName: String, age: Int)
    &lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;What if I want to make a copy that modifies one or more fields. There&amp;#8217;s no elegant way to add such a method in 2.7 without implementing every permutation, that is every possible combination of fields I might want to change. The new &lt;code&gt;copy&lt;/code&gt; method will make this easy.&lt;/p&gt;


&lt;pre&gt;
    &lt;code&gt;
case class Person(firstName: String, lastName: String, age: Int)

val youngPerson = Person("Dean", "Wampler", 29)
val oldPerson = youngPerson copy (age = 30)
    &lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;I&amp;#8217;m using the infix notation for method invocation on the last line (&lt;em&gt;i.e.,&lt;/em&gt; it&amp;#8217;s equivalent to &lt;code&gt;... youngPerson.copy(...)&lt;/code&gt;). I can specify any combination of the fields I want to change in the list passed to &lt;code&gt;copy&lt;/code&gt;. The generated implementation of &lt;code&gt;copy&lt;/code&gt; will use the current values of any other fields as the default values.&lt;/p&gt;


	&lt;p&gt;The implementation looks something like this.&lt;/p&gt;


&lt;pre&gt;
    &lt;code&gt;
case class Person(firstName: String, lastName: String, age: Int) {
  def copy (fName: String = this.firstName, 
            lName: String = this.lastName, 
            aje: Int = this.age) = new Person(fName, lName, aje)
}
    &lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;Quite elegant, once you have default and named arguments!!&lt;/p&gt;


	&lt;p&gt;Defaults for parameters can&amp;#8217;t refer to previous parameters in the list, unless the function is curried. (I&amp;#8217;m not sure I got this right, nor do I understand the reasons why this is true &amp;#8211; if it&amp;#8217;s true!)&lt;/p&gt;


	&lt;p&gt;By the way, Martin reminded us that method parameters are always evaluated left to right at the call site. Do you remember the rules for Java, C++, C#,...?&lt;/p&gt;


	&lt;h3&gt;Nested Annotations&lt;/h3&gt;


	&lt;p&gt;Annotations can now be nested, which is important for using some of the standard annotation definitions in the &lt;span class="caps"&gt;JDK&lt;/span&gt; and &lt;span class="caps"&gt;JEE&lt;/span&gt;. This feature also exploits named and default arguments.&lt;/p&gt;


&lt;pre&gt;
    &lt;code&gt;
@Annotation1(foo = @Annotation2)
    &lt;/code&gt;
&lt;/pre&gt;

	&lt;h3&gt;Package Objects&lt;/h3&gt;


	&lt;p&gt;People have complained that they want to define top-level definitions for a package, but they have to put those definitions, like types and methods, in an &lt;code&gt;object&lt;/code&gt; or &lt;code&gt;class&lt;/code&gt;, which doesn&amp;#8217;t quite fit and it&amp;#8217;s awkward for referencing through package and type qualification. The problem was especially obvious when the team started working on the major reorganization of the collections (discussed below). So, Scala 2.8 will support &amp;#8220;package objects&amp;#8221;.&lt;/p&gt;


&lt;pre&gt;
    &lt;code&gt;
package object scala {
  type List[+T] = scala.collection.immutable.List
  val List = scala.collection.immutable.List
}
    &lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;Our friend &lt;code&gt;List&lt;/code&gt; is now moved to &lt;code&gt;scala.collection.immutable.List&lt;/code&gt;, but we would still like to reference it as if it were in the &lt;code&gt;scala&lt;/code&gt; package. The definition defines a package-level &lt;code&gt;type&lt;/code&gt; and &lt;code&gt;val&lt;/code&gt; the effectively make List accessible in the &lt;code&gt;scala&lt;/code&gt; scope. In Scala 2.7 you would have to do something like the following (ignoring &lt;code&gt;Predef&lt;/code&gt; for a moment).&lt;/p&gt;


&lt;pre&gt;
    &lt;code&gt;
package scala {
  object toplevel {
    type List[+T] = scala.collection.immutable.List
    val List = scala.collection.immutable.List
  }
}
    &lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;But then you would have to reference &lt;code&gt;List&lt;/code&gt; using &lt;code&gt;scala.toplevel.List&lt;/code&gt;.&lt;/p&gt;


	&lt;p&gt;Now, they got around this problem previously by putting a bunch of stuff like this in &lt;code&gt;Predef&lt;/code&gt; and importing it automatically, but that has several disadvantages.&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;&lt;code&gt;Predef&lt;/code&gt; is a big, amorphous collection of stuff.&lt;/li&gt;
		&lt;li&gt;You can&amp;#8217;t define your own &lt;code&gt;Predef&lt;/code&gt; with the same convenient usage semantics, &lt;em&gt;i.e.,&lt;/em&gt; no special import required and no way to reference definitions like &lt;code&gt;package.type&lt;/code&gt;. You would have to use the alternative I just showed with &lt;code&gt;toplevel&lt;/code&gt; in the middle.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Package objects give you a place for definitions that you want to appear at the package scope without having to define them in a singleton object or class.&lt;/p&gt;


	&lt;p&gt;Finally, besides types and fields as shown, package objects can also define methods. They can also inherit from traits and classes.&lt;/p&gt;


	&lt;h3&gt;@specialized&lt;/h3&gt;


	&lt;p&gt;Scala generics are fully specified at declaration time using a uniform representation, not when they are used, like C++ templates. This supports the way Java works, where there isn&amp;#8217;t a giant link step to resolve all references, &lt;em&gt;etc.&lt;/em&gt; However, this has a major performance disadvantage for generic types when they are actually used with &lt;code&gt;AnyVal&lt;/code&gt; types that Scala optimizes to primitives.&lt;/p&gt;


	&lt;p&gt;For example, any closures require the use of FunctionN[T1, T2, ...], &lt;em&gt;e.g.,&lt;/em&gt;&lt;/p&gt;


&lt;pre&gt;
    &lt;code&gt;
def m[T](x: T, f: T =&amp;gt; T) = f(x)

m(2, (x:Int) =&amp;gt; x * 2)
    &lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;The &lt;code&gt;f&lt;/code&gt; closure in the definition of &lt;code&gt;m&lt;/code&gt; will require instantiation of &lt;code&gt;Function2[T,T]&lt;/code&gt;. However, when use &lt;code&gt;AnyVal&lt;/code&gt; classes, as in the last line , this has the effect of causing primitive boxing and unboxing several times, hurting performance when this is completely unnecessary in the special case of primitives being used. This is also bad for arrays and some other data structures.&lt;/p&gt;


	&lt;p&gt;The new &lt;code&gt;@specialized&lt;/code&gt; annotation fixes this problem by causing scala to generate different versions of the user-specified generic type or method for each of the primitive types.&lt;/p&gt;


&lt;pre&gt;
    &lt;code&gt;
def m[@specialized T](x: T, f: T =&amp;gt; T) = f(x)

m(2, (x:Int) =&amp;gt; x * 2)
    &lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;There is a real risk of an explosion of code. Consider what would have to be generated to support every type permutation for &lt;code&gt;Function22&lt;/code&gt;! For this reason they only do cases with up to two type parameters in the library. You can also choose to annotate only some of the type parameters, as appropriate, and the annotation will support parameters that let you limit the primitive types that will be supported, &lt;em&gt;e.g.,&lt;/em&gt; only &lt;code&gt;Ints&lt;/code&gt; and &lt;code&gt;Longs&lt;/code&gt;.&lt;/p&gt;


	&lt;p&gt;This feature is not yet in the 2.8 trunk, but it will be soon.&lt;/p&gt;


	&lt;h2&gt;Improved Collections&lt;/h2&gt;


	&lt;p&gt;Collections are getting a major revamp. First they want to eliminate gratuitous differences in package structure and implementations. In many cases, the &lt;code&gt;map&lt;/code&gt; method and others have to be redefined for each basic collection type, rather than shared between them.&lt;/p&gt;


	&lt;h3&gt;New Collections Design&lt;/h3&gt;


	&lt;p&gt;The new version of the library will support the following.&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;Uniform structure.&lt;/li&gt;
		&lt;li&gt;Every operation is implemented only once.&lt;/li&gt;
		&lt;li&gt;Selection of building blocks in a separate package called &lt;code&gt;scala.collection.generic&lt;/code&gt;. These are normally only used by implementers of immutable and mutable collections.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Because of the reorganization, some Scala 2.7 source code won&amp;#8217;t be compatible with 2.8 without modifications.&lt;/p&gt;


	&lt;h2&gt;Better Tools&lt;/h2&gt;


	&lt;ul&gt;
	&lt;li&gt;The &lt;span class="caps"&gt;REPL&lt;/span&gt; will have command completion, in addition to other enhancements.&lt;/li&gt;
		&lt;li&gt;They have greatly improved the &lt;span class="caps"&gt;IDE&lt;/span&gt; and compiler interface. Miles Sabin and Iulian Dragos worked on this with Martin. There is limited and somewhat unstable support in Eclipse now.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;h2&gt;New Control Abstractions&lt;/h2&gt;


	&lt;p&gt;Several new control abstractions are being introduced.&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;Continuations will be supported with a compiler plugin.&lt;/li&gt;
		&lt;li&gt;Scala has not had the &lt;code&gt;break&lt;/code&gt; keyword. It will now exist, but as a library method.&lt;/li&gt;
		&lt;li&gt;Scala will optimize trampolining tail calls (&lt;em&gt;e.g.&lt;/em&gt;, &lt;code&gt;foo1&lt;/code&gt; tail calls &lt;code&gt;foo2&lt;/code&gt;, which tail calls &lt;code&gt;foo1&lt;/code&gt;, and back and forth).&lt;/li&gt;
	&lt;/ul&gt;


	&lt;h2&gt;More features&lt;/h2&gt;


	&lt;ul&gt;
	&lt;li&gt;The Swing wrapper library has been enhanced.&lt;/li&gt;
		&lt;li&gt;The performance has been improved in several ways.
	&lt;ul&gt;
	&lt;li&gt;Structural type dispatch&lt;/li&gt;
		&lt;li&gt;Actors&lt;/li&gt;
		&lt;li&gt;Vectors, sets, and maps. Their long-term goal is to implement the fastest ones available for the &lt;span class="caps"&gt;JVM&lt;/span&gt;.&lt;/li&gt;
	&lt;/ul&gt;&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;These changes are not yet in the trunk.&lt;/p&gt;


	&lt;h2&gt;Beyond 2.8&lt;/h2&gt;


Longer term, they plan significant improvements in support for parallelism and concurrency, including new concurrency models besides actors, such as:
	&lt;ul&gt;
	&lt;li&gt;Transactions (STM)&lt;/li&gt;
		&lt;li&gt;Data parallelism&lt;/li&gt;
		&lt;li&gt;stream processing&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Clojure is influencing this. Martin praised the competition ;) Fortunately, the original designer of the data structures and algorithms used heavily by Clojure is working on Scala versions. (Name?)&lt;/p&gt;


	&lt;p&gt;Doug Lea wants to work with the team on concurrency data structures. The lack of closures in Java makes this effort difficult in Java.&lt;/p&gt;


	&lt;p&gt;There is some exciting work in advanced type system support for guaranteeing actor isolation and effect tracking. For example, this technology wouuld allow actors to exchange references to big objects without copying them while ensuring that they aren&amp;#8217;t modified concurrently.&lt;/p&gt;


	&lt;p&gt;On a final note, Bill Wake described a conversation he had with Joshua Bloch today who admitted that the time has arrived for him to look seriously at Scala. A possible endorsement from Joshua Bloch would be a major step for Scala.&lt;/p&gt;</description>
      <pubDate>Fri, 05 Jun 2009 02:13:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:b489a56a-baea-484e-b0d6-686ecc39d34c</guid>
      <author>Dean Wampler</author>
      <link>http://blog.objectmentor.com/articles/2009/06/05/bay-area-scala-enthusiasts-base-meeting-whats-new-in-scala-2-8</link>
      <category>Dean's Deprecations</category>
      <category>Scala</category>
      <category>JavaOne</category>
    </item>
    <item>
      <title>Refactoring Exercise</title>
      <description>&lt;p&gt;So I&amp;#8217;ve written a somewhat ugly method with the intent of having people clean it up. Want to give it a try? Post your results and then I&amp;#8217;ll show what I ended up doing in a few days (or after the activity dies down).&lt;/p&gt;


	&lt;p&gt;It&amp;#8217;s in Java, but feel free to post in other languages. I&amp;#8217;d be interested in seeing something in whatever language Michael Feathers happens to be deeply studying right now!-)&lt;/p&gt;


	&lt;p&gt;Oh, and if you feel like going &amp;#8220;overboard&amp;#8221; and using a few design patterns just because you can, I&amp;#8217;d like to see that as well.&lt;/p&gt;


	&lt;p&gt;Here it is:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_java "&gt;  public void take(int v) {
    if (currentMode == Mode.accumulating) {
      int digits = (int)Math.pow(10, (int)Math.log10(v) + 1);
      int x = stack.pop();
      x *= digits;
      x += v;
      stack.push(x);
    }

    if (currentMode == Mode.replacing) {
      stack.pop();
      stack.push(v);
      currentMode = Mode.accumulating;
    }

    if (currentMode == Mode.inserting) {
      int top = stack.peek();
      stack.push(top);
      stack.push(v);
      currentMode = Mode.accumulating;
    }
  }&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
      <pubDate>Thu, 04 Jun 2009 21:23:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:ce8dfe6e-cd31-4b42-acee-f98327c0bd2a</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2009/06/04/refactoring-exercise</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>refactoring</category>
      <category>exercise</category>
    </item>
    <item>
      <title>Updates for using .Slim in FitNesse</title>
      <description>&lt;p&gt;Bob Koss and I are teaching an XP Immersion this week and he&amp;#8217;s going to be using FitNesse with both .Net and Java. It&amp;#8217;s been some time since I checked the instructions or updated to the latest Slim.Net component.&lt;/p&gt;


First off, Mike Stockdale has been busy and made several improvements (kudos). Also, I updated the instructions in two of my tutorials to make sure they were current:
	&lt;ul&gt;
	&lt;li&gt;&lt;a href="http://schuchert.wikispaces.com/Acceptance+Testing.UsingSlimDotNetInFitNesse"&gt;Using Slim .Net in FitNesse&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href="http://schuchert.wikispaces.com/FitNesse.Tutorials.0.CSharp"&gt;FitNesse Tutorial 0, C# Details&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Comments and corrections welcome!&lt;/p&gt;</description>
      <pubDate>Tue, 02 Jun 2009 22:54:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:dac415a2-a069-4c83-9727-ae38ec4df093</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2009/06/02/updates-for-using-slim-in-fitnesse</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>FitNesse</category>
      <category>.NET</category>
    </item>
    <item>
      <title>Mockito Example (Java Mocking Framework)</title>
      <description>&lt;p&gt;Recently I was lamenting how much I liked Moq for C# and its &lt;span class="caps"&gt;API&lt;/span&gt;. I like that is uses lambdas and generics and I think both the interface and general approach are great.&lt;/p&gt;


	&lt;p&gt;Someone I follow on twitter, &lt;a href="http://twitter.com/tieTYT"&gt;@tieTYT&lt;/a&gt;, suggested that I should give &lt;a href="http://mockito.org/"&gt;Mockito&lt;/a&gt; a try. It is a mocking library for Java, written by Szczepan Faber and friends.&lt;/p&gt;


	&lt;p&gt;Well I gave it a try and I found it to be an excellent Mocking framework similar in spirit to Moq and it worked well while not requiring lambdas.&lt;/p&gt;


I was in a mood, so I went ahead and wrote a &lt;a href="http://schuchert.wikispaces.com/Mockito.LoginServiceExample"&gt;quick tutorial&lt;/a&gt;. While it is still under construction, you can have a look at it. If you work through it, you&amp;#8217;ll:
	&lt;ul&gt;
	&lt;li&gt;Develop something using &lt;span class="caps"&gt;TDD&lt;/span&gt;.&lt;/li&gt;
		&lt;li&gt;Using a &lt;a href="http://martinfowler.com/articles/mocksArentStubs.html#SoShouldIBeAClassicistOrAMockist"&gt;mockist&lt;/a&gt; approach&lt;/li&gt;
		&lt;li&gt;Use &lt;a href="http://en.wikipedia.org/wiki/Inversion_of_Control"&gt;Inversion of Control&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;Refactor code to use the &lt;a href="http://en.wikipedia.org/wiki/State_pattern"&gt;GoF state pattern&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;Refactor code to use the &lt;a href="http://en.wikipedia.org/wiki/Template_method_pattern"&gt;GoF Template Method Pattern&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;Fix the code to avoid violation of the &lt;a href="http://www.objectmentor.com/resources/articles/lsp.pdf"&gt;Liskov substitution principle&lt;/a&gt; (this is in there though not currently emphasized)&lt;/li&gt;
		&lt;li&gt;Fix the code to avoid violation of the &lt;a href="http://www.objectmentor.com/resources/articles/dip.pdf"&gt;Dependency Inversion Principle&lt;/a&gt;.&lt;/li&gt;
		&lt;li&gt;And as a side benefit, by using a &lt;span class="caps"&gt;TDD&lt;/span&gt; approach you&amp;#8217;ll naturally avoid violating the &lt;a href="http://en.wikipedia.org/wiki/Law_of_Demeter"&gt;Law of Demeter&lt;/a&gt; (though you will introduce some feature envy).&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Have fun and please comment. &lt;a href="http://schuchert.wikispaces.com/Mockito.LoginServiceExample?f=print"&gt;You can also view a printable version.&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;&lt;span class="caps"&gt;FWIW&lt;/span&gt;, I learned Mockito and wrote this tutorial in about a single work day, so it was pretty easy to pick up and use. I suspect my recent experience with Moq gave me the mental model and then it was just a matter of syntax.&lt;/p&gt;</description>
      <pubDate>Wed, 27 May 2009 00:15:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:d42c0cda-3601-48a3-97b5-bec85c11e3a6</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2009/05/27/mockito-example-java-mocking-framework</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>mock</category>
      <category>mockito</category>
      <category>TDD</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Moq examples, Part II</title>
      <description>&lt;p&gt;&lt;a href="http://blog.objectmentor.com/articles/2009/05/19/a-first-look-at-moq"&gt;A few blog articles ago&lt;/a&gt; I showed some examples using Moq. I created those examples in anticipation of using Moq in a &lt;span class="caps"&gt;TDD&lt;/span&gt; class with a group in Canada.&lt;/p&gt;


	&lt;p&gt;What I ended up creating was different for a number of reasons. The final version is somewhat cleaned up compared to those first examples, so here are those examples as well: &lt;a href="http://schuchert.wikispaces.com/Moq.Logging+In+Example+Implemented"&gt;actual test class created&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;These tests are not really that different from the first version, other than I did not use exceptions as much.&lt;/p&gt;


After the underlying LoginService was created with these tests, I had the students refactor to the GoF State Design Pattern. If you&amp;#8217;re feeling like a little practice, consider:
	&lt;ul&gt;
	&lt;li&gt;Creating one test at a time&lt;/li&gt;
		&lt;li&gt;Write the underlying service&lt;/li&gt;
		&lt;li&gt;When all tests are passing, try to refactor to the state pattern.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;It&amp;#8217;s a good exercise. The guys in Canada seemed to really grok Moq and started using it to characterize their actual code the next day.&lt;/p&gt;</description>
      <pubDate>Mon, 25 May 2009 21:57:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:cc7851f6-5d05-4623-83f9-f98210dc8845</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2009/05/25/moq-examples-part-ii</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>moq</category>
      <category>c</category>
      <category>TDD</category>
      <category>state</category>
    </item>
    <item>
      <title>Strict Mocks and Characterization Tests</title>
      <description>&lt;p&gt;This week I worked with a great group in Canada. This group of people had me using Moq for the first time and I found it to be a fine mocking tool. In fact, it reminded me of why I think the Java language is now far outclassed by C# and only getting more behind (luckily the &lt;span class="caps"&gt;JVM&lt;/span&gt; has many languages to offer).&lt;/p&gt;


One issue this group is struggling with is a legacy base with several services written with static &lt;span class="caps"&gt;API&lt;/span&gt;&amp;#8217;s. These classes are somewhat large, unwieldy and would be much improved with some of the following refactorings:
	&lt;ul&gt;
	&lt;li&gt;Replace switch with polymorphism&lt;/li&gt;
		&lt;li&gt;Replace type code with strategy/state&lt;/li&gt;
		&lt;li&gt;Introduce Instance Delegator&lt;/li&gt;
		&lt;li&gt;Use a combination of template method pattern + strategy and also strategy + composite&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;This is actually pretty standard stuff and this group understands the way forward. But what of their existing technical debt?&lt;/p&gt;


	&lt;p&gt;Today we picked one method in particular and attempted to work our way through it. This method was a classic legacy method (no unit tests). It also had a switch on type and then it also did one or more things based on a set of options. All of this was in one method.&lt;/p&gt;


	&lt;p&gt;If you read &lt;a href="http://www.amazon.com/Refactoring-Improving-Existing-Addison-Wesley-Technology/dp/0201485672/ref=sr_1_1?ie=UTF8&amp;#38;s=books&amp;#38;qid=1243043314&amp;#38;sr=8-1"&gt;Fowler&amp;#8217;s Refactoring Book&lt;/a&gt;, it mentions a combination of encapsulating the type code followed by replacing switch with polymorphism for the first problem in this method (the switch). We were able to skip encapsulating the type code since we wanted to keep the external &lt;span class="caps"&gt;API&lt;/span&gt; unchanged (legacy code).&lt;/p&gt;


	&lt;p&gt;So we first created a base strategy for the switch and then several empty derived classes, one for each of the enums. This is a safe legacy refactoring because it only involved adding new code.&lt;/p&gt;


	&lt;p&gt;Next, we created a factory to create the correct strategy based on the type code and added that to the existing method (we also added a few virtual methods). Again, a safe refactoring since it only involved adding effectively unused code (we did create the factory using nearly strict &lt;span class="caps"&gt;TDD&lt;/span&gt;). Finally, we delegated from the original method to the strategy returned from the factory. Safe again, since we had tested the factory.&lt;/p&gt;


	&lt;p&gt;So far, so good. But next, we wanted to push the method down to each of the subclasses and remove the parts of the logic that did not apply to each given type. We did a spike refactoring to see what that&amp;#8217;d be like and it was at least a little dicey. We finally decided to get the original method under test so that as we refactored, we had the safety net necessary to refactor with confidence.&lt;/p&gt;


	&lt;p&gt;We started by simply calling the method with null&amp;#8217;s and 0 values. We worked our way through the method, adding hand-rolled test doubles until we came across our first static class.&lt;/p&gt;


Their current system has &lt;span class="caps"&gt;DAO&lt;/span&gt;&amp;#8217;s with fully static interfaces. This is something that is tough to fake (well we were not using and &lt;span class="caps"&gt;AOP&lt;/span&gt; framework, so &amp;#8230;). Anyway, this is where we introduced the instance delegator. We:
	&lt;ul&gt;
	&lt;li&gt;Added an instance of the class as a static member (essentially creating a singleton).&lt;/li&gt;
		&lt;li&gt;Added a property setter and getter (making it an overridable singleton).&lt;/li&gt;
		&lt;li&gt;We then copied the body of the static method into an instance method, which we made virtual.&lt;/li&gt;
		&lt;li&gt;We then delegated the static method to the virtual method.&lt;/li&gt;
		&lt;li&gt;Then, in the unit test, we set the singleton to a hand-coded test double in the setup and reset the singleton in the tear down method.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;We had to do this several times and on the third time (I think it was the third time), the hand-rolled test double would have had to implement several (17ish) methods and it became clear that we were ready to use a mocking framework. They are using Moq so we started using Moq to accomplish the remainder of the mocking.&lt;/p&gt;


	&lt;p&gt;After some time, we managed to get a test that essentially sent a tracer bullet through one path of the method we wanted to get under test. When the test turned green there was much rejoicing.&lt;/p&gt;


However, we had to ask the question: &amp;#8220;So what are we testing?&amp;#8221; After some discussion, we came up with a few things:
	&lt;ul&gt;
	&lt;li&gt;This method currently makes calls to the service layers and those calls depend on both an enumeration (replaced with a shallow and wide hierarchy of strategies) and options (to be replaced with a composition of strategies).&lt;/li&gt;
		&lt;li&gt;It also changes some values in an underling domain object.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;So that&amp;#8217;s what we needed to &lt;a href="http://en.wikipedia.org/wiki/Characterization_Test"&gt;characterize&lt;/a&gt;.&lt;/p&gt;


We had a discussion on this and as a group. We wanted a way to report on the actual method calls so we could then assert (or in Moq parlance Verify). We looked at using Moq&amp;#8217;s callbacks, but it appears that those are registered on a per-method basis. We briefly toyed with the idea of using an &lt;span class="caps"&gt;AOP&lt;/span&gt; tool to introduce tracing, but that&amp;#8217;s for another time (I&amp;#8217;m thinking of looking into it out of curiosity) but we decided that we could instead do the following:
	&lt;ul&gt;
	&lt;li&gt;Begin as we already had, get through the method with a tracer.&lt;/li&gt;
		&lt;li&gt;Determine the paths we want to get under test.&lt;/li&gt;
		&lt;li&gt;For each path:
	&lt;ul&gt;
	&lt;li&gt;Create a test using strict mocks (which fail as soon as an unexpected method is called)&lt;/li&gt;
		&lt;li&gt;Use a Setup to document this call as expected &amp;#8211; this is essentially one of the assertions for the characterization test.&lt;/li&gt;
		&lt;li&gt;Continue until we have all the Setups required to get through the test.&lt;/li&gt;
		&lt;li&gt;Add any final assertions based on state-based checks and call VerifyAll on the Moq-based mock object.&lt;/li&gt;
	&lt;/ul&gt;&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;This would be a way we could work through the method and characterize it before we start refactoring it in earnest.&lt;/p&gt;


	&lt;p&gt;This might sound like a lot of work and it certainly is no cake walk, but all of this work was done by one of the attendees and as a group they certainly have the expertise to do this work. And in reality, it did not take too long. As they practice and get some of the preliminary work finished, this will be much easier.&lt;/p&gt;


Overall, it was a fun week. We:
	&lt;ul&gt;
	&lt;li&gt;Spent time on one project practicing &lt;span class="caps"&gt;TDD&lt;/span&gt; and refactoring to patterns (they implemented 5 of the GoF patterns).&lt;/li&gt;
		&lt;li&gt;Spent time practicing some of Fowler&amp;#8217;s refactorings and Feather&amp;#8217;s legacy refactorings.&lt;/li&gt;
		&lt;li&gt;Spent a day practicing &lt;span class="caps"&gt;TDD&lt;/span&gt; using mocks for&lt;i&gt; &lt;b&gt;everything&lt;/b&gt;&lt;/i&gt; but the unit under test. At the end they had a test class, one production class and several interfaces.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;In retrospect, the work they did in the first three days was nearly exactly what they needed to practice for the final day of effort. When we started tackling their legacy code, they had already practiced everything they used in getting the method under test.&lt;/p&gt;


	&lt;p&gt;So overall great week with a fun group of guys in Canada.&lt;/p&gt;</description>
      <pubDate>Fri, 22 May 2009 20:34:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:cbf32d08-3237-4a89-85ed-807948fd45e0</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2009/05/22/strict-mocks-and-characterization-tests</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>characterization</category>
      <category>moq</category>
      <category>mock</category>
      <category>c</category>
      <category>design</category>
      <category>patterns</category>
      <category>legacy</category>
      <category>code</category>
      <category>refactoring</category>
    </item>
    <item>
      <title>Clean Code and Battle Scarred Architecture</title>
      <description>&lt;p&gt;If you go &lt;a href="http://internal.objectmentor.com:9090/job/fitnesse/crap/"&gt;here&lt;/a&gt; you&amp;#8217;ll see that I struggle to keep the &lt;a href="http://www.crap4j.org/"&gt;&lt;span class="caps"&gt;CRAP&lt;/span&gt;&lt;/a&gt; out of FitNesse.  Despite the whimsical name of this metric (which I take a perverse delight in), I find it to be remarkably useful.&lt;/p&gt;


	&lt;p&gt;&lt;span class="caps"&gt;CRAP&lt;/span&gt; is a metric that is applied to each function in the system.  The formula for &lt;span class="caps"&gt;CRAP&lt;/span&gt; is:
&lt;acronym title="f"&gt;CRAP&lt;/acronym&gt; = comp(f)&lt;sup&gt;2.&lt;/sup&gt; X (1 &amp;#8211; cov(f)/100)&lt;sup&gt;3.&lt;/sup&gt; + comp(f)&lt;/p&gt;


	&lt;p&gt;Where comp(f) = the cyclomatic complexity of the function f.
and cov(f) = the unit test coverage of function f.&lt;/p&gt;


	&lt;p&gt;So a function&amp;#8217;s &lt;span class="caps"&gt;CRAP&lt;/span&gt; will be small iff the cyclomatic complexity is low and the test coverage is high.  &lt;span class="caps"&gt;CRAP&lt;/span&gt; will be &lt;em&gt;huge&lt;/em&gt; if cyclomatic complexity is high, and there is no coverage.&lt;/p&gt;


	&lt;p&gt;What does this have to do with architecture?  Read on&amp;#8230;&lt;/p&gt;


	&lt;p&gt;I work very hard to keep the ratio of crappy methods near .1%.  Of the 5643 methods in FitNesse, only 6 are crappy, and five of those I have no control over.&lt;/p&gt;


	&lt;p&gt;If you study the graph you can see how quickly I react to even the slightest uptick in crap.  I don&amp;#8217;t tolerate it because it means that either I&amp;#8217;ve got a horrifically complex method that needs to be refactored, or (and this is far more likely) I&amp;#8217;ve got a method that isn&amp;#8217;t sufficiently tested.&lt;/p&gt;


	&lt;p&gt;Why am I so fastidious about this?  Why am I so concerned about keeping the crap out of FitNesse?  The reason is pretty simple.  It&amp;#8217;s the &lt;em&gt;least&lt;/em&gt; I can do.&lt;/p&gt;


	&lt;p&gt;If you look inside of FitNesse, you&amp;#8217;ll find that there are lots of structures and decisions that don&amp;#8217;t seem to make a lot of sense at first reading.  There are complexities and abstractions that will leave you shaking your head.&lt;/p&gt;


	&lt;p&gt;For example.  We generate all our &lt;span class="caps"&gt;HTML&lt;/span&gt; &lt;em&gt;in code&lt;/em&gt;.  Yes, you read that correctly.  We write Java code that constructs &lt;span class="caps"&gt;HTML&lt;/span&gt;.  And yes, that means we are slinging angle brackets around.&lt;/p&gt;


	&lt;p&gt;To be fair, we&amp;#8217;ve managed to move most of the angle bracket slingers into a single module that hides the &lt;span class="caps"&gt;HTML&lt;/span&gt; construction behind an abstraction barrier.  This helps a lot, but &lt;em&gt;cripe&lt;/em&gt; who would sling angle brackets when template system are so prevalent?  I hope nobody.  But FitNesse was not conceived at a time when template systems made sense (at least to us).&lt;/p&gt;


	&lt;p&gt;Fear not, I am working through the Fitnesse code replacing the &lt;span class="caps"&gt;HTML&lt;/span&gt; generation with Velocity templates.  It&amp;#8217;ll take some time, but I&amp;#8217;ll get it done.  The point is, that just like every other software system you&amp;#8217;ve seen, FitNesse is a collection of historical compromises.  The architecture shows the scars of many decisions that have since had to be reversed or deeply modified.&lt;/p&gt;


	&lt;p&gt;What does this have to do with &lt;span class="caps"&gt;CRAP&lt;/span&gt;?  Simply this.  The battle scarred architecture is something that will never really go away.  I can stop the bleeding, and disinfect the wounds, but there will always be evidence of the battle.&lt;/p&gt;


	&lt;p&gt;That scarring makes the system hard to understand.  It complicates the job of adding features and fixing bugs.  It decreases the effectiveness of the developers who work on FitNesse.  And though I work hard to massage the scars and bandage the wounds,  the war goes on.&lt;/p&gt;


	&lt;p&gt;&lt;em&gt;But I can keep the &lt;span class="caps"&gt;CRAP&lt;/span&gt; out!&lt;/em&gt;  I &lt;em&gt;can&lt;/em&gt; keep the code so clean and simple at the micro level, that the poor folks who try to make sense out of the macro scale aren&amp;#8217;t impeded by huge deeply nested functions that aren&amp;#8217;t tested!&lt;/p&gt;


	&lt;p&gt;Think of it this way.  &lt;span class="caps"&gt;CRAP&lt;/span&gt; is disease at the cellular level.  &lt;span class="caps"&gt;CRAP&lt;/span&gt; is a rot so pervasive that it can infest every nook and cranny of the system.  My system may have scars, &lt;em&gt;but it&amp;#8217;s not diseased!&lt;/em&gt;  In fact, despite the evidence of battles long past, the FitNesse code is &lt;em&gt;very&lt;/em&gt; healthy.&lt;/p&gt;


	&lt;p&gt;And I aim to keep it that way.&lt;/p&gt;</description>
      <pubDate>Wed, 20 May 2009 17:35:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:33c6eb39-6431-415a-9e68-edea9078cdd0</guid>
      <author>Uncle Bob</author>
      <link>http://blog.objectmentor.com/articles/2009/05/20/clean-code-and-battle-scarred-architecture</link>
      <category>Uncle Bob's Blatherings</category>
      <category>Agile Methods</category>
      <category>Clean Code</category>
    </item>
    <item>
      <title>A First Look at Moq</title>
      <description>&lt;p&gt;This week I&amp;#8217;m working with a customer that uses two tools I have not previously used: MBUnit (instead of NUnit, and it is now part of Gallio [sic]) and Moq (by &lt;a href="http://www.clariusconsulting.net/blogs/kzu/"&gt;Daniel Cazzulino&lt;/a&gt;).&lt;/p&gt;


	&lt;p&gt;For how I&amp;#8217;m using MBUnit, there are no differences (that&amp;#8217;s not to say it&amp;#8217;s the same as NUnit, I&amp;#8217;m just using it that way). However, Moq is a different mocking framework.&lt;/p&gt;


	&lt;p&gt;While you can do something similar to a record/playback approach, Moq encourages a different approach. Rather than try to describe it, I&amp;#8217;ll show a few examples and you can decide for yourself (or you can tell me how I should have done it better).&lt;/p&gt;


&lt;h2&gt;Background&lt;/h2&gt;
Given a login service, I want to make sure it follows a set of requirements. The list of requirements I typically use for this example are here: &lt;a href="http://schuchert.wikispaces.com/Tdd.Problems.LoggingIn"&gt;http://schuchert.wikispaces.com/Tdd.Problems.LoggingIn&lt;/a&gt;. What follows are tests that are similar to, but not quite consistent with those requirements.

&lt;blockquote&gt;When I was working through this example, I was a little exception happy. I was trying to learn how to make certain things happen with the moq. I&amp;#8217;ve simply repeated my experiments here, when I use this later on, I&amp;#8217;ll approach this problem a bit differently.&lt;/blockquote&gt;

&lt;H2&gt;Example 1: Logging in successfully&lt;/H2&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;00: [Test]
01: public void WhenUserFoundAndPasswordMatchesUserShouldBeLoggedIn()
02: {
03:   var userMock = new Mock&amp;lt;IUser&amp;gt;();
04:   userMock.Setup(user =&amp;gt; user.PasswordMatches(It.IsAny&amp;lt;string&amp;gt;())).Returns(true);
05:
06:   var daoMock = new Mock&amp;lt;IUserDao&amp;gt;();
07:   daoMock.Setup(dao =&amp;gt; dao.Get(It.IsAny&amp;lt;string&amp;gt;())).Returns(userMock.Object);
08:
09:   var service = new UserService(daoMock.Object);
10:   service.Login(&amp;quot;Brett&amp;quot;, &amp;quot;password&amp;quot;);
11:
12:   userMock.VerifySet(user =&amp;gt; user.LoggedIn = true);
13: }&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;TABLE border="2" rules="cols,rows"&gt;
&lt;TR&gt;&lt;td&gt;Line 3&lt;td&gt;Create a userMock.&lt;/tr&gt;
&lt;TR&gt;&lt;td&gt;Line 4&lt;td&gt;Using a C# lambad, when a user object is sent the PasswordMatched message with any string object, return true.&lt;/tr&gt;
&lt;TR&gt;&lt;td&gt;Line 6&lt;td&gt;Create a mock IUserDao.&lt;/tr&gt;
&lt;TR&gt;&lt;td&gt;Line 7&lt;td&gt;Whenever the Get method is called with any string, return the userMock&amp;#8217;s Object property (the actual mock object).&lt;/tr&gt;
&lt;TR&gt;&lt;td&gt;Line 9&lt;td&gt;Create a user service and inject into it the daoMock&amp;#8217;s Object property (the actual dao mock).&lt;/tr&gt;
&lt;TR&gt;&lt;td&gt;Line 10&lt;td&gt;Send the login message, which should result in the User being logged in.&lt;/tr&gt;
&lt;TR&gt;&lt;td&gt;Line 12&lt;td&gt;Verify that the LoggedIn property was set to true.&lt;/tr&gt;&lt;/table&gt;

	&lt;p&gt;Notice that rather than setting expectations, line 12 verifies only what I want to verify. It is possible to call Setup more times and then use &amp;#8220;VerifyAll&amp;#8221; to confirm all the Setup&amp;#8217;s were actually used. However, that makes the test more coupled to the underlying implementation. All I care about is that as a result of this configuration of objects, a user was LoggedIn.&lt;/p&gt;


	&lt;p&gt;By default, mocks are not strict. That is, code may call any methods it wishes on a give mock object. So the default behavior is more like a stub than a mock object. If you call &amp;#8220;VerifyAll&amp;#8221; on the userMock or the daoMock, then all of the descriptions in the various Setup method invocations need to happen.&lt;/p&gt;


&lt;H2&gt;Example 2: User not found? Throw an exception&lt;/H2&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;00: [Test]
01: [ExpectedException(typeof(UserDoesNotExistException))]
02: public void WhenUserNotFoundShouldThrowException()
03: {
04:   var daoMock = new Mock&amp;lt;IUserDao&amp;gt;();
05:   daoMock.Setup(dao =&amp;gt; dao.Get(It.IsAny&amp;lt;string&amp;gt;())).Returns((IUser) null);
06:
07:   var service = new UserService(daoMock.Object);
08:   service.Login(&amp;quot;Brett&amp;quot;, &amp;quot;password&amp;quot;);
09: }&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;TABLE border="2" rules="cols,rows"&gt;
&lt;tr&gt;&lt;td&gt;Line 1&lt;td&gt;Create an IUserDao mock.&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Line 5&lt;td&gt;When Get is called with any string, return null &amp;#8211; that is, never find an object. I think of this as a kind of Saboteur, which is a specific kind of stub.&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Line 7&lt;td&gt;Create a user service and inject the daoMock.Object property, the actual mock.&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Line 8&lt;td&gt;Call the Login method, which should throw an exception for this test to pass.&lt;/tr&gt;&lt;/table&gt;

	&lt;p&gt;Notice that this example includes another non-strict mock. You can call it as often as you wish and there&amp;#8217;s no checking on the methods called. However, this stub should force the implementation of the Login method to throw a UserDoesNotExist exception.&lt;/p&gt;


&lt;H2&gt;Example 3: Throw an Exception if the password does not match&lt;/H2&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;00: [Test]
01: [ExpectedException(typeof(PasswordDoesNotMatchException))]
02: public void WhenLoginAttemptDoesNotMatchPasswordThrowsException()
03: {
04:   var userMock = new Mock&amp;lt;IUser&amp;gt;();
05:   userMock.Setup(user =&amp;gt; user.PasswordMatches(It.IsAny&amp;lt;string&amp;gt;())).Returns(false);
06:
07:   var daoMock = new Mock&amp;lt;IUserDao&amp;gt;();
08:   daoMock.Setup(dao =&amp;gt; dao.Get(It.IsAny&amp;lt;string&amp;gt;())).Returns(userMock.Object);
09:
10:   var service = new UserService(daoMock.Object);
11:   service.Login(&amp;quot;&amp;quot;, &amp;quot;&amp;quot;);
12: }&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;TABLE border="2" rules="cols,rows"&gt;
&lt;tr&gt;&lt;td&gt;Line 4&lt;td&gt;Create an IUser mock.&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Line 5&lt;td&gt;Whenever the PasswordMatches method is called with any string, it will return false. All passwords are wrong!&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Line 7&lt;td&gt;Create an IUserDao mock.&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Line 8&lt;td&gt;Whenever Get is called with any string on the IUserDao mock object, return the userMock.Object property (the real mock object).&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Line 10&lt;td&gt;Create a UserService, injecting the daoMock.Object property (the real IUserDao mock).&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Line 11&lt;td&gt;Logging in with any user/password combination should now throw a PasswordDoesNotMatchException.&lt;/tr&gt;
&lt;/table&gt;

&lt;H2&gt;Eample 4: Three failed login attempts should cause user account to be revoked.&lt;/H2&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;00: [Test]
01: public void WhenLoginAttemptThreeTimesInARowWithInvalidPasswordUserRevoked()
02: {
03:   var userMock = new Mock&amp;lt;IUser&amp;gt;();
04:   userMock.Setup(user =&amp;gt; user.PasswordMatches(It.IsAny&amp;lt;string&amp;gt;())).Returns(false);
05: 
06:   var daoMock = new Mock&amp;lt;IUserDao&amp;gt;();
07:   daoMock.Setup(dao =&amp;gt; dao.Get(It.IsAny&amp;lt;string&amp;gt;())).Returns(userMock.Object);
08:
09:   var service = new UserService(daoMock.Object);
10:   for (int i = 0; i &amp;lt; 3; ++i)
11:     AttempLoginIgnoringException(service, &amp;quot;&amp;quot;);
12:   
13:   userMock.VerifySet(user =&amp;gt; user.Revoked = true);
14: }&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;TABLE border="2" rules="cols,rows"&gt;
&lt;tr&gt;&lt;td&gt;Lines 3 &amp;#8211; 4&lt;td&gt;Create an IUser mock (stub or Saboteur really) that will not match any password.&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Lines 6 &amp;#8211; 7&lt;td&gt;Create an IUserDao mock (stub) that will return the userMock.Object for all calls to Get with any string.&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Line 9&lt;td&gt;Create a UserService, injecting the IUserDao mock object.&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Lines 10 &amp;#8211; 11&lt;td&gt;Attempt to login 3 times, each of which will fail.&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Line 13&lt;td&gt;Verify that the user.Revoked property was set to true on the userMock object.&lt;/tr&gt;
&lt;/table&gt;

&lt;H2&gt;Example 5: Failing 2x with one account and then switching to another account and failing again does not revoke account.&lt;/H2&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;00: [Test]
01: public void LoginWrongPassword2XandThenSwitchAccountsWithWrongPassowrdNothingRevoked()
02: {
03:   var userMock1 = new Mock&amp;lt;IUser&amp;gt;();
04:   userMock1.Setup(user =&amp;gt; user.PasswordMatches(It.IsAny&amp;lt;string&amp;gt;())).Returns(false);
05:
06:   var userMock2 = new Mock&amp;lt;IUser&amp;gt;(MockBehavior.Strict);
07:   userMock2.Setup(user =&amp;gt; user.PasswordMatches(It.IsAny&amp;lt;string&amp;gt;())).Returns(false);
08: 
09:   var daoMock = new Mock&amp;lt;IUserDao&amp;gt;();
10:   daoMock.Setup(dao =&amp;gt; dao.Get(&amp;quot;user1&amp;quot;)).Returns(userMock1.Object);
11:   daoMock.Setup(dao =&amp;gt; dao.Get(&amp;quot;user2&amp;quot;)).Returns(userMock2.Object);
12:
13:   var service = new UserService(daoMock.Object);
14:
15:   AttempLoginIgnoringException(service, &amp;quot;user1&amp;quot;);
16:   AttempLoginIgnoringException(service, &amp;quot;user1&amp;quot;);
17:   AttempLoginIgnoringException(service, &amp;quot;user2&amp;quot;);
18:
19:   userMock2.VerifyAll();
20: }&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;TABLE border="2" rules="cols,rows"&gt;
&lt;tr&gt;&lt;td&gt;Lines 3 &amp;#8211; 4&lt;td&gt;Create user mock that will not match any password.&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Lines 6 &amp;#8211; 7&lt;td&gt;Ibid, but this is a strict mock. That is, other than PasswordMatches, no other methods/properties should be called/used (we do &lt;b&gt;not&lt;/b&gt; want it&amp;#8217;s Revoked property to be set or even called).&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Lines 9 &amp;#8211; 11&lt;td&gt;Create an IUserDao mock. Whenever Get is called with &amp;#8220;user1&amp;#8221;, return userMock1.Object. Whenever Get is called with &amp;#8220;user2&amp;#8221;, return userMock2. Object.&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Lines 12&lt;td&gt;Create the UserService injecting the daoMock.Object.&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Lines 15 &amp;#8211; 16&lt;td&gt;Attempt login 2x to account User1, both will fail.&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Line 17&lt;td&gt;Attempt login to account User2, which will also fail, but we do not want the user2 account revoked.&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Line 19&lt;td&gt;Verify all, meaning that&lt;i&gt; &lt;b&gt;only&lt;/b&gt;&lt;/i&gt; the PasswordMatches method was called on userMock2.Object. If any other methods were called, the test will fail.&lt;/tr&gt;
&lt;/table&gt;

&lt;h2&gt;Conclusion&lt;/h2&gt;
That&amp;#8217;s it for now. If you want to more examples or better explanations, or if you can tell me how to make these examples better, please let me know.</description>
      <pubDate>Tue, 19 May 2009 21:46:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:95ba6a5e-a5b6-40a0-b40b-f4a711ca5b46</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2009/05/19/a-first-look-at-moq</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>c</category>
      <category>moq</category>
      <category>TDD</category>
      <category>mocking</category>
    </item>
    <item>
      <title>Why the sea is boiling hot</title>
      <description>&lt;p&gt;In my &lt;a href="http://blip.tv/file/2089545"&gt;keynote&lt;/a&gt; at the &lt;a href="http://en.oreilly.com/rails2009/"&gt;Rails Conference&lt;/a&gt; last Wednesday, I spoke about &lt;em&gt;What Killed Smalltalk and could it Kill Ruby Too?&lt;/em&gt;.  In this keynote, as is my wont, I spoke about the need for our industry to define itself as a profession, and for us to define ourselves as professionals.  I closed the keynote with this statement: &amp;#8220;Professionalism does not mean rigid formalism.  Professionalism does not mean adhering to beaurocrasy.  Professionalism is &lt;em&gt;honor&lt;/em&gt;.  Professionalism is being honest with yourself and disciplined in the way you work.  Professionalism is not letting fear take over.&amp;#8221;&lt;/p&gt;


	&lt;p&gt;David Heinemeier Hansson, inventor of Rails, and affectionately referred to as @dhh has posted a &lt;a href="http://www.loudthinking.com/posts/42-we-need-both-engineers-and-artists-in-programming"&gt;blog&lt;/a&gt; in response in which he asserts that we need &lt;em&gt;artists&lt;/em&gt; as well as &lt;em&gt;professionals&lt;/em&gt;, and draws a dichotomy between the two.  The dichotomy is a false one&amp;#8230;&lt;/p&gt;


	&lt;p&gt;We are a community of artisans.  &lt;em&gt;We make things with our hands!&lt;/em&gt;  We all strive, like @dhh, to make things of great beauty and utility.  In no way, and by no means, do I wish to assail that artistry.  Indeed, my hope is to free it.  I want to convince all programmers that the desire for, and the pursuit of beauty is &lt;em&gt;the way you satisfy your customers&lt;/em&gt;.  The only way to go fast, &lt;em&gt;is to go well.&lt;/em&gt;&lt;/p&gt;


	&lt;p&gt;I want developers to take pride in their work.  I also want them to take pride in &lt;em&gt;the way&lt;/em&gt; that they work.  I want them to be able to look back on the last few days, weeks, and months, and be able to say to themselves, &amp;#8220;I made something beautiful, and I made it well.&amp;#8221;&lt;/p&gt;


	&lt;p&gt;We are a quirky lot.  Some of us wear faded jeans with yesterday&amp;#8217;s spaghetti on them.  Others wear T-shirts that have PI wrapped around them.  There are beards, tatoos, tongue-studs and hair in all shapes and colors. There are hawaiian shirts and sandals.  There are jackets and ties and sometimes even suits. Some of us speak carefully.  Some of us drop F-bombs at a whim.  Some of us are liberal, and some are conservative.  Some of us relish in being seen, and some of us are glad to be overlooked.  In short, we are a group of diverse people who are drawn together by our common passion for code.&lt;/p&gt;


	&lt;p&gt;There is nothing wrong with this diversity.  Indeed it&amp;#8217;s healthy.  The fact that we all think differently about styles, language, appearance, and values means that there are a zillion different ways that we can learn from each other.  And in that learning grows the seed of our profession.&lt;/p&gt;


	&lt;p&gt;So @dhh is right, at least about the diversity.  We should all relish the opportunity to share ideas with people who think differently than we do.  But @dhh is wrong when he draws the dichotomy between artists and engineers.  Every engineer is an artist, and every artist is an engineer.   Every engineer strives for elegance and beauty.  Every artist has the need to make their art actually work.  The two are inextricably tied.  You cannot be one without also being the other.&lt;/p&gt;


	&lt;p&gt;Now, certainly there are environments where the engineering side of things is emphasized over the artistry side.  In extreme cases the artistry is repressed into near non-existence.  Such places are soul-searing hell-holes that every programmer should strive to escape (or for the brave: change from within!)  Indeed, @dhh implies that he worked in such places and found he was &amp;#8220;faking [his] way along in this world.&amp;#8221;  I completely understand that.&lt;/p&gt;


	&lt;p&gt;But then @dhh makes his biggest mistake.  He equates the professionalism I was talking about in my keynote with those repressive environments.  He seems to think that professionalism and artistry are mutually exclusive.  That wearing a green band means you give up on beauty.  That discipline somehow saps programmer happiness.&lt;/p&gt;


	&lt;p&gt;But remember what I said when I closed my keynote: &amp;#8220;Professionalism does not mean rigid formalism.  Professionalism does not mean adhering to beaurocrasy.  Professionalism is &lt;em&gt;honor&lt;/em&gt;.  Professionalism is being honest with yourself and disciplined in the way you work.  Professionalism is not letting fear take over.&amp;#8221;&lt;/p&gt;


	&lt;p&gt;This is not a complete definition; but it will serve for my current purposes.  Because, you see, I made a big mistake during that keynote. And it is in how we deal with our own errors that the claim of professionalism is most frequently, and most thoroughly tested.&lt;/p&gt;


	&lt;p&gt;In my keynote I used a metaphor to link hormones and languages.  I said that C++ was a testosterone language, but Java was an estrogen language.  And then I used the word &amp;#8220;insipid&amp;#8221; to describe Java.&lt;/p&gt;


	&lt;p&gt;Now clearly C++ and testosterone have very little in common.  My use of this metaphor was an oratory device &amp;#8211; a joke.  As far as the operation of that device is concerned, it was a success.  The vast majority of the audience laughed, demonstrating to me that they were a) listening and b) understanding and c) open.&lt;/p&gt;


	&lt;p&gt;There is a kind of &lt;em&gt;artistry&lt;/em&gt; in making oratory devices like this, and I take a certain amount pride in it.  Such devices need to be timed appropriately, delivered skillfully, and used to gauge the audience.  They can help to turn virtually any dry topic into a compelling speech.&lt;/p&gt;


	&lt;p&gt;On the other hand, the construction of &lt;em&gt;this&lt;/em&gt; device had a significant flaw.  I had equated women with weakness.  This was not intentional.  I do not think of women as weak.  But there it was: Estrogen === Insipid. If you were a woman in that audience, how could you come to any conclusion other than &amp;#8220;Uncle Bob thinks women are weak.&amp;#8221;&lt;/p&gt;


	&lt;p&gt;How did I make this error?  Lack of discipline.  I did not &lt;em&gt;test&lt;/em&gt; this keynote adequately.  I should at least have run it past my wife!  I mis-engineered my art!  (Or perhaps my engineering was artless &amp;lt;grin&amp;gt;).&lt;/p&gt;


	&lt;p&gt;Within minutes of concluding my talk, the complaints appeared on twitter.   Women who had been offended and hurt by the remark were tweeting their dissatisfaction.  Some men were joining them.&lt;/p&gt;


	&lt;p&gt;There were two ways I could have responded to this.  I could have asserted that these people were just being too sensitive; that they should have realized that this was just an oratory device and that I didn&amp;#8217;t mean any harm; that they should just recognize me for who I am and not get so hung up in their own fears and values.&lt;/p&gt;


	&lt;p&gt;But I think that reaction would have been unprofessional.  Why?  Because it would have been dishonest.  The truth was that this was just a stupid mistake.  I built the device badly.  I executed the device without testing it properly.  I screwed up; and I needed to own up that.  So I immediately tweeted apologies to those concerned and ate an appropriate amount of humble pie.&lt;/p&gt;


	&lt;p&gt;The reason I told you this story (at the risk of sounding somewhat self-aggrandizing) is so that I could use it to help define professionalism.  The construction of my oratory device was unprofessional.  I should have tested it better.  I should have realized the danger of using gender comparisons and taken greater care with their use.  &lt;em&gt;I could have done better&lt;/em&gt;.&lt;/p&gt;


	&lt;p&gt;We professionals aren&amp;#8217;t prefect.  We all make mistakes.  We recover from those mistakes by owning up to them &lt;em&gt;as&lt;/em&gt; mistakes.  We do not cover those mistakes by claiming that everyone else is wrong.&lt;/p&gt;


	&lt;p&gt;Confronting your mistakes and taking appropriate action is a &lt;em&gt;discipline&lt;/em&gt;. It is a &lt;em&gt;discipline&lt;/em&gt; of honor and self-honesty.  It is a demonstration that we do not let the fear of our own errors take us over.&lt;/p&gt;</description>
      <pubDate>Mon, 11 May 2009 11:09:57 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:0740eb61-d264-4e84-8d93-142a484e6943</guid>
      <author>Uncle Bob</author>
      <link>http://blog.objectmentor.com/articles/2009/05/11/why-the-sea-is-boiling-hot</link>
      <category>Uncle Bob's Blatherings</category>
      <category>Software Craftsmanship</category>
    </item>
    <item>
      <title>The Scatology of Agile Architecture</title>
      <description>&lt;p&gt;One of the more insidious and persistent myths of agile development is that up-front architecture and design are bad; that you should never spend time up front making architectural decisions.  That instead you should evolve your architecture and design from nothing, one test-case at a time.&lt;/p&gt;


	&lt;p&gt;Pardon me, but that&amp;#8217;s Horse Shit.&lt;/p&gt;


	&lt;p&gt;This myth is not part of agile at all.  Rather it is an hyper-zealous response to the &lt;em&gt;real&lt;/em&gt; Agile proscription of &lt;em&gt;Big Design Up Front&lt;/em&gt; (BDUF).  There should be no doubt that &lt;span class="caps"&gt;BDUF&lt;/span&gt; is harmful.  It makes no sense at all for designers and architects to spend month after month spinning system designs based on a daisy-chain of untested hypotheses. To paraphrase John Gall: &lt;em&gt;Complex systems designed from scratch never work.&lt;/em&gt;&lt;/p&gt;


	&lt;p&gt;However, there &lt;em&gt;are&lt;/em&gt; architectural issues that need to be resolved up front.  There &lt;em&gt;are&lt;/em&gt; design decisions that must be made early.  It &lt;em&gt;is&lt;/em&gt; possible to code yourself into a very nasty cul-de-sac that you might avoid with a little forethought.&lt;/p&gt;


	&lt;p&gt;Notice the emphasis on size here.  Size matters!  &amp;#8216;B&amp;#8217; is bad, but &amp;#8216;L&amp;#8217; is good.  Indeed, &lt;span class="caps"&gt;LDUF&lt;/span&gt; is absolutely essential.&lt;/p&gt;


	&lt;p&gt;How big are these B&amp;#8217;s and L&amp;#8217;s?  It depends on the size of the project of  course.  For most projects of moderate size I think a few days ought to be sufficient to think through the most important architectural issues and start testing them with iterations.  On the other hand, for very large projects, I seen nothing wrong with spending anywhere from a week to even a month, thinking through architectural issues.&lt;/p&gt;


	&lt;p&gt;In some circles this early spate of architectural thought is called &lt;em&gt;Iteration 0&lt;/em&gt;.  The goal is to make sure you&amp;#8217;ve got your ducks in a row before you go off half-cocked and code yourself into a nightmare.&lt;/p&gt;


	&lt;p&gt;When I work on FitNesse, I spend a lot of time thinking about how I should implement a new feature.  For most features I spend an hour or two considering alternative implementations.  For larger features I&amp;#8217;ve spent one or two days batting notions back and forth.  There have been times when I&amp;#8217;ve even drawn &lt;em&gt;&lt;span class="caps"&gt;UML&lt;/span&gt; diagrams&lt;/em&gt;.&lt;/p&gt;


	&lt;p&gt;On the other hand, I don&amp;#8217;t allow those early design plans to dominate once I start TDDing.  Often enough the &lt;span class="caps"&gt;TDD&lt;/span&gt; process leads me in a direction different from those plans.  That&amp;#8217;s OK, I&amp;#8217;m glad I made those earlier plans.  Even if I don&amp;#8217;t follow them they helped me to understand and constrain the problem. They gave me the context to evaluate the new solution that &lt;span class="caps"&gt;TDD&lt;/span&gt; helped me to discover.  To paraphrase Eisenhower: Individual plans may not turn out to be helpful, but the act of planning is always indispensable.&lt;/p&gt;


	&lt;p&gt;So here&amp;#8217;s the bottom line.  If you are working in an Agile team, don&amp;#8217;t feel guilty about taking a day or two to think some issues through.  Indeed, &lt;em&gt;feel&lt;/em&gt; guilty if you &lt;em&gt;don&amp;#8217;t&lt;/em&gt; take &lt;em&gt;a little&lt;/em&gt; time to think things through.  Don&amp;#8217;t feel that &lt;span class="caps"&gt;TDD&lt;/span&gt; is the only way to design.  On the other hand, don&amp;#8217;t let yourself get too vested in your designs.  Allow &lt;span class="caps"&gt;TDD&lt;/span&gt; to change your plans if it leads you in a different direction.&lt;/p&gt;</description>
      <pubDate>Sat, 25 Apr 2009 15:23:09 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:75b7d6e4-6c5a-4bba-b373-321a2bb29d1b</guid>
      <author>Uncle Bob</author>
      <link>http://blog.objectmentor.com/articles/2009/04/25/the-scatology-of-agile-architecture</link>
      <category>Uncle Bob's Blatherings</category>
      <category>Agile Methods</category>
    </item>
    <item>
      <title>C&amp;amp;#43;&amp;amp;#43; shared_ptr and circular references, what's the practice?</title>
      <description>&lt;p&gt;I&amp;#8217;m looking for comments on the practice of using shared pointers in C&amp;#43;&amp;#43;. I&amp;#8217;m not actively working on C&amp;#43;&amp;#43; projects these days and I wonder if you&amp;#8217;d be willing to give your experience using shared pointers, if any.&lt;/p&gt;


	&lt;p&gt;I&amp;#8217;m porting one of our classes to C&amp;#43;&amp;#43; from Java (it&amp;#8217;s already in C#). So to remove memory issues, I decided to use boost::shared_ptr. It worked fine until I ran a few tests that resulted in a circular reference between objects.&lt;/p&gt;


Specifically:
	&lt;ul&gt;
	&lt;li&gt;A book may have a receipt (this is a poor design, that&amp;#8217;s part of the exercise).&lt;/li&gt;
		&lt;li&gt;A receipt may have a book.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Both sides of the relationship are 0..1. After creating a receipt, I end up with a circular reference between Receipt and Book.&lt;/p&gt;


	&lt;p&gt;In the existing Java and C# implementations, there was no cleanup code in the test teardown to handle what happens when the receipt goes away. This was not a problem since C# and Java garbage collection algorithms easily handle this situation.&lt;/p&gt;


	&lt;p&gt;Shared pointers, however, do not handle this at all. They are good, sure, but not as good as a generation-scavenging garbage collector (or whatever algorithms are used these days &amp;#8211; I know the &lt;span class="caps"&gt;JVM&lt;/span&gt; for 1.6 sometimes uses the &lt;strong&gt;stack&lt;/strong&gt; for dynamic allocation based on &lt;span class="caps"&gt;JIT&lt;/span&gt;, so it&amp;#8217;s much more sophisticated than a simple generation-scavenger, right?)&lt;/p&gt;


OK, so how to fix this problem? One way I could do is is manually break the circularity:
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_cpp "&gt;boost::shared_ptr&amp;lt;Receipt&amp;gt; r = ...;
CHECK(xxx, yyy);
r.setCopy(boost::shared_ptr&amp;lt;Book&amp;gt;());&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;(I did not use these types like this. When I use templates, especially those in a namespace, I use typedefs and I even, gasp, use Hungarian-esque notation.)&lt;/p&gt;


	&lt;p&gt;That would work, though it is ugly. Also, it is error prone and will either require violating &lt;span class="caps"&gt;DRY&lt;/span&gt; or making an automatic variable a field.&lt;/p&gt;


	&lt;p&gt;I could have removed the back reference from the Receipt to the book. That&amp;#8217;s OK, but is a redesign of a system deliberately written with problems (part of the assignment).&lt;/p&gt;


	&lt;p&gt;Maybe I could explicitly &amp;#8220;return&amp;#8221; the book, which could remove the receipt and the back-reference. That would make the test teardown a bit more complex (and sort of upgrade the test from a unit test to something closer to an integration test), but it makes some sense. The test validate borrowing a book, so to clean up, return the book.&lt;/p&gt;


	&lt;p&gt;Instead of any of these options, I decided to use a boost::weak_ptr&lt;Book&gt; on the Receipt side. (This is the &amp;#8220;technology to the rescue solution&amp;#8221;, thus my question, is this an OK approach.)&lt;/p&gt;


	&lt;p&gt;I did this since the lifetime of a book object is much longer than its receipt (you return your library books, right?). Also, the Receipt only exists on a book. But the book could exist indefinitely without a Receipt.&lt;/p&gt;


	&lt;p&gt;This fixed the problem right away. I got a clean run using CppUTest. All tests passed and no memory leaks.&lt;/p&gt;


Once I had the test working, I experimented. Why? The use of a weak_ptr exposes some underlying details that I didn&amp;#8217;t like exposing. For example, this line of code:
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_cpp "&gt;aReceipt-&amp;gt;getBook()-&amp;gt;getIsbn();&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;(Yes, violating Law of Demeter, get over it, the alternative would make a bloated &lt;span class="caps"&gt;API&lt;/span&gt; on the Book class.)&lt;/p&gt;


Became instead:
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_cpp "&gt;aReceipt-&amp;gt;getBook().lock()-&amp;gt;getIsbn();&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;The lock() method promotes a weak_ptr to a shared_ptr for the life of the expression. In this case, it&amp;#8217;s a temporary in that line of code.&lt;/p&gt;


This worked fine, but I decided to put that promotion into the Receipt class. So internally, the class stores weak_ptr, but when you ask the receipt for its book, it does the lock:
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_cpp "&gt;boost::shared_ptr&amp;lt;Book&amp;gt; getBook() {
    return book.lock();
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;On the one hand, anybody using the getBook() method is paying the price of the promotion. However, the weak_ptr doesn&amp;#8217;t allow access to its payload without the promotion so it&amp;#8217;s really required to be of any value. Or at least that&amp;#8217;s my take on it.&lt;/p&gt;


	&lt;p&gt;Do you have different opinions?&lt;/p&gt;


	&lt;p&gt;Please keep in mind, this is example code we use in class to give students practice naming things like methods and variables and also practice cleaning up code by extracting methods and such.&lt;/p&gt;


	&lt;p&gt;Even so, what practice do you use, if any, when using shared_ptr? Do you use weak_ptr?&lt;/p&gt;


	&lt;p&gt;Thanks in advance for your comments. I&amp;#8217;ll be reading and responding as they come up.&lt;/p&gt;</description>
      <pubDate>Sat, 25 Apr 2009 02:30:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:543a82de-e5b6-4c4e-890b-826115372dad</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2009/04/25/c-43-43-shared_ptr-and-circular-references-whats-the-practice</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>c</category>
      <category>boost</category>
      <category>shared_ptr</category>
      <category>weak_ptr</category>
      <category>circular</category>
      <category>references</category>
    </item>
    <item>
      <title>Crap Code Inevitable?  Rumblings from ACCU.</title>
      <description>&lt;p&gt;I gave the opening Keynote at &lt;a href="http://accu.org/index.php/conferences/accu_conference_2009"&gt;&lt;span class="caps"&gt;ACCU 2009&lt;/span&gt;&lt;/a&gt; on Wednesday.  It was entitled: &lt;em&gt;The Birth of Craftsmanship&lt;/em&gt;.  Nicolai Josuttis finshed the day with the closing keynote: &lt;em&gt;Welcome Crappy Code &amp;#8211; The Death of Code Quality&lt;/em&gt;.  It was like a blow to the gut.&lt;/p&gt;


	&lt;p&gt;In my keynote I attempted to show the historical trajectory that has led to the emergence of the &lt;a href="http://manifesto.softwarecraftsmanship.org/"&gt;software craftsmanship&lt;/a&gt; movement.  My argument was that since the business practices of &lt;span class="caps"&gt;SCRUM&lt;/span&gt; have been widely adopted, and since teams who follow those practices but do not follow the technical practices of XP experience a relentless decrease in velocity, and since that decrease in velocity is &lt;em&gt;exposed&lt;/em&gt; by the transparency of scrum, then if follows that the eventual adoption of those technical XP practices is virtually assured.  My conclusion was that Craftsmanship was the &amp;#8220;next big thing&amp;#8221; (tm) that would capture the attention of our industry for the next few years, driven by the business need to increase velocity.  (See Martin Fowler&amp;#8217;s blog on &lt;a href="http://martinfowler.com/bliki/FlaccidScrum.html"&gt;Flaccid Scrum&lt;/a&gt;)  In short, we are on a trajectory towards a higher degree of professionalism and craftsmanship.&lt;/p&gt;


	&lt;p&gt;Nicolai&amp;#8217;s thesis was the exact opposite of mine.  His argument was that we are all ruled by marketing and that businesses will do whatever it takes to cut costs and increase revenue, and therefore businesses will drive software quality inexorably downward.  He stipulated that this will necessarily create a crisis as the defect rates and deadline slips increased, but that all attempts to improve quality would be short lived and followed by a larger drive to decrease quality even further.&lt;/p&gt;


	&lt;p&gt;Josuttis&amp;#8217; talk was an hour of highly depressing rhetoric couched in articulate delivery and brilliant humor.  One of the more memorable moments came when he playacted how a manger would respond to a developer&amp;#8217;s plea to let them write clean code like Uncle Bob says.  The manager replies: &amp;#8220;I don&amp;#8217;t care what Uncle Bob says, and if you don&amp;#8217;t like it you can leave and take Uncle Bob with you.&amp;#8221;&lt;/p&gt;


	&lt;p&gt;One of the funnier moments came when Josuttis came up with his rules for crap code, one of which was &amp;#8220;Praise Copy and Paste&amp;#8221;.  Here he showed the evolution of a module from the viewpoint of clean code, and then from the viewpoint of copy-paste.  His conclusion, delivered with a lovely irony, was the the copy-paste solution was more maintainable because it was clear which code belonged to which version.&lt;/p&gt;


	&lt;p&gt;It was at this point that I thought that this whole talk was a ribald joke, an elaborate spoof.  I predicted that he was about to turn the tables on everyone and ringingly endorse the craftsmanship movement.&lt;/p&gt;


	&lt;p&gt;Alas, it was not so. In the end he said that he was serious about his claims, and that he was convinced that crap code would dominate our future.  And then he gave his closing plea which went like this:&lt;/p&gt;


	&lt;p&gt;We finally accepted that requirements change, and so we invented Agile.&lt;/p&gt;


	&lt;p&gt;We must finally accept that code will be crap and so we must ???&lt;/p&gt;


	&lt;p&gt;He left the question marks on the screen and closed the talk.&lt;/p&gt;


	&lt;p&gt;This was like a blow to the gut.  The mood of the conference changed, at least for me, from a high of enthralled geekery, to depths of hoplessness and feelings of futile striving against the inevitable. Our cause was lost.  Defeat was imminent.  There was no hope.&lt;/p&gt;


	&lt;p&gt;&lt;strong&gt;Bulls Bollocks!&lt;/strong&gt;&lt;/p&gt;


	&lt;p&gt;To his credit, there are a few things that Josuttis got right.  There &lt;em&gt;is&lt;/em&gt; a lot of crap code out there.  And there &lt;em&gt;is&lt;/em&gt; a growing cohort of crappy coders writing that crap code.&lt;/p&gt;


	&lt;p&gt;But the solution to that is not to give up and become one of them.  The solution to that is to design our systems so that they don&amp;#8217;t require an army of maintainers slinging code.  Instead we need to design our systems such that the vast majority of changes can be implemented in DSLs that are tuned to business needs, and do not require &amp;#8220;programmers&amp;#8221; to maintain.&lt;/p&gt;


	&lt;p&gt;The thing that Josuttis got completely wrong, in my mildly arrogant opinion, is the notion that low quality code is cheaper than high quality code.  Low quality code is &lt;em&gt;not&lt;/em&gt; cheaper; it is &lt;em&gt;vastly&lt;/em&gt; more expensive, even in the short term.  Bad code slows everyone down from the minute that it is written.  It creates a continuous and copious drag on further progress. It requires armies of coders to overcome that drag; and those armies must grow exponentially to maintain constant velocity against that drag.&lt;/p&gt;


	&lt;p&gt;This strikes at the very heart of Josuttis&amp;#8217; argument.  His claim that crappy code is inevitable is based on the notion that crappy code is cheaper than clean code, and that therefore businesses will demand the crap every time.  But it has generally not been &lt;em&gt;business&lt;/em&gt; that has demanded crappy code.  Rather it has been &lt;em&gt;developers&lt;/em&gt; who mistakenly thought that the business&amp;#8217; need for speed meant that they had to produce crappy code.  Once &lt;em&gt;we&lt;/em&gt;, as &lt;em&gt;professional developers&lt;/em&gt;, realize that the only way to go fast is to create clean and well designed code, then we will see the business&amp;#8217; need for speed as a demand for high quality code.&lt;/p&gt;


	&lt;p&gt;My vision of the future is quite different from Josuttis&amp;#8217;.  I see software developers working together to create a discipline of craftsmanship, professionalism, and quality similar to the way that doctors, lawyers, architects, and many other professionals and artisans have done.  I see a future where team velocities increase while development costs decrease because of the steadily increasing skill of the teams.    I see a future where large software systems are engineered by relatively small teams of craftsmen, and are configured and customized by business people using DSLs tuned to their needs.&lt;/p&gt;


	&lt;p&gt;I see a future of &lt;em&gt;Clean Code&lt;/em&gt;, Craftsmanship, Professionalism, and an overriding imperative for Code Quality.&lt;/p&gt;</description>
      <pubDate>Thu, 23 Apr 2009 04:56:22 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:3032f508-8860-43f1-a16b-5b26b563999d</guid>
      <author>Uncle Bob</author>
      <link>http://blog.objectmentor.com/articles/2009/04/23/crap-code-inevitable-rumblings-from-accu</link>
      <category>Uncle Bob's Blatherings</category>
      <category>Software Craftsmanship</category>
      <category>Clean Code</category>
    </item>
    <item>
      <title>Is the Supremacy of Object-Oriented Programming Over?</title>
      <description>&lt;p&gt;I never expected to see this. When I started my career, Object-Oriented Programming (OOP) was going mainstream. For many problems, it was and still is a natural way to &lt;em&gt;modularize&lt;/em&gt; an application. It grew to (mostly) rule the world. Now it seems that the supremacy of objects may be coming to an end, of sorts.&lt;/p&gt;


	&lt;p&gt;I say this because of recent trends in our industry and my hands-on experience with many enterprise and Internet applications, mostly at client sites. You might be thinking that I&amp;#8217;m referring to the mainstream breakout of Functional Programming (FP), which is happening right now. The &lt;em&gt;killer app&lt;/em&gt; for FP is concurrency. We&amp;#8217;ve all heard that more and more applications must be concurrent these days (which doesn&amp;#8217;t necessarily mean multithreaded). When we remove side effects from functions and disallow mutable variables, our concurrency issues largely go away. The success of the Actor model of concurrency, as used to great effect in &lt;a href="http://erlang.org/"&gt;Erlang&lt;/a&gt;, is one example of a functional-style approach. The rise of &lt;a href="http://labs.google.com/papers/mapreduce.html"&gt;map-reduce&lt;/a&gt; computations is another example of a functional technique going mainstream. A related phenomenon is the emergence of key-value store databases, like &lt;a href="http://labs.google.com/papers/bigtable.html"&gt;BigTable&lt;/a&gt; and &lt;a href="http://couchdb.apache.org/"&gt;CouchDB&lt;/a&gt;, is a reaction to the overhead of &lt;span class="caps"&gt;SQL&lt;/span&gt; databases, when the performance cost of the Relational Model isn&amp;#8217;t justified. These databases are typically managed with functional techniques, like map-reduce.&lt;/p&gt;


	&lt;p&gt;But actually, I&amp;#8217;m thinking of something else. Hybrid languages like &lt;a href="http://scala-lang.org"&gt;Scala&lt;/a&gt;, &lt;a href="http://research.microsoft.com/en-us/um/cambridge/projects/fsharp/"&gt;F#&lt;/a&gt;, and &lt;a href="http://caml.inria.fr/ocaml/index.en.html"&gt;OCaml&lt;/a&gt; have demonstrated that &lt;span class="caps"&gt;OOP&lt;/span&gt; and FP can complement each other. In a given context, they let you use the idioms that make the most sense for your particular needs. For example, immutable &amp;#8220;objects&amp;#8221; and functional-style pattern matching is a killer combination.&lt;/p&gt;


	&lt;p&gt;What&amp;#8217;s really got me thinking that objects are losing their supremacy is a very mundane problem. It&amp;#8217;s a problem that isn&amp;#8217;t new, but like concurrency, it just seems to grow worse and worse.&lt;/p&gt;


	&lt;p&gt;The problem is that there is never a stable, clear object model in applications any more. What constitutes a &lt;code&gt;BankAccount&lt;/code&gt; or &lt;code&gt;Customer&lt;/code&gt; or whatever is fluid. It changes with each iteration. It&amp;#8217;s different from one subsystem to another even within the &lt;em&gt;same&lt;/em&gt; iteration! I see a lot of misfit object models that try to be all things to all people, so they are bloated and the teams that own them can&amp;#8217;t be agile. The other extreme is &amp;#8220;balkanization&amp;#8221;, where each subsystem has its own model. We tend to think the latter case is bad. However, is lean and mean, but non-standard, worse than bloated, yet standardized?&lt;/p&gt;


	&lt;p&gt;The fact is, for a lot of these applications, it&amp;#8217;s just data. The ceremony of object wrappers doesn&amp;#8217;t carry its weight. Just put the data in a hash map (or a list if you don&amp;#8217;t need the bits &amp;#8220;labeled&amp;#8221;) and then process the collection with your iterate, map, and reduce functions. This may sound heretical, but how much Java code could you delete today if you replaced it with a stored procedure?&lt;/p&gt;


	&lt;p&gt;These alternatives won&amp;#8217;t work for all situations, of course. Sometimes polymorphism carries its weight. Unfortunately, it&amp;#8217;s too tempting to use objects as if more is always better, like &lt;a href="http://www.google.com/search?client=safari&amp;#38;rls=en-us&amp;#38;q=more+cowbell&amp;#38;ie=UTF-8&amp;#38;oe=UTF-8"&gt;cow bell&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;So what would replace objects for supremacy? Well, my point is really that there is no one true way. We&amp;#8217;ve led ourselves down the wrong path. Or, to be more precise, we followed a single, very good path, but we didn&amp;#8217;t know when to take a different path.&lt;/p&gt;


	&lt;p&gt;Increasingly, the best, most nimble designs I see use objects with a light touch; shallow hierarchies, small objects that try to obey the Single Responsibility Principle, composition rather than inheritance, &lt;em&gt;etc.&lt;/em&gt; Coupled with a liberal use of functional idioms (like iterate, map, and reduce), these designs strike the right balance between the protection of data hiding &lt;em&gt;vs.&lt;/em&gt; openness for easy processing. By the way, you can build these designs in almost any of our popular languages. Some languages make this easier than others, of course.&lt;/p&gt;


	&lt;p&gt;Despite the hype, I think &lt;a href="http://www.martinfowler.com/bliki/DomainSpecificLanguage.html"&gt;Domain-Specific Languages&lt;/a&gt; (DSLs) are also very important and worth mentioning in this context. (&lt;a href="http://en.wikipedia.org/wiki/Language-oriented_programming"&gt;Language-Oriented Programming&lt;/a&gt; &amp;#8211; &lt;span class="caps"&gt;LOP&lt;/span&gt; &amp;#8211; generalizes these ideas). It&amp;#8217;s true that people drink the &lt;span class="caps"&gt;DSL&lt;/span&gt; Kool-Aid and create a mess. However, when used appropriately, DSLs reduce a program to its &lt;a href="http://en.wikipedia.org/wiki/Essential_complexity"&gt;essential complexity&lt;/a&gt;, while hiding and modularizing the &lt;a href="http://en.wikipedia.org/wiki/Accidental_complexity"&gt;accidental complexity&lt;/a&gt; of the implementation. When it becomes easy to write a user story in code, we won&amp;#8217;t obsess as much over the details of a &lt;code&gt;BankAccount&lt;/code&gt; as they change from one story to another. We will embrace more flexible data persistence models, too.&lt;/p&gt;


	&lt;p&gt;Back to &lt;span class="caps"&gt;OOP&lt;/span&gt; and FP, I see the potential for their combination to lead to a rebirth of the old vision of &lt;em&gt;software components&lt;/em&gt;, but that&amp;#8217;s a topic for another blog post.&lt;/p&gt;</description>
      <pubDate>Mon, 20 Apr 2009 21:45:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:69ac398f-694c-4e0b-bc13-a8765608f6cf</guid>
      <author>Dean Wampler</author>
      <link>http://blog.objectmentor.com/articles/2009/04/20/is-the-supremacy-of-object-oriented-programming-over</link>
      <category>Dean's Deprecations</category>
      <category>Agile Methods</category>
      <category>Design Principles</category>
      <category>Clean Code</category>
      <category>design</category>
      <category>OOP</category>
      <category>FP</category>
      <category>polyglot</category>
      <category>Polyparadigm</category>
      <category>Scala</category>
      <category>F</category>
      <category>OCaml</category>
      <category>MapReduce</category>
      <category>BigTable</category>
      <category>CouchDB</category>
      <category>SQL</category>
      <category>dsl</category>
      <category>LOP</category>
    </item>
    <item>
      <title>FitNesse.Slim Table Table Tutorial and a few minor features</title>
      <description>&lt;p&gt;Finally, the last in the table series is ready for prime time: &lt;a href="http://schuchert.wikispaces.com/FitNesse.Tutorials.TableTables"&gt;http://schuchert.wikispaces.com/FitNesse.Tutorials.TableTables&lt;/a&gt;.&lt;/p&gt;


So what&amp;#8217;s next? What do you want to see in additional tutorials?
	&lt;ul&gt;
	&lt;li&gt;New FitNesse.Slim features&lt;/li&gt;
		&lt;li&gt;Acceptance Test Staging&lt;/li&gt;
		&lt;li&gt;...&lt;/li&gt;
	&lt;/ul&gt;


During this past week I added a few things into FitNesse (very small things compared to what others are doing). When the next release happens (or if you build from source):
	&lt;ul&gt;
	&lt;li&gt;If you create a page whose name ends in &amp;#8220;Examples&amp;#8221;, FitNesse will set its type to Suite.&lt;/li&gt;
		&lt;li&gt;If you create a page whose begins with or ends with &amp;#8220;Example&amp;#8221; (in addition to &amp;#8220;Test&amp;#8221;), FitNesse will set its type to Test.&lt;/li&gt;
		&lt;li&gt;The SetUp and TearDown links are back. They add a SetUp or TearDown page as a child of the page you are currently viewing. So if you wanted to add a SetUp/TearDown for a suite, go to the suite page and click SetUp or TearDown.&lt;/li&gt;
		&lt;li&gt;By default, when you build from source, ant starts FitNesse on port 8080 to run acceptance tests. This can be a problem if you, like me, typically keep FitNesse running on port 8080. You can set an environment variable, &lt;span class="caps"&gt;FITNESSE&lt;/span&gt;_TEST_PORT, and the ant build.xml will pick up that environment variable and use the port specified instead.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Enjoy!&lt;/p&gt;</description>
      <pubDate>Sat, 18 Apr 2009 23:45:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:a0d3d209-e493-4488-8104-73d8ddf7d9a8</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2009/04/18/fitnesse-slim-table-table-tutorial-and-a-few-minor-features</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>FitNesse</category>
      <category>table</category>
      <category>fixtures</category>
    </item>
    <item>
      <title>Wormholes, FitNesse and the return of SetUp and TearDown links</title>
      <description>&lt;p&gt;Recently, I was working on adding back a feature to &lt;a href="http://fitnesse.org"&gt;FitNesse&lt;/a&gt; that had been removed, links at the bottom of each page to add a setup or teardown page to the current page. After racking my brain and spending time in git with file histories, I had discovered a point in time where the feature was there and the next commit where it was gone. It was not obvious to me what had changed to break the feature until I talked with Bob Martin (much of this has to do with my lack of experience using git). He mentioned a change in the handling of importing header and footer pages (related to my problem) and sure enough, when I took a look in the debugger, I found out that the information I needed to reintroduce the feature had essentially be removed as a result of a bug fix.&lt;/p&gt;


	&lt;p&gt;This was, apparently, not a heavily used feature. In fact, I had not used it much until I recently started working on &lt;a href="http://schuchert.wikispaces.com/FitNesse.Tutorials"&gt;tutorials for FitNesse&lt;/a&gt;. And given the release criterion for FitNesse, removal of the feature did not break anything (no acceptance tests nor unit tests).&lt;/p&gt;


	&lt;p&gt;Anyway, the point at which the information was available that I needed and the point where I needed to use the information were may steps away from each other both in the call stack as well as the instance hierarchy (think composite pattern). I did not want to significantly change the method call hierarchy so I instead decided to hand-roll the wormhole pattern as it manifests itself in AspectJ (and not the wormhole anti-pattern).&lt;/p&gt;


	&lt;p&gt;For background on AspectJ and &lt;span class="caps"&gt;AOP&lt;/span&gt; in general, have a look at &lt;a href="http://schuchert.wikispaces.com/AspectJ+Self+Study"&gt;these self-study tutorials&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;The wormhole pattern is well-documented in &lt;a href-"http://www.amazon.com/AspectJ-Action-Practical-Aspect-Oriented-Programming/dp/1930110936/ref=sr_1_1?ie=UTF8&amp;#38;s=books&amp;#38;qid=1239907707&amp;#38;sr=8-1"&gt;AspectJ In Action&lt;/a&gt;. It consists of two point cuts that combine two different, separated, parts of the system. It grabs information available at (in this case) the entry point to the system and makes that information available deeper in the system without passing the parameter directly. That&amp;#8217;s where the name comes from, the pattern bridges information across to unconnected points via the wormhole. It is my favorite patter name (not favorite pattern, just name).&lt;/p&gt;


	&lt;p&gt;AspectJ happens to store certain runtime information in thread local storage and the wormhole pattern exploits this fact. &lt;a href="http://schuchert.wikispaces.com/ThreadLocal+Context+Initialization"&gt;Here&amp;#8217;s another example that&amp;#8217;s close to the wormhole pattern.&lt;/a&gt; This is actually a common technique. If you&amp;#8217;ve read up on the recommendations on using Hibernate in a &lt;span class="caps"&gt;JSE&lt;/span&gt; environment either in &amp;#8220;Hibernate in Action&amp;#8221; or the more recent &lt;a href="http://www.amazon.com/Java-Persistence-Hibernate-Christian-Bauer/dp/1932394885/ref=sr_1_2?ie=UTF8&amp;#38;s=books&amp;#38;qid=1239907948&amp;#38;sr=1-2"&gt;Javer Persistence with Hibernate&lt;/a&gt;, one recommendation is to pass around sessions and such in thread local variables. Under the covers, &lt;span class="caps"&gt;JEE&lt;/span&gt; containers do the same thing.&lt;/p&gt;


	&lt;p&gt;Even though this is a &amp;#8220;common&amp;#8221; technique, I&amp;#8217;m not a huge fan of using thread-locals.
1. They are thread-specific global variables.
1. You better be sure there&amp;#8217;s no threading between the two points.
In this case, the threading has already happened. Once a FitNesse responder gets a hold of an &lt;span class="caps"&gt;HTTP&lt;/span&gt; request, the remaining processing is in a single thread.&lt;/p&gt;


	&lt;p&gt;On the other hand, if I did not use thread local storage, the change required to get information I needed would have either require changing one of the objects already in the parameters being passed (very ugly) or changing method signatures all over the place (somewhat less ugly but a stronger violation of &lt;span class="caps"&gt;LSP&lt;/span&gt;). So in this case, I think thread local variables are the least ugly of the available options.&lt;/p&gt;


	&lt;p&gt;(As a side note, that&amp;#8217;s my definition of design: Select the solution that sucks the least.)&lt;/p&gt;


	&lt;p&gt;If you&amp;#8217;re like me, you don&amp;#8217;t use thread locals very often. I wanted to make sure that the thread local information would get properly cleaned up and I wanted to hide all of the magic in one place, so I created a simple class called ThreadLocalUtil. I used &lt;span class="caps"&gt;TDD&lt;/span&gt; to create the class and when I though I was done, I wanted to make sure that I had written the clear() method correctly. I knew that for a single thread the clear() method worked as expected, but I wanted to make sure it did not affect other threads.&lt;/p&gt;


So my problem was I needed 2 threads and I wanted a particular ordering of events:
	&lt;ul&gt;
	&lt;li&gt;T1: Store value in thread-local storage.&lt;/li&gt;
		&lt;li&gt;T2: Clear its local storage.&lt;/li&gt;
		&lt;li&gt;T1: Read its local storage, value stored should still be available.&lt;/li&gt;
	&lt;/ul&gt;


This really isn&amp;#8217;t a hard test to write other than the ordering of events. To make that work, I used latches and I had the threads manually single each other. Here&amp;#8217;s the test:
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_java "&gt;package fitnesse.threadlocal;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

import java.util.concurrent.CountDownLatch;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class ThreadLocalUtilTest {
  private String valueFound;

  // snip - several other tests removed to focus on this test

  CountDownLatch t1Latch = new CountDownLatch(1);
  CountDownLatch t2Latch = new CountDownLatch(1);

  class T1 implements Runnable {
    public void run() {
      try {
        ThreadLocalUtil.setValue(&amp;quot;t1&amp;quot;, &amp;quot;value&amp;quot;);
        t2Latch.countDown();
        Thread.yield();
        t1Latch.await();
        valueFound = ThreadLocalUtil.getValue(&amp;quot;t1&amp;quot;);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
  }

  class T2 implements Runnable {
    public void run() {
      try {
        t2Latch.await();
        ThreadLocalUtil.clear();
        t1Latch.countDown();
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
  }

  @Test
  public void assertThatClearInOneThreadDoesNotMessUpAnotherThread()
      throws InterruptedException {
    Thread t1 = new Thread(new T1());
    Thread t2 = new Thread(new T2());
    t1.start();
    t2.start();
    t1.join();
    t2.join();
    assertEquals(&amp;quot;value&amp;quot;, valueFound);
  }
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;This example illustrates using the java.util.concurrent.CountDownLatch class to signal between threads.&lt;/p&gt;


&lt;b&gt;Main Test Method&lt;/b&gt;
	&lt;ul&gt;
	&lt;li&gt;Creates two threads and start them.&lt;/li&gt;
		&lt;li&gt;Wait for both threads to complete.&lt;/li&gt;
	&lt;/ul&gt;


&lt;b&gt;T1.run(), T2.run()&lt;/b&gt;
	&lt;ul&gt;
	&lt;li&gt;If T2 starts running before T1, no problem it waits on the countdown latch.&lt;/li&gt;
		&lt;li&gt;When T1 starts, it stores a value in a thread local using the util class.&lt;/li&gt;
		&lt;li&gt;T1 then counts down, releasing T2.&lt;/li&gt;
		&lt;li&gt;T1 then yields, it is done until its countdown latch is signaled.&lt;/li&gt;
		&lt;li&gt;T1 waits for a signal.&lt;/li&gt;
		&lt;li&gt;T2 is released from its countdown latch.&lt;/li&gt;
		&lt;li&gt;T2 sends clear to the thread local util class (there&amp;#8217;s a test that verifies clear() works as named in a single thread.&lt;/li&gt;
		&lt;li&gt;T2 then signals T1 to continue by calling its countdown latch.&lt;/li&gt;
		&lt;li&gt;T2 completes at some point later.&lt;/li&gt;
		&lt;li&gt;T1 starts running again, grabs the value out of thread local storage and puts it in the valueFound.&lt;/li&gt;
		&lt;li&gt;T1 completes.&lt;/li&gt;
	&lt;/ul&gt;


&lt;b&gt;Main Test Method&lt;/b&gt;
	&lt;ul&gt;
	&lt;li&gt;The completion of T1 and T2 make the join methods called in the original test method to return, whereupon the test can complete.&lt;/li&gt;
		&lt;li&gt;Verifies that the variable valueFound, set in T1.run, stores the expected result.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;This kind of hand-rolled synchronization is certainly error prone. This is where having a second pair of eyes can really help. However, this seemed to verify that the clear method as written worked in multiple threads as expected.&lt;/p&gt;


	&lt;p&gt;If you&amp;#8217;re interested in seeing the ThreadLocalUtil class or ThreadLocalUtilTest class, grab a copy of &lt;a href="http://github.com/unclebob/fitnesse/tree/master"&gt;FitNesse from github&lt;/a&gt;.&lt;/p&gt;</description>
      <pubDate>Thu, 16 Apr 2009 13:33:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:4ae69f4d-d669-4834-adf7-6317dbe8f8bc</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2009/04/16/wormholes-fitnesse-and-the-return-of-setup-and-teardown-links</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>multi</category>
      <category>threading</category>
      <category>Unit</category>
      <category>test</category>
      <category>non</category>
      <category>blocking</category>
    </item>
    <item>
      <title>X Tests are not X Tests</title>
      <description>&lt;p&gt;Testing is a slippery subject, and it&#8217;s reasonably hard to talk about for one simple reason: the nomenclature is chaotic.  Years ago, I went to a summit with some testing gurus.  I was one of the lone developers there and I asked about the taxonomy of testing.  Cem Kaner, Bret Pettichord,  Brian Marick, and James Bach went through it for us on a flipchart, and it was a nightmare.  You can name tests after their scope: (unit, component, system), their place in the development process (smoke, integration, acceptance, regression), their focus (performance, functional) their visibility (white box, black box), the role of the people writing them (developer, customer).. The list goes on.  There are far more than I can remember.&lt;/p&gt;

&lt;p&gt;Why is it so confusing?  There are are a couple of reasons.  One is that different communities have developed different nomenclature over time.  But, let&#8217;s face it, that&#8217;s true in most fields.  The thing which makes testing nomenclature worse is that the tests themselves aren&#8217;t all that different, or at least, they are often not different enough for us to for us to distinguish them without being told.  Yes, we can tell the difference between a unit test and an acceptance test in most systems, but really there is no force which prevents tests of different types from bleeding through into each other.  Often the &#8220;type&#8221; of a test is more like an attribute: &#8220;here I have a blackbox smoke test, written by a developer for component integration.&#8221;  In the end, all we have are tests and each of them can serve purposes beyond the purpose we originally intended.&lt;/p&gt;

&lt;p&gt;Earlier today, I read a blog by Stephen Walther: &lt;a href=http://stephenwalther.com/blog/archive/2009/04/11/tdd-tests-are-not-unit-tests.aspx&gt;&lt;span class="caps"&gt;TDD&lt;/span&gt; Tests are not Unit Tests&lt;/a&gt;.  In it, he draws some distinctions between various types of testing.  It&#8217;s great that he wrote it because it&#8217;s nice for us to have mental categories for these things, but we have to remember is that they really are just categories.  We get to choose how distinct they will be.  When I write code, most of my &lt;span class="caps"&gt;TDD&lt;/span&gt; tests end up being the same as my unit tests.  I find value in forcing that overlap, and in general, I think overlapping test purposes are great to the degree that the purposes don&amp;#8217;t conflict. You get more for less that way.&lt;/p&gt;

&lt;p&gt;I don&amp;#8217;t see any remedy for the muddle of test types.  We will continue to make up terms to distinguish tests.  We&amp;#8217;ll just have to remember that the types are labels, not bins.</description>
      <pubDate>Mon, 13 Apr 2009 11:48:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:198bd544-9462-4558-9212-989882ced158</guid>
      <author>Michael Feathers</author>
      <link>http://blog.objectmentor.com/articles/2009/04/13/x-tests-are-not-x-tests</link>
      <category>Michaels Musings</category>
    </item>
    <item>
      <title>Twitter Does Not Allow For Nuance</title>
      <description>&lt;p&gt;If you have something deep to say, 140 characters is not going to cut it very often. And sometimes, when it does, it&amp;#8217;s almost too opaque to be grasped by anybody who doesn&amp;#8217;t already grok it.&lt;/p&gt;


Here&amp;#8217;s one example:
&lt;blockquote&gt;
Polymorphsim &amp;#8211; Same request different response.
&lt;/blockquote&gt;

	&lt;p&gt;That&amp;#8217;s the essence of polymorphism, which can help with the &lt;span class="caps"&gt;SRP&lt;/span&gt; and the &lt;span class="caps"&gt;OCP&lt;/span&gt;. That one happens to fit in to a single bullet of &amp;lt; 140 characters. However, there&amp;#8217;s a lot there. In fact, while that could be the definition, it has many ramifications and the context matters. So this probably falls in the opaque category.&lt;/p&gt;


A few days ago I made a pithy statement on twitter:
&lt;blockquote&gt;
Test is Definition (TDD), therefore code w/o Test, not defined. Therefore, it is broken (or never wrong, take your pick).
&lt;/blockquote&gt;

I wanted to make that fit in a single tweet. I forgot to put in to whom I was replying (and now I cannot remember[sorry]). Anyway, I got the following replies:
&lt;blockquote&gt;
&lt;b&gt;@dws&lt;/b&gt; &amp;#8211; Test is &lt;em&gt;a&lt;/em&gt; form of definition. It&amp;#8217;s a very good form, but it&amp;#8217;s not the only one.
&lt;/blockquote&gt;

&lt;blockquote&gt;
&lt;b&gt;@jamesmarcusbach&lt;/b&gt; &amp;#8211; If test is definition, then * must be the same as +, because 2+2=4 &amp;#38; 2 * 2=4. No, a test is just an &lt;strong&gt;event&lt;/strong&gt;. (via )
&lt;/blockquote&gt;

&lt;blockquote&gt;
&lt;b&gt;@ecomba&lt;/b&gt; I love this statement!
&lt;/blockquote&gt;

I wanted to reply with a little more length, so I figured this was a good place to do it.
&lt;hr/&gt;
To @ecomba, thank you. I&amp;#8217;m assuming your reply was in response to that statement, but if not, then thanks anyway!-)
&lt;hr/&gt;
To jamesmarcusbach &amp;#8211; I do not agree. When I assess &amp;#8220;Test is Definition (TDD)&amp;#8221;, that suggests to me that there are many, many unit tests (and even acceptance test, load tests, smoke tests, manual tests, exploratory tests, debugging, ...). The union of all of those tests form the definition. You&amp;#8217;ve picked one example and erroneously extrapolated from it to discount a tweet, and I don&amp;#8217;t think you did it. (And to be clear, I strongly prefer certain forms of tests over others.)

	&lt;p&gt;I also do not agree with your interpretation of testing as an event. At the very least it is a process. Even more so, it is a continuous process that is only done when the project is done, which is when the customer stops paying. So I think you and I are using the same 4 letters (test) in very different ways. I suspect, however, that I&amp;#8217;ve committed the same error in interpreting your use of the word event as you&amp;#8217;ve interpreted my use of the word test.&lt;/p&gt;


And finally, I don&amp;#8217;t agree with your example for many reasons, two of which are:
&lt;ul&gt;
&lt;li&gt;I mentioned &lt;span class="caps"&gt;TDD&lt;/span&gt;, I don&amp;#8217;t check the compiler very often, so I won&amp;#8217;t be testing 2+2 or 2*2.&lt;/li&gt;
&lt;li&gt;However, if I am, I would not only pick your two examples. I&amp;#8217;d have many trying to capture all of the equivalence classes.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr/&gt;
To @dws &amp;#8211; Sure, test is a form a definition. And I also agree that it is not the only form. I never said it was the only form (I think that came from you). As for not including the word form in my tweet, I did include &lt;span class="caps"&gt;TDD&lt;/span&gt;. Does that not invoke a large context, part of which is that &lt;span class="caps"&gt;TDD&lt;/span&gt; can possibly be a form of definition? Of course, saying Test is Definition is actually a metaphor, right? 
&lt;hr/&gt;
OK, having replied with &amp;gt; 140 characters, I&amp;#8217;m going to restate the tweet. Since the restatement is longer than &amp;gt; 140 characters it will have the luxury of being wrong in many more ways than the original.
&lt;blockquote&gt;
Test is one form of Definition (TDD). If you do not have any other form [the context of the original tweet I believe, to which I was responding but mistakenly forgot to include the @..] (e.g., some requirements specification or a verbal agreement with some sales person), then the tests are one good definition of what is/is not correct. If we go with the definition of our system in terms of the tests, then where there are no tests, there is no definition and therefore any behavior is OK. Sure you can argue, the system should not crash when a user enters a character into a field that expects numbers, but really, if that behavior is not defined, saying &amp;#8220;it should not do that because of common sense&amp;#8221; really is saying &amp;#8220;Well I assumed it would not do that, you violated my assumption therefore I will prove you wrong in a battle royal.&amp;#8221; Even more, it&amp;#8217;s great because when it happens, the user will be so mad that s/he will make sure to let you know your definition of the system is incorrect. You can respond by writing another test to improved the fidelity of your understanding of the system.
&lt;/blockquote&gt;

This last part is really a tip of the hat to Jerry Weinberg who said (and I paraphrase probably incorrectly):
&lt;blockquote&gt;
If there are no requirements, any solution will do.
&lt;/blockquote&gt;

Of course, he was probably referring to Alice in Wonderland&amp;#8230;
&lt;hr/&gt;

There&amp;#8217;s a lot more to this subject. For example, I don&amp;#8217;t believe in proving systems correct. Why? Even if you&amp;#8217;ve proven that your system conforms 100% to your formal specification, there&amp;#8217;s no reasonable way to prove:
&lt;ul&gt;
&lt;li&gt;Your formal description is complete (yes you can for simple data structures, &lt;span class="caps"&gt;BFD&lt;/span&gt;, don&amp;#8217;t care about formally proving a simple data structure).&lt;/li&gt;
&lt;li&gt;For any complex system described in terms of a formal language, the original inception of the system was in natural language. Prove the transformation, and then prove the natural language specification is correct/complete.&lt;/li&gt;
&lt;li&gt;I&amp;#8217;m a big fan of G&#246;del&amp;#8217;s incompleteness theorem. It is related to this at least loosely because.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr/&gt;

	&lt;p&gt;By logical extension, you can pick up from this that I&amp;#8217;m not a big fan of using formal languages like &lt;span class="caps"&gt;UML&lt;/span&gt; to build my system &amp;#8220;from the diagrams.&amp;#8221;&lt;/p&gt;


	&lt;p&gt;So in conclusion I like my original statement. I understand that it is not literally true or &amp;#8220;The Truth.&amp;#8221; It&amp;#8217;s a way of thinking about things. I think the feedback was valuable because communication is ambiguous.&lt;/p&gt;


	&lt;p&gt;I could have been more clear. Maybe I should not have tried to even express the idea on Twitter.  By throwing something out there, it gets refined through feedback and there&amp;#8217;s a bettering understanding to be had. At some point we can create some pithy statement that has all of the meaning and none of the meaning at the same time. When we&amp;#8217;ve done that, we get to start all over again.&lt;/p&gt;


	&lt;p&gt;Maybe the statement is simply wrong. At the very least it has an agenda. Question is, does it help, hinder or simply represent a single drop in an infinite bucket?&lt;/p&gt;


	&lt;p&gt;Flame on. I deserve it.&lt;/p&gt;</description>
      <pubDate>Sun, 12 Apr 2009 22:26:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:cf999500-5dd1-43ce-8e6c-0b0ff03a00dd</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2009/04/12/twitter-does-not-allow-for-nuance</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>TDD</category>
      <category>twitter</category>
      <category>test</category>
      <category>G&#246;del</category>
      <category>s</category>
      <category>incompleteness</category>
      <category>theorem</category>
    </item>
    <item>
      <title>FitNesse Scenario Tables</title>
      <description>&lt;p&gt;This is a slightly rougher draft that the previous tutorials. Bob and I have talked about writing a new FitNesse book and these tutorials are practice for one part of the book. By the time these examples make it into a book, they will be the 3rd or 4th major revision.&lt;/p&gt;


	&lt;p&gt;In any case, here&amp;#8217;s a tutorial that picks up where Script tables left off: &lt;a hrre="http://schuchert.wikispaces.com/FitNesse.Tutorials.ScenarioTables"&gt;http://schuchert.wikispaces.com/FitNesse.Tutorials.ScenarioTables&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;I&amp;#8217;ll be updating it over the weekend and into next week. I also hope to get the table table example done so I&amp;#8217;ll have a complete set. If you are chomping at the bits for a table table example, let me know.&lt;/p&gt;


	&lt;p&gt;If you have comments about any of the tutorials or a wish list of what you&amp;#8217;d like to see in a book related to acceptance testing with FitNesse, please post a comment or email me directly. shoe &lt;del&gt;at&lt;/del&gt; objectmentor &lt;del&gt;dot&lt;/del&gt; com.&lt;/p&gt;</description>
      <pubDate>Fri, 10 Apr 2009 02:21:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:6786bbd0-e04b-4c0c-8d7d-10dc82040e73</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2009/04/10/fitnesse-scenario-tables</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>FitNesse</category>
      <category>Scenario</category>
      <category>Tables</category>
      <category>tutorial</category>
      <category>tutorials</category>
    </item>
    <item>
      <title>FitNesse Script Tables Tutorials + updates</title>
      <description>&lt;p&gt;There is now a 4th FitNesse tutorial at: &lt;a href="http://schuchert.wikispaces.com/FitNesse.Tutorials.ScriptTables"&gt;http://schuchert.wikispaces.com/FitNesse.Tutorials.ScriptTables&lt;/a&gt;. As the &lt;span class="caps"&gt;URL&lt;/span&gt; suggests, this is about Script Tables.&lt;/p&gt;


	&lt;p&gt;Next up: Scenario Tables and then Table Tables.&lt;/p&gt;


One other change, each of the 4 first tutorials now have source available at &lt;a href="http://github.com/schuchert/fitnesse-tutorials/tree/master"&gt;github&lt;/a&gt; along with tags:
&lt;ul&gt;&lt;li&gt;FitNesse.Tutorials.0.Start&lt;/li&gt;
&lt;li&gt;FitNesse.Tutorials.1.Start&lt;/li&gt;
&lt;li&gt;FitNesse.Tutorials.2.Start&lt;/li&gt;
&lt;li&gt;FitNesse.Tutorials.ScenarioTables.Start&lt;/li&gt;
&lt;li&gt;FitNesse.Tutorials.ScriptTables.Start&lt;/li&gt;&lt;/ul&gt;

	&lt;p&gt;So you can start at any of the tutorials rather than having to work your way through each one from the beginning. (Of course, that last tag is my starting point for the next tutorial, which will take a few days to update and add to this sequence of tutorials.)&lt;/p&gt;


	&lt;p&gt;Comments/suggestions/requests please.&lt;/p&gt;</description>
      <pubDate>Tue, 07 Apr 2009 11:18:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:f185193f-3b92-45ae-8354-9dca61d6e971</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2009/04/07/fitnesse-script-tables-tutorials-updates</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>FitNesse</category>
      <category>script</category>
      <category>Tables</category>
      <category>github</category>
    </item>
    <item>
      <title>FitNesse Tutorials</title>
      <description>&lt;p&gt;Here is another tutorial for FitNesse: &lt;a href="http://schuchert.wikispaces.com/FitNesse.Tutorials.2"&gt;http://schuchert.wikispaces.com/FitNesse.Tutorials.2&lt;/a&gt;.&lt;/p&gt;


This tutorial and the first now all fit together and form one ongoing example. If you work though the first three tutorials at: &lt;a href="http://schuchert.wikispaces.com/FitNesse.Tutorials"&gt;http://schuchert.wikispaces.com/FitNesse.Tutorials&lt;/a&gt;, you&amp;#8217;ll have practiced:
	&lt;ul&gt;
	&lt;li&gt;Using Decision Tables&lt;/li&gt;
		&lt;li&gt;Using Query Tables&lt;/li&gt;
		&lt;li&gt;Refactoring within FitNesse&lt;/li&gt;
		&lt;li&gt;Using SetUp and TearDown pages&lt;/li&gt;
		&lt;li&gt;Understanding inheritance of SetUp and TearDown pages&lt;/li&gt;
		&lt;li&gt;Basic test organization under a suite&lt;/li&gt;
		&lt;li&gt;Switching into unit testing from acceptance testing&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;There&amp;#8217;s more to go, but that&amp;#8217;s a good start to get you cracking at the fundamentals of FitNesse.&lt;/p&gt;


	&lt;p&gt;As a bonus, there&amp;#8217;s a demonstration of some code in Java that produces query results in a snap. The source code is on github: &lt;a href="http://github.com/schuchert/queryresultbuilder/tree/master"&gt;http://github.com/schuchert/queryresultbuilder/tree/master&lt;/a&gt;.&lt;/p&gt;


Here is one such example taken from that tutorial:
&lt;pre&gt;
   public List&amp;lt;Object&amp;gt; query() {
      List&amp;lt;Program&amp;gt; programs = CreateSeasonPassFor.getSeasonPassManager()
            .toDoListContentsFor(programId);

      QueryResultBuilder builder = new QueryResultBuilder(Program.class);
      builder.register("timeSlot", new TimeSlotPropertyHandler());
      QueryResult result = builder.build(programs);
      return result.render();
   }
&lt;/pre&gt;

	&lt;p&gt;Hope this is useful!&lt;/p&gt;</description>
      <pubDate>Thu, 02 Apr 2009 19:35:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:d4d9a4e3-4199-45a5-b4e6-08322f4e55c2</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2009/04/02/fitnesse-tutorials</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>FitNesse</category>
      <category>query</category>
      <category>result</category>
      <category>builder</category>
      <category>Java</category>
      <category>acceptance</category>
      <category>testing</category>
    </item>
    <item>
      <title>Master Craftsman Teams.</title>
      <description>&lt;p&gt;In the early &amp;#8216;70s F. T. Baker, and Fred Brooks wrote about the notion of Chief Programmer teams.  The idea was that a highly skilled chief programer would be assisted by a team of helpers.  The chief would write most of the code, delegating simpler tasks to the helpers.&lt;/p&gt;


	&lt;p&gt;Though the idea was tried at &lt;span class="caps"&gt;IBM&lt;/span&gt; and shown to work well, the idea has never really caught on.  One reason may be that the economics don&amp;#8217;t appear to be all that good.  A team of four juniors making $50K supporting a senior making $100K costs $300K. That just seems like a lot of money for one well supported chief programmer writing most of the code.&lt;/p&gt;


	&lt;p&gt;But in light of the movement towards software craftsmanship, perhaps it&amp;#8217;s time to dust off this old idea and look at it from a different perspective.  Consider the following thought experiment&amp;#8230;&lt;/p&gt;


	&lt;p&gt;We are in the throes of a recession that is challenging us to think differently about things.  At the same time our universities are &lt;em&gt;raising&lt;/em&gt; tuitions and &lt;em&gt;increasing&lt;/em&gt; faculty salaries, while requiring ever less from both the faculty and the students.  Today&amp;#8217;s professors spend about 9 hours per week in the classroom.  And the quality of the CS majors graduating from these institutions is, to put it bluntly, &lt;em&gt;wretched&lt;/em&gt;.&lt;/p&gt;


	&lt;p&gt;Why should a young aspiring software professional spend four years and $200K+ to attend an institution that will teach them less about their chosen profession than 3 months of working on a real project with talented mentors?  Indeed, why should employers pay $50K for undertrained programmers who are sure to make horrific messes for the next three years of their career?&lt;/p&gt;


	&lt;p&gt;Consider instead a team of craftspeople.  At the center of this team is a master programmer.  This is someone who has been programming for two decades or more.  This person understand systems at a gut level, and can quickly make technical judgements without agonizing over them.  Such a person can direct a team with the kind of calm confidence that only comes with years of experience and seasoning.&lt;/p&gt;


	&lt;p&gt;Our master has three lieutenant journeymen who themselves each have three apprentices.  Our journeymen have at least five years of experience, and are capable both of taking and giving direction.  They can make short term tactical decisions, and direct their apprentices accordingly.  At the same time they take technical and architectural direction from the master.&lt;/p&gt;


	&lt;p&gt;The journeymen write a &lt;em&gt;lot&lt;/em&gt; of code &amp;#8211; almost as much as the master.  They also throw away two thirds of the code written by the apprentices, and drive them to redo it better &amp;#8211; always better.  They teach the apprentices how to refactor, and often pair with them and sit with them while reviewing their code.&lt;/p&gt;


	&lt;p&gt;The master probably writes more code than any of the team members.  This code is often architectural in nature, and helps to establish the seed about which the system will crystalize.  The master also sets technical direction and overall architecture, and makes all critical technical decisions.  However, the chief job of the master is to relentlessly drive the journeymen towards higher quality and productivity by establishing and enforcing the appropriate disciplines and practices.  From the master&amp;#8217;s point of view, it&amp;#8217;s &amp;#8220;my way or the highway.&amp;#8221;&lt;/p&gt;


	&lt;p&gt;Yes, I know this is very &lt;em&gt;anti-scrum&lt;/em&gt;.  But this is a case where I think scrum in particular, and agile in general just got it wrong.  No battle was won by gaining the consensus of the soldiers.  And if you don&amp;#8217;t think developing a system is a &lt;em&gt;battle&lt;/em&gt; against time, resources, and attitudes, then you&amp;#8217;ve never built a system.  No great team has ever succeeded without a strong coach who imposed discipline, set the vision, and had the final authority over who played and who sat on the bench.  Consensus and team rule may be useful tools &lt;em&gt;some of the time&lt;/em&gt;, but only in the context of effective leadership.&lt;/p&gt;


	&lt;p&gt;The apprentices write a significant amount of code&amp;#8212;most of which is discarded by the journeymen.  The journeymen act as committers.  When an apprentice delivers code that the journeyman finds acceptable, the journeyman will commit that code to their main line.  Otherwise he sends it back to the apprentice to do over.  By the same token the master accepts subsystems from the journeymen and, if acceptable, commits it to the master main line.&lt;/p&gt;


	&lt;p&gt;The master sees every line of code in the system. The Journeymen see every line of code written by their apprentices, and they write a significant amount themselves.  Pairing is prevalent though not universal.  Anyone on the team can pair with anyone else.  It should not be uncommon for the master to pair with the apprentices from time to time.&lt;/p&gt;


	&lt;p&gt;Apprentices begin at a young age&amp;#8212;perhaps 18 or 19.  After all, the idea is that they aren&amp;#8217;t going to a university.  Rather, the brightest would start as apprentices right out of high school, while others might opt for two years of community college first.&lt;/p&gt;


	&lt;p&gt;Apprenticeship would last 2-4 years, depending on how quickly the apprentice learns.  Apprentices earn no more than minimum wage.  After all, they are young, barely productive, and are deriving great benefit from working with experienced journeyman under the guidance of a master.&lt;/p&gt;


	&lt;p&gt;Attaining journeyman status is something for the master to decide, with advice from the journeymen.  The decision is bittersweet because it is a decision to eject the apprentice from the team so that he or she can start the &lt;em&gt;journey&lt;/em&gt;.  Usually the new journeyman would join the team of a different master.&lt;/p&gt;


	&lt;p&gt;Some apprentices simply won&amp;#8217;t attain journeyman status.  In the end, if they fail to make progress, they must be removed from the team.  No one should stay an apprentice year after year.  It is the responsibility of the journeymen and master to decide if an apprentice should be removed from the team.&lt;/p&gt;


	&lt;p&gt;The skills of new journeymen will gradually increase.  At first they should have only one apprentice.  Over the months and years their increasing leadership skills will allow them to take two or three at a time.  The most experienced Journeymen might play the role of master in smaller projects.&lt;/p&gt;


	&lt;p&gt;Attaining master status is no small feat.  It requires the consensus of other masters, and must be demonstrated through several successful accomplishments.&lt;/p&gt;


	&lt;p&gt;I expect a journeyman would make $50-100K depending on their experience.  I expect a master would make $150-$250K or more.&lt;/p&gt;


	&lt;p&gt;Now imagine a team of 13.  One master, three journeymen, and nine apprentices.  This is a powerful unit.  Its size is right at the sweet spot for hyper productive teams.  It has the right balance of experience.  And&amp;#8230; it&amp;#8217;s pretty cheap.  This team costs ~$600K per year, or about $50K per person.  Or (consulting companies take notice) about $23/person/hour.&lt;/p&gt;


	&lt;p&gt;It seems to me that such a team could do much more, much better, than a team of 12 graduates lead by a tech-lead with five years experience.  The productivity and efficiency (and efficiencies of scale!) of this approach should be obvious.  Moreover, I think that being an apprentice on a team like this would provide a much better, much faster, and &lt;em&gt;much&lt;/em&gt; cheaper education than a university degree.  Finally, I think that using teams of this kind could be a remarkably cost-effective way to get very high quality software written very quickly.&lt;/p&gt;</description>
      <pubDate>Wed, 01 Apr 2009 16:51:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:f9df49b6-e79e-445b-96de-203dbf363851</guid>
      <author>Uncle Bob</author>
      <link>http://blog.objectmentor.com/articles/2009/04/01/master-craftsman-teams</link>
      <category>Uncle Bob's Blatherings</category>
      <category>Software Craftsmanship</category>
    </item>
    <item>
      <title>FitNesse Decision Tables, a Tutorial</title>
      <description>&lt;p&gt;There&amp;#8217;s a new tutorial on using FitNesse decision tables: &lt;a href="http://schuchert.wikispaces.com/FitNesse.Tutorials.1"&gt;http://schuchert.wikispaces.com/FitNesse.Tutorials.1&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;This tutorial is a lead-up into using Query tables (that&amp;#8217;s the next one I&amp;#8217;ll be writing), which will describe some code you can get from github that will turn an object/collection into a well-formed query result.&lt;/p&gt;


	&lt;p&gt;These tutorials are background for a presentation I gave at SD West 2009 and will probably be giving at Agile 2009.&lt;/p&gt;


	&lt;p&gt;Comments Welcome.&lt;/p&gt;</description>
      <pubDate>Tue, 31 Mar 2009 13:50:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:da84a6c9-3d3f-49f6-a232-39dcfa2331ff</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2009/03/31/fitnesse-decision-tables-a-tutorial</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>FitNesse</category>
      <category>Decision</category>
      <category>Tables</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Different Test Examples in C++ Using C++ CppUTest</title>
      <description>&lt;p&gt;Here are several versions of the same unit tests written in different styles using CppUTest: &lt;a href="http://schuchert.wikispaces.com/tdd.cpp.MovingTowardsStoryBasedExpressionOfTests"&gt;C++ Unit Test Examples.&lt;/a&gt; If you look near the bottom, you&amp;#8217;ll see what looks like story tests in C++. Shocking!&lt;/p&gt;


	&lt;p&gt;These are all based on Bob&amp;#8217;s &lt;a href="http://www.butunclebob.com/ArticleS.UncleBob.ThePrimeFactorsKata"&gt;Prime Factors Kata&lt;/a&gt;.&lt;/p&gt;</description>
      <pubDate>Thu, 26 Mar 2009 18:08:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:89bd9003-1951-4006-a8bf-5a67432361e3</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2009/03/26/different-test-examples-in-c-using-c-cpputest</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>cpp</category>
      <category>c</category>
      <category>Unit</category>
      <category>Tests</category>
      <category>story</category>
      <category>cucumber</category>
    </item>
    <item>
      <title>Tdd with C++ and Boost</title>
      <description>&lt;p&gt;I&amp;#8217;m going to give Boost another whirl. There appears to be a &lt;a href="http://tinyurl.com/2tqxaa"&gt;great installer for Visual Studio&lt;/a&gt;. It requires free registration. I&amp;#8217;m on the fence about what to use first and was wondering if you have any suggestions.&lt;/p&gt;


I&amp;#8217;m thinking about basic things initially:
	&lt;ul&gt;
	&lt;li&gt;Regex&lt;/li&gt;
		&lt;li&gt;Threading&lt;/li&gt;
		&lt;li&gt;Sockets&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Maybe a multi-threaded server responding to message via socket, with client threads processing requests using regex?&lt;/p&gt;


	&lt;p&gt;If you have anything you&amp;#8217;d like to see, reply to this blog and I&amp;#8217;ll follow up with you.&lt;/p&gt;</description>
      <pubDate>Mon, 23 Mar 2009 22:28:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:b7b43c9a-e0e2-43c4-b7d8-d2d9d5f329fb</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2009/03/23/tdd-with-c-and-boost</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>TDD</category>
      <category>c</category>
      <category>boost</category>
      <category>recommendations</category>
    </item>
    <item>
      <title>A Brief Collection of Convenient Lies about Functional Programming</title>
      <description>&lt;p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;i&gt;A value is the instantaneous state of an object.&lt;/i&gt; &amp;#8211; In OO languages, we have objects. In FP languages, we throw out the object and instead manipulate the values it would take on over time.
&lt;li&gt;&lt;i&gt;Algebraic data types are classes.&lt;/i&gt; &amp;#8211; Every case in an &lt;span class="caps"&gt;ADT&lt;/span&gt; is a state that an &#8220;object&#8221; can be in.

&lt;code&gt;&lt;pre&gt;
data Tree = Empty 
          | Leaf Int 
          | Node Tree Tree
&lt;/pre&gt;&lt;/code&gt;

When we write functions over ADTs, we are obliged to cover all of the cases.  So, for instance, if we define depth for Empty, we have to define depth for the Leaf and Node cases as well.  When we do, we can evaluate &lt;i&gt;depth t&lt;/i&gt; for any tree value and have a well-defined result.
&lt;li&gt;&lt;i&gt;The functions which we define over an &lt;span class="caps"&gt;ADT&lt;/span&gt; can be considered its public interface.&lt;/i&gt; &amp;#8211; There&#8217;s a school of thought which says that encapsulation doesn&#8217;t matter in an functional programming language because values are immutable and corruption can&#8217;t happen.  Nothing could be further from the truth.  If we add or remove a case from an &lt;span class="caps"&gt;ADT&lt;/span&gt; all of the functions which pattern match against it are impacted.  While we don&#8217;t need to have an encapsulation boundary as tight as we might have in an OO language &amp;#8211; it pays to be conscious of how far ADTs travel in a program.  Encapsulation is the act of forming a boundary by transforming an &lt;span class="caps"&gt;ADT&lt;/span&gt; into some other form of data.
&lt;/ol&gt; 
&lt;/p&gt;
&lt;p&gt;
Each of these statements is a lie, an artful simplification, but they are a convenient and not entirely false way of thinking about functional programming until it becomes second-nature.&lt;/p&gt;</description>
      <pubDate>Mon, 23 Mar 2009 10:19:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:96dfa233-e7b6-4c3c-b5e4-6f2d4ff07191</guid>
      <author>Michael Feathers</author>
      <link>http://blog.objectmentor.com/articles/2009/03/23/a-brief-collection-of-convenient-lies-about-functional-programming</link>
      <category>Michaels Musings</category>
    </item>
    <item>
      <title>The Successor Value Pattern</title>
      <description>&lt;p&gt;Functional programming is in the air.  It&amp;#8217;s nearly unavoidable. Even if you haven&#8217;t heard people talk about it or haven&#8217;t read a blog about it, you&#8217;ve probably seen its influence in your project.  People are taking ideas that they learned in functional programming and applying them in straight object-oriented code.  In Java, where there are no closures, today you are much more likely to encounter someone&#8217;s hand-rolled fold or map abstraction, and even if they haven&#8217;t gone that far, you are likely to find attempts to replace mutable data with immutable data.  It&#8217;s part of the learning process, and there are some interesting patterns which occur along the way.
&lt;/p&gt;

&lt;p&gt;OO programmers often think in terms of entities.  They imagine objects with identity and  changeable local state; messages sent to objects alter their local state and trigger further message sends.  Classic OO is intrinsically time-oriented.  How do we pull this into a functional world?  One thing that we can do is choose to see an entity as a series of values over time.  Here&#8217;s one way to do it.  If we have an entity like this:
&lt;/p&gt;

&lt;code&gt;&lt;pre&gt;
public class EventDay {
    private LocalDate date;

    ...

    public void advance() {
        do {
            date = RegionalEventCalendar.nextValidDate(date)
        } while (!fitsLocalCalendar(date));
    }

    ...
}

&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;We can change it to this:&lt;/p&gt;

&lt;code&gt;&lt;pre&gt;
public class EventDay {
    private final LocalDate date;

    ...

    public EventDay next() {
        return new EventDay(prospectiveDay(date));
    }

    ...
}

&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;This is the &lt;i&gt;successor value pattern&lt;/i&gt;.  The notion is that you model state change as a series of value transformations.  Is this good?  Well, successor value is extremely common in functional programming languages.  In Haskell, for instance, you don&#8217;t have mutation so you are always constructing new values.  When Scala and F# are used in a functional style, you do the same thing; but is this a good idea in Java, C#, and C++?  One concern is that the runtimes and libraries of those languages might not be as well tuned for continual reconstruction of value representations of the larger domain objects that we often see in OO designs.  On the surface, however, &lt;i&gt;successor value&lt;/i&gt; is nice; it gives us a mapping to immutable values and a dose of referential transparency.
&lt;/p&gt;

&lt;p&gt;&lt;i&gt;Successor Value&lt;/i&gt; has an interesting quality from a type perspective.  You compute successor values using a function which takes a type to another value of that same type.  In the example above, &lt;code&gt;next&lt;/code&gt; is a function like that.  It maps from &#8216;this&#8217;, which has the type EventDay, to a new EventDay. In category theory, this is called an endomorphism.  It&#8217;s a relationship with some cool characteristics.  One of them is closure. You can chain any number of endomorphic operations and still end up with the type you started with:&lt;/p&gt;

&lt;code&gt;&lt;pre&gt;
LocalDate next  = date.nextDay().nextWeek().fridayAfter();
&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;
This is really about as encapsulated as you can get.  Endomorphic chains don&#8217;t betray their representations and they don&#8217;t force users to use new types.  In a way, you can look at an endomorphic chain as a state machine over an entity, spread out over time.
&lt;/p&gt;

&lt;p&gt;If you are used to thinking in terms of entities, you can mechanically translate entities into values and mapping functions.  However, the better thing is to rethink your data types a bit. Sometimes the mapping from entities to values is clean but often with a bit of thought you can end up with representations which are better tuned for functional work.&lt;/p&gt;</description>
      <pubDate>Sun, 22 Mar 2009 11:03:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:9069d8ed-dd87-4cb4-8252-180bea0aad4d</guid>
      <author>Michael Feathers</author>
      <link>http://blog.objectmentor.com/articles/2009/03/22/the-sucessor-value-pattern</link>
      <category>Michaels Musings</category>
    </item>
    <item>
      <title>Pat Eyler Interviews Dean Wampler and Alex Payne on &amp;quot;Programming Scala&amp;quot;.</title>
      <description>&lt;p&gt;&lt;a href="http://twitter.com/gnupate"&gt;Pat Eyler&lt;/a&gt; posted an &lt;a href="http://on-ruby.blogspot.com/2009/03/dean-wampler-and-alex-payne-author.html"&gt;interview&lt;/a&gt; with &lt;a href="http://twitter.com/al3x"&gt;Alex Payne&lt;/a&gt; and me (Dean Wampler), which we conducted over email. We dish on Scala, Functional Programming, and our forthcoming book &lt;a href="http://oreilly.com/catalog/9780596157746/index.html"&gt;Programming Scala&lt;/a&gt;.&lt;/p&gt;</description>
      <pubDate>Tue, 17 Mar 2009 12:48:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:a53602a4-52af-4c4f-8bb5-105224343067</guid>
      <author>Dean Wampler</author>
      <link>http://blog.objectmentor.com/articles/2009/03/17/pat-eyler-interviews-dean-wampler-and-alex-payne-on-programming-scala</link>
      <category>Dean's Deprecations</category>
      <category>Scala</category>
    </item>
    <item>
      <title>FitNesse.Slim Scenario Shenanigans </title>
      <description>&lt;p&gt;I was working with Uncle Bob today and we came across a case where we wanted to invoke a &lt;a href="http://en.wikipedia.org/wiki/Currying"&gt;curried method&lt;/a&gt;, but it was in FitNesse. It took me a while to grok it. Now I do, but it took some time.&lt;/p&gt;


	&lt;p&gt;On the surface it involves a Decision Table using a Scenario Table, which uses a Scenario Table that ultimately uses a named Fixture. It&amp;#8217;s a bit of a long read but the results do suggest a way to express a generic test and then invoke it while reducing duplicated information.&lt;/p&gt;


	&lt;p&gt;Here&amp;#8217;s the link: &lt;a href="http://schuchert.wikispaces.com/FitNesse.Tutorials.ScenarioTables"&gt;http://schuchert.wikispaces.com/FitNesse.Tutorials.ScenarioTables&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;This is a rough draft. I&amp;#8217;ll be updating it over the next few days. If something does not make sense, please post a comment and I&amp;#8217;ll update it.&lt;/p&gt;


	&lt;p&gt;For C# users: I have not tried this example using Slim.Net. It should work if you follow the instructions from the previous tutorial and simply replace the Java code with C# (not really a big deal when you see the code). In fact, C# offers a more flexible switch, so it would be a bit cleaner.&lt;/p&gt;</description>
      <pubDate>Mon, 16 Mar 2009 23:25:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:daa17787-8acc-4810-b055-6169044772b8</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2009/03/16/fitnesse-slim-scenario-shenanigans</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>FitNesse</category>
      <category>tutorial</category>
      <category>slim</category>
      <category>Scenario</category>
    </item>
    <item>
      <title>Tighter Ruby Methods with Functional-style Pattern Matching, Using the Case Gem</title>
      <description>&lt;p&gt;Ruby doesn&amp;#8217;t have overloaded methods, which are methods with the same name, but different &lt;em&gt;signatures&lt;/em&gt; when you consider the argument lists and return values. This would be somewhat challenging to support in a dynamic language with very flexible options for method argument handling.&lt;/p&gt;


	&lt;p&gt;You can &amp;#8220;simulate&amp;#8221; overloading by parsing the argument list and taking different paths of execution based on the structure you find. This post discusses how &lt;em&gt;pattern matching&lt;/em&gt;, a hallmark of &lt;em&gt;functional programming&lt;/em&gt;, gives you powerful options.&lt;/p&gt;


	&lt;p&gt;First, let&amp;#8217;s look at a typical example that handles the arguments in an &lt;em&gt;ad hoc&lt;/em&gt; fashion. Consider the following &lt;code&gt;Person&lt;/code&gt; class. You can pass three arguments to the initializer, the &lt;code&gt;first_name&lt;/code&gt;, the &lt;code&gt;last_name&lt;/code&gt;, and the &lt;code&gt;age&lt;/code&gt;. Or, you can pass a hash using the keys &lt;code&gt;:first_name&lt;/code&gt;, &lt;code&gt;:last_name&lt;/code&gt;, and &lt;code&gt;:age&lt;/code&gt;.&lt;/p&gt;


&lt;pre&gt;
&lt;code&gt;
require "rubygems" 
require "spec" 

class Person
  attr_reader :first_name, :last_name, :age
  def initialize *args
    arg = args[0]
    if arg.kind_of? Hash       # 1
      @first_name = arg[:first_name]
      @last_name  = arg[:last_name]
      @age        = arg[:age]
    else
      @first_name = args[0]
      @last_name  = args[1]
      @age        = args[2]
    end
  end
end

describe "Person#initialize" do 
  it "should accept a hash with key-value pairs for the attributes" do
    person = Person.new :first_name =&amp;gt; "Dean", :last_name =&amp;gt; "Wampler", :age =&amp;gt; 39
    person.first_name.should == "Dean" 
    person.last_name.should  == "Wampler" 
    person.age.should        == 39
  end
  it "should accept a first name, last name, and age arguments" do
    person = Person.new "Dean", "Wampler", 39
    person.first_name.should == "Dean" 
    person.last_name.should  == "Wampler" 
    person.age.should        == 39
  end
end
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;The condition on the &lt;code&gt;# 1&lt;/code&gt; comment line checks to see if the first argument is a &lt;code&gt;Hash&lt;/code&gt;. If so, the attribute&amp;#8217;s values are extracted from it. Otherwise, it is assumed that three arguments were specified in a particular order. They are passed to &lt;code&gt;#initialize&lt;/code&gt; in a three-element array. The two &lt;a href="http://rspec.info"&gt;rspec&lt;/a&gt; &lt;em&gt;examples&lt;/em&gt; exercise these behaviors. For simplicity, we ignore some more general cases, as well as error handling.&lt;/p&gt;


	&lt;p&gt;Another approach that is more flexible is to use duck typing, instead. For example, we could replace the line with the &lt;code&gt;# 1&lt;/code&gt; comment with this line:&lt;/p&gt;


&lt;pre&gt;
&lt;code&gt;
if arg.respond_to? :has_key?
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;There aren&amp;#8217;t many objects that respond to &lt;code&gt;#has_key?&lt;/code&gt;, so we&amp;#8217;re highly confident that we can use &lt;code&gt;[symbol]&lt;/code&gt; to extract the values from the hash.&lt;/p&gt;


	&lt;p&gt;This implementation is fairly straightforward. You&amp;#8217;ve probably written code like this yourself. However, it could get complicated for more involved cases.&lt;/p&gt;


	&lt;h2&gt;Pattern Matching, a Functional Programming Approach&lt;/h2&gt;


	&lt;p&gt;Most programming languages today have &lt;code&gt;switch&lt;/code&gt; or &lt;code&gt;case&lt;/code&gt; statements of some sort and most have support for regular expression matching. However, in &lt;em&gt;functional programming&lt;/em&gt; languages, pattern matching is so important and pervasive that these languages offer very powerful and convenient support for pattern matching.&lt;/p&gt;


	&lt;p&gt;Fortunately, we can get powerful pattern matching, typical of functional languages, in Ruby using the &lt;a href="http://rubyforge.org/frs/?group_id=3690"&gt;Case&lt;/a&gt; gem that is part of the MenTaLguY&amp;#8217;s &lt;a href="http://rubyforge.org/frs/?group_id=3690"&gt;Omnibus Concurrency library&lt;/a&gt;. &lt;code&gt;Omnibus&lt;/code&gt; provides support for the hot &lt;em&gt;Actor model of concurrency&lt;/em&gt;, which Erlang has made famous. However, it would be a shame to restrict the use of the &lt;code&gt;Case&lt;/code&gt; gem to parsing Actor messages. It&amp;#8217;s much more general purpose than that.&lt;/p&gt;


	&lt;p&gt;Let&amp;#8217;s rework our example using the &lt;a href="http://rubyforge.org/frs/?group_id=3690"&gt;Case&lt;/a&gt; gem.&lt;/p&gt;


&lt;pre&gt;
&lt;code&gt;
require "rubygems" 
require "spec" 
require "case" 

class Person
  attr_reader :first_name, :last_name, :age
  def initialize *args
    case args
    when Case[Hash]       # 1
      arg = args[0]
      @first_name = arg[:first_name]
      @last_name  = arg[:last_name]
      @age        = arg[:age]
    else
      @first_name = args[0]
      @last_name  = args[1]
      @age        = args[2]
    end
  end
end

describe "Person#initialize" do 
  it "should accept a first name, last name, and age arguments" do
    person = Person.new "Dean", "Wampler", 39
    person.first_name.should == "Dean" 
    person.last_name.should  == "Wampler" 
    person.age.should        == 39
  end
  it "should accept a has with :first_name =&amp;gt; fn, :last_name =&amp;gt; ln, and :age =&amp;gt; age" do
    person = Person.new :first_name =&amp;gt; "Dean", :last_name =&amp;gt; "Wampler", :age =&amp;gt; 39
    person.first_name.should == "Dean" 
    person.last_name.should  == "Wampler" 
    person.age.should        == 39
  end
end
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;We require the &lt;code&gt;case&lt;/code&gt; gem, which puts the &lt;code&gt;#===&lt;/code&gt; method on steroids. In the &lt;code&gt;when&lt;/code&gt; statement in &lt;code&gt;#initialize&lt;/code&gt;, the expression &lt;code&gt;when Case[Hash]&lt;/code&gt; matches on a one-element array where the element is a &lt;code&gt;Hash&lt;/code&gt;. We extract the key-value pairs as before. The &lt;code&gt;else&lt;/code&gt; clause assumes we have an array for the arguments.&lt;/p&gt;


	&lt;p&gt;So far, this is isn&amp;#8217;t very impressive, but all we did was to reproduce the original behavior. Let&amp;#8217;s extend the example to really exploit some of the neat features of the &lt;code&gt;Case&lt;/code&gt; gem&amp;#8217;s pattern matching. First, let&amp;#8217;s narrow the allowed array values.&lt;/p&gt;


&lt;pre&gt;
&lt;code&gt;
require "rubygems" 
require "spec" 
require "case" 

class Person
  attr_reader :first_name, :last_name, :age
  def initialize *args
    case args
    when Case[Hash]       # 1
      arg = args[0]
      @first_name = arg[:first_name]
      @last_name  = arg[:last_name]
      @age        = arg[:age]
    when Case[String, String, Integer]
      @first_name = args[0]
      @last_name  = args[1]
      @age        = args[2]
    else
      raise "Invalid arguments: #{args}" 
    end
  end
end

describe "Person#initialize" do 
  it "should accept a first name, last name, and age arguments" do
    person = Person.new "Dean", "Wampler", 39
    person.first_name.should == "Dean" 
    person.last_name.should  == "Wampler" 
    person.age.should        == 39
  end
  it "should accept a has with :first_name =&amp;gt; fn, :last_name =&amp;gt; ln, and :age =&amp;gt; age" do
    person = Person.new :first_name =&amp;gt; "Dean", :last_name =&amp;gt; "Wampler", :age =&amp;gt; 39
    person.first_name.should == "Dean" 
    person.last_name.should  == "Wampler" 
    person.age.should        == 39
  end
  it "should not accept an array unless it is a [String, String, Integer]" do
    lambda { person = Person.new "Dean", "Wampler", "39" }.should raise_error(Exception)
  end
end
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;The new expression &lt;code&gt;when Case[String, String, Integer]&lt;/code&gt; only matches a three-element array where the first two arguments are strings and the third argument is an integer, which are the types we want. If you use an array with a different number of arguments or the arguments have different types, this &lt;code&gt;when&lt;/code&gt; clause won&amp;#8217;t match. Instead, you&amp;#8217;ll get the default &lt;code&gt;else&lt;/code&gt; clause, which raises an exception. We added another rspec example to test this condition, where the user&amp;#8217;s age was specified as a string instead of as an integer. Of course, you could decide to attempt a conversion of this argument, to make your code more &amp;#8220;forgiving&amp;#8221; of user mistakes.&lt;/p&gt;


	&lt;p&gt;Similarly, what happens if the method supports default values some of the parameters. As written, we can&amp;#8217;t support that option, but let&amp;#8217;s look at a slight variation of &lt;code&gt;Person#initialize&lt;/code&gt;, where a hash of values is not supported, to see what would happen.&lt;/p&gt;


&lt;pre&gt;
&lt;code&gt;
require "rubygems" 
require "spec" 
require "case" 

class Person
  attr_reader :first_name, :last_name, :age
  def initialize first_name = "Bob", last_name = "Martin", age = 29
    case [first_name, last_name, age]
    when Case[String, String, Integer]
      @first_name = first_name
      @last_name  = last_name
      @age        = age
    else
      raise "Invalid arguments: #{first_name}, #{last_name}, #{age}" 
    end
  end
end

def check person, expected_fn, expected_ln, expected_age
  person.first_name.should == expected_fn
  person.last_name.should  == expected_ln
  person.age.should        == expected_age
end

describe "Person#initialize" do 
  it "should require a first name (string), last name (string), and age (integer) arguments" do
    person = Person.new "Dean", "Wampler", 39
    check person, "Dean", "Wampler", 39
  end
  it "should accept the defaults for all parameters" do
    person = Person.new
    check person, "Bob", "Martin", 29
  end
  it "should accept the defaults for the last name and age parameters" do
    person = Person.new "Dean" 
    check person, "Dean", "Martin", 29
  end
  it "should accept the defaults for the age parameter" do
    person = Person.new "Dean", "Wampler" 
    check person, "Dean", "Wampler", 29
  end
  it "should not accept the first name as a symbol" do
    lambda { person = Person.new :Dean, "Wampler", "39" }.should raise_error(Exception)
  end
  it "should not accept the last name as a symbol" do
  end
  it "should not accept the age as a string" do
    lambda { person = Person.new "Dean", "Wampler", "39" }.should raise_error(Exception)
  end
end
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;We match on all three arguments as an array, asserting they are of the correct type. As you might expect, &lt;code&gt;#initialize&lt;/code&gt; always gets three parameters passed to it, including when default values are used.&lt;/p&gt;


	&lt;p&gt;Let&amp;#8217;s return to our original example, where the object can be constructed with a hash or a list of arguments. There are two more things (at least &amp;#8230;) that we can do. First, we&amp;#8217;re not yet validating the types of the values in the hash. Second, we can use the &lt;code&gt;Case&lt;/code&gt; gem to impose constraints on the values, such as requiring non-empty name strings and a positive age.&lt;/p&gt;


&lt;pre&gt;
&lt;code&gt;
require "rubygems" 
require "spec" 
require "case" 

class Person
  attr_reader :first_name, :last_name, :age
  def initialize *args
    case args
    when Case[Hash]
      arg = args[0]
      @first_name = arg[:first_name]
      @last_name  = arg[:last_name]
      @age        = arg[:age]
    when Case[String, String, Integer]
      @first_name = args[0]
      @last_name  = args[1]
      @age        = args[2]
    else
      raise "Invalid arguments: #{args}" 
    end
    validate_name @first_name, "first_name" 
    validate_name @last_name, "last_name" 
    validate_age
  end

  protected

  def validate_name name, field_name
    case name
    when Case::All[String, Case.guard {|s| s.length &amp;gt; 0 }]
    else
      raise "Invalid #{field_name}: #{first_name}" 
    end
  end

  def validate_age
    case @age
    when Case::All[Integer, Case.guard {|n| n &amp;gt; 0 }]
    else
      raise "Invalid age: #{@age}" 
    end
  end
end

describe "Person#initialize" do 
  it "should accept a first name, last name, and age arguments" do
    person = Person.new "Dean", "Wampler", 39
    person.first_name.should == "Dean" 
    person.last_name.should  == "Wampler" 
    person.age.should        == 39
  end
  it "should accept a has with :first_name =&amp;gt; fn, :last_name =&amp;gt; ln, and :age =&amp;gt; age" do
    person = Person.new :first_name =&amp;gt; "Dean", :last_name =&amp;gt; "Wampler", :age =&amp;gt; 39
    person.first_name.should == "Dean" 
    person.last_name.should  == "Wampler" 
    person.age.should        == 39
  end
  it "should not accept an array unless it is a [String, String, Integer]" do
    lambda { person = Person.new "Dean", "Wampler", "39" }.should raise_error(Exception)
  end
  it "should not accept a first name that is a zero-length string" do
    lambda { person = Person.new "", "Wampler", 39 }.should raise_error(Exception)
  end    
  it "should not accept a first name that is not a string" do
    lambda { person = Person.new :Dean, "Wampler", 39 }.should raise_error(Exception)
  end    
  it "should not accept a last name that is a zero-length string" do
    lambda { person = Person.new "Dean", "", 39 }.should raise_error(Exception)
  end    
  it "should not accept a last name that is not a string" do
    lambda { person = Person.new :Dean, :Wampler, 39 }.should raise_error(Exception)
  end    
  it "should not accept an age that is less than or equal to zero" do
    lambda { person = Person.new "Dean", "Wampler", -1 }.should raise_error(Exception)
    lambda { person = Person.new "Dean", "Wampler", 0 }.should raise_error(Exception)
  end    
  it "should not accept an age that is not an integer" do
    lambda { person = Person.new :Dean, :Wampler, "39" }.should raise_error(Exception)
  end    
end
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;We have added &lt;code&gt;validate_name&lt;/code&gt; and &lt;code&gt;validate_age&lt;/code&gt; methods that are invoked at the end of &lt;code&gt;#initialize&lt;/code&gt;. In &lt;code&gt;validate_name&lt;/code&gt;, the one &lt;code&gt;when&lt;/code&gt; clause requires &amp;#8220;all&amp;#8221; the conditions to be true, that the name is a string and that it has a non-zero length. Similarly, &lt;code&gt;validate_age&lt;/code&gt; has a &lt;code&gt;when&lt;/code&gt; clause that requires &lt;code&gt;age&lt;/code&gt; to be a positive integer.&lt;/p&gt;


	&lt;h2&gt;Final Thoughts&lt;/h2&gt;


	&lt;p&gt;So, how valuable is this? The code is certainly longer, but it specifies and enforces expected behavior more precisely. The rspec examples verify the enforcement. It smells a little of static typing, which is good or bad, depending on your point of view. ;)&lt;/p&gt;


	&lt;p&gt;Personally, I think the conditional checks are a good way to add robustness in small ways to libraries that will grow and evolve for a long time. The checks document the required behavior for code readers, like new team members, but of course, they should really get that information from the tests. ;) (However, it would be nice to extract the information into the &lt;code&gt;rdocs&lt;/code&gt;.)&lt;/p&gt;


	&lt;p&gt;For small, short-lived projects, I might not worry about the conditional checks as much (but how many times have those &amp;#8220;short-lived projects&amp;#8221; refused to die?).&lt;/p&gt;


	&lt;p&gt;You can read more about &lt;code&gt;Omnibus&lt;/code&gt; and &lt;code&gt;Case&lt;/code&gt; in this &lt;a href="http://www.infoq.com/articles/actors-rubinius-interview"&gt;InfoQ interview&lt;/a&gt; with MenTaLguY. I didn&amp;#8217;t discuss using the Actor model of concurrency, for which these gems were designed. For an example of Actors using Omnibus, see my &lt;a href="http://aspectprogramming.com/papers/BetterRubyThroughFP_v5.pdf"&gt;Better Ruby through Functional Programming&lt;/a&gt; presentation or the &lt;a href="http://confreaks.com/"&gt;Confreak&amp;#8217;s&lt;/a&gt; video of an earlier version of the presentation I gave at last year&amp;#8217;s &lt;a href="http://rubyconf2008.confreaks.com/better-ruby-through-functional-programming-2.html"&gt;RubyConf&lt;/a&gt;.&lt;/p&gt;</description>
      <pubDate>Mon, 16 Mar 2009 19:59:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:4e6b0c8e-7b8b-4c8d-b20c-6e30fe39c98c</guid>
      <author>Dean Wampler</author>
      <link>http://blog.objectmentor.com/articles/2009/03/16/tighter-ruby-methods-with-functional-style-pattern-matching-using-the-case-gem</link>
      <category>Dean's Deprecations</category>
      <category>Dynamic Languages</category>
      <category>Design Principles</category>
      <category>Ruby</category>
      <category>methods</category>
      <category>functional</category>
      <category>programming</category>
      <category>pattern</category>
      <category>matching</category>
    </item>
    <item>
      <title>Getting Started with FitNesse in C#</title>
      <description>&lt;p&gt;The tutorial I mentioned yesterday now has a Java path and a C# path. Check out &lt;a href="http://schuchert.wikispaces.com/FitNesse.Tutorials.0"&gt;http://schuchert.wikispaces.com/FitNesse.Tutorials.0&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;In addition, you&amp;#8217;ll need to get Slim.net. Check out here: &lt;a href="http://schuchert.wikispaces.com/Acceptance+Testing.UsingSlimDotNetInFitNesse"&gt;http://schuchert.wikispaces.com/Acceptance+Testing.UsingSlimDotNetInFitNesse&lt;/a&gt;.&lt;/p&gt;</description>
      <pubDate>Fri, 13 Mar 2009 01:45:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:98ba8262-bc45-4d8c-ae11-f010b3a533a9</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2009/03/13/getting-started-with-fitnesse-in-c</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>FitNesse</category>
      <category>tutorial</category>
      <category>c</category>
      <category>slim</category>
    </item>
    <item>
      <title>Getting Started with FitNesse</title>
      <description>&lt;p&gt;Want to know the very basics of getting a first FitNesse example up and running? Check it out here: &lt;a href="http://schuchert.wikispaces.com/FitNesse.Tutorials.0"&gt;http://schuchert.wikispaces.com/FitNesse.Tutorials.0&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;This is really bare-bones basic. I&amp;#8217;ll be adding more tutorials (mostly by request).&lt;/p&gt;


	&lt;p&gt;Please place requests in the comments if you&amp;#8217;d like to see other subjects (e.g. same thing with .Net and C#).&lt;/p&gt;


	&lt;p&gt;I&amp;#8217;ll be sticking to Slim-based implementations unless there&amp;#8217;s many requests for Fit.&lt;/p&gt;</description>
      <pubDate>Thu, 12 Mar 2009 01:29:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:23f9680b-cddd-41b8-aec5-14f2468e4699</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2009/03/12/getting-started-with-fitnesse</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>FitNesse</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Let's Hear it for the Zealots!</title>
      <description>&lt;p&gt;In his March 1st, 2009 &lt;a href="http://www.sdtimes.com/link/33300"&gt;column&lt;/a&gt; in SDTimes, Andrew Binstock takes the &amp;#8220;Zealots of Agile&amp;#8221; to task for claiming that Agile is the &lt;em&gt;one true way&lt;/em&gt;.  He made the counter-argument that non-agile projects have succeeded, and that agile projects have failed.  He implied that the attitudes of the agile zealots are blind to these facts.&lt;/p&gt;


	&lt;p&gt;What a load of dingoes kidneys!&lt;/p&gt;


	&lt;p&gt;There is a difference between a zealot, and a religious fanatic.  A religious fanatic cannot envision themselves to be wrong.  We in the agile community may indeed be zealots, but we know we can be wrong.  We know that projects succeeded before agile, and we know that agile projects have failed.  We know that there are other schools of thought that are just as valid as ours.  Indeed, most of us expect (even hope!) that agile will be superseded by something better one day.&lt;/p&gt;


	&lt;p&gt;Some of you may remember my keynote address at the 2002 XPUniverse in Chicago.  My son, Micah, and I got up in front of the group dressed in Jiu Jistsu garb, and commenced to do a martial arts demonstration.&lt;/p&gt;


	&lt;p&gt;After the demonstration I made the point that a student of Karate could have given an equally spellbinding, though quite different, show.  A student of Tae Kwon Do would amaze us with still other wonderful moves.  The morale, of course, was that there are many ways to get the job done.  There are many equally valid schools of thought.&lt;/p&gt;


	&lt;p&gt;However, the knowledge that there are other valid schools of thought does not dilute the zeal a student has for the school of thought he has chosen to study.  Do you think that a Jiu Jistsu master isn&amp;#8217;t a zealot?  You&amp;#8217;d better believe he is!  To be great, one must have zeal.  To rail against zeal is to rail against the desire for greatness.  It is &lt;em&gt;zeal&lt;/em&gt; that makes you go the extra distance to become great.  The Jiu Jitsu master may respect the Karate master, but his goal is to become great at Jiu Jitsu.&lt;/p&gt;


	&lt;p&gt;So I think it is &lt;em&gt;healthy&lt;/em&gt; that agile proponents are vociferous advocates of their school of thought.  They are like Karate students who are excited about their new skills, and want to teach those skills to others.  If their zeal to excel can infect others with similar zeal, so much the better.  We &lt;em&gt;need&lt;/em&gt; people in this industry who want to excel.&lt;/p&gt;


	&lt;p&gt;In his column Andrew derided agile zealots for claiming that Agile was the &lt;em&gt;one true path&lt;/em&gt;.  I don&amp;#8217;t know of any prominent agile advocate who has ever made that claim.  Indeed, when Kent Beck and I sat down in 1999 to plan out the XP Immersion training, we were very concerned that we might turn the XP movement into a religion.  We did not want to create the impression that XPers were the chosen people and that wisdom would die with us.  So we were, in fact, very careful to avoid any hint of the &amp;#8220;one true path&amp;#8221; argument.&lt;/p&gt;


	&lt;p&gt;As evidence of this, consider the Snowbird meeting in 2001.  That meeting was &lt;em&gt;inclusive&lt;/em&gt;, not exclusive.  We invited people from all over the spectrum to join us there.  &lt;span class="caps"&gt;DSDM&lt;/span&gt;, FDD, Scrum, Crystal, &lt;span class="caps"&gt;MDA&lt;/span&gt;, &amp;#38; &lt;span class="caps"&gt;RUP&lt;/span&gt; were all represented; and the agile manifesto (Yes, Andrew, Manifesto![1]) was the result.  That manifesto was a simple statement of values, not a claim to deific knowledge.&lt;/p&gt;


	&lt;p&gt;Am I an Agile Zealot?  Damned right I am!  Do I think Agile is the best way to get software done?  Damned right I do!  I wouldn&amp;#8217;t be doing Agile if I didn&amp;#8217;t think it was best.  Do I think Agile is better than someone else&amp;#8217;s school of thought?  Let me put it this way: I&amp;#8217;m quite happy to go head to head against someone who follows another school of thought.  I believe I&amp;#8217;d code him right into the ground!  Isn&amp;#8217;t that what any good student of his craft would think?  But I also recognize that one day I&amp;#8217;ll lose that competition, and that will be a great day for me because it will give me the opportunity to learn something new and better.&lt;/p&gt;


	&lt;p&gt;Andrew also mentioned that Kent Beck and I are so obsessed with our &amp;#8220;evangelical fervor&amp;#8221; that we: &amp;#8220;endlessly test and endlessly refine and refactor code to the point that it becomes an all-consuming diversion that does not advance the project&amp;#8221;.  &lt;span class="caps"&gt;WTF&lt;/span&gt;?  I&amp;#8217;ve been making monthly releases of FitNesse, and Kent has been cranking out releases of JunitMax; neither of us has been so busy gilding our respective lilies that we are failing to move our respective projects forward. Look around Andrew, we&amp;#8217;re shipping code over here brother.&lt;/p&gt;


	&lt;p&gt;As part of his rant against our &amp;#8220;evangelical fervor&amp;#8221; Andrew asked this rather snide question: &amp;#8220;I broke up that code into a separate class and added seven methods for what benefit, again?&amp;#8221;  This would appear to be a dig against refactoring &amp;#8211; or perhaps &lt;em&gt;excess&lt;/em&gt; refactoring.  Still the question has a simple answer.  We would only break up a module into a class with seven methods if that module was big, ugly, and complex, and by breaking it up we made it simple and easy to understand and modify.  It seems to me that leaving the module in a messy state is irresponsible and unprofessional.&lt;/p&gt;


	&lt;p&gt;Andrew complains that there is very little Agile experience with projects over six million lines of code.  I&amp;#8217;m not sure where he got that number from, perhaps he&amp;#8217;s been watching Steve Austin re-runs.  Actually, the majority of my 2008 consulting business has been with very large companies with products &lt;em&gt;well&lt;/em&gt; over six million lines of code.  Agile-in-the-Large is the name of the game in those companies!&lt;/p&gt;


	&lt;p&gt;Finally, Andrew says Michael Feathers is a &amp;#8220;moderate&amp;#8221; Agile proponent.  This is the same Michael Feathers who wrote a book defining Legacy code as code without tests &amp;#8211; hardly a moderate point of view.  Michael is a master, not a moderate.&lt;/p&gt;


	&lt;p&gt;I think Andrew has fallen into a common trap.  He sees the zeal of the agile proponents and mistakes it for religious fanaticism.  Instead of respecting that zeal as the outward manifestation of the inward desire to excel, he rails against it as being myopic and exclusive and then views all the statements of the agile proponents through that clouded viewport.  Once you have decided that someone is a religious fanatic, it is difficult to accept anything they say.&lt;/p&gt;


	&lt;p&gt;I think standing against religious fanaticism in the software community is a good thing.  I also think that those of us who are zealous must constantly watch that we are not also becoming blind to our own weaknesses and exclusive in our outlook.  But I could wish that those who fear religious fanaticism as much as I do would stop confusing it with professional zeal.&lt;/p&gt;


	&lt;p&gt;So here&amp;#8217;s the bottom line.  People who excel are, by definition, zealots.  People who aren&amp;#8217;t zealous, do not excel. So there&amp;#8217;s nothing wrong with being a zealot; indeed, zeal is a very positive emotion. The trick to being a zealot is to be mindful that the day will eventually come when some other zealot from a different school of thought will code you into the ground.  When that happens, you should thank him for showing you a better way.&lt;/p&gt;


	&lt;p id="fn1"&gt;&lt;sup&gt;1&lt;/sup&gt; I kicked off the Snowbird meeting by challenging the group to write a &amp;#8220;manifesto&amp;#8221;.  I chose the word &amp;#8220;manifesto&amp;#8221; because some years earlier I had read &lt;em&gt;The Object Oriented Database System Manifesto&lt;/em&gt; and I thought it was a clever use of the word.&lt;/p&gt;</description>
      <pubDate>Tue, 10 Mar 2009 16:58:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:7987e28e-935e-4303-b2e4-1e010beba6b7</guid>
      <author>Uncle Bob</author>
      <link>http://blog.objectmentor.com/articles/2009/03/10/lets-hear-it-for-the-zealots</link>
      <category>Uncle Bob's Blatherings</category>
      <category>Software Craftsmanship</category>
      <category>Clean Code</category>
    </item>
    <item>
      <title>Quality:  It's alive!  It's ALIVE!</title>
      <description>&lt;p&gt;Recently James Bach wrote a compelling post entitled &lt;a href="http://www.satisfice.com/blog/archives/224"&gt;Quality is Dead&lt;/a&gt;.  As much as I&amp;#8217;d like to agree, something interesting has just happened that tempts me to believe in a rebirth.&lt;/p&gt;


	&lt;p&gt;Just when James finally declares the death of quality, along comes the &lt;a href="http://manifesto.softwarecraftsmanship.org/main"&gt;Manifesto for Software Craftsmanship&lt;/a&gt;.  This simple document that builds upon the four values declared in the &lt;a href="http://agilemanifesto.org/"&gt;Agile Manifesto&lt;/a&gt; went live late on Friday evening.  Now, at 3PM on Saturday over 600 people have signed it!&lt;/p&gt;


	&lt;p&gt;What does this mean?  I think it means that many of us have seen what James was talking about, and are tired of it.  We don&amp;#8217;t want our users posting blogs &amp;#8211; as James did &amp;#8211; crying that they &lt;span class="caps"&gt;HATE&lt;/span&gt; us.  We want our users to be astonished by the elegance and simplicity of our creations.  We want other software developers to look under the hood and be amazed and impressed at the clarity and simplicity they see.&lt;/p&gt;


	&lt;p&gt;&lt;strong&gt;We want to be proud of our work!&lt;/strong&gt;&lt;/p&gt;


	&lt;p&gt;&lt;strong&gt;We want our quality back!&lt;/strong&gt;&lt;/p&gt;


	&lt;p&gt;And so a few weeks ago some software developers gathered at the offices of &lt;a href="http://www.8thlight.com/main"&gt;8th Light&lt;/a&gt; in Libertyville, Illinois, and began the process of creating this manifesto.  There followed a very active and passionate discussion in the &lt;a href="http://groups.google.com/group/software_craftsmanship?lnk=srg"&gt;Software Craftsmanship email group&lt;/a&gt;.  The end result was this manifesto.&lt;/p&gt;


	&lt;p&gt;I encourage all of you to read and sign the manifesto, join the email group, and help bring quality back to life in the software profession.&lt;/p&gt;</description>
      <pubDate>Sat, 07 Mar 2009 15:25:00 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:7fda0576-ab31-4f6b-bf1c-d87078134a6b</guid>
      <author>Uncle Bob</author>
      <link>http://blog.objectmentor.com/articles/2009/03/07/quality-its-alive-its-alive</link>
      <category>Uncle Bob's Blatherings</category>
      <category>Software Craftsmanship</category>
      <category>Clean Code</category>
    </item>
    <item>
      <title>!define TEST_SYSTEM {fit:A} part II</title>
      <description>&lt;p&gt;In 11/2008 I wrote the &lt;a href="http://blog.objectmentor.com/articles/2008/11/03/define-test_system-fit-a"&gt;first part of this article&lt;/a&gt; but I really did not give the background on why I originally asked Bob to add this feature.&lt;/p&gt;


	&lt;p&gt;So why does FitNesse need to be able to run different parts of suites in different VM&amp;#8217;s?&lt;/p&gt;


	&lt;p&gt;Imagine you are testing services registered on an &lt;span class="caps"&gt;ESB&lt;/span&gt;. That &lt;span class="caps"&gt;ESB&lt;/span&gt; allows 
deployment of services as &lt;span class="caps"&gt;EJB&lt;/span&gt;&amp;#8217;s. There&amp;#8217;s something important about that fact.
By default, different &lt;span class="caps"&gt;EJB&lt;/span&gt;&amp;#8217;s run with their own class loader. You can dig into
the &lt;span class="caps"&gt;EJB&lt;/span&gt; spec if you&amp;#8217;d like, but there&amp;#8217;s roughly a hierarchy of 5 class loaders 
by the time you get to an executing &lt;span class="caps"&gt;EJB&lt;/span&gt; (can be more, could be less).&lt;/p&gt;


	&lt;p&gt;Why is this important? If two &lt;span class="caps"&gt;EJB&lt;/span&gt;&amp;#8217;s make reference to the &amp;#8220;same&amp;#8221; &lt;span class="caps"&gt;JAR&lt;/span&gt; file, 
then each could get loaded by the same or a different class loader. If the
&lt;span class="caps"&gt;JAR&lt;/span&gt; file is installed high in the class-loader hierarchy, then they will
be loaded by the same class loader instance and therefore will be the same
classes.&lt;/p&gt;


	&lt;p&gt;However, let&amp;#8217;s assume that each &lt;span class="caps"&gt;EJB&lt;/span&gt; represents ones service. Furthermore,
each &lt;span class="caps"&gt;EJB&lt;/span&gt; makes a reference to some &lt;span class="caps"&gt;JAR&lt;/span&gt; file directly, that is, it is not
visible to a hierarchically higher class loader. Then that same &lt;span class="caps"&gt;JAR&lt;/span&gt; file will
get loaded twice, once by each class loader (this really happens), and those
exact same classes will be considered different.&lt;/p&gt;


	&lt;p&gt;That&amp;#8217;s right, the exact same &lt;span class="caps"&gt;JAR&lt;/span&gt; file loaded by 2 different class loaders are 
treated as unrelated classes.&lt;/p&gt;


	&lt;p&gt;In reality, each deployed &lt;span class="caps"&gt;EJB&lt;/span&gt; is &amp;#8220;complete&amp;#8221; in that in includes the &lt;span class="caps"&gt;JAR&lt;/span&gt;&amp;#8217;s it
needs to execute. So the &amp;#8220;same&amp;#8221; jar &amp;#8211; same in terms of file contents &amp;#8211; exists
twice in the system and is loaded by two class loaders.&lt;/p&gt;


	&lt;p&gt;Now, it gets a little worse. Those two &lt;span class="caps"&gt;EJB&lt;/span&gt;&amp;#8217;s work off a &amp;#8220;common&amp;#8221; data model.
Common in that the underlying business objects are common across a set of
applications. However, the common data model is a moving target (it&amp;#8217;s grown
as needed). To manage complexity, not all services are forced to update to the
latest version of the common data model at the same time (it&amp;#8217;s not really a
manageable solution &amp;#8211; generally).&lt;/p&gt;


	&lt;p&gt;So now we have 2 (really several) &lt;span class="caps"&gt;EJB&lt;/span&gt;&amp;#8217;s that refer to logically the same &lt;span class="caps"&gt;JAR&lt;/span&gt;
but different versions. Luckily, this is&lt;i&gt; &lt;b&gt;no&lt;/i&gt;&lt;/b&gt; problem because 
each &lt;span class="caps"&gt;EJB&lt;/span&gt; has its own class loader, so it is OK for 2 &lt;span class="caps"&gt;EJB&lt;/span&gt;&amp;#8217;s to refer to 
different versions of the same logical data model.&lt;/p&gt;


	&lt;p&gt;How does any of this have&lt;i&gt; &lt;b&gt;anything&lt;/i&gt;&lt;/b&gt; to do with FitNesse? When
FitNesse executes a suite, by default all tests are executed in the same
VM with one class loader. So if you have a suite of tests that test different
services, each of which might be using a different version of the common data
model, then the first service executed loads the common data model, which 
really isn&amp;#8217;t exactly common. This causes tests to fail that would not fail
if each text executed with its own class loader.&lt;/p&gt;


	&lt;p&gt;Rather than deal with writing custom class loaders, Bob instead make it 
possible to name a VM (see the title for the syntax). By doing this, Bob
make it possible to effect a similar environment to that experienced by &lt;span class="caps"&gt;EJB&lt;/span&gt;&amp;#8217;s by default.&lt;/p&gt;</description>
      <pubDate>Wed, 04 Mar 2009 04:07:00 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:4111f3d3-5049-47f4-9649-56b586e7df6b</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2009/03/04/define-test_system-fit-a-part-ii</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>ejb</category>
      <category>class</category>
      <category>loading</category>
      <category>acceptnace</category>
      <category>testing</category>
    </item>
    <item>
      <title>Whiners that Fail</title>
      <description>&lt;p&gt;The acronym is not accidental.&lt;/p&gt;


	&lt;p&gt;Recently, Michael Feathers posted a hugely valuable &lt;a href="http://tinyurl.com/ab3tgn"&gt;blog&lt;/a&gt; entitled: &lt;em&gt;10 Papers every Programmer should read at least twice&lt;/em&gt;.  Do you have &lt;em&gt;any&lt;/em&gt; idea how valuable this is?  Michael has read hundreds, if not thousands, of papers, and he is freely offering his opinion about which ten are the best.  A wise man would pay thousands of dollars for this information.  But some people prefer to whine.&lt;/p&gt;


	&lt;p&gt;Get a load of this gem posted by someone named David:&lt;/p&gt;


	&lt;blockquote&gt;
		&lt;p&gt;... you should have actual pdfs of these papers, not links that require you to pay. If these papers were truly important, then you would be able to read them without paying &amp;#8230;  your tone is arrogant and annoying. Get over yourself.&lt;/p&gt;
	&lt;/blockquote&gt;


	&lt;p&gt;Clearly this is a troll.  Normally I do not feed the trolls.  But this one pushed my buttons (I know, I know, that&amp;#8217;s the intent of a troll&amp;#8212;well it worked.)  But it wasn&amp;#8217;t only this response.  Here&amp;#8217;s another one by someone named Mik:&lt;/p&gt;


	&lt;blockquote&gt;
		&lt;p&gt;Thanks for the list, but please don&amp;rsquo;t link to &lt;span class="caps"&gt;ACM&lt;/span&gt; portal, it is a pay site. Always link to a free version if it is available. Yes, these papers are worth spending a minute or two searching for a free version, and yes they are probably worth spending real money to read as well, but if a free version exists, save us all the time and money and link to it. &lt;p/&gt; One small moment for an author, or one giant waste of time for mankind.&lt;/p&gt;
	&lt;/blockquote&gt;


	&lt;p&gt;&lt;strong&gt;What a bunch of whiners!&lt;/strong&gt;&lt;/p&gt;


	&lt;p&gt;Here is this golden nugget laid in front of them, and they complain that it&amp;#8217;s too heavy to pick up.  &lt;strong&gt;Fools!  Losers!&lt;/strong&gt;&lt;/p&gt;


	&lt;p&gt;I&amp;#8217;m sorry for the anger, but the attitude makes me crazy.  Are we professionals who stand on our own and take responsibility for our careers?  Or are we children who expect our parents to wipe our bums?&lt;/p&gt;


	&lt;p&gt;I know I&amp;#8217;m preaching to the choir. The people who take the time to read this blog don&amp;#8217;t generally need to be told this. But on the off-chance that this might actually reach someone and change their attitude&amp;#8230;here goes.&lt;/p&gt;


	&lt;p&gt;&lt;span class="caps"&gt;YOU&lt;/span&gt;, and &lt;em&gt;NO  &amp;nbsp;&amp;nbsp;  &lt;span class="caps"&gt;ONE&lt;/span&gt; &amp;nbsp;&amp;nbsp; &lt;span class="caps"&gt;ELSE&lt;/span&gt;&lt;/em&gt;, is responsible for your career.  Your employer is not responsible for it.  You should not depend on your employer to advance your career.  You should not depend on your employer to buy you books, it&amp;#8217;s great if they do, but it&amp;#8217;s not really their responsibility.  If they won&amp;#8217;t buy them, &lt;span class="caps"&gt;YOU&lt;/span&gt; buy them!  It&amp;#8217;s not your employers responsibility to teach you a new language.  It&amp;#8217;s great if they send you to a training course, but if they don&amp;#8217;t &lt;span class="caps"&gt;YOU&lt;/span&gt; teach the language to your self!&lt;/p&gt;


	&lt;p&gt;I fear greatly that our culture of entitlement has created a bunch of whining sissy programmers who think it&amp;#8217;s unfair that they have to pay for a copyrighted article.  &lt;em&gt;(Pay?  Who me?  That&amp;#8217;s my employer&amp;#8217;s job!  That&amp;#8217;s my teacher&amp;#8217;s job!  That&amp;#8217;s Michael Feathers&amp;#8217; job! I mean if they want me to be a good programmer then they&amp;#8217;d better not expect ME to pay for these articles!  They&amp;#8217;d better not expect ME to do a google search for an article! They&amp;#8217;d better come right over here to my cubicle between 9am and 10am and read the article to me while stroking my hair!)&lt;/em&gt;&lt;/p&gt;


	&lt;p&gt;The world does not owe you a living.  Your employer does not owe you a career.  And Michael Feathers&amp;#8217; does not owe you access to free articles.&lt;/p&gt;</description>
      <pubDate>Fri, 27 Feb 2009 18:55:40 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:f919918b-d789-4369-bb58-9fdbbe1fa866</guid>
      <author>Uncle Bob</author>
      <link>http://blog.objectmentor.com/articles/2009/02/27/whiners-that-fail</link>
      <category>Uncle Bob's Blatherings</category>
    </item>
    <item>
      <title>10 Papers Every Programmer Should Read (At Least Twice)</title>
      <description>&lt;p&gt;I spent most of yesterday afternoon working on a paper I&#8217;m co-writing.  It was one of those days when the writing came easy.  I was moving from topic to topic, but then I realized that I was reaching too far backward &amp;#8211; I was explaining things which I shouldn&#8217;t have had to explain to the audience I was trying to reach.&lt;/p&gt;

&lt;p&gt;When I first started writing, one of the pieces of advice that I heard was that you should always imagine that you are writing to a particular person.  It gets your juices going &amp;#8211; you&#8217;re automatically in an explanatory state of mind and you know what you can expect from your audience.  I was doing that, but I noticed that I was drifting.  I was losing my sense of audience. I started to explain one thing, and then I realized that I would have to explain something else to help it make sense. I couldn&#8217;t imagine that person any more. How could I know what they know and what they don&#8217;t?&lt;/p&gt;

&lt;p&gt;
The problem I was experiencing is only getting worse. People come into programming from many different directions.  Some started in other fields, and others started programming as teens.  Some started with &lt;span class="caps"&gt;BASIC&lt;/span&gt;, others started with Ruby or C.  The industry is filled with knowledge, but it isn&#8217;t common knowledge. It isn&#8217;t knowledge that we all share. We have to dig for it because of a peculiar fact about our industry: we reinvent our languages and notations every ten years.  It&#8217;s hard to find deeply technical books and articles which stand the test of time in software: they are all Latin within 20 years.&lt;/p&gt;

&lt;p&gt;So, I was thinking about this and trying to not to get too glum.  I realized that instead of complaining, I could help by pointing to some papers which are easily available online and which (to me at least) point to some of the most interesting ideas about software.  To me, these are classic papers which contain deep &#8220;things you oughta know&amp;#8221; about code &amp;#8211; the material you work with.&lt;/p&gt;

&lt;p&gt;
We&#8217;ve taken an interesting turn in the industry over the past ten years.  We&#8217;ve come to value experiential learning much more, and we&#8217;ve regained a strong pragmatic focus, but I think it would be a shame if we lost sight of some of the deeper things which people have learned over the past 50 years.  Rediscovering them would be painful, and (to me) not knowing them would be a shame.&lt;/p&gt;

&lt;p&gt;Here&#8217;s the original list.  It&#8217;s a rather personal list of foundational papers and papers with deep ideas. I wrote it &amp;#8220;off the cuff&amp;#8221; and threw it into a tumblr blog the other day and I got responses from people who suggested others.  I&#8217;ll add those in a later blog.&lt;/p&gt;

&lt;p&gt;Most are easy to read but some are rough going &amp;#8211; they drop off into math after the first few pages.   Take the math to tolerance and then move on. The ideas are the important thing.&lt;/p&gt; 

	&lt;ol&gt;
	&lt;li&gt;&lt;a href="http://sunnyday.mit.edu/16.355/parnas-criteria.html"&gt;On the criteria to be used in decomposing systems into modules&lt;/a&gt; &amp;#8211; David Parnas&lt;/li&gt;
		&lt;li&gt;&lt;a href="http://research.sun.com/techrep/1994/abstract-29.html"&gt;A Note On Distributed Computing&lt;/a&gt; &amp;#8211; Jim Waldo, Geoff Wyant, Ann Wollrath, Sam Kendall&lt;/li&gt;
		&lt;li&gt;&lt;a href="http://portal.acm.org/citation.cfm?id=365257"&gt;The Next 700 Programming Languages&lt;/a&gt; &amp;#8211; P. J. Landin&lt;/li&gt;
		&lt;li&gt;&lt;a href="http://portal.acm.org/citation.cfm?id=359579"&gt;Can Programming Be Liberated from the von Neumann Style?&lt;/a&gt; &amp;#8211; John Backus&lt;/li&gt;
		&lt;li&gt;&lt;a href="http://cm.bell-labs.com/who/ken/trust.html"&gt;Reflections on Trusting Trust&lt;/a&gt; &amp;#8211; Ken Thompson&lt;/li&gt;
		&lt;li&gt;&lt;a href="http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.50.6083"&gt;Lisp: Good News, Bad News, How to Win Big&lt;/a&gt; &amp;#8211; Richard Gabriel&lt;/li&gt;
		&lt;li&gt;&lt;a href="http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.29.363"&gt;An experimental evaluation of the assumption of independence in multiversion programming&lt;/a&gt; &amp;#8211; John Knight and Nancy Leveson&lt;/li&gt;
		&lt;li&gt;&lt;a href="http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.50.7565"&gt;Arguments and Results&lt;/a&gt; &amp;#8211; James Noble&lt;/li&gt;
		&lt;li&gt;&lt;a href="http://c2.com/doc/oopsla89/paper.html"&gt;A Laboratory For Teaching Object-Oriented Thinking&lt;/a&gt; &amp;#8211; Kent Beck, Ward Cunningham&lt;/li&gt;
		&lt;li&gt;&lt;a href="http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.31.562"&gt;Programming as an Experience: the inspiration for Self&lt;/a&gt; &amp;#8211; David Ungar, Randall B. Smith&lt;/li&gt;
	&lt;/ol&gt;


&lt;p&gt;&lt;i&gt;(edit: Added a brief synopsis of each of them and why I think they are special):&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;On the criteria to be used in decomposing systems into modules &amp;#8211; Parnas&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;This is a very old paper, but it is more than a classic.  In in it, Parnas introduces a forerunner to the &lt;i&gt;Single Responsibility Principle&lt;/i&gt;.  He introduces the idea that we should use modularity to hide design decisions &amp;#8211; things which could change.  People still don&amp;#8217;t consider this as often as they should.&lt;/p&gt;

&lt;p&gt; Another thing I really like in the paper is his comment on the &lt;span class="caps"&gt;KWIC&lt;/span&gt; system which he used as an example.  He mentioned that it would take a good programmer a week or two to code. Today, it would take practically no time at all.  Thumbs up for improved skills and better tools.  We have made progress.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;A Note On Distributed Computing &#8211; Waldo, Wyant, Wollrath, Kendall&lt;/b&gt;&lt;/p&gt;&lt;p&gt; Abstraction is great but it can only go so far.  In this paper, the authors lay to rest what was once a pervasive myth &amp;#8211; that we could design a distributed system and make distribution transparent.  Ever wonder why you had to implement specific interfaces to do remoting in Java?  This is why. &lt;/p&gt;&lt;p&gt; In the aftermath it might seem hard to believe that people thought this was possible.  I think we can we partially thank this paper for that.
&lt;/p&gt;
&lt;p&gt;&lt;b&gt;
The Next 700 Programming Languages &amp;#8211; Landin&lt;/b&gt;&lt;/p&gt;&lt;p&gt; Most of us have spent a lot of time working in traditional programming languages, but functional programming languages are slowly seeing an uptick and many OO languages are gaining functional features. This paper (which reads like a tutorial) makes an argument for an expression-oriented style of programming. It also lays the foundation for lazy evaluation. &lt;/p&gt;
&lt;p&gt;One of the other neat things about this paper, from a historical point of view, is that there is a discussion section at the end in which there a number of questions and comments about whether making indentation significant in a language is a good idea.  I was thrown to see people asking whether or not this would be a problem for functions which span over several pages(!).&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Can Programming Be Liberated from the von Neumann Style? &#8211; Backus&lt;/b&gt;&lt;/p&gt;&lt;p&gt; John Backus is known for a number of achievements in computer science.  He received the &lt;span class="caps"&gt;ACM&lt;/span&gt; Turing Award for his work on Fortran.  This paper, which he presented at the award ceremony was rather shocking at the time because it said, in essence, &#8220;we got it wrong.&#8221;  Backus took the opportunity to make a plea for pure functional programming.  His arguments were convincing and they helped to set a research agenda which is just now starting to make some waves in the mainstream.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Reflections on Trusting Trust &#8211; Thompson&lt;/b&gt;&lt;/p&gt;&lt;p&gt; I once heard that when this paper was presented, people in attendance rushed back to de-compile their C compilers and look for, er, problems.  This paper unveiled a hard problem at the heart of computer security.  If you&#8217;ve spent any time at all thinking about security, you need to read it.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Lisp: Good News, Bad News, How to Win Big &#8211; Gabriel&lt;/b&gt;&lt;/p&gt;&lt;p&gt; This paper is a bit atypical in this list.  It&#8217;s aimed at the Lisp community and it comes off as a bit of a lament.  But, hidden deep within it is the Gabriel&#8217;s description of the &#8216;Worse is Better&#8217; philosophy &amp;#8211; an idea with profound implications for the acceptance and spread of technology.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;An experimental evaluation of the assumption of independence in multiversion programming &#8211; John Knight and Nancy Leveson&lt;/b&gt;&lt;/p&gt;&lt;p&gt; Behind this dry title lies something very interesting. I first heard about this paper from Ralph Johnson in a newsgroup discussion about program correctness.  It turns out that one of the avenues that engineers in other disciplines take to make their products stronger &amp;#8211; redundancy &amp;#8211; doesn&#8217;t really work in software.  Multi-version programming was the idea that you could decrease faults in critical systems by handing the spec to several teams, having them develop the software independently, and then having the systems run in parallel.  A monitoring process verifies their results and if there is any discrepancy it picks the most common result.  Sounds like it should work, right? Well..&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Arguments and Results &#8211; Noble&lt;/b&gt;&lt;/p&gt;&lt;p&gt; I think that all of the other papers in this list are rather well known in some circles. This one isn&#8217;t, or if it is, I just haven&#8217;t found that circle yet.  What I like about this paper is that it takes something which we deal with every day &amp;#8211; the set of arguments and results of functions &amp;#8211; and it works them through a series of variations which just don&#8217;t occur to many people.  The fact is, every function that you work with has a number of possible directions if could evolve in.  Not all of them are appropriate, but if you know the possible directions, you&#8217;re richer for it.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;A Laboratory For Teaching Object-Oriented Thinking &#8211;  Beck, Cunningham&lt;/b&gt;&lt;/p&gt;&lt;p&gt; There are an incredible number of papers about there about object orientation.  The thing which makes this one great is its directness.  OO went through a number of stages.  It was once fresh and novel, then it was ornate, and then it became matter-of-fact.  This paper hits upon key ideas which many people don&#8217;t talk about much any more: anthropomorphism and dropping the top/down perspective.  It also shows you how you can design with index cards. It may not sound cool but it is incredibly effective.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Programming as an Experience: the inspiration for Self &#8211; Ungar, Smith&lt;/b&gt;&lt;/p&gt;&lt;p&gt; How many people know about the Self Project? Not enough in my opinion.  Self was an attempt to take two ideas in computing and push them as far as humanly possible.  The first was minimalism: the Self programming language was thoroughly in the Lisp and Smalltalk vein &amp;#8211; everything was defined in terms of the smallest number of primitives possible.  The other idea was direct manipulation &amp;#8211; the idea that the object metaphor could be pushed all the way in the user interface &amp;#8211; the programmer and user sit with a mouse in a sea of directly clickable objects and use them for everything.  If they could&#8217;ve gotten away with dropping the keyboard, I think they would&#8217;ve.&lt;/p&gt;

&lt;p&gt;The amount of technology which the Self project threw off is terrifying also.  Self broke ground in dynamic language optimization and VM design.  Chances are, your VM uses technology it pioneered.  It&#8217;s also one of the more perverse ironies that the most widely distributed programming language today (JavaScript) is a prototype-based programming language which borrowed ideas from the hyper-research-y Self.&lt;/p&gt;

&lt;p&gt;What would you add to the list?&lt;/p&gt;</description>
      <pubDate>Thu, 26 Feb 2009 20:49:00 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:2a8b62cf-d3ae-4c95-9105-32548762637b</guid>
      <author>Michael Feathers</author>
      <link>http://blog.objectmentor.com/articles/2009/02/26/10-papers-every-programmer-should-read-at-least-twice</link>
      <category>Michaels Musings</category>
    </item>
  </channel>
</rss>
