<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>//FIXME</title>
	
	<link>http://eraserhead.net</link>
	<description>Jason Felice's blog</description>
	<lastBuildDate>Sat, 04 Sep 2010 03:13:54 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/eraserhead/ADNx" /><feedburner:info uri="eraserhead/adnx" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Coping with Pathological Task-Switching</title>
		<link>http://feedproxy.google.com/~r/eraserhead/ADNx/~3/QlnGU2pn52o/</link>
		<comments>http://eraserhead.net/2010/09/coping-with-pathological-task-switching/#comments</comments>
		<pubDate>Sat, 04 Sep 2010 03:13:54 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://eraserhead.net/?p=589</guid>
		<description><![CDATA[In one week, I will be moving on to Blue Frog Gaming from Micros Retail.  Everything tells me this will be a transition to a much calmer environment.  Now is probably one of the last chances I have to record the big lessons I&#8217;ve learned about working in a stressful task-switching environment.
The Problems
Task [...]]]></description>
			<content:encoded><![CDATA[<p>In one week, I will be moving on to Blue Frog Gaming from Micros Retail.  Everything tells me this will be a transition to a <em>much</em> calmer environment.  Now is probably one of the last chances I have to record the big lessons I&#8217;ve learned about working in a stressful task-switching environment.</p>
<h1>The Problems</h1>
<h2>Task Confusion</h2>
<p>If you work on lots of similar tasks, especially if they are sometimes yanked out from under you while you work on them and replaced with other similar tasks, they start to run together.  You remember that you just fixed a timeout issue that was reported by &#8211; who was that, that you worked on this morning?  The Flarg Shoppe project?  No, you did that yesterday.  But the timeout fix was certainly on the Quux module, and only Flarg and Butterford use that module.  Wait&#8230;</p>
<h2>Splattered Attention Span</h2>
<p>Your brain can only handle so much task switching.  As you task switch more, each context transition becomes more fragile, and you can have a &#8220;bad switch&#8221;.  For me, a &#8220;bad switch&#8221; results in a complete loss of context &#8211; a short term memory wipe where you have to reboot and rebuild your current memory state.</p>
<h2>Morale Shutdown</h2>
<p>We know that task switching has negative affects on short-term memory.  We also know that we do not accomplish more by trying to do multiple things at once.  It might be difficult to convince management of this, but you might just get through. But sometimes, management finds this is necessary for political reasons anyway.  (It actually serves a purpose for management &#8211; they can point to their actions and show that the failure doesn&#8217;t stem from the Socially Worst Sin Of Management &#8211; Inactivity In The Face Of A Problem.  It is actually <em>much</em> more difficult to defend against an accusation of inactivity than an accusation of failure.  But don&#8217;t get all high-and-mighty when you realize this &#8211; it&#8217;s the same reason we coders pull extra hours on a late and doomed project.)</p>
<p>But there is a point &#8211; for me, usually by the fourth activity yanked out from under me in one day, preventing me from accomplishing <em>anything</em> because <em>everything</em> is important &#8211; where Complete Morale Shutdown occurs.  My brain has checked out, turn up the headphones, open Eclipse.  Don&#8217;t forget to scroll the code window every few minutes until 5PM.</p>
<h2>Stress Body Buzz</h2>
<p>This was the worst.  I&#8217;ve only had this maybe three times, and I get very worried that this has a big negative affect on health.  I&#8217;ve walked out of the office literally unable to calm down.  On the worst occasion, I called my doctor on Sunday because I still hadn&#8217;t recovered from Friday.</p>
<p>I&#8217;ve found that an extremely rigorous bike ride can greatly speed recovery.</p>
<h1>The Solutions</h1>
<h2>Work on the Big Problem</h2>
<p>The first lesson, of course, is that frequent task-switchng doesn&#8217;t really improve throughput or profitability &#8211; and most certainly destroys it &#8211; so seek to remove the fundamental underlying issues.  This, of course, takes time and management involvement and systems thinking, and there probably aren&#8217;t any standard solutions to this problem.</p>
<p>The rest of this article is about interim fixes that you will need while you work on the big problem.</p>
<h2>Turn Off E-Mail Alerts</h2>
<p>Do you really think you&#8217;re going to forget to check your e-mail?  Really?</p>
<p>If you can arrange it, steal time by closing e-mail and telling your manager to physically get you if something really requires immediate attention.</p>
<h2>Use Tactile Reminders</h2>
<p>If you work on multiple tasks in one day and they are similar, it is <em>very</em> easy to become confused which task for which customer you are working on.  Tactile reminders such as Post-It(r) notes or index cards that you move around are very useful for this purpose.  They are invaluable for rebuilding memory state during a Splattered Attention Span reboot.</p>
<h2>Make TDD Fail</h2>
<p>TDD in any form is a big help when coding.  In a normal environment it adds a rhythm which keeps momentum from leaving, but in a frenetic environment it keeps you on task.  Can&#8217;t remember what you were doing before that interruption?  Click the &#8220;run test&#8221; button&#8230; ah, that was it.</p>
<p>If you have a research phase to your current task, write a failing test immediately for any requirement discovered.  This is a bit different from the normal TDD rules, where you don&#8217;t write the next failing test until you&#8217;ve passed the last test.  In this mode, you collect failing tests when necessary, and commit when they reach zero.  Note that zero can still be reached a couple times on one task.</p>
<p>Unless you can just spit out the test&#8217;s code in one go, simply make the test fail with the <tt>fail()</tt> command and a very descriptive test name; otherwise, you are inviting Splattered Attention Span.</p>
<h2>Use the Shell&#8217;s &#8220;&amp;&amp;&#8221;</h2>
<p>As you thrash your short-term memory, your idea of what is a &#8220;long running&#8221; command becomes shorter and shorter.  Longer than 30 seconds is hard to keep focused.  If you need to run multiple steps, you can chain them together with your shell&#8217;s &#8220;&amp;&amp;&#8221; operator.  Joining multiple steps reduces opportunity for a context-switch-overload full-stop.</p>
<h2>Learn VCS Hygiene</h2>
<p>You should become adept at using your version control system from the command-line to inqure about what changes exist.  Make it a strong habit to check before coding something new and review all changes before commit.  It&#8217;s harder to get an overview when you are frequently task-switching.</p>
<h2>Use git</h2>
<p>Git is wonderful, and it even makes a good SVN client (once you bootstrap it from your SVN repository &#8211; which is admittedly painful).  Become familiar with with &#8220;git stash&#8221; &#8211; a task switcher&#8217;s savior.</p>
<p>Switching between branches (when necessary &#8211; running multiple branches is a bad practice when it can be avoided) is also <em>much</em> less painful to the short-term-memory impaired in git than SVN.  In git, it is a practically instantaneous operation; in Subversion, it is an assured short-term memory snow crash.</p>
<h2>Automate, Automate, Automate</h2>
<p>There are many technical investments that you can to reduce the affect of task switching.  Multi-step manual processes are much more costly in a stressful environment than other environments, because each step transition invites a high probability of attention-span splatter.  Consequently, investing in automation is a big win.</p>
<p>Of course, you are trying to invest in automation in a frenetic environment&#8230; how could this work?  The answer is that you need to grow these automations from tiny improvements.  A few notes I&#8217;ve learned along the way:</p>
<ul>
<li>For the most part, you don&#8217;t need TDD if it is a process that will be run only by you or other developers and it prints a stack trace on failure.
<li>A small batch file that does three sequential things is a big win for a small investment.  Use a language that you won&#8217;t mind maintaining when it grows into a big, hairy ball.
<li>Weigh the possibility of reuse of your application code in your automations.  If there is potential, either use the same language as your application code or a scripting language which you can bind to it (e.g. Python/Jython, Ruby/JRuby).
</ul>
<img src="http://feeds.feedburner.com/~r/eraserhead/ADNx/~4/QlnGU2pn52o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://eraserhead.net/2010/09/coping-with-pathological-task-switching/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://eraserhead.net/2010/09/coping-with-pathological-task-switching/</feedburner:origLink></item>
		<item>
		<title>A Dirty C++ Testing Trick</title>
		<link>http://feedproxy.google.com/~r/eraserhead/ADNx/~3/VXIZpOBa8eo/</link>
		<comments>http://eraserhead.net/2010/08/a-dirty-c-testing-trick/#comments</comments>
		<pubDate>Sun, 15 Aug 2010 16:25:22 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[TDD]]></category>

		<guid isPermaLink="false">http://eraserhead.net/?p=584</guid>
		<description><![CDATA[Say you need access to a private member when testing.  In my current case, I haven&#8217;t invented the machinery for state transitions, but I&#8217;m writing the OpenGL rendering based on our hero&#8217;s state (this is for my Impossible Mission clone).
Boost often provides friend classes and template friends to do this, but this can be [...]]]></description>
			<content:encoded><![CDATA[<p>Say you need access to a private member when testing.  In my current case, I haven&#8217;t invented the machinery for state transitions, but I&#8217;m writing the OpenGL rendering based on our hero&#8217;s state (this is for my Impossible Mission clone).</p>
<p>Boost often provides friend classes and template friends to do this, but this can be a lot of work.  What I&#8217;ve done is made the member protected, then:</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">struct</span> TestableGuy <span style="color: #008080;">:</span> <span style="color: #0000ff;">public</span> Guy <span style="color: #008000;">&#123;</span>
    <span style="color: #0000ff;">inline</span> State<span style="color: #000040;">&amp;</span> state<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span> <span style="color: #0000ff;">return</span> state_<span style="color: #008080;">;</span> <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span></pre></div></div>

<p>In my testing code:</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;">      Guy g<span style="color: #008000;">&#40;</span>Point<span style="color: #008000;">&#40;</span><span style="color: #0000dd;">99</span>,<span style="color: #0000dd;">99</span><span style="color: #008000;">&#41;</span>, ts<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
      <span style="color: #0000ff;">reinterpret_cast</span><span style="color: #000080;">&lt;</span>TestableGuy<span style="color: #000040;">&amp;</span><span style="color: #000080;">&gt;</span><span style="color: #008000;">&#40;</span>g<span style="color: #008000;">&#41;</span>.<span style="color: #007788;">state</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #000080;">=</span> s<span style="color: #008080;">;</span></pre></div></div>

<p>I&#8217;m using reinterpret_cast&lt;&gt; to avoid needing to maintain constructors on TestableGuy as I add them or change them on Guy.  Since no new data members or virtual functions were added, we can be assured that the classes have the same binary representation.</p>
<img src="http://feeds.feedburner.com/~r/eraserhead/ADNx/~4/VXIZpOBa8eo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://eraserhead.net/2010/08/a-dirty-c-testing-trick/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://eraserhead.net/2010/08/a-dirty-c-testing-trick/</feedburner:origLink></item>
		<item>
		<title>Using hstest to Run Haskell Tests</title>
		<link>http://feedproxy.google.com/~r/eraserhead/ADNx/~3/zpPFI1_6Xl4/</link>
		<comments>http://eraserhead.net/2010/06/collecting-tests-in-haskell/#comments</comments>
		<pubDate>Sun, 27 Jun 2010 17:00:22 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Haskell]]></category>
		<category><![CDATA[hstest]]></category>
		<category><![CDATA[HUnit]]></category>
		<category><![CDATA[QuickCheck]]></category>
		<category><![CDATA[TDD]]></category>
		<category><![CDATA[test-framework]]></category>

		<guid isPermaLink="false">http://eraserhead.net/?p=558</guid>
		<description><![CDATA[Unit Testing in Haskell
QuickCheck is the gold standard for testing pure functional (side-effect free) code in Haskell. It allows you to assert properties of functions, such as &#8220;this function returns a non-negative result for any input.&#8221; QuickCheck generates input cases and checks the proposition automatically.
HUnit is the usual xUnit clone for Haskell. It deals with [...]]]></description>
			<content:encoded><![CDATA[<h2>Unit Testing in Haskell</h2>
<p><a href="http://www.haskell.org/haskellwiki/Introduction_to_QuickCheck">QuickCheck</a> is the gold standard for testing pure functional (side-effect free) code in Haskell. It allows you to assert properties of functions, such as &#8220;this function returns a non-negative result for any input.&#8221; QuickCheck generates input cases and checks the proposition automatically.</p>
<p><a href="http://hunit.sourceforge.net/">HUnit</a> is the usual xUnit clone for Haskell. It deals with actions (Haskell&#8217;s term for functions having side-effects). You perform some action then assert the resulting state has been correctly mutated.</p>
<p>It is mighty convenient to use both for TDD on any non-trivial program.</p>
<h2>Test Collection</h2>
<p>Relying on the coder to remember to add tests to suites will eventually produce orphaned suites.  Then comes the false confidence: <em>I ran all the tests and they passed, and I </em>know<em> it doesn&#8217;t break assertion X, because there&#8217;s a test for that.  I&#8217;ve seen it.</em></p>
<p>As <a href="http://onesock.cc/">OneSock</a> has gotten a little bit bigger (it&#8217;s still small, don&#8217;t worry), I start to worry about this.  I did a bit of research and found some test-collection tools:</p>
<h3><a href="http://hackage.haskell.org/package/quickcheck-script">quickcheck-script</a></h3>
<p>This script will scan the source files supplied on the command-line for QuickCheck assertions and run them.  It is very useful and easy to use.  The drawback here is that it will not run my HUnit tests.</p>
<h3><a href="http://bitbucket.org/dave4420/hstest/wiki/Home">hstest</a></h3>
<p>This program will scan for QuickCheck1 and HUnit tests in all sources in the current directory and run them.  The drawback is its current lack of support for QuickCheck2.  The philosophy is right for what I want to do &#8211; have a simple &#8220;brain idle&#8221; command for my TDD cycle that runs all the tests.</p>
<h3><a href="http://batterseapower.github.com/test-framework/">test-framework</a></h3>
<p>This package provides a class with instances for HUnit, QuickCheck1, and QuickCheck2.  For the most part, manual collection is required; however, there is a <a href="http://hackage.haskell.org/package/test-framework-th">test-framework-th</a> package which uses the <a href="http://www.haskell.org/haskellwiki/Template_Haskell">TemplateHaskell</a> extension to provide a meta-function that scans the current source file for tests and collects them.</p>
<h2>The Decision</h2>
<p>I&#8217;ve decided to go with hstest.  </p>
<p><tt>quickcheck-script</tt> doesn&#8217;t run HUnit tests.</p>
<p>While <tt>test-framework</tt> seems to have more mindshare and also seems to be well-thought-out, there is no script to automatically collect tests.  The TemplateHaskell trick is nice; however, introducing another layer of complexity just for test collection is a bit overwhelming at this early stage&#8212;especially because it doesn&#8217;t solve the original problem: now a programmer must remember to register all source files rather than all tests in a test-runner program.</p>
<p>To work around the current lack of support for QuickCheck2, you can supply parameters to hide and expose packages.  I&#8217;ve written this shell function:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> t<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	hstest <span style="color: #660033;">--expose-package</span>=QuickCheck-1.2.0.0 <span style="color: #660033;">--hide-package</span>=QuickCheck-2.1.0.3
	<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> hugsin
	<span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #007800;">$?</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>I&#8217;ve found that my current few properties run unaltered under QuickCheck1.</p>
<p>I&#8217;ve also specified QuickCheck1 in my cabal file for the moment so that I don&#8217;t use features that hstest doesn&#8217;t like.  This provokes a warning:</p>
<pre>
jfelice@flarp64:~/src/onesock$ cabal configure
Resolving dependencies...
Configuring OneSock-0.1...
Warning: This package indirectly depends on multiple versions of the same
package. This is highly likely to cause a compile failure.
package OneSock-0.1 requires QuickCheck-1.2.0.0
package Crypto-4.2.1 requires QuickCheck-2.1.0.3
jfelice@flarp64:~/src/onesock$
</pre>
<p>No build issues occur.  Maybe the linker is eliminating all QuickCheck references (which are unreachable from <tt>main</tt>).</p>
<img src="http://feeds.feedburner.com/~r/eraserhead/ADNx/~4/zpPFI1_6Xl4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://eraserhead.net/2010/06/collecting-tests-in-haskell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://eraserhead.net/2010/06/collecting-tests-in-haskell/</feedburner:origLink></item>
		<item>
		<title>Five Line Hex Dump</title>
		<link>http://feedproxy.google.com/~r/eraserhead/ADNx/~3/n1dyDmBM-9k/</link>
		<comments>http://eraserhead.net/2010/06/five-line-hex-dump/#comments</comments>
		<pubDate>Fri, 11 Jun 2010 15:57:36 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Hex]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://eraserhead.net/?p=556</guid>
		<description><![CDATA[I work with message formats a lot.  Being able to conjure up a hex dump on the spot is an invaluable skill.  You&#8217;d think that you should have a library function for this; however, there&#8217;s often problems &#8211; it&#8217;s not in the path for this project, the built-in one doesn&#8217;t work on this [...]]]></description>
			<content:encoded><![CDATA[<p>I work with message formats a lot.  Being able to conjure up a hex dump on the spot is an invaluable skill.  You&#8217;d think that you should have a library function for this; however, there&#8217;s often problems &#8211; it&#8217;s not in the path for this project, the built-in one doesn&#8217;t work on this JVM, the link settings aren&#8217;t right to use it, etc.  So I&#8217;ve typed this hundreds of times:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> data.<span style="color: #006633;">length</span><span style="color: #339933;">;</span> <span style="color: #339933;">++</span>i<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>i<span style="color: #339933;">%</span>16<span style="color: #339933;">==</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #003399;">System</span>.<span style="color: #006633;">err</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003399;">System</span>.<span style="color: #006633;">err</span>.<span style="color: #006633;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;%02x &quot;</span>,data<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #003399;">System</span>.<span style="color: #006633;">err</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The C and C++ equivalents are almost identical.</p>
<img src="http://feeds.feedburner.com/~r/eraserhead/ADNx/~4/n1dyDmBM-9k" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://eraserhead.net/2010/06/five-line-hex-dump/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://eraserhead.net/2010/06/five-line-hex-dump/</feedburner:origLink></item>
		<item>
		<title>Too Much TDD</title>
		<link>http://feedproxy.google.com/~r/eraserhead/ADNx/~3/fVxO0pL4OPo/</link>
		<comments>http://eraserhead.net/2010/05/too-much-tdd/#comments</comments>
		<pubDate>Mon, 24 May 2010 16:30:22 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Agile]]></category>
		<category><![CDATA[Pair Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[TDD]]></category>

		<guid isPermaLink="false">http://eraserhead.net/?p=549</guid>
		<description><![CDATA[A couple weeks ago, I met up Attila Domokos and did the LCD rubyquiz.  Let me set the scene about the pattern in use at these Hackabous:

Pair up.
One test is written first.
Only as much functionality as is needed to make the test pass is written.
The next test is written&#8230;

&#8230;and so forth.
We moved through parsing [...]]]></description>
			<content:encoded><![CDATA[<p>A couple weeks ago, I met up Attila Domokos and did the <a href="http://www.rubyquiz.com/quiz14.html">LCD rubyquiz</a>.  Let me set the scene about the pattern in use at these Hackabous:</p>
<ol>
<li>Pair up.
<li>One test is written first.
<li>Only as much functionality as is needed to make the test pass is written.
<li>The next test is written&#8230;
</ol>
<p>&#8230;and so forth.</p>
<p>We moved through parsing the command-line easily, then coded the test for displaying a single digit.  We noticed we were at a particular sort of impasse:</p>
<p><em>Implementing as little code as possible to pass this test could not produce code which could survive the next test.</em>  At least, not in a way that I can see.</p>
<p>What should you do?  Should you write the code, debug it and pass the test, then add the next test and delete the code?  This seems like an odd question to ask. The only reason I even ask it now is I&#8217;ve found some people who really advocate this.</p>
<p>Another example: I listened during the Roman Numerals kata as one team made first I, then II and III pass by coding:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">  <span style="color:#9966CC; font-weight:bold;">def</span> convert<span style="color:#006600; font-weight:bold;">&#40;</span>n<span style="color:#006600; font-weight:bold;">&#41;</span>
    n.<span style="color:#CC0066; font-weight:bold;">split</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">size</span>
  <span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>If I understand proponents&#8217; arguments, in writing the code you are learning, and this learning will dominate the inefficiencies in this process over time.</p>
<p>I honestly think this is a misreading of agile.  Agile was built in the context of an industry addicted to wasteful, heavy and rigid process.  Should TDD become a wasteful, heavy and rigid process?</p>
<p>How do I proceed in these cases?  First, I have nothing against writing more than one test up front.  If I can think of several of the corner cases and potential pitfalls right now, I will write them down in xUnit. Sometimes switching from researching the requirements to coding is an expensive operation, and in these cases, I&#8217;ll lay out five or ten tests documenting the requirements.  Sometimes, I have no idea how I&#8217;m going to implement something.  Writing a batch of tests up front allows me to explore the corner cases and think more about designing a useful approach.</p>
<p>Given the multiple tests, I have no problem writing the more complicated algorithm first.  We&#8217;ve already determined that we can&#8217;t (or perhaps just don&#8217;t know how) to evolve it, so we&#8217;re going to end up going for it anyway.</p>
<img src="http://feeds.feedburner.com/~r/eraserhead/ADNx/~4/fVxO0pL4OPo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://eraserhead.net/2010/05/too-much-tdd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://eraserhead.net/2010/05/too-much-tdd/</feedburner:origLink></item>
		<item>
		<title>Wishing for “let rec” in Java</title>
		<link>http://feedproxy.google.com/~r/eraserhead/ADNx/~3/HKMoiAayVCg/</link>
		<comments>http://eraserhead.net/2010/04/wishing-for-let-rec-in-java/#comments</comments>
		<pubDate>Thu, 15 Apr 2010 13:03:08 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Functional Programming]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://eraserhead.net/?p=544</guid>
		<description><![CDATA[
    public void testCallsRollbackIfSendingAuthResponseFails&#40;&#41; throws Exception &#123;
        final MockSender sender = new MockSender&#40;&#41;;
        final MockSession session = new MockSession&#40;&#41; &#123;
            @Override
       [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testCallsRollbackIfSendingAuthResponseFails<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">final</span> MockSender sender <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> MockSender<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">final</span> MockSession session <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> MockSession<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            @Override
            <span style="color: #000000; font-weight: bold;">public</span> DASAuthObj authorize<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">final</span> DASAuthObj authObj<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                mgr.<span style="color: #006633;">dispatch</span><span style="color: #009900;">&#40;</span> ... <span style="color: #666666; font-style: italic;">// AGHAGHAGH!</span>
                <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">authorize</span><span style="color: #009900;">&#40;</span>authObj<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">final</span> DASSessionManager mgr <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DASSessionManager<span style="color: #009900;">&#40;</span>session, sender<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        ...</pre></div></div>

<p>[EDIT: OK, you can do it manually with Java arrays.  Still icky.]</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testCallsRollbackIfSendingAuthResponseFails<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">final</span> MockSender sender <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> MockSender<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">final</span> DASSessionManager<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> mgrHolder <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DASSessionManager<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">final</span> MockSession session <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> MockSession<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            @Override
            <span style="color: #000000; font-weight: bold;">public</span> DASAuthObj authorize<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">final</span> DASAuthObj authObj<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                mgrHolder<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #006633;">dispatch</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> DASCloseAuthSinkPacket<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span>, <span style="color: #000066; font-weight: bold;">true</span>, <span style="color: #cc66cc;">42</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">authorize</span><span style="color: #009900;">&#40;</span>authObj<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">final</span> DASSessionManager mgr <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DASSessionManager<span style="color: #009900;">&#40;</span>session, sender<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        mgrHolder<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> mgr<span style="color: #339933;">;</span></pre></div></div>

<img src="http://feeds.feedburner.com/~r/eraserhead/ADNx/~4/HKMoiAayVCg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://eraserhead.net/2010/04/wishing-for-let-rec-in-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://eraserhead.net/2010/04/wishing-for-let-rec-in-java/</feedburner:origLink></item>
		<item>
		<title>R Utilities for Software Kanban – Plotting Your CFD</title>
		<link>http://feedproxy.google.com/~r/eraserhead/ADNx/~3/QoKridOo3CA/</link>
		<comments>http://eraserhead.net/2010/04/r-utilities-for-software-kanban-plotting-your-cfd/#comments</comments>
		<pubDate>Mon, 12 Apr 2010 13:59:53 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Guerilla Software Recovery]]></category>
		<category><![CDATA[CFD]]></category>
		<category><![CDATA[Kanban]]></category>
		<category><![CDATA[Process]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[Workflow]]></category>

		<guid isPermaLink="false">http://eraserhead.net/?p=537</guid>
		<description><![CDATA[I&#8217;ve started a set of R utilities for software kanban at GitHub.  I&#8217;ve been using the R environment more lately, and I really like how easy it makes visualizing and working with data.  It has a bit of an &#8220;old-school&#8221; environment feel as well and it is functional and efficient.  If you [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve started a set of <a href="http://github.com/eraserhd/rkanban">R utilities for software kanban</a> at <a href="http://github.com/">GitHub</a>.  I&#8217;ve been using the R environment more lately, and I really like how easy it makes visualizing and working with data.  It has a bit of an &#8220;old-school&#8221; environment feel as well and it is functional and efficient.  If you are an R guru (I&#8217;m not really, though I&#8217;m learning) and you have utilities, please contribute!</p>
<p>The utilities expect data to be stored in a <tt>data.frame</tt>.  The first column must be named &#8220;Date&#8221; and have &#8220;Date&#8221; class.  The second column is currently ignored; however, the intention is that it indicates the ticket category (usually represented on the board by ticket color), and so it should be a factor.  Columns three onward (as many as you have flow steps) are tallies of each work flow step for the day, in reverse chronological order &#8211; starting with &#8220;Done&#8221; and ending with &#8220;Backlog&#8221;, in other words.</p>
<p>The easiest way to get this data into R is to store it in a CSV file and use <tt>read.csv</tt> to load it.  Here is some sample data:</p>
<pre>
Date,Category,Done,QA,Development,Ready,Backlog
2009/10/20,Project,0,2,2,0,0
2009/10/20,Urgent,0,0,1,0,0
2009/10/22,Project,1,2,1,0,0
2009/10/22,Urgent,0,0,2,0,0
2009/10/23,Project,1,2,2,0,0
2009/10/23,Urgent,0,0,2,0,0
</pre>
<p>Load this into R with:</p>
<pre>
> my.data <- read.csv("my_data.csv")
</pre>
<p>An alternate method for maintaining your data within R is to use the <tt>fix()</tt> function on a daily basis, which is what I do.  Two warnings, however:</p>
<ol>
<li>Make sure to save your workspace so that you don't lose your stats.</p>
<li><tt>fix()</tt> will strip the "Date" class from the Date column.
</ol>
<p>To re-add the Date class after using <tt>fix()</tt>, do this:</p>
<pre>
> my.data$Date <- as.Date(my.data$Date)
</pre>
<h2>Plotting your CFD</h2>
<p>Check out the <a href="http://github.com/eraserhd/rkanban">rkanban</a> sources into the "rkanban" directory under your R working directory and source the <tt>kanban.R</tt> file.</p>
<p>You can then plot your CFD from within R like so:</p>
<pre>
> source("rkanban/kanban.R")
> PlotCFD(my.data)
</pre>
<p><img src="http://eraserhead.net/files/plotcfd.png"></p>
<img src="http://feeds.feedburner.com/~r/eraserhead/ADNx/~4/QoKridOo3CA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://eraserhead.net/2010/04/r-utilities-for-software-kanban-plotting-your-cfd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://eraserhead.net/2010/04/r-utilities-for-software-kanban-plotting-your-cfd/</feedburner:origLink></item>
		<item>
		<title>Creating boilerplate with Google Guice</title>
		<link>http://feedproxy.google.com/~r/eraserhead/ADNx/~3/6DXgTCDIalc/</link>
		<comments>http://eraserhead.net/2010/03/creating-boilerplate-with-google-guice/#comments</comments>
		<pubDate>Thu, 18 Mar 2010 04:09:39 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Dependency Injection]]></category>
		<category><![CDATA[Guice]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Patterns]]></category>
		<category><![CDATA[Singleton]]></category>

		<guid isPermaLink="false">http://eraserhead.net/?p=508</guid>
		<description><![CDATA[We&#8217;ve been Guicing up XPay for a couple weeks.  For those not familiar with Guice, it is a dependency injection framework.
Guice in Ten Seconds
You annotate your classes types&#8217; primary constructors, create &#8220;modules&#8221; which bind concrete types or singleton instances to interface and abstract types, then ask Guice to create you one of some type. [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve been <a href="http://code.google.com/p/google-guice/">Guicing up</a> XPay for a couple weeks.  For those not familiar with Guice, it is a <a href="http://en.wikipedia.org/wiki/Dependency_injection">dependency injection</a> framework.</p>
<h2>Guice in Ten Seconds</h2>
<p>You annotate your classes types&#8217; primary constructors, create &#8220;modules&#8221; which bind concrete types or singleton instances to interface and abstract types, then ask Guice to create you one of some type.  Guice will automatically create all dependencies (constructor parameters) for that type before invoking the primary constructor, and if any of those types require dependencies create those first, and so forth.  For example, if your class <tt>Foo</tt> needs some kind of <tt>PackagingStrategy</tt> (presumably an interface) passed to its constructor, and your module binds <tt>PackagingStrategy.class</tt> to <tt>BinaryPackagingStrategy.class</tt>, then when you ask Guice for an instance of <tt>Foo</tt>, it will create a new <tt>BinaryPackagingStrategy</tt>, &#8220;newing up&#8221; its constructor parameters recursively, and pass this to <tt>Foo</tt>&#8217;s constructor.</p>
<p>The benefits of this scheme are in the class of &#8220;hard to describe, but definitely there.&#8221;  First and foremost, it improves system design, making interfaces clearer and more self-documenting by removing hidden dependencies on things like Singletons and Monostates.  This improves testability because mucking with the global state encapsulated in Singleton and Monostate patterns requires a much deeper knowledge of classes under test and some often-shady practices.  Without a good DI framework, passing a dependency down several layers of object graph is complicated and provides extra coupling, making the Singleton pattern much more attractive.  With the DI framework, there&#8217;s really no inclination to make the dependency of a class anything other than a constructor parameter.</p>
<h2>But, More Boilerplate?</h2>
<p>There&#8217;s plenty of boilerplate that Guice removes, mostly in the &#8220;bean wiring&#8221; category, and this is good.  Interestingly, there are areas in which I&#8217;ve found myself writing <em>more</em> boilerplate with Guice, and an instance of this is what I&#8217;d like to discuss today.</p>
<p>I work with some people who have become thoroughly disgusted with OOP and advocate for functional style with immutable data types.  I appreciate functional style with immutable data types, but I must say that the <a href="http://en.wikipedia.org/wiki/Strategy_pattern">Strategy pattern</a> is something OOP does well and not something that FP does nearly as well.  I tend to use strategy pattern quite a bit in our XPay (and in our C++ product, DAS).  One reason to <a href="http://c2.com/cgi/wiki?SwitchStatementsSmell">prefer Strategy pattern to switch statements</a> is to have a single point of control over <em>which</em> strategy implementation to use.  This use case usually conjures itself into being in a <a href="http://en.wikipedia.org/wiki/Factory_method_pattern">Factory method pattern</a> which has the single switch statement which provides an instance of the concrete type based on input parameters.</p>
<p>In Guice, you can inject a <tt>Provider&lt;Foo&gt;</tt> and Guice will automatically create a type that produces instances of <tt>Foo</tt>.  This is useful for dependencies.  So our factory ends up looking something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> FooFactory <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> Provider<span style="color: #339933;">&lt;</span>TypeAFoo<span style="color: #339933;">&gt;</span> typeAFooProvider<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> Provider<span style="color: #339933;">&lt;</span>TypeBFoo<span style="color: #339933;">&gt;</span> typeBFooProvider<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> Provider<span style="color: #339933;">&lt;</span>TypeCAFoo<span style="color: #339933;">&gt;</span> typeCAFooProvider<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> Provider<span style="color: #339933;">&lt;</span>TypeCBFoo<span style="color: #339933;">&gt;</span> typeCBFooProvider<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> Provider<span style="color: #339933;">&lt;</span>TypeDFoo<span style="color: #339933;">&gt;</span> typeDFooProvider<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> Provider<span style="color: #339933;">&lt;</span>TypeEFoo<span style="color: #339933;">&gt;</span> typeEFooProvider<span style="color: #339933;">;</span>
&nbsp;
    @Inject
    <span style="color: #000000; font-weight: bold;">public</span> FooFactory<span style="color: #009900;">&#40;</span>
            <span style="color: #000000; font-weight: bold;">final</span> Provider<span style="color: #339933;">&lt;</span>TypeAFoo<span style="color: #339933;">&gt;</span> typeAFooProvider,
            <span style="color: #000000; font-weight: bold;">final</span> Provider<span style="color: #339933;">&lt;</span>TypeBFoo<span style="color: #339933;">&gt;</span> typeBFooProvider,
            <span style="color: #000000; font-weight: bold;">final</span> Provider<span style="color: #339933;">&lt;</span>TypeCAFoo<span style="color: #339933;">&gt;</span> typeCAFooProvider,
            <span style="color: #000000; font-weight: bold;">final</span> Provider<span style="color: #339933;">&lt;</span>TypeCBFoo<span style="color: #339933;">&gt;</span> typeCBFooProvider,
            <span style="color: #000000; font-weight: bold;">final</span> Provider<span style="color: #339933;">&lt;</span>TypeDFoo<span style="color: #339933;">&gt;</span> typeDFooProvider,
            <span style="color: #000000; font-weight: bold;">final</span> Provider<span style="color: #339933;">&lt;</span>TypeEFoo<span style="color: #339933;">&gt;</span> typeEFooProvider
            <span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">typeAFooProvider</span> <span style="color: #339933;">=</span> typeAFooProvider<span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">typeBFooProvider</span> <span style="color: #339933;">=</span> typeBFooProvider<span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">typeCAFooProvider</span> <span style="color: #339933;">=</span> typeCAFooProvider<span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">typeCBFooProvider</span> <span style="color: #339933;">=</span> typeCBFooProvider<span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">typeDFooProvider</span> <span style="color: #339933;">=</span> typeDFooProvider<span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">typeEFooProvider</span> <span style="color: #339933;">=</span> typeEFooProvider<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> Foo get<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">char</span> type, <span style="color: #000066; font-weight: bold;">boolean</span> inverted<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">switch</span> <span style="color: #009900;">&#40;</span>type<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #0000ff;">'A'</span><span style="color: #339933;">:</span>
            <span style="color: #000000; font-weight: bold;">return</span> typeAFooProvider.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>         
        <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #0000ff;">'B'</span><span style="color: #339933;">:</span>
            <span style="color: #000000; font-weight: bold;">return</span> typeBFooProvider.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>         
        <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #0000ff;">'C'</span><span style="color: #339933;">:</span>
            <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>inverted<span style="color: #009900;">&#41;</span>
                <span style="color: #000000; font-weight: bold;">return</span> typeCAFooProvider.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">else</span>
                <span style="color: #000000; font-weight: bold;">return</span> typeCBFooProvider.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #0000ff;">'D'</span><span style="color: #339933;">:</span>
            <span style="color: #000000; font-weight: bold;">return</span> typeBFooProvider.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>         
        <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #0000ff;">'E'</span><span style="color: #339933;">:</span>
            <span style="color: #000000; font-weight: bold;">return</span> typeBFooProvider.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>         
        <span style="color: #000000; font-weight: bold;">default</span><span style="color: #339933;">:</span>
            <span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> FooFactoryException<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Can't determine type.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Ugh!</p>
<p>This is &#8220;better&#8221; boilerplate than the bean wiring before in that it hints that we might be able to concoct a general solution; however, I haven&#8217;t yet found it.  One solution which I&#8217;ve rejected is the &#8220;injecting an injector&#8221; solution:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> FooFactory <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> Injector injector<span style="color: #339933;">;</span>
&nbsp;
    @Inject
    <span style="color: #000000; font-weight: bold;">public</span> FooFactory<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">final</span> Injector injector<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">injector</span> <span style="color: #339933;">=</span> injector<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">public</span> Foo get<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">char</span> type, <span style="color: #000066; font-weight: bold;">boolean</span> inverted<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">switch</span> <span style="color: #009900;">&#40;</span>type<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #0000ff;">'A'</span><span style="color: #339933;">:</span>
            <span style="color: #000000; font-weight: bold;">return</span> injector.<span style="color: #006633;">createInstance</span><span style="color: #009900;">&#40;</span>TypeAFoo.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #0000ff;">'B'</span><span style="color: #339933;">:</span>
            <span style="color: #000000; font-weight: bold;">return</span> injector.<span style="color: #006633;">createInstance</span><span style="color: #009900;">&#40;</span>TypeBFoo.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #0000ff;">'C'</span><span style="color: #339933;">:</span>
            <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>inverted<span style="color: #009900;">&#41;</span>
                <span style="color: #000000; font-weight: bold;">return</span> injector.<span style="color: #006633;">createInstance</span><span style="color: #009900;">&#40;</span>TypeCAFoo.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">else</span>
                <span style="color: #000000; font-weight: bold;">return</span> injector.<span style="color: #006633;">createInstance</span><span style="color: #009900;">&#40;</span>TypeCBFoo.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #0000ff;">'D'</span><span style="color: #339933;">:</span>
            <span style="color: #000000; font-weight: bold;">return</span> injector.<span style="color: #006633;">createInstance</span><span style="color: #009900;">&#40;</span>TypeDFoo.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #0000ff;">'E'</span><span style="color: #339933;">:</span>
            <span style="color: #000000; font-weight: bold;">return</span> injector.<span style="color: #006633;">createInstance</span><span style="color: #009900;">&#40;</span>TypeEFoo.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">default</span><span style="color: #339933;">:</span>
            <span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> FooFactoryException<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Can't determine type.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The reason I&#8217;ve rejected this approach is that it prevents Guice from checking the entire dependency graph at boot &#8211; Guice doesn&#8217;t know which types you are going to create with the injector, and this <em>has</em> to defeat a lot of it&#8217;s validation magic.</p>
<img src="http://feeds.feedburner.com/~r/eraserhead/ADNx/~4/6DXgTCDIalc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://eraserhead.net/2010/03/creating-boilerplate-with-google-guice/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://eraserhead.net/2010/03/creating-boilerplate-with-google-guice/</feedburner:origLink></item>
		<item>
		<title>Making MSVC6 Crash</title>
		<link>http://feedproxy.google.com/~r/eraserhead/ADNx/~3/xZcIlSq5d_g/</link>
		<comments>http://eraserhead.net/2010/03/making-msvc6-crash/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 13:00:25 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[MSVC6]]></category>

		<guid isPermaLink="false">http://eraserhead.net/?p=116</guid>
		<description><![CDATA[I&#8217;ve been collecting these for a little while.  Since we are now well under way in migrating to VS2005, now is a good time to post them.
.\Components/CommComponents/FDMSInterleaveTcpipComm/Test_FDMSInterleaveTcpipComm.h(106) : fatal error C1001: INTERNAL COMPILER ERROR
        (compiler file 'msc1.cpp', line 1794)
         [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been collecting these for a little while.  Since we are now well under way in migrating to VS2005, now is a good time to post them.</p>
<pre>.\Components/CommComponents/FDMSInterleaveTcpipComm/Test_FDMSInterleaveTcpipComm.h(106) : fatal error C1001: INTERNAL COMPILER ERROR
        (compiler file 'msc1.cpp', line 1794)
         Please choose the Technical Support command on the Visual C++
         Help menu, or open the Technical Support help file for more information
</pre>
<p>was caused by:</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;">    <span style="color: #0000ff;">template</span><span style="color: #000080;">&lt;</span><span style="color: #0000ff;">typename</span> VersionPolicy<span style="color: #000080;">&gt;</span> <span style="color: #0000ff;">class</span> SVDotPacketProductionPolicy<span style="color: #008080;">;</span>
    <span style="color: #0000ff;">class</span> SVDotPacketProductionPolicy<span style="color: #000080;">&lt;</span>SV24VersionPolicy<span style="color: #000080;">&gt;</span><span style="color: #008080;">;</span>
    <span style="color: #0000ff;">friend</span> <span style="color: #0000ff;">class</span> SVDotPacketProductionPolicy<span style="color: #000080;">&lt;</span>SV24VersionPolicy<span style="color: #000080;">&gt;</span><span style="color: #008080;">;</span>
    <span style="color: #0000ff;">class</span> SVDotPacketProductionPolicy<span style="color: #000080;">&lt;</span>SV40VersionPolicy<span style="color: #000080;">&gt;</span><span style="color: #008080;">;</span>
    <span style="color: #0000ff;">friend</span> <span style="color: #0000ff;">class</span> SVDotPacketProductionPolicy<span style="color: #000080;">&lt;</span>SV40VersionPolicy<span style="color: #000080;">&gt;</span><span style="color: #008080;">;</span></pre></div></div>

<hr />
<pre>Include\boost/bind/arg.hpp(25) : fatal error C1001: INTERNAL COMPILER ERROR
        (compiler file 'msc1.cpp', line 1794)
         Please choose the Technical Support command on the Visual C++
         Help menu, or open the Technical Support help file for more information
</pre>
<p>This one started after I added</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #339900;">#include &lt;boost/bind.hpp&gt;</span></pre></div></div>

<p> to a file and a simple, every-day use of <tt>boost::bind()</tt>.  Moving the <tt>#include</tt> directive up before a number of other standard includes resolved the issue.</p>
<pre>
C:\projects\DASV2>scons
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
cl /FoComponents\AuthComponents\Credit\CCMps\Release\Tests.obj /c Components\AuthComponents\Credit\CCMps\Release\Tests.cpp /nologo /
TP /nologo /MT /W2 /GX /GR /O2 /Zi /Zm200 /D "WIN32" /D "_WINDOWS" /D "NDEBUG" /D "_MBCS" /FD /D "_WIN32_WINNT=0x0400" /D "_WIN32_DC
OM" /IWindowsSDK\Include /IInclude /Icryptlib /IXML\Xerces\src /I. /IComponents\AuthComponents\Credit\CCMps
Tests.cpp
Include\boost/function/function_template.hpp(514) : fatal error C1001: INTERNAL COMPILER ERROR
        (compiler file 'msc1.cpp', line 1794)
         Please choose the Technical Support command on the Visual C++
         Help menu, or open the Technical Support help file for more information
scons: *** [Components\AuthComponents\Credit\CCMps\Release\Tests.obj] Error 2
scons: building terminated because of errors.
</pre>
<p>06/01/2009 &#8211; This one was the result of passing a pointer to a static member function to <tt>boost::function1&lt;&gt;</tt>.</p>
<pre>
C:\projects\DASV2>scons
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
python.exe Utilities/CxxTest/cxxtestgen.py --runner=XmlPrinter --have-eh --have-std --check-memory -o CBase\ISOMsg\Debug\Tests.cpp CBase\ISOMsg\Test_Fields.h
cl /FoCBase\ISOMsg\Debug\Tests.obj /c CBase\ISOMsg\Debug\Tests.cpp /nologo /TP /nologo /MTd /Od /W2 /GX /GR /Zi /Zm200 /D "WIN32" /D "_WINDOWS" /D "_MBCS" /FD /D "_WIN32_WINNT=0x0400" /D "_WIN32_DCOM" /D "DEBUG" /D "_DEBUG" /IWindowsSDK\Include /IInclude /Icryptlib /IXML\Xerces\src /I. /ICBase\ISOMsg
Tests.cpp
.\CBase/ISOMsg/Test_Fields.h(157) : fatal error C1001: INTERNAL COMPILER ERROR
        (compiler file 'msc1.cpp', line 1794)
         Please choose the Technical Support command on the Visual C++
         Help menu, or open the Technical Support help file for more information
scons: *** [CBase\ISOMsg\Debug\Tests.obj] Error 2
scons: building terminated because of errors.
</pre>
<p>06/18/2009 &#8211; This one is the result of attempting to use a template member of template class.  Here&#8217;s the (abbreviated) code:</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">template</span><span style="color: #000080;">&lt;</span><span style="color: #0000ff;">typename</span> C, C v<span style="color: #000080;">&gt;</span>
<span style="color: #0000ff;">struct</span> ThreeArgConstructor
<span style="color: #008000;">&#123;</span>
    <span style="color: #0000ff;">template</span><span style="color: #000080;">&lt;</span><span style="color: #0000ff;">class</span> BaseT<span style="color: #000080;">&gt;</span>
    <span style="color: #0000ff;">struct</span> Type <span style="color: #008080;">:</span> <span style="color: #0000ff;">public</span> BaseT
    <span style="color: #008000;">&#123;</span>
        Type<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> length<span style="color: #008000;">&#41;</span>
            <span style="color: #008080;">:</span> BaseT<span style="color: #008000;">&#40;</span>length, <span style="color: #FF0000;">&quot;TEST FIELD PACKAGER&quot;</span>, v<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span><span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
&nbsp;
<span style="color: #0000ff;">template</span><span style="color: #000080;">&lt;</span>
      BaseT
    , ConstructorT
    <span style="color: #000080;">&gt;</span>
<span style="color: #0000ff;">class</span> Foo
<span style="color: #008000;">&#123;</span>
    <span style="color: #0000ff;">typedef</span> <span style="color: #0000ff;">typename</span> ConstructorT<span style="color: #008080;">::</span><span style="color: #0000ff;">template</span> Type<span style="color: #000080;">&lt;</span>BaseT<span style="color: #000080;">&gt;</span> TestPackager<span style="color: #008080;">;</span>
&nbsp;
    <span style="color: #0000ff;">void</span> run<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
        TestPackager<span style="color: #008000;">&#40;</span><span style="color: #0000dd;">10</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
&nbsp;
<span style="color: #0000ff;">int</span> main<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    Foo<span style="color: #000080;">&lt;</span>Bar, ThreeArgConstructor<span style="color: #000080;">&lt;</span><span style="color: #0000ff;">bool</span>, <span style="color: #0000ff;">false</span><span style="color: #000080;">&gt;</span> <span style="color: #000080;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>.<span style="color: #007788;">run</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    <span style="color: #0000ff;">return</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<img src="http://feeds.feedburner.com/~r/eraserhead/ADNx/~4/xZcIlSq5d_g" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://eraserhead.net/2010/03/making-msvc6-crash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://eraserhead.net/2010/03/making-msvc6-crash/</feedburner:origLink></item>
		<item>
		<title>Make Work Visible</title>
		<link>http://feedproxy.google.com/~r/eraserhead/ADNx/~3/EA_vG_ktwx4/</link>
		<comments>http://eraserhead.net/2010/03/make-work-visible/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 04:24:34 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Guerilla Software Recovery]]></category>
		<category><![CDATA[Patterns]]></category>

		<guid isPermaLink="false">http://eraserhead.net/?p=497</guid>
		<description><![CDATA[Context
A significant portion of your activities aren&#8217;t visible to your management, possibly because

you have become the &#8220;product expert&#8221; which consults with others or
your products&#8217; production deployments require significant developer attention
  
Therefore,
Divide your whiteboard up into columns representing your work flow (e.g. &#8220;Backlog,&#8221; &#8220;Ready&#8221;, &#8220;Develop&#8221;, &#8220;QA&#8221;, &#8220;Done&#8221;) and obtain a large supply of Post-It(tm) notes. [...]]]></description>
			<content:encoded><![CDATA[<h2>Context</h2>
<p>A significant portion of your activities aren&#8217;t visible to your management, possibly because
<ul>
<li>you have become the &#8220;product expert&#8221; which consults with others or
<li>your products&#8217; production deployments require significant developer attention
  </ul>
<h2>Therefore,</h2>
<p>Divide your whiteboard up into columns representing your work flow (e.g. &#8220;Backlog,&#8221; &#8220;Ready&#8221;, &#8220;Develop&#8221;, &#8220;QA&#8221;, &#8220;Done&#8221;) and obtain a large supply of Post-It(tm) notes.  Use separate colors for the items assigned to you by your management and the items which come to you as the domain expert.  If necessary, track enough information to build a cumulative flow diagram.</p>
<h2>Discussion</h2>
<p>There is something visceral about this approach that conveys understanding in a way which is not possible by explanation or discussion.  It may be the case that your management <em>knows</em> what is happening but doesn&#8217;t quite &#8220;<em>get it</em>.&#8221;</p>
<p>This is a minimum useful subset of <a href="http://limitedwipsociety.org/">software kanban</a> and an instance of &#8220;Information Radiator.&#8221;</p>
<p>A cumulative flow diagram can be created by simply counting the number of tickets in each bucket each morning and entering these into a spreadsheet in backwards order.  You can read your average work-in-process (WIP) and cycle time from this diagram, making it an incredibly inexpensive way to measure the amount of effort spent on visible work versus other work.</p>
<h2>Observed Instances</h2>
<h3>One</h3>
<p>[to be filled in]</p>
<img src="http://feeds.feedburner.com/~r/eraserhead/ADNx/~4/EA_vG_ktwx4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://eraserhead.net/2010/03/make-work-visible/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://eraserhead.net/2010/03/make-work-visible/</feedburner:origLink></item>
	</channel>
</rss>
