<?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: Category Schuchert's Scattered Synapses </title>
    <link>http://blog.objectmentor.com/articles/category/schuchert%27s-scattered-synapses</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>!define TEST_SYSTEM {fit:A}</title>
      <description>&lt;p&gt;Uncle Bob has been busy with &lt;a href="http://www.fitnesse.org/"&gt;FitNesse&lt;/a&gt; lately. If you have been following him on &lt;a href="http://twitter.com/unclebobmartin"&gt;Twitter&lt;/a&gt; or if you read his &lt;a href="http://blog.objectmentor.com/articles/2008/10/02/slim"&gt;blog post&lt;/a&gt; on the subject, then you are aware of his work on &lt;a href="http://blog.objectmentor.com/articles/2008/10/02/slim"&gt;Slim&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;This post, however, is not about that. It is about something he did to make it possible to execute different tests in different VM&amp;#8217;s.&lt;/p&gt;


	&lt;p&gt;By default, when you click on the &lt;b&gt;test&lt;/b&gt; or &lt;b&gt;suite&lt;/b&gt; buttons to run tests, &lt;a href="http://www.fitnesse.org/"&gt;FitNesse&lt;/a&gt; finds the tests it will run and executes them in a single VM.&lt;/p&gt;


If you want to select a particular test runner in &lt;a href="http://www.fitnesse.org/"&gt;FitNesse&lt;/a&gt;, you can add the following to a page:
&lt;div style="background-color: #eee; font-family: Monaco, "Courier New", monospaced"&gt;
!define &lt;span class="caps"&gt;TEST&lt;/span&gt;_SYSTEM {fit}
&lt;/div&gt;

Or you could add the following:
&lt;div style="background-color: #eee; font-family: Monaco, "Courier New", monospaced"&gt;
!define &lt;span class="caps"&gt;TEST&lt;/span&gt;_SYSTEM {slim}
&lt;/div&gt;

	&lt;p&gt;If you do not define this variable, then &lt;a href="http://fit.c2.com/"&gt;fit&lt;/a&gt; is the test system used to execute tests, making the first example redundant&amp;#8230;almost.&lt;/p&gt;


	&lt;p&gt;These variable definitions are inherited. &lt;a href="http://www.fitnesse.org/"&gt;FitNesse&lt;/a&gt; will search up the page hierarchy to find variable definitions. If you do not define &lt;span class="caps"&gt;TEST&lt;/span&gt;_SYSTEM anywhere in a page&amp;#8217;s hierarchy, then that test will be executed with &lt;a href="http://fit.c2.com/"&gt;fit&lt;/a&gt;. However, if any of the pages above the current page changed the runner to &lt;a href="http://blog.objectmentor.com/articles/2008/10/02/slim"&gt;slim&lt;/a&gt;, then &lt;a href="http://blog.objectmentor.com/articles/2008/10/02/slim"&gt;Slim&lt;/a&gt; will be the test runner.&lt;/p&gt;


The other thing that you can do is add a &amp;#8220;logical-vm name&amp;#8221; to the end of the runner. Here are two examples:
&lt;h3&gt;On some page&lt;/h3&gt;
&lt;div style="background-color: #eee; font-family: Monaco, "Courier New", monospaced"&gt;
!define &lt;span class="caps"&gt;TEST&lt;/span&gt;_SYSTEM {fit&lt;b&gt;:vm1&lt;/b&gt;}
&lt;/div&gt;

&lt;h3&gt;On a different page&lt;/h3&gt;
&lt;div style="background-color: #eee; font-family: Monaco, "Courier New", monospaced"&gt;
!define &lt;span class="caps"&gt;TEST&lt;/span&gt;_SYSTEM {fit&lt;b&gt;:vm2&lt;/b&gt;}
&lt;/div&gt;

	&lt;p&gt;All tests under the page containing the first define run in a vm with the logical name vm1. The same is true for vm2.&lt;/p&gt;


By default (i.e., you have not defined &lt;span class="caps"&gt;TEST&lt;/span&gt;_SYSTEM anywhere), all tests are run in the same vm. More precisely:
&lt;ul&gt;
&lt;li&gt;When you click the &lt;b&gt;test&lt;/b&gt; button, all tests executed as a result of that button click run in one VM.&lt;/li&gt;
&lt;li&gt;When you click the &lt;b&gt;suite&lt;/b&gt; button, all tests executed as a result are executed in the same VM.&lt;/li&gt;
&lt;/ul&gt;

	&lt;p&gt;As soon as you introduce the &lt;span class="caps"&gt;TEST&lt;/span&gt;_SYSTEM variable, the tests might execute in the same VM or different VM&amp;#8217;s.&lt;/p&gt;


	&lt;p&gt;Conceptually, there&amp;#8217;s a default or unnamed VM under which all tests execute. As soon as a page contains a &lt;span class="caps"&gt;TEST&lt;/span&gt;_SYSTEM with the added :VMName syntax, that page and all pages hierarchically below it run in a different VM.&lt;/p&gt;


	&lt;p&gt;If for some reason you want to have two unrelated page hierarchies execute in the same VM, you can. Define the &lt;span class="caps"&gt;TEST&lt;/span&gt;_SYSTEM variable with the same logical VM name.&lt;/p&gt;


&lt;h3&gt;Why did he add this feature&lt;/h3&gt;
I asked him to. He was working on that part of &lt;a href="http://www.fitnesse.org/"&gt;FitNesse&lt;/a&gt; so I figured he&amp;#8217;d be able to add the feature for a project I&amp;#8217;m working on. 

	&lt;p&gt;It has to do with service-level testing of a &lt;span class="caps"&gt;SOA&lt;/span&gt;-based solution. If you&amp;#8217;re interested in hearing about that and the rationale for adding this feature to &lt;a href="http://www.fitnesse.org/"&gt;FitNesse&lt;/a&gt;, let me know in the comments and I&amp;#8217;ll describe the background.&lt;/p&gt;</description>
      <pubDate>Mon, 03 Nov 2008 18:08:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:4ac12665-d98e-4253-a9a4-16896fe27b41</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2008/11/03/define-test_system-fit-a</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>FitNesse</category>
      <category>test</category>
      <category>isloation</category>
      <category>slim</category>
      <category>runner</category>
    </item>
    <item>
      <title>I'm glad that static typing is there to help...  </title>
      <description>&lt;h2&gt;The Background&lt;/h2&gt;
A colleague was using &lt;a hlink="http://www.fitnesse.org/"&gt;FitNesse&lt;/a&gt; to create a general fixture for setting values in various objects rendered from a &lt;span class="caps"&gt;DTD&lt;/span&gt;. Of course you can write one per top level object, but given the number of eventual end-points, this would require a bit too much manual coding.

	&lt;p&gt;This sounds like a candidate for reflection, correct? Yep, but rather than do that manually, using the &lt;a href="http://commons.apache.org/beanutils/"&gt;Jakarta Commons BeanUtils&lt;/a&gt; makes sense &amp;#8211; it&amp;#8217;s a pretty handy library to be familiar with if you&amp;#8217;re ever doing reflective programming with attributes.&lt;/p&gt;


So far, so good. However, the auto-generated classes included one-to-many relationships represented with arrays. Before getting any further, let&amp;#8217;s define this problem (at least partially) with a test: 
&lt;pre style="line-height: 1em; background-color: #d8d5c3; border: 1px solid #888;;"&gt;
package com.objectmentor.arraycopyexample;

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

public class ArrayPropertySetterTest {
   @Test
   public void assertCanAssignToArrayFieldFromArrayOfObject() {
      Object[] arrayOfBars = createArrayOfBars();
      Foo foo = new Foo();

      ArrayPropertySetter.assignToArrayFieldFromObjectArray(foo, "bars", arrayOfBars);

      assertEquals(3, foo.getBars().length);
   }

   private Object[] createArrayOfBars() {
      Object[] objectArray = new Object[3];
      for (int i = 0; i &amp;lt; objectArray.length; ++i)
         objectArray[i] = new Bar();

      return objectArray;
   }
}
&lt;/pre&gt;

For completeness, you&amp;#8217;ll need to see the Foo and Bar classes:
&lt;h3&gt;Bar&lt;/h3&gt;
&lt;pre style="line-height: 1em; background-color: #d8d5c3; border: 1px solid #888;;"&gt;
package com.objectmentor.arraycopyexample;

public class Bar {
}
&lt;/pre&gt;

&lt;h3&gt;Foo&lt;/h3&gt;
&lt;pre style="line-height: 1em; background-color: #d8d5c3; border: 1px solid #888;;;"&gt;
package com.objectmentor.arraycopyexample;

public class Foo {
    Bar[] bars;

    public Bar[] getBars() {
        return bars;
    }

    public void setBars(Bar[] bars) {
        this.bars = bars;
    }

}
&lt;/pre&gt;

	&lt;p&gt;So an instance of a Foo holds on to an array of Bar objects; and the Foo class has the standard java-bean-esque setters and getters.&lt;/p&gt;


	&lt;p&gt;With this description of how to set an array field on a Java bean, let&amp;#8217;s get this to actually work.&lt;/p&gt;


First question, how do you deal with arrays in Java? Sounds trivial, right. If you don&amp;#8217;t mind a little pain, it&amp;#8217;s not that bad&amp;#8230; By dealing, I mean what happens when someone has given you an array created as follows:
&lt;pre style="line-height: 1em; background-color: #d8d5c3; border: 1px solid #888;;"&gt;
   Object[] arrayOfObject = new Object[3]:
&lt;/pre&gt;

Note that this is very different from this:
&lt;pre style="line-height: 1em; background-color: #d8d5c3; border: 1px solid #888;;"&gt;
   Object[] arrayOfBars = new Bar[3]:
&lt;/pre&gt;

	&lt;p&gt;The runtime type of these two results is different. One is array of Object; the other is Array of Bar.&lt;/p&gt;


This will not work:
&lt;pre style="line-height: 1em; background-color: #d8d5c3; border: 1px solid #888;;"&gt;
   Bar[] arrayOfBar = (Bar[])arrayOfObject;
&lt;/pre&gt;

This will generate a runtime cast exception. You cannot simply take something allocated as an array of objects and cast it to an array of a specific type. NO, you have to do something more like the following:
&lt;pre style="line-height: 1em; background-color: #d8d5c3; border: 1px solid #888;;"&gt;
    Array.newInstance(typeYouWantAnArrayOf, sizeOfArray);
&lt;/pre&gt;

	&lt;p&gt;That&amp;#8217;s not too bad, right? You can then either use another method on the Array class to set the values, or you can cast the result to an appropriate array.&lt;/p&gt;


That&amp;#8217;s enough information to write a generic method to copy from an array of Object to an array of a subtype of Object:
&lt;pre style="line-height: 1em; background-color: #d8d5c3; border: 1px solid #888;;"&gt;
   public static Object[] copyToArrayOfType(Class destinationType, Object[] fromArray) {
      Object[] result = (Object[])Array.newInstance(destinationType, fromArray.length);

      for(int i = 0; i &amp;lt; fromArray.length; ++i)
         result[i] = fromArray[i];

      return result;
   }
&lt;/pre&gt;

This is a bit unruly because the caller still needs to cast the result:
&lt;pre style="line-height: 1em; background-color: #d8d5c3; border: 1px solid #888;;"&gt;
   Object[] arrayOfObject = new Object[] { new Foo(), new Foo(), new Foo() };
   Foo[] arrayOfFoo = (Foo[])copyToArrayOfType(Foo.class, arrayOfObject);
&lt;/pre&gt;

We can get rid of this cast if we use generics:
&lt;pre style="line-height: 1em; background-color: #d8d5c3; border: 1px solid #888;;"&gt;
   public static &amp;lt;T&amp;gt; T[] copyToArrayOfType(Class&amp;lt;T&amp;gt; destinationType, Object[] fromArray) {
      T[] result = (T[])Array.newInstance(destinationType, fromArray.length);

      for(int i = 0; i &amp;lt; fromArray.length; ++i)
         result[i] = (T) fromArray[i];

      return result;
   }
&lt;/pre&gt;

This doesn&amp;#8217;t quite work because of type erasure, so to get this to &amp;#8220;compile cleanly &amp;#8211; no warnings&amp;#8221;, you&amp;#8217;ll need to add the following line above the method:
&lt;pre style="line-height: 1em; background-color: #d8d5c3; border: 1px solid #888;;"&gt;
   @SuppressWarnings("unchecked")
&lt;/pre&gt;

	&lt;p&gt;That&amp;#8217;s just me telling the compiler I really think I know what I&amp;#8217;m doing.&lt;/p&gt;


With this change, you can now write the following:
&lt;pre style="line-height: 1em; background-color: #d8d5c3; border: 1px solid #888;;"&gt;
   Object[] arrayOfObject = new Object[] { new Foo(), new Foo(), new Foo() };
   Foo[] arrayOfFoo = copyToArrayOfType(Foo.class, arrayOfObject);
&lt;/pre&gt;

	&lt;p&gt;The original problem was to take an array of Object[] and set it into a destination object&amp;#8217;s attribute. Now we can create an array with the correct type, what next?&lt;/p&gt;


There are several things still remaining:
&lt;ol&gt;
   &lt;li&gt;Given the name of the property, determine its underlying array type.&lt;/li&gt;
   &lt;li&gt;Create the array (above)&lt;/li&gt;
   &lt;li&gt;Assign the value to the underlying field&lt;/li&gt;
   &lt;li&gt;Do some suficient hand-waving to handle exceptions&lt;/li&gt;
&lt;/ol&gt;

	&lt;p&gt;Here are solutions for each of those things:&lt;br/&gt;
&lt;b&gt;Determine underlying type&lt;/b&gt;
&lt;pre style="line-height: 1em; background-color: #d8d5c3; border: 1px solid #888;;"&gt;
   PropertyDescriptor pd = PropertyUtils.getPropertyDescriptor( destObject, fieldName);
   Class&amp;lt;?&amp;gt; destType = pd.getPropertyType().getComponentType();
&lt;/pre&gt;&lt;/p&gt;


	&lt;p&gt;&lt;b&gt;Create the array&lt;/b&gt;
&lt;pre style="line-height: 1em; background-color: #d8d5c3; border: 1px solid #888;;"&gt;
   Object[] destArray = copyToArrayOfType.(destType, fromArray);
&lt;/pre&gt;&lt;/p&gt;


&lt;B&gt;Assign the value&lt;/b&gt;
&lt;pre style="line-height: 1em; background-color: #d8d5c3; border: 1px solid #888;;"&gt;
   PropertyUtils.setSimpleProperty(destObject, fieldName, destArray);
&lt;/pre&gt;

Here&amp;#8217;s all of that put together and simply capturing all of the checked exceptions (that&amp;#8217;s a whole other can of worms):
&lt;pre style="line-height: 1em; background-color: #d8d5c3; border: 1px solid #888;;"&gt;
   public static void assignToArrayFieldFromObjectArray(Object destObject, String fieldName, Object[] fromArray) {
      try {
         PropertyDescriptor pd = PropertyUtils.getPropertyDescriptor(destObject, fieldName);
         Class&amp;lt;?&amp;gt; destType = pd.getPropertyType().getComponentType();
         Object[] destArray = copyToArrayOfType(destType, fromArray);
         PropertyUtils.setSimpleProperty(destObject, fieldName, destArray);
      } catch (Exception e) {
         throw new RuntimeException(e);
      }
   }
&lt;/pre&gt;

	&lt;p&gt;That&amp;#8217;s all it takes to copy an array and then set the value in the field of a destination object.&lt;/p&gt;


	&lt;p&gt;Simple, right?&lt;/p&gt;


	&lt;p&gt;Sometimes static (and strong) typing can get in the way. This is one of those cases. Luckily, you can write this one and use it all over. Maybe it&amp;#8217;s a part of the BeanUtils that I was unable to track down (probably).&lt;/p&gt;</description>
      <pubDate>Sat, 25 Oct 2008 05:24:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:ca4fa4d0-1f85-4f16-9e5e-4b517e015f3e</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2008/10/25/im-glad-that-static-typing-is-there-to-help</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>reflection</category>
      <category>beanutils</category>
      <category>FitNesse</category>
      <category>Java</category>
      <category>rant</category>
    </item>
    <item>
      <title>Markup's Where It's At</title>
      <description>&lt;p&gt;My first word processor ran in under 8K on a Commodore 64 and that included playing pomp and circumstance. It was adequate. It was markup based. When you wanted to view your work, you previewed the results. (When my friend John got a spell checker add-on, I was really impressed!)&lt;/p&gt;


	&lt;p&gt;Next, I started using Apple Write (I think that was the name). All of those dot commands on the left margin. I got to the point where I didn&amp;#8217;t need to preview, I knew what my stuff was going to look like.&lt;/p&gt;


	&lt;p&gt;After that, I worked with Word Star on a CP/M emulator running on Apple &lt;span class="caps"&gt;IIE&lt;/span&gt;&amp;#8217;s. I actually liked Word Star. I still remember the ^k madness.&lt;/p&gt;


	&lt;p&gt;But then there was WordPerfect. To this day it is my favorite Word Processor (that&amp;#8217;s WordPerfect 4.2 for &lt;span class="caps"&gt;DOS&lt;/span&gt;). I taught classes on it while I was working on a CS degree. I had the 40 function keys memorized and even the &lt;span class="caps"&gt;F11&lt;/span&gt; and &lt;span class="caps"&gt;F12&lt;/span&gt; keys &amp;#8211; when I had keyboards with &lt;span class="caps"&gt;F11&lt;/span&gt; and &lt;span class="caps"&gt;F12&lt;/span&gt;.&lt;/p&gt;


	&lt;p&gt;Here&amp;#8217;s the thing, WordPerfect was logical. There were three general categories of markup (codes) and those three categories, when added, went to specific places on the line (home back-arrow, home-home back-arrow, home-home-home back-arrow) and it was related to the scope of the thing. And you could see them with revel codes, Alt-F3. Sure it took a bit of learning but it was expert friendly.&lt;/p&gt;


	&lt;p&gt;At the same time that Ultima IV came out, I decided to write a book for one of the classes I taught. The first week some friends of mine and I finished Ultima IV &amp;#8211; we did not stop playing, but played in shifts. I finished the outline that week. The next week I wrote the first version of a book. I still have one physical copy of that book.&lt;/p&gt;


	&lt;p&gt;I did this work (Ultima IV and WordPerfect) on my Leading Edge, 2 &amp;#8211; 5.25&amp;#8221; floppy drive system. The first version was about 170 pages, the final was around 350 pages. Printing took about 3 hours. 1 hour to merge the master document, update the &lt;span class="caps"&gt;TOC&lt;/span&gt;, generate the index, 2 hours to print on my HP DeskJet (the first one).&lt;/p&gt;


	&lt;p&gt;WordPerfect never crashed (4.2 was solid, 4.0 no so much), and I knew what the resulting print was going to look like before it printed. I groked it. I had lots of formatting, graphics (mostly had-drawn bitmaps), numbered items, tutorials, chapters, page numbers, you know, stuff.&lt;/p&gt;


	&lt;p&gt;In the mid 80&amp;#8217;s I started using Microsoft Word. I didn&amp;#8217;t like it then and to this day I do not like it. Anybody who has ever tried working with numbered lists across versions understands what I&amp;#8217;m talking about (this feature worked perfectly in WordPerfect). I can get it to work. And I know that when to grab the hidden character at the end of a paragraph (or not) when copying &amp;#8211; which leads to selecting paragraphs in a particular direction. I work to avoid using it as much as I can, which is getting better all the time.&lt;/p&gt;


	&lt;p&gt;I&amp;#8217;m not a big fan of complex formatting simply because I have not found anything so clear as WordPerfect. The later versions didn&amp;#8217;t do it for me.&lt;/p&gt;


	&lt;p&gt;I am a fan of using Wiki&amp;#8217;s because part of the whole reason to use one is to keep away from messing around with formatting and get to writing.&lt;/p&gt;


	&lt;p&gt;Lately I&amp;#8217;ve been learning &lt;span class="caps"&gt;CSS&lt;/span&gt;. It&amp;#8217;s powerful. It&amp;#8217;s also magic. Working with flow layouts reminds me of the grid-bag-layout of X fame (or was that Motif &amp;#8211; certainly Java has one as well). I like what I can do with it.&lt;/p&gt;


	&lt;p&gt;I like that I can get the basic content looking decent and then when I&amp;#8217;m in the mood, I can attempt to cast spells to make the stuff I&amp;#8217;ve written look better. So far, I&amp;#8217;m a rank amateur.&lt;/p&gt;


	&lt;p&gt;I probably should be spending more time re-learning JavaScript (which is a cool language &amp;#8211; I love prototype-based languages &amp;#8211; first one I used was Self). But I&amp;#8217;ve been working on some tutorials for Ruby, one on practicing &lt;span class="caps"&gt;TDD&lt;/span&gt; and a few on &lt;span class="caps"&gt;BDD&lt;/span&gt;.&lt;/p&gt;


	&lt;p&gt;These are low-level. For example, I have not used the story tests of RSpec yet. That&amp;#8217;s the next tutorial &amp;#8211; I still have the second &lt;span class="caps"&gt;BDD&lt;/span&gt; tutorial to finish. I already have stories for the next tutorial, so writing story tests and working my way into a solution should be a blast.&lt;/p&gt;


	&lt;p&gt;If you&amp;#8217;d like to have a look, check out: &lt;a href="http://schuchert.wikispaces.com/ruby.tutorials" &gt;http://schuchert.wikispaces.com/ruby.tutorials&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;These are works in progress!&lt;/p&gt;


	&lt;p&gt;To bring the train track back into a complete oval &amp;#8211; we want the train to run after all &amp;#8211; I came across something from James Martin (&lt;a href="http://martinfowler.com/bliki/DuplexBook.html"&gt;http://martinfowler.com/bliki/DuplexBook.html&lt;/a&gt;) and it got me to thinking. In these tutorials, I have a lot of &amp;#8220;sidebars&amp;#8221; where I give a little more context. Those sidebars are scattered throughout.&lt;/p&gt;


	&lt;p&gt;In 2001 I took a writers workshop with Jerry Weinberg (&lt;a href="http://geraldmweinberg.com/Site/Communication.html"&gt;http://geraldmweinberg.com/Site/Communication.html&lt;/a&gt;) and in that workshop we had one exercise involving taking paragraphs from other people on various subjects and attempting to weave a common theme throughout.&lt;/p&gt;


	&lt;p&gt;Martin&amp;#8217;s idea of a duplex book and Weinberg&amp;#8217;s writing exercise led me to refactor all of those tutorials such that the sidebars are included files. This leads to a summary of all of the sidebars so far: &lt;a href="http://schuchert.wikispaces.com/ruby.sidebars"&gt;http://schuchert.wikispaces.com/ruby.sidebars&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;I think I&amp;#8217;m going to take Martin&amp;#8217;s message to heart and have 2-views into this material; the sidebars and the tutorials. I&amp;#8217;m going to try that exercise I learned from Weinberg and see where it takes me.&lt;/p&gt;


	&lt;p&gt;How does this relate? As I was refactoring, I made sure to put a span around the titles so I could have consistent, and externally defined formatting in my &lt;span class="caps"&gt;CSS&lt;/span&gt;. So it&amp;#8217;s loosely related. I&amp;#8217;ve been working with spans and included files a bunch this week.&lt;/p&gt;


	&lt;p&gt;So what do you think? Is the name of this blog appropriate?&lt;/p&gt;


	&lt;p&gt;Goodnight!&lt;/p&gt;</description>
      <pubDate>Thu, 16 Oct 2008 04:22:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:383e9430-f784-405e-ad7a-24b385a19056</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2008/10/16/markups-where-its-at</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>markup</category>
      <category>wordperfect</category>
      <category>TDD</category>
      <category>bdd</category>
      <category>writing</category>
    </item>
    <item>
      <title>The Physical Realm Matters</title>
      <description>&lt;p&gt;In 1997 I took a class called &lt;span class="caps"&gt;SEM&lt;/span&gt; offered by Weinberg and company. It was a rather profound learning experience; I&amp;#8217;m probably not aware of much of what I learned. However, there&amp;#8217;s one thing I learned that has been coming up lately.&lt;/p&gt;


	&lt;p&gt;The training was somewhat like an un-conference. We got together and as a group formed the schedule. It was hell. Somehow I ended up at the flip-chart taking notes. After I don&amp;#8217;t know how long &amp;#8211; certainly an hour, probably more &amp;#8211; maybe much less, I wanted out. People were throwing out suggestions and I kept asking the group if anybody would like to take over. I pointed the marker even. I never got out of that role (at the course, that is).&lt;/p&gt;


	&lt;p&gt;Jerry took me aside afterwards and suggested that the next time I am in that situation, simply put the marker down and physically move.&lt;/p&gt;


	&lt;p&gt;Stupid, right? I should have just done that, right? Well the best time to plant a tree is 100 years ago, right now is the next best time. I have not forgotten that lesson. In fact, I often do just that and I often train people to do the same thing. It is absolutely amazing what moving can do. (It often increases the congruence between your words and your actions.)&lt;/p&gt;


	&lt;p&gt;What about pair programming? More often than not, workstations are not conducive to working in pairs. One person is &amp;#8220;in front&amp;#8221; and the other is over the shoulder, off to the side, whatever. Or, worse yet, the monitor is in the corner. The setup needs to allow for equal access to the keyboard, mouse and monitor. If not, then you are not peers, there&amp;#8217;s the driver and the other person. That&amp;#8217;s just a fact. The physical location is of first-order importance.&lt;/p&gt;


	&lt;p&gt;Here&amp;#8217;s another example. In the scrum meetings you&amp;#8217;ve attended, are people talking to each other or is everybody reporting to the manager? More often than not, I observe a status meeting with everybody standing up.&lt;/p&gt;


	&lt;p&gt;This week I observed a profound transformation that I hope sticks (OK, I thought it was important, we&amp;#8217;ll see). I&amp;#8217;ve been working with a team that was really doing the stand-up, activity-oriented, daily status report &amp;#8211; cargo culting scrum meetings.&lt;/p&gt;


	&lt;p&gt;Last week we had a &amp;#8220;come to your deity&amp;#8221; meeting. The result, while painful, was useful. We went from having mostly activities in the backlog to a much better mix of deliverables and some activities (I&amp;#8217;m not looking for perfection, just striving for it &amp;#8211; perfection is a journey, not a destination). I came back this week (on Wednesday) and I was unimpressed with the wall of tasks &amp;#8211; or rather the seeming lack of progress.&lt;/p&gt;


	&lt;p&gt;Wednesday we created a sprint burndown, calculated both by number of tasks and estimated ideal days (I prefer story points, but this team is using ideal time for a good reason).&lt;/p&gt;


	&lt;p&gt;Based on that, the team was simply going to be way too late. We published that chart and next day things were looking better. By idea days, we were going to be late but closer. Tasks were just about there.&lt;/p&gt;


	&lt;p&gt;Then today two things happened. During the scrum, better than half of the reporting was on what tasks had been completed and what tasks were on the table. It was simply amazing.&lt;/p&gt;


	&lt;p&gt;Another thing that I noticed was that the developers seemed to be talking to each other. Not 100%, but rather than a nearly visual conduit between the manager or scrum master and the person reporting, it was more of a broadcast. The quasi-circle stayed such; it did not become a line between reporter and manager, followed by another line.&lt;/p&gt;


	&lt;p&gt;I mentioned it to a few people. I&amp;#8217;m not sure the team noticed it. I was really impressed with the team.&lt;/p&gt;


	&lt;p&gt;Of course I make a huge mistake. I did not tell them this right after the meeting so I missed a prime reinforcement opportunity.&lt;/p&gt;


	&lt;p&gt;The difference was palpable.&lt;/p&gt;


	&lt;p&gt;Years ago I learned the &amp;#8220;trick&amp;#8221; of not sitting &amp;#8220;on a side&amp;#8221; in meetings. If I was in a meeting with colleagues and clients, I tried to make sure to mix it up. This is another example of the same idea.&lt;/p&gt;


	&lt;p&gt;Bottom line, you often have a profound tool at your disposal that you can use. That&amp;#8217;s your current location. If you need to mix things up then change from standing to sitting, or one side of the room to another. If you are at the front of the room, move to the back of the room. If you&amp;#8217;re cowering in a corner, consider moving up to the table.&lt;/p&gt;


	&lt;p&gt;It really makes a difference.&lt;/p&gt;


	&lt;p&gt;What do you think?&lt;/p&gt;</description>
      <pubDate>Fri, 26 Sep 2008 22:57:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:4bd0674c-6f7f-4864-bde3-41171f622502</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2008/09/26/the-physical-realm-matters</link>
      <category>Schuchert's Scattered Synapses </category>
    </item>
    <item>
      <title>TDD is how I do it, not what I do</title>
      <description>&lt;blockquote&gt;
&amp;#8220;Do not seek to follow in the footsteps of the men of old; seek what they sought.&amp;#8221; ~Basho
&lt;/blockquote&gt;

	&lt;p&gt;That quote resonates with me. I happend across that a few days after co-teaching 
an &amp;#8220;advanced &lt;span class="caps"&gt;TDD&lt;/span&gt;&amp;#8221; course with Uncle Bob. One of the recurring themes during the week
was that &lt;span class="caps"&gt;TDD&lt;/span&gt; is a &amp;#8220;how&amp;#8221; not a &amp;#8220;what&amp;#8221;. It&amp;#8217;s important to remember that &lt;span class="caps"&gt;TDD&lt;/span&gt; is not the
goal, the&lt;i&gt; &lt;b&gt;results&lt;/b&gt;&lt;/i&gt; of successfully applying &lt;span class="caps"&gt;TDD&lt;/span&gt; are.&lt;/p&gt;


	&lt;p&gt;What are those results?&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;You could end up writing less code to accomplish the same thing&lt;/li&gt;
		&lt;li&gt;You might write better code that is less-coupled and more maleable&lt;/li&gt;
		&lt;li&gt;The code tends to be testable because, well, it IS tested&lt;/li&gt;
		&lt;li&gt;The coverage of your tests will be such that making significant changes will not be too risky&lt;/li&gt;
		&lt;li&gt;The number of defects should be quite low&lt;/li&gt;
		&lt;li&gt;The tests serve as excellent exampls of how to use the various classes in your solution&lt;/li&gt;
		&lt;li&gt;Less &amp;#8220;just in case&amp;#8221; code written, which typically doesn&amp;#8217;t work in those cases that they targeted&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Right now I do not know of a better way to accomplish all of these results more effectively
than practicing &lt;span class="caps"&gt;TDD&lt;/span&gt;. Even so, this does not elevate &lt;span class="caps"&gt;TDD&lt;/span&gt; from a &amp;#8220;how&amp;#8221; to a &amp;#8220;what.&amp;#8221; 
&lt;span class="caps"&gt;TDD&lt;/span&gt; remains a technique to accomplish thigns I value. It is not a self-justifying
practice. If someone asks me &amp;#8220;why do we do it this way&amp;#8221;, saying something like
&amp;#8220;we practice &lt;span class="caps"&gt;TDD&lt;/span&gt;&amp;#8221; or &amp;#8220;well you don&amp;#8217;t understand &lt;span class="caps"&gt;TDD&lt;/span&gt;&amp;#8221; is not a good answer.&lt;/p&gt;


We had an interesting result during that class. One group was practicing Bob&amp;#8217;s three rules of &lt;span class="caps"&gt;TDD&lt;/span&gt; (paraphrased); 
	&lt;ul&gt;
	&lt;li&gt;Write no production code without failing tests&lt;/li&gt;
		&lt;li&gt;Write only enough test code so that it fails (not compiling is failing)&lt;/li&gt;
		&lt;li&gt;Write only enough production code to get your tests to pass.&lt;/li&gt;
	&lt;/ul&gt;


But they ended up with a bit of a mess. Following the three rules wasn&amp;#8217;t enough. These rules are guiding principles, but those three rules mean nothing if you forget about clean code, refactoring and basic design principles (here are a few):
	&lt;ul&gt;
	&lt;li&gt;S.O.L.I.D.&lt;/li&gt;
		&lt;li&gt;F.I.R.S.T.&lt;/li&gt;
		&lt;li&gt;Separation of Concerns (Square Law of Computation)&lt;/li&gt;
		&lt;li&gt;Coupling/Cohesion&lt;/li&gt;
		&lt;li&gt;Protected Variation&lt;/li&gt;
		&lt;li&gt;...&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;&lt;span class="caps"&gt;TDD&lt;/span&gt; is a means to an end but it is the end we care about. What is that end? 
Software that has few defects and is easy to change. Tests give us that. Not 
testing generally does not give us that. And testing in a common &amp;#8220;QA over the wall&amp;#8221; configuration typically does not cut it.&lt;/p&gt;


	&lt;p&gt;Since I do not know how to so easily produce those results in any other way. &lt;span class="caps"&gt;TDD&lt;/span&gt; becomes the defacto means of implementation for me. That doesn&amp;#8217;t mean I should turn a blind eye to new ways of doing things. In lieu of any such information, however, I&amp;#8217;ll pick &lt;span class="caps"&gt;TDD&lt;/span&gt; as a starting point. This is still a &amp;#8220;how&amp;#8221; and not a &amp;#8220;what&amp;#8221;.&lt;/p&gt;


It turns out that for me there are several tangible benefits I&amp;#8217;ve personally 
experienced from practicing &lt;span class="caps"&gt;TDD&lt;/span&gt;:
	&lt;ul&gt;
	&lt;li&gt;Increased confidence in the code I produce (even more than when I was simply test infected)&lt;/li&gt;
		&lt;li&gt;Less worrying about one-off conditions and edge cases. I&amp;#8217;ll get to them and as I think about then, they become tests&lt;/li&gt;
		&lt;li&gt;Fun&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Fun?&lt;/p&gt;


Yes I wrote fun. There are several aspects of this:
	&lt;ul&gt;
	&lt;li&gt;I seem to produce demonstrable benefits sooner&lt;/li&gt;
		&lt;li&gt;I actually do more analysis throughout&lt;/li&gt;
		&lt;li&gt;I get to do more OO programming&lt;/li&gt;
	&lt;/ul&gt;


&lt;h4&gt;Demonstrable Benefits Sooner&lt;/h4&gt;
Since I focus on one test at a time, I frequently get back to running tests. I&amp;#8217;m able to see results sooner. Sure, those results are sometimes disjoint and piecemeal, but over time they organically grow into something useful. I really enjoy teaching a class and moving from a trivial test to a suite a tests that together have caused what students can see is a tangible implementation of something complex.

&lt;h4&gt;More Analysis&lt;/h4&gt;
Analysis means to break into constituent parts. When I practice &lt;span class="caps"&gt;TDD&lt;/span&gt;, I think about some end (say a user story or a scenario) then I think about a small part of that overall work and tackle it. In the act of getting to a test, I&amp;#8217;m doing enough analysis to figure out at least some of the parts of what I&amp;#8217;m trying to do. I&amp;#8217;m breaking my goal into a parts, that&amp;#8217;s a pretty good demonstration of analysis.

&lt;h4&gt;More OO&lt;/h4&gt;
I like polymorphism. I like lots of shallow, but broad hierarchies. 
I prefer delegation to inheritance. But often, the things I&amp;#8217;m writing 
don&amp;#8217;t need a lot of this &amp;#8211; or so it might seem.

	&lt;p&gt;When I try to create a good unit test, much of what I&amp;#8217;m doing is trying 
to figure out how the effect I&amp;#8217;m shooting for can be isolated 
to make the test fast, independent, reliable &amp;#8230; To do so, I 
make heavy use of test doubles. Sometimes I hand-roll them, sometimes 
I use mocking libraries. I&amp;#8217;ve event used &lt;span class="caps"&gt;AOP&lt;/span&gt; frameworks, but not nearly as extensively.&lt;/p&gt;


	&lt;p&gt;Doing all of this allows me to use polymorphism more often. And that&amp;#8217;s fun.&lt;/p&gt;


&lt;h3&gt;Conclusion&lt;/h3&gt;
Am I wasting time writing all of these tests? Is my enjoyment of my work
an indication that I might be wasting the time of my product owner?

	&lt;p&gt;Those are good questions. And these are things you might want to ask yourself.&lt;/p&gt;


Personally, I&amp;#8217;m pretty sure I&amp;#8217;m not wasting anyone&amp;#8217;s time for several reasons:
	&lt;ul&gt;
	&lt;li&gt;The product owner is keeping me focused on things that add value&lt;/li&gt;
		&lt;li&gt;Short iterations keep me reigned in&lt;/li&gt;
		&lt;li&gt;I&amp;#8217;m only doing as much as necessary to get the stories for an iteration implemented&lt;/li&gt;
		&lt;li&gt;The tests I&amp;#8217;m writing stay passing, run quickly and over time remain (become) maintainable&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Even so, since &lt;span class="caps"&gt;TDD&lt;/span&gt; is a how and not a what, I still need to keep asking myself
if the work I&amp;#8217;m doing is moving us towards a working solution that will be
maintainable during its lifetime.&lt;/p&gt;


	&lt;p&gt;I think it is. What about you?&lt;/p&gt;</description>
      <pubDate>Mon, 21 Jul 2008 14:32:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:b4795a7f-9544-422c-bb60-8cf16917afbd</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2008/07/21/tdd-is-how-i-do-it-not-what-i-do</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>TDD</category>
      <category>how</category>
      <category>versus</category>
      <category>what</category>
    </item>
    <item>
      <title>It's all in how you approach it</title>
      <description>&lt;p&gt;I was painting a bedroom over the last week. Unfortunately, it was well populated with furniture, a wall-mounted TV that needed lowering, clutter, the usual stuff. Given the time I had available, I didn&amp;#8217;t think I&amp;#8217;d be able to finish the whole bedroom before having to travel again.&lt;/p&gt;


	&lt;p&gt;I decided to tackle the wall with the wall-mounted TV first, so I moved the furniture to make enough room, taped just that wall (but not the ceiling since I was planning on painting it) and then proceeded to apply two coats of primer and two coats of the real paint. I subsequently moved around to an alcove and another wall and the part of the ceiling I could reach without having to rent scaffolding.&lt;/p&gt;


	&lt;p&gt;I managed to get two walls done and everything moved back into place before I left for another business trip. My wife is happy because the bedroom looks better. I did no damage and made noticeable progress. I still have some &lt;b&gt;P&lt;/b&gt;ainting to do (the capital P is to indicate it will be a Pain). I eventually have to move the bed, rent scaffolding, and so on. That&amp;#8217;s probably more in the future than I&amp;#8217;d prefer, but I&amp;#8217;ll do it when I know I have the time and space to do it.&lt;/p&gt;


	&lt;p&gt;Contrast this to when we bough the house back in March. I entered an empty house. I managed to get two bedrooms painted (ceilings included) and the &amp;#8220;grand&amp;#8221; room with 14&amp;#8217; vaulted ceilings. I only nearly killed myself once &amp;#8211; don&amp;#8217;t lean a ladder against a wall but put the legs on plastic &amp;#8211; and it was much easier to move around. I had a clean slate.&lt;/p&gt;


	&lt;p&gt;Sometimes you&amp;#8217;ve got to get done what you can get done to make some progress. When I was younger, my desire to finish the entire bedroom might have stopped me from making any progress. Sure, the bedroom is now half old paint and half new paint, but according to my wife it looks better &amp;#8211; and she&amp;#8217;s the product owner! I can probably do one more wall without having to do major lifting and when I&amp;#8217;m finally ready to rent the scaffolding, I won&amp;#8217;t have as much to do. I can break down the bed, rent the scaffolding and then in one day I might be able to finish the remainder of the work. (Well probably 2 days because I&amp;#8217;ll end up wanting to apply 2 coats to the ceiling and I&amp;#8217;ll need to wait 8 hours).&lt;/p&gt;


	&lt;p&gt;Painting is just like software development.&lt;/p&gt;</description>
      <pubDate>Mon, 21 Jul 2008 13:15:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:54fa00c2-ce8f-489f-9937-74ee4e508156</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2008/07/21/its-all-in-how-you-approach-it</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>refactoring</category>
      <category>greenvield</category>
      <category>versus</category>
      <category>legacy</category>
    </item>
    <item>
      <title>I love the 90's: The Fusion Episode</title>
      <description>&lt;p&gt;A few weeks back I was working with a team on the East Coast. They wanted to develop a simulator to assist in testing other software components. Their system to simulate is well-described in a specification using diagrams close to sequence diagrams as described in the &lt;span class="caps"&gt;UML&lt;/span&gt;.&lt;/p&gt;


	&lt;p&gt;In fact, these diagrams were of a variety I&amp;#8217;d call &amp;#8220;system&amp;#8221; sequence diagrams. They described the interaction between outside entities (actors &amp;#8211; in this case another system) and the system to be simulated.&lt;/p&gt;


	&lt;p&gt;This brought be back to 1993 when I was introduced to The Fusion Method by Coleman et al. Before that I had read Booch (1 and 2) and Rumbaugh (OMT) and I honestly didn&amp;#8217;t follow much of their material &amp;#8211; I had book knowledge but I really didn&amp;#8217;t practice it. I always thought that Booch was especially strong in Design ideas and notation but weak in Analysis. I though the opposite for Rumbaugh, so the two together + Jacobson with Use Cases and Business Modeling really formed a great team in terms of covering the kinds of things you need to cover in a thorough software process (UP + &lt;span class="caps"&gt;UML&lt;/span&gt;).&lt;/p&gt;


	&lt;p&gt;But before all that was Fusion.&lt;/p&gt;


	&lt;p&gt;Several colleagues and I really groked Fusion. It started with system sequence diagrams showing interactions much like the specification I mentioned above. It also described a difference between analysis and design (and if Uncle Bob reads this, he&amp;#8217;ll probably have some strong words about so-called object-oriented analysis, well this was 15 years ago&amp;#8230; though I still there there is some value to be found there). Anyway, this is mostly about system sequence diagrams so I won&amp;#8217;t say much more about that&lt;i&gt; &lt;b&gt;excellent&lt;/b&gt;&lt;/i&gt; process.&lt;/p&gt;


	&lt;p&gt;Each system sequence diagram represented a scenario. To represent many scenarios, Fusion offered a &lt;acronym title="Backus&#8211;Naur Form"&gt;BNF&lt;/acronym&gt;-based syntax to express those various scenarios. (I understand that this was also because for political reasons within HP they were not allowed to include a state model, but I don&amp;#8217;t know if that is true or not.) For several years I practiced Fusion and really I often revert back to that if I&amp;#8217;m not trying to do anything in particular.&lt;/p&gt;


	&lt;p&gt;Spending a little time up front thinking a little about the logical interaction between the system and its various actors helps me get a big picture view of the system boundary and its general flow. I have also found it helps others as well, but your mileage may vary.&lt;/p&gt;


	&lt;p&gt;So when I viewed their protocol specification, it really brought back some good memories. And in fact, that&amp;#8217;s how we decided to look at the problem.&lt;/p&gt;


	&lt;p&gt;(What follows is highly-idealized)&lt;/p&gt;


	&lt;p&gt;We reviewed their specification and decided we&amp;#8217;d try to work through the initialization sequence and then work through one sequence that involved &amp;#8220;completing a simple job.&amp;#8221; I need to keep this high level to keep the identity of the company a secret.&lt;/p&gt;


	&lt;p&gt;There was prior work and we kept that in mind but really started from scratch. In our very first attempt, there had been some work done along the lines of using the Command pattern, so we started there. Of course, once we did our first command, we backed off and when with a more basic design that seemed to fit the complexity a bit better (starting with the command pattern at the beginning is an example of solution-problemming to use a Weinberg term &amp;#8211; and one of the reasons I&amp;#8217;m sometimes skeptical when people start talking in patterns).&lt;/p&gt;


We continued working from the request coming into the system and working its way through the system. Along the way, we wrote unit tests, driven by our end goal of trying to complete a simple job and guided by the single responsibility principle. As we thought about the system, there were several logical steps:
	&lt;ul&gt;
	&lt;li&gt;Receive a message from the outside as some array of bytes&lt;/li&gt;
		&lt;li&gt;Determine the &amp;#8220;command&amp;#8221; represented by the bytes&lt;/li&gt;
		&lt;li&gt;Process the parameters within the command&lt;/li&gt;
		&lt;li&gt;Issue a message to the simulator&lt;/li&gt;
		&lt;li&gt;Create a logical response&lt;/li&gt;
		&lt;li&gt;Format the logical response into the underlying protocol&lt;/li&gt;
		&lt;li&gt;Send the response back&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;At the time, they were considering using &lt;span class="caps"&gt;JNI&lt;/span&gt;, so we spent just over a day validating that we could communicate bi-directionally, maintaining a single process space.&lt;/p&gt;


Along the way we moved from using hand-rolled test doubles to using JMock 2 to create mock objects. I mentioned this to friend of mine who lamented that there are several issues using a mock-based approach:
	&lt;ul&gt;
	&lt;li&gt;It is easy to end up with a bunch of tested objects but no fully-connected system&lt;/li&gt;
		&lt;li&gt;Sharing setup between various mocks is difficult and often not done so there&amp;#8217;s a lot of violation of &lt;span class="caps"&gt;DRY&lt;/span&gt;&lt;/li&gt;
		&lt;li&gt;You have to learn a new syntax&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;We accepted learning a new syntax because it was deemed less painful than maintaining existing hand-rolled test doubles (though there are several reasonable solution for that, ask if you want to know what it is). There is the issue of sharing setup on mocks, but we did not have enough work yet to really notice that as a problem. However, they were at least aware of that and we briefly discussed how to share common expectation-setting (it&amp;#8217;s well supported).&lt;/p&gt;


Finally, there&amp;#8217;s the issue of not having a fully connected system. We knew this was an issue so we started by writing an integration test using JUnit. We needed to design a system that:
	&lt;ul&gt;
	&lt;li&gt;Could be tested up to but excluding the &lt;span class="caps"&gt;JNI&lt;/span&gt; stuff&lt;/li&gt;
		&lt;li&gt;Could be configured to stub out &lt;span class="caps"&gt;JNI&lt;/span&gt; or use real &lt;span class="caps"&gt;JNI&lt;/span&gt;&lt;/li&gt;
		&lt;li&gt;Was easily configurable&lt;/li&gt;
		&lt;li&gt;Was automatically configured by C++ (since it was a C++ process that was started to get the whole system in place)&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;We designed that (15 minute white-board session), coded it and ended up with a few integration tests. Along the way, we built a simple factory for creating the system fully connected. That factory was used both in tests as well as by the &lt;span class="caps"&gt;JNI&lt;/span&gt;-based classes to make sure that we had a fully-connected systems when it was finally started by C++.&lt;/p&gt;


	&lt;p&gt;Near the end, we decided we wanted to demonstrate asynchronous computation, which we did using tests. I stumbled a bit but we got it done in a few hours. We demonstrated that the system receiving messages from the outside world basically queued up requests rather than making the sender wait synchronously (we demonstrated this indirectly &amp;#8211; that might be a later blog post &amp;#8211; let me know if you&amp;#8217;re interested).&lt;/p&gt;


	&lt;p&gt;By the way, that was the first week. These guys were good and I had a great time.&lt;/p&gt;


	&lt;p&gt;There was still a little work to be done on the C++ side and I only had a week, so I asked them to keep me posted. The following Tuesday they had the first end-to-end interaction, system initialization.&lt;/p&gt;


	&lt;p&gt;By Wednesday (so 3 business days later), they had a complete demonstration of end-to-end interaction with a single, simple job finishing. Not long after that they demonstrated several simple jobs finishing. The next thing on their list? Completing more complex jobs, system configuration, etc.&lt;/p&gt;


However, it all goes back to having a well-defined protocol. After we had one system interaction described end-to-end, doing the next thing was easier:
	&lt;ul&gt;
	&lt;li&gt;Select a system interaction&lt;/li&gt;
		&lt;li&gt;List all of the steps it needs to accomplish (some requests required a response, some did not)&lt;/li&gt;
		&lt;li&gt;Write unit tests for each &amp;#8220;arm&amp;#8221; of the interaction&lt;/li&gt;
	&lt;/ul&gt;


So they had a very natural way to form the backlog:
&lt;blockquote&gt;
Select a set of end-to-end interactions that add value to the user of the system
&lt;/blockquote&gt; 

They also had an easy way to create a sprint backlog:
&lt;blockquote&gt;
For each system-level interaction, enumerate all of its steps and then add implementing those steps as individual back-log items
&lt;/blockquote&gt;

	&lt;p&gt;Now some of those individual steps will end up being small (less than an hour) but some will be quite large when they start working with variable parameters and commands that need to operate at a higher priority.&lt;/p&gt;


	&lt;p&gt;But they are well on their way and I was reminded of just how much I really enjoyed using Fusion.&lt;/p&gt;</description>
      <pubDate>Wed, 02 Jul 2008 15:55:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:1ad1c750-6da0-4af6-9cea-806723f73d6f</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2008/07/02/i-love-the-90s-the-fusion-episode</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>system</category>
      <category>sequence</category>
      <category>diagrams</category>
      <category>sprint</category>
      <category>backlog</category>
      <category>design</category>
      <category>patterns</category>
    </item>
    <item>
      <title>Test Driven Meetings</title>
      <description>&lt;p&gt;I&amp;#8217;ve seen it as I&amp;#8217;m sure you have. You look in to a conference room, there&amp;#8217;s a spreadhseet or a word document or some such &amp;#8220;deliverable&amp;#8221; displayed on the overhead. There&amp;#8217;s one person engaged, talking about it and N &amp;#8211; 1 people with glassy-eyed stairs, hoping for the meeting to end.&lt;/p&gt;


	&lt;p&gt;What&amp;#8217;s even worse. You have the next meeting in that same room and you know your meeting is going to be a repeat of the previous meeting. Even so, it irritates you when they go over because that meeting room is&lt;i&gt; &lt;b&gt;yours&lt;/b&gt;&lt;/i&gt;.&lt;/p&gt;


	&lt;p&gt;Make an agenda! That&amp;#8217;ll solve it.&lt;/p&gt;


	&lt;p&gt;Maybe, but probably not. Most agendas are task-orietned rather than goal-oritned. So you might make it through the agenda but what have you accomplished besides following an agenda?&lt;/p&gt;


	&lt;p&gt;When people discuss wasted time, do they joke about meetings? Do they? Are you listening? If people are joking about meetings being a complete waste of time, then the meetings are probably a complete waste of time. (Ever consider keeping a count of the number of times you hear the same thing during a single day? You&amp;#8217;d be amazed what you can learn by just listenting to your team.)&lt;/p&gt;


Does that mean all meetings need to be that way?
&lt;blockquote&gt;No&lt;/blockquote&gt;
Why were we told to write agendas?
&lt;blockquote&gt;To keep focus and know we&amp;#8217;re making progress&lt;/blockquote&gt;
What purpose does a meeting serve in the delivery of value to someone who&amp;#8217;s got $$ to spend?
&lt;blockquote&gt;That varies by the meeting&lt;/blockquote&gt;
What do tests written first (unit or acceptance) accomplish?
&lt;blockquote&gt;Exress how we know somethign has worked&lt;/blockquote&gt;

	&lt;p&gt;Can we do this with meetings? If we did, what might it look like? Would the very act of trying to express success critera for a meeting have a profound effect on how a meeting progresses? Isn&amp;#8217;t this really just Covey&amp;#8217;s 2nd habit (begin with the end in mind).&lt;/p&gt;


What if you wanted to try? How might you begin?
&lt;blockquote&gt;It&amp;#8217;s all about he benjamins.&lt;/blockquote&gt;

	&lt;p&gt;The first thing you need to ask is how what you&amp;#8217;re going to do in a given meeting directly or indireclty adds value. Of coruse, to do that you need to know what is valuable.&lt;/p&gt;


	&lt;p&gt;Suppose, for example, you need to have a traditional requirements meeting of some sort (there is a traditional requirements meeting, it is usually bogged down in implementation details or it&amp;#8217;s stuck in &amp;#8220;how&amp;#8221; mode versus &amp;#8220;what&amp;#8221; mode &amp;#8211; the more you talk about database columns, the more you&amp;#8217;re deep into requirements &amp;#8230; &lt;B&gt;&lt;span class="caps"&gt;NOT&lt;/span&gt;!&lt;/B&gt;).&lt;/p&gt;


	&lt;p&gt;OK, so take a step back. You think you&lt;i&gt; &lt;b&gt;need&lt;/b&gt;&lt;/i&gt; this meeting on requirements.&lt;/p&gt;


Why?
&lt;blockquote&gt;So we can figure out what this feature needs to do&lt;/blockquote&gt;
Why?
&lt;blockquote&gt;So we know what to what to write, what schema changes we need&lt;/blockquote&gt;
Why?
&lt;blockquote&gt;So we can implement it&lt;/blockquote&gt;
Why?
&lt;blockquote&gt;Because customer X has a contract and we&amp;#8217;ll be in breech of contract if we don&amp;#8217;t write it&lt;/blockquote&gt;

	&lt;p&gt;AH! That sounds like we&amp;#8217;re getting close to something valuable. We have some feature that&amp;#8217;s been promised to a current customer. OK, so before we go any further, that information needs to be part of the context for the meeting.&lt;/p&gt;


What&amp;#8217;s been promised? What does the customer think has been promised?
&lt;blockquote&gt;If you cannot answer this, you are in deep trouble&lt;/blockquote&gt;

	&lt;p&gt;OK, so you have promised some feature. Apparently that feature is ill defined (or you wouldn&amp;#8217;t need the requirements meeting). So, what problem does that feature address?&lt;/p&gt;


If you know this, then you have something to grow. Maybe your first attempt at an acceptance test for your meeting is something like this:
&lt;blockquote&gt;This meeting is a success if we have described scenarios that cover what this feature will do for at the top three uses of this feature&lt;/blockquote&gt;

OK, so now here&amp;#8217;s your agend:
	&lt;ul&gt;
	&lt;li&gt;This requirements meeting is to address feature X&lt;/li&gt;
		&lt;li&gt;We need to discuss this because customer X has been promised this feature and if we do not do it by (insert a real date here), we are in breech of contract&lt;/li&gt;
		&lt;li&gt;This meeting will be a success if we can describe scenarios covering the top three uses of this feature&lt;/li&gt;
	&lt;/ul&gt;


That&amp;#8217;s a start. I can think of ways to improve that. Here are a few examples:
	&lt;ul&gt;
	&lt;li&gt;How do we define top 3? Is that something we know or something we need to accomplish?&lt;/li&gt;
		&lt;li&gt;What do we mean by &amp;#8220;describe scenarios&amp;#8221; does it include:
	&lt;ul&gt;
	&lt;li&gt;Acceptance tests&lt;/li&gt;
		&lt;li&gt;One or more stories (or maybe it is just a scenario in a use case, pick your requirements coolaid)&lt;/li&gt;
		&lt;li&gt;Used by whom? Are there different roles? Is that important?&lt;/li&gt;
		&lt;li&gt;What about a timebox? (Maybe that&amp;#8217;s implicit because it&amp;#8217;d be an electronic request)&lt;/li&gt;
		&lt;li&gt;...&lt;/li&gt;
	&lt;/ul&gt;&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Here&amp;#8217;s the thing, do you think&lt;i&gt; &lt;b&gt;you&amp;#8217;d&lt;/b&gt;&lt;/i&gt; be more inclined to think a meeting described thusly would have some value?&lt;/p&gt;</description>
      <pubDate>Thu, 12 Jun 2008 00:28:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:1f7d3342-73f1-4f52-b8ac-1858f79a55af</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2008/06/12/test-driven-meetings</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>meetings</category>
      <category>test</category>
      <category>driven</category>
    </item>
    <item>
      <title>Premature Optimization?</title>
      <description>&lt;p&gt;I have a theory.&lt;/p&gt;


	&lt;p&gt;It&amp;#8217;s one of those theories that I don&amp;#8217;t want to get ruined with actual facts, but I suppose I&amp;#8217;ll put it out  there and see what I learn.&lt;/p&gt;


	&lt;p&gt;The theory stems from a series of observations about the way some Microsoft development shops write code versus others. I&amp;#8217;ve noticed that some shops like to make many things sealed (final). I&amp;#8217;m not talking about the occasional class, but rather the default is to use sealed on most things. In addition to classes being sealed, there&amp;#8217;s a heavy bias against virtual methods. I&amp;#8217;ve not noticed this with Java development groups, though in the spirit of honest disclosure, I&amp;#8217;ve only noticed thins tendency is about 50% of the MS shops I&amp;#8217;ve visited &amp;#8211; and it seems like the tendency is reducing.&lt;/p&gt;


Even so, I&amp;#8217;ve wondered about this quite a bit. Here are some of the reasons I&amp;#8217;ve heard to justify this practice:
	&lt;ul&gt;
	&lt;li&gt;It expresses the design intent&lt;/li&gt;
		&lt;li&gt;It&amp;#8217;s for performance&lt;/li&gt;
		&lt;li&gt;The code as written cannot be safely overridden.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;(Before I go any further, I am not arguing against the use of sealed or final. I will say that in my practice, it has to be justified to be used rather than the other way around.)&lt;/p&gt;


	&lt;p&gt;Back to the reasons. I generally don&amp;#8217;t buy these reasons. Each may be perfectly valid but none of them stand on their own; each requires further discussion.&lt;/p&gt;


I&amp;#8217;ve had those discussions with various people and most of the time they really don&amp;#8217;t hold water. Here are some quip-y responses to each of them:
	&lt;ul&gt;
	&lt;li&gt;It expresses design intent &amp;#8211; you don&amp;#8217;t know how to design&lt;/li&gt;
		&lt;li&gt;It&amp;#8217;s for performance &amp;#8211; do you have any idea how a VM works?&lt;/li&gt;
		&lt;li&gt;The code as written cannot be safely overridden &amp;#8211; So the code is so badly written that nobody understands it?&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Again, let me be clear, there are good reasons to seal things. My point is that while there are good reasons, most of the time I&amp;#8217;ve seen the habit is a form of cargo culting; monkey see, monkey do.&lt;/p&gt;


	&lt;p&gt;This observation sat around for some time until I read some stuff in a book called &lt;span class="caps"&gt;CLR&lt;/span&gt; via C# (good reading if you want to better understand the &lt;span class="caps"&gt;CLR&lt;/span&gt;, and if you&amp;#8217;re developing code for a virtual machine, I think it&amp;#8217;s a good idea to understand the virtual machine at least a little).&lt;/p&gt;


Reading that book and my observations led to my theory:
&lt;blockquote&gt;
People are sealing as much as they are because virtual table binding is done way to early.
&lt;/blockquote&gt;

	&lt;p&gt;The thing I read in the book I mentioned above relates to when virtual methods are bound. This applies to 2.0 version of the &lt;span class="caps"&gt;CLR&lt;/span&gt;, but I don&amp;#8217;t think there&amp;#8217;s any change for the latest version of the &lt;span class="caps"&gt;CLR&lt;/span&gt; and this seems like a pretty &amp;#8220;hard&amp;#8221; design decision. This book mentions that binding of virtual methods is performed at compile time.&lt;/p&gt;


	&lt;p&gt;I&amp;#8217;m not making a distinction between compile time and link time for this discussion, but I&amp;#8217;ll be a little more precise. The generated code stored in an assembly &amp;#8220;knows&amp;#8221; which virtual function it is invoking because in the generated byte code is an index into a virtual table.&lt;/p&gt;


	&lt;p&gt;How is this a problem?&lt;/p&gt;


	&lt;p&gt;I write a base class and ship it. You write a derived class (OK, maybe you use delegation, good for you, but the problem still remains). Your coupling to my class involves using a method with the virtual keyword (Java programmers, you don&amp;#8217;t have to do this, regular methods [not static, not a constructor, ...] have the potential for dynamic dispatch unless you declare them final). At&lt;i&gt; &lt;b&gt;compile time&lt;/b&gt;&lt;/i&gt;, your object module (which eventually resides in an assembly that will get loaded and executed some time later) knows that it wants to call the 3rd virtual method in the v-table.&lt;/p&gt;


	&lt;p&gt;So far, so good.&lt;/p&gt;


	&lt;p&gt;Next, I add a new virtual method to my class and ship a new assembly.&lt;/p&gt;


	&lt;p&gt;Question. To use this new assembly, do you need to recompile?&lt;/p&gt;


	&lt;p&gt;Yes.&lt;/p&gt;


	&lt;p&gt;What?&lt;/p&gt;


	&lt;p&gt;Yes. What happens if my newly added method is the first virtual method? Then your compiled code that is happily living in a peaceful assembly somewhere has a stale reference. It thinks it wants to run the 3rd method in the virtual table but now it really should be using the 4th virtual method.&lt;/p&gt;


	&lt;p&gt;This is similar to a caching issue or premature optimization. The calling code has a compile-time generated index into the v-table. Why is this? Is it for performance? Not a good argument, this pre-calculation is irrelevant with modern &lt;span class="caps"&gt;JIT&lt;/span&gt; compiling techniques. I think the reason it is done this way is that C++ does things this way. C++ needs to because of its execution model (there&amp;#8217;s not virtual machine between the code and its execution).&lt;/p&gt;


	&lt;p&gt;No big deal, you think, I&amp;#8217;ll just recompile my code.&lt;/p&gt;


	&lt;p&gt;That will fix the problem. Or will it?&lt;/p&gt;


	&lt;p&gt;Say you&amp;#8217;re stuck using an old version of some assembly that uses an old version of another assembly that you also use. Do you recompile both your code and that other assembly? You&amp;#8217;ll have to but you might forget. Or you might not be able to.&lt;/p&gt;


	&lt;p&gt;.Net handles this by having an excellent dependency system to track which versions of which assemblies work with with other versions of assemblies. They need this to address problems introduced by the decision to perform such early binding.&lt;/p&gt;


	&lt;p&gt;Simply put, this is an unfortunate decision that I believe was more based on precedence or history than on sound design decisions.&lt;/p&gt;


	&lt;p&gt;This is not what happens in the Java Virtual Machine (JVM).&lt;/p&gt;


	&lt;p&gt;In the &lt;span class="caps"&gt;JVM&lt;/span&gt;, the binding is done later&amp;#8212;much later. It is possible that my class got loaded and &lt;span class="caps"&gt;JIT&lt;/span&gt;&amp;#8217;ed so that all of the methods that could be virtually invoked (not final) are in fact not virtually invoked. So far, no subclasses have been loaded, so there&amp;#8217;s been no need. After my system has been running for a few weeks, a new class (a subclass) gets loaded and invalidates the &lt;span class="caps"&gt;JIT&lt;/span&gt;&amp;#8217;d version of my class. No problem, the system will dump the old version and &lt;span class="caps"&gt;JIT&lt;/span&gt; it again, on the fly.&lt;/p&gt;


	&lt;p&gt;Even if there is a need for virtual dispatch, it might be that most of the time I use one version of method for a particularly heavily used subclass. The &lt;span class="caps"&gt;JVM&lt;/span&gt; might inline the common case and virtually dispatch the others.&lt;/p&gt;


	&lt;p&gt;Bottom line: what&amp;#8217;s being done with &lt;span class="caps"&gt;JVM&lt;/span&gt;&amp;#8217;s is indistinguishable from black magic for most of us.&lt;/p&gt;


	&lt;p&gt;I can use new &lt;span class="caps"&gt;JAR&lt;/span&gt; files and not have to worry about recompiling to remove stale v-table references. The method binding will just work. (This does not remove all problems with changing versions of &lt;span class="caps"&gt;JAR&lt;/span&gt;&amp;#8217;s but it gets rid of one persnickety one.)&lt;/p&gt;


	&lt;p&gt;But it goes deeper. As I mentioned above, I&amp;#8217;ve noticed several Microsoft shops that use a lot of sealed classes or avoid using virtual methods because &amp;#8220;they perform poorly&amp;#8221;.&lt;/p&gt;


	&lt;p&gt;OK, let&amp;#8217;s talk about method invocation for just a second (or make that pico second). On my machine, I timed virtual method dispatch. I should check my numbers, but what I got was that virtual method dispatch was taking around 450 pico-seconds. So you can invoke roughly 2.2 Billion methods per second.&lt;/p&gt;


So:
	&lt;ul&gt;
	&lt;li&gt;Virtual method dispatch is not that expensive&lt;/li&gt;
		&lt;li&gt;The &lt;span class="caps"&gt;JVM&lt;/span&gt; can address caching issues with code analysis and inlining&lt;/li&gt;
		&lt;li&gt;You only pay the price if your design requires it&lt;/li&gt;
		&lt;li&gt;The people writing the &lt;span class="caps"&gt;JVM&lt;/span&gt; are better and micro optimization than certainly me, and I&amp;#8217;d say most people&lt;/li&gt;
	&lt;/ul&gt;


OK, but so it doesn&amp;#8217;t help with performance. Is there a benefit to leaving things unsealed and using more virtual methods?
	&lt;ul&gt;
	&lt;li&gt;Testability&lt;/li&gt;
		&lt;li&gt;Maintainability&lt;/li&gt;
		&lt;li&gt;Flexibility&lt;/li&gt;
		&lt;li&gt;Extensibility&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Look up the percentage of time spent &amp;#8220;building&amp;#8221; a system versus &amp;#8220;maintaining&amp;#8221; a system. The percentage has been on the rise, and it&amp;#8217;s 80 &amp;#8211; 95% typically. 80% of the cost of development is spent maintaining code. (I believe a lot of this percentage has to do with the definition of &#226;&#8364;&#339;done&#226;&#8364;&#157; &amp;#8211; but that&amp;#8217;s a whole other discussion).&lt;/p&gt;


	&lt;p&gt;You might think that locking things down make them more stable and that stability leads to maintainability.&lt;/p&gt;


	&lt;p&gt;That&amp;#8217;s not really the case.&lt;/p&gt;


	&lt;p&gt;Things change. Requirements change.&lt;/p&gt;


	&lt;p&gt;Locking down a class to keep it from breaking is like signing off on requirements to keep them from changing. Neither thing is really a good idea.&lt;/p&gt;


	&lt;p&gt;&lt;span class="caps"&gt;I CAN&lt;/span&gt; lock down my classes in a sense. I can use tests to describe my assumptions so the class is locked down so long as we all agree that we&amp;#8217;ll keep the tests passing. That is a fine level of granularity.&lt;/p&gt;


	&lt;p&gt;But I digress.&lt;/p&gt;


	&lt;p&gt;Back to the whole sealed thing. I was wondering why so many places that use Microsoft stuff seal their classes and do not use virtual methods (in my experience, it&amp;#8217;s about 50%). I then read that thing about the binding of virtual methods at compile time. And then about 2 weeks later it hit me.&lt;/p&gt;


	&lt;p&gt;If you use virtual methods and you have a messed up build system, then you&amp;#8217;ll get strange behavior. Sealing things makes those surprising behaviors go away, so seal stuff.&lt;/p&gt;


	&lt;p&gt;It makes sense. This is something that C++ was notorious about. You hoped you&amp;#8217;d get a segmentation violation but often the wrong method could get called and the system continued to run&amp;#8230;&lt;/p&gt;


	&lt;p&gt;Unfortunately, the &amp;#8220;solution&amp;#8221; &amp;#8211; sealing &amp;#8211; is attacking a symptom, not the actual problem. This is where following the 5-why&amp;#8217;s of Toyota would have been a good idea.&lt;/p&gt;


&amp;#8220;Seal your classes&amp;#8221; 
Why?
	&lt;ul&gt;
	&lt;li&gt;Because they will be more stable. More safe/it expresses my design.
Why?&lt;/li&gt;
		&lt;li&gt;Because my design says that this should not change.
Why?&lt;/li&gt;
		&lt;li&gt;Because when things change, sometimes &amp;#8220;bad things happen.&amp;#8221; 
Why?&lt;/li&gt;
		&lt;li&gt;I don&amp;#8217;t know&amp;#8230;&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;And right there is where you know the solution is a bad idea.&lt;/p&gt;


	&lt;p&gt;In reality I suspect the habit perpetuates because once something appears to work, it is cut and pasted ad nauseam.&lt;/p&gt;


	&lt;p&gt;Should you never seal things?&lt;/p&gt;


	&lt;p&gt;Never say never.&lt;/p&gt;


	&lt;p&gt;Or better yet, never say &amp;#8220;never, never, never.&amp;#8221;&lt;/p&gt;


There are three levels of never:
	&lt;ul&gt;
	&lt;li&gt;Never: Don&amp;#8217;t do it because you may not know what you are doing. (Once you know the rules, you can do it.)&lt;/li&gt;
		&lt;li&gt;Never, Never: You know what you&amp;#8217;re doing most of the time, you are doing a bad thing but you really do know better.&lt;/li&gt;
		&lt;li&gt;Never, Never, Never: &lt;span class="caps"&gt;DON&lt;/span&gt;&amp;#8217;T &lt;span class="caps"&gt;DO IT&lt;/span&gt;!&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;There are few things that are Never, Never, Never. Dereferencing &lt;span class="caps"&gt;NULL&lt;/span&gt; comes to mind (but then maybe I waned a core dump if I get to this point in the code).&lt;/p&gt;


	&lt;p&gt;I&amp;#8217;d place using sealed/final in the Never, Never camp if I&amp;#8217;m using tests to describe the semantics of my classes. OR, if I&amp;#8217;m writing concurrent code, using final on fields provides certain guarantees&amp;#8230;&lt;/p&gt;


	&lt;p&gt;However, let&amp;#8217;s say that I&amp;#8217;ve been told not to use tests (I&amp;#8217;ve seen it at more than one place). Then that &amp;#8220;never, never&amp;#8221; becomes a &#226;&#8364;&#339;sure do it to cover my ass&#226;&#8364;&#157;. Someone can&amp;#8217;t subclass and mess things up. Someone can&amp;#8217;t forget to compile their code when mine changes and cause their code to break&amp;#8230;&lt;/p&gt;


	&lt;p&gt;Now is this a reason to avoid using Microsoft products? No. I really do like C# (for a statically-typed language that is). And I&amp;#8217;m convinced that Java is a better language because of the work done by and in C#. And let&amp;#8217;s face it, having more VM&amp;#8217;s is a good thing. It improves competition. It raises the level at which we can expect to work.&lt;/p&gt;


	&lt;p&gt;But to quote Tim Booth/James in a rather trite way, &amp;#8220;there&amp;#8217;s a chain of consequence within, without.&amp;#8221; That one thing, binding to the v-table so early, has caused a chain of events that leads to a platform that seems a little bit more sluggish to develop in to me. (I expect flames for this.)&lt;/p&gt;


	&lt;p&gt;I think this design decision is a reflection of a mind-set that permeates the development environment. For example, if I have a large solution with several projects, it sure seems that dependency checking in the build environment takes a long time. When I watch Developer Studio build things, it looks like make is running under the covers and performing a bunch of file checks to see what has changed. Where&amp;#8217;s the incremental compilation?&lt;/p&gt;


	&lt;p&gt;I&amp;#8217;ve seen very good work in both .Net and Java development efforts. It just seems that the frequency of unnecessary, basic kinds of environmental design debt occur more frequently in a .NET development effort than in similar Java development efforts.&lt;/p&gt;


	&lt;p&gt;Maybe it&amp;#8217;s a sampling effect. To paraphrase Weinberg, &amp;#8220;there&amp;#8217;s always a sample, be aware of it, you can&amp;#8217;t remove it.&amp;#8221; I&amp;#8217;m a consultant, I go places where they need consultants. I never, never go places that don&amp;#8217;t need consultants, so my sample set is biased (I have one experience, maybe two, where I went and the people did not need consultants because they were doing fine &#226;&#8364;&#8220; or maybe they didn&amp;#8217;t need technically-oriented consultants).&lt;/p&gt;


So what do you think?
	&lt;ul&gt;
	&lt;li&gt;Is using sealed by default a good design choice?&lt;/li&gt;
		&lt;li&gt;Is the binding of methods early a good thing?
	&lt;ul&gt;
	&lt;li&gt;Was the decision by design or because of history?&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
		&lt;li&gt;Has/will the &lt;span class="caps"&gt;CLR&lt;/span&gt; change?&lt;/li&gt;
	&lt;/ul&gt;</description>
      <pubDate>Tue, 03 Jun 2008 22:46:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:8aa193ec-d507-4979-9939-f9ec95363671</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2008/06/03/premature-optimization</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>sealed</category>
      <category>final</category>
      <category>c</category>
      <category>.NET</category>
    </item>
    <item>
      <title>It's All Data</title>
      <description>&lt;p&gt;&amp;lt;sarcasm&amp;gt;&lt;/p&gt;


	&lt;p&gt;&amp;#8220;So, you managed to pick stories that only involved changing data&amp;#8230;&amp;#8221;&lt;/p&gt;


	&lt;p&gt;&amp;#8220;Yep.&amp;#8221;&lt;/p&gt;


	&lt;p&gt;Great, there&amp;#8217;s no need to test it, right?&lt;/p&gt;


Therefore, testing Java classes is unnecessary.
	&lt;ol&gt;
	&lt;li&gt;The &lt;span class="caps"&gt;JVM&lt;/span&gt; simply reads files in a particular format (the Java Class format)&lt;/li&gt;
		&lt;li&gt;The &lt;span class="caps"&gt;JVM&lt;/span&gt; processes those files&lt;/li&gt;
		&lt;li&gt;Java class files are just data to the &lt;span class="caps"&gt;JVM&lt;/span&gt;&lt;/li&gt;
		&lt;li&gt;Java source files are just data to the Java Compiler to generate data used by the &lt;span class="caps"&gt;JVM&lt;/span&gt; &lt;/li&gt;
		&lt;li&gt;We do not need to test data changes&lt;/li&gt;
		&lt;li&gt;Therefore we do not need to test Java classes.&lt;/li&gt;
	&lt;/ol&gt;


&lt;p/&gt;

	&lt;p&gt;q.e.d.&lt;/p&gt;


	&lt;p&gt;Then Norbert asked &amp;#8220;Oh, by the way, did you version your data changes?&amp;#8221;&lt;/p&gt;


	&lt;p&gt;&amp;lt;/sarcasm&amp;gt;&lt;/p&gt;</description>
      <pubDate>Wed, 14 May 2008 16:37:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:d1a1903c-5b5d-415d-ba25-2605dd57ec49</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2008/05/14/its-all-data</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>test</category>
      <category>sarcasm</category>
    </item>
    <item>
      <title>Your code is not flat</title>
      <description>&lt;p&gt;There are three possibilities for the universe. On the one hand it is Closed. 
There&amp;#8217;s enough matter that the universe, currently expanding, will eventually 
stop expanding and collapse in on itself.&lt;/p&gt;


	&lt;p&gt;The universe might be open. There&amp;#8217;s not enough matter for gravitational forces
to bring the universe back in on itself.&lt;/p&gt;


	&lt;p&gt;The final option is that the universe is flat. There&amp;#8217;s just enough mass that it will stop
expanding but it will not collapse in on itself.&lt;/p&gt;


	&lt;p&gt;Assuming an infinite number of universes, the final option, the flat option,
must surly exist, somewhere. Probably not here, but somewhere. So for all 
intents and purposes, our universe is likely open or closed but not flat.&lt;/p&gt;


	&lt;p&gt;While you were reading that, your code rotted just a little. You&amp;#8217;ve heard of 
it, bit rot. The bits in a program sitting on a disk rot. It&amp;#8217;s a well known
fact. Sure the magnetic surface could give out or if it&amp;#8217;s in memory, a stray cosmic 
ray could flip a bit.&lt;/p&gt;


	&lt;p&gt;But that&amp;#8217;s not what I&amp;#8217;m talking about. You know the experience. It was just
working and now it is not working. You did not change anything so therefore
it is the same as it was and so something else must have changed. This is
bit rot.&lt;/p&gt;


	&lt;p&gt;Typically, bit rot is really just our expectations being crushed by reality.
Never let a fact get in the way of a good theory, that&amp;#8217;s my motto. This works
especially well if you tend to be a better talker than listener (guilty).&lt;/p&gt;


	&lt;p&gt;At any rate, your code continues to rot as you continue to read this. Why?
Someone using it has managed to find another thing programmers did not think about.
So what was &amp;#8220;working&amp;#8221; before is not &amp;#8220;working&amp;#8221; now. Wait, was it really working?
If someone was getting value out of using it then yes it was working. Is it
working now? If nothing about the system has changed but it no longer serves
a purpose, then it is not working.&lt;/p&gt;


	&lt;p&gt;Here&amp;#8217;s a question. If a tree falls in the forest and nobody hears it, does 
it make a sound? Answer from a human perspective, no. If there&amp;#8217;s nobody to
hear it, then it didn&amp;#8217;t make a sound. Sure it moved some air about and you
could take an infinite sum of sine waves to characterize that air movement
but then if you characterize it then something was there to observe it
and that seems to violate the spirit of &amp;#8220;nobody hears it.&amp;#8221;&lt;/p&gt;


	&lt;p&gt;What about if there&amp;#8217;s a problem in the code and nobody hits it, does your 
code have a defect? Using the tree as an example, then the answer is no.
However, unlike the tree&amp;#8217;s sound, which quickly dissipates (if for no
other reason that then laws of thermodynamics), your code tends to stay
around a bit longer so the chance for observation of a sleeping 
defect is higher (though to be fair, if you wait long enough your code, like the sound in the forest, will go away).&lt;/p&gt;


	&lt;p&gt;OK, but it is even worse than that. Things change. If your body is not changing
then you are dead. That&amp;#8217;s a fact. In one study by Dr. Frisen, he demonstrated
the age of cells in a rib bone of a 30 year old to be just over 15 years, while
the cells that line the stomach to be closer to 5 days. Your body is constantly
fixing itself. Cells replace themselves. That&amp;#8217;s why you can donate platelets 
every 3 days and blood every 56 days.&lt;/p&gt;


	&lt;p&gt;What about your code? Is it fixing itself? Is it repairing itself? Does it need to?
If your code is not changing, then the project is dead. Sure, it takes some time
for all usefulness to finally wear out of the system but at some point the
system will essentially bit rot so badly that is serves no useful purpose.
(While there are multiple clinical definitions of &amp;#8220;dead&amp;#8221; for a body, some life
remains long after you are clinically dead &amp;#8211; your fingernails will keep growing
for some time after you expire.)&lt;/p&gt;


There are several things that cause your system to decay. Here are just a
few:
	&lt;ul&gt;
	&lt;li&gt;What the business needs changed so until the system catches up it has less value&lt;/li&gt;
		&lt;li&gt;The act of introducing the system has changed the business so that the system needs to change&lt;/li&gt;
		&lt;li&gt;Someone misunderstood something (it&amp;#8217;s actually no small miracle that people can communicate at all &amp;#8211; my wife would argue she cannot get through to me)&lt;/li&gt;
		&lt;li&gt;Someone actually changed some code badly (most 1-line bug fixes introduce new defects &amp;#8211; see Weinberg)&lt;/li&gt;
		&lt;li&gt;Someone is compelled to hack it in to meet the deadline/demo/beat the lunch crowd/...&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Your code is rotting while you read this because the environment around it is 
changing. Add to that an observation that most changes to code
introduce rather than reduce chaos and it&amp;#8217;s no wonder your system is either
closed (code collapses in on itself, weighed down by its own incidental complexity) or open (nobody can decide what to do and
the project eventually sort of fizzles into nothingness).&lt;/p&gt;


	&lt;p&gt;So what are you doing to actively maintain your system&amp;#8217;s integrity? Are you 
just using antibiotics (patching things quickly hoping that there&amp;#8217;s no super
bug on the horizon &amp;#8211; there&amp;#8217;s always a super bug on the horizon no matter 
how strong an alligator&amp;#8217;s immune system might be), or are you doing what
the surgeon general has been saying for years: getting enough sleep, 
working out regularly, eat healthily (there&amp;#8217;s a moving target).&lt;/p&gt;


	&lt;p&gt;Your code is rotting every day in every way unless you are actively working 
against that tide. Talking to your users &amp;#8211; being friendly even, writing tests 
(acceptance, integration, smoke, unit, load, exploratory, ... mostly automated),
integrating often, refactoring, learning to see beginning of rot rather than the end of it, etc.&lt;/p&gt;


	&lt;p&gt;There are a lot of things we can do and need to do to make a system. Part of that
is keeping the system alive and breathing. Unlike biological systems where nature
(and natural selection) has resulted in a self-monitoring, self-healing systems, code
does not really monitor itself and fix itself (well most code does not do that).&lt;/p&gt;


	&lt;p&gt;Maybe there&amp;#8217;s been a hidden force driving the creation of these things we
called code maintainers whose existence is predicated on the need to
repair living code to keep it around just a bit longer.&lt;/p&gt;


	&lt;p&gt;If this is the case, then just like the waist lines of americans are increasing 
as our biological systems have not had enough time to adjust to the changing 
environment, our code bases are bloating and getting to the point where code 
maintainers cannot keep the systems living long enough.&lt;/p&gt;


	&lt;p&gt;It seems a shift is in order to make it possible to keep these living, but often
very sick, applications alive longer. In a sense, if you are practicing keeping your
code clean, you are like a doctor because you diagnosing sickness, prescribing 
a path to heath and, if necessary, making incisions, using slugs or just waiting
for a given sickness to simply follow its natural course before going away (like the 
requirement that simply must be done right away, just because).&lt;/p&gt;


	&lt;p&gt;Unfortunately, if we are calling ourselves doctors, then we&amp;#8217;re still learning the value of
keeping our hands clean between procedures. Unlike doctors of the mid-19th century
who thought more blood on clothes = more experience, Ignaz Semmelweis figured 
out that hand washing saved lives.&lt;/p&gt;


	&lt;p&gt;As a community we&amp;#8217;re not there yet. There&amp;#8217;s still pride is hacking something together.&lt;/p&gt;


	&lt;p&gt;Your code is getting worse, what are you going to do about it?&lt;/p&gt;</description>
      <pubDate>Mon, 05 May 2008 23:35:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:270143c7-bfa7-491e-a827-6672b0ad46bb</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2008/05/05/your-code-is-not-flat</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>bit</category>
      <category>rot</category>
      <category>clean</category>
      <category>code</category>
    </item>
    <item>
      <title>Your Attitude is Affecting Other Departments</title>
      <description>&lt;p&gt;The &lt;span class="caps"&gt;CIO&lt;/span&gt; looked into the eyes of his agile development staff last Friday. &amp;#8220;Your attitude is affecting other departments&amp;#8221; he said.&lt;/p&gt;


	&lt;p&gt;I&amp;#8217;ve heard a lot of department-level speeches start this way, and in relatively small companies it is not unheard-of for a C-level manager to address attitudes of development teams.&lt;/p&gt;


	&lt;p&gt;The group has been working to stabilize and improve a product that was developed by a tiger team of outsider contractors and handed over to the in-house team post-facto. The developers had to overcome many obstacles to come up to speed on the code, to learn the new programming languages and tools, and to try to keep the feature set moving forward.  None of them had been involved in the original design, but it was now their product, and its problems were their problems.&lt;/p&gt;


	&lt;p&gt;At the time of this meeting, I was one part of a coaching team which had introduced a great many changes.   We were trying to help the organization to build a &amp;#8220;whole team&amp;#8221; mentality that encompassed documentation, security, systems administration, QA, customer representatives, and developers alike.  We&amp;#8217;d attacked the problem of matrix management.  We reorganized the seating floorplan.  I think at some point we&amp;#8217;d been an inconvenience to just about everybody. The developers were in the middle of their second two-week iteration.&lt;/p&gt;


	&lt;p&gt;On this occasion, the team was in the midst of a recurring production difficulty, and had been gathered into the &lt;span class="caps"&gt;CIO&lt;/span&gt;&amp;#8217;s office to work through a top-20 list of problems to solve.&lt;/p&gt;


	&lt;p&gt;&amp;#8220;Your attitude has been affecting other departments&amp;#8221;, he said. &amp;#8220;And I want to thank you for it.&amp;#8221;&lt;/p&gt;</description>
      <pubDate>Sat, 05 Apr 2008 21:17:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:293e08d9-74d8-475a-b2aa-a66c2c1a1436</guid>
      <author>Tim Ottinger</author>
      <link>http://blog.objectmentor.com/articles/2008/04/05/your-attitude-is-affecting-other-departments</link>
      <category>Tim's Tepid Torrent</category>
      <category>Schuchert's Scattered Synapses </category>
      <category>XP</category>
      <category>transitions</category>
      <category>attitude</category>
    </item>
    <item>
      <title>Discipline often directed at the symptom, not the cause</title>
      <description>Have you ever heard something like?
&lt;blockquote&gt;
If the developer just had a little discipline and did it the right way, we would not have this problem.
&lt;/blockquote&gt;

	&lt;p&gt;That&amp;#8217;s often a sign that the way something is getting done is hard to do, not supported well or just plain works against against you.&lt;/p&gt;


	&lt;p&gt;Here&amp;#8217;s an example I recently came across&amp;#8230;&lt;/p&gt;


In a particular organization, part of their build system produces &amp;#8220;project&amp;#8221; information to allow for development on multiple platforms and with different C++ compilers. That&amp;#8217;s excellent, it sounds like a great tool. For a developer to get started, he/she:
	&lt;ul&gt;
	&lt;li&gt;Checks out the source tree&lt;/li&gt;
		&lt;li&gt;Runs the script&lt;/li&gt;
		&lt;li&gt;Starts working&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;So far, everything is great and this part of their build system is essential to their environment &amp;#8211; and good in general.&lt;/p&gt;


	&lt;p&gt;Here&amp;#8217;s the next part&amp;#8230;&lt;/p&gt;


To add a file to the system you have to:
	&lt;ul&gt;
	&lt;li&gt;Create the file&lt;/li&gt;
		&lt;li&gt;Update project information&lt;/li&gt;
		&lt;li&gt;Rerun the script to regenerate project information.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;When I asked how long it takes to add a class, I was told about 5 minutes. So if I want to add a header file and source file, it takes 5 minutes. That&amp;#8217;s a big problem. Why?&lt;/p&gt;


	&lt;p&gt;After this discussion, I heard one of the senior people lamenting that a developer had put another class in an existing file rather than creating a second file. He said something like &amp;#8220;If the developer just had discipline, he&amp;#8217;d to the right thing.&amp;#8221; Those darn developers.&lt;/p&gt;


	&lt;p&gt;It takes 5 minutes to add a few files to a build. That does not include build time. That&amp;#8217;s just the time to configure the build information.&lt;/p&gt;


	&lt;p&gt;Does 5 minutes seem like very much time?&lt;/p&gt;


Here are a few more thins I noticed(before I knew about the build system):
	&lt;ul&gt;
	&lt;li&gt;Some header files defined multiple classes&lt;/li&gt;
		&lt;li&gt;Some source files had the methods for those multiple classes&lt;/li&gt;
		&lt;li&gt;Some of the header files had names that did not match any of the classes defined in that header file&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;So is this a problem?&lt;/p&gt;


Here&amp;#8217;s an important rule from Jerry Weinberg:
&lt;blockquote&gt;
Nothing + Nothing + Nothing eventually equals something
&lt;/blockquote&gt;

	&lt;p&gt;5 minutes may not seem like a lot of time, and if it were isolated, then it&amp;#8217;s probably not a problem. On the other hand, when you multiply it by a team and time, you end up with big problems.&lt;/p&gt;


	&lt;p&gt;Imagine, you need to use class X. Its header file is actually named Q.h and by the way, classes &lt;span class="caps"&gt;T U&lt;/span&gt; and L are defined in that file &amp;#8211; none of which you want to know about.&lt;/p&gt;


	&lt;p&gt;So your class now has phantom dependencies on T, U and L. Also, how did you find the right header file? A quick search (time wasted). Someone changed U, so you end up having to recompile even though you don&amp;#8217;t care about nor use (wasted time). I&amp;#8217;m sure you can come up with a few things on your own.&lt;/p&gt;


	&lt;p&gt;So what do you do about it?&lt;/p&gt;


OK, first, do not throw the baby out with the bathwater. The original tool solved an important problem. But the first rule of problem solving, again from Jerry Weinberg:
&lt;blockquote&gt;
Every solution introduces problems
&lt;/blockquote&gt;

The problems include (but are not limited to):
	&lt;ul&gt;
	&lt;li&gt;Time wasting adding files&lt;/li&gt;
		&lt;li&gt;It requires discipline to add new files, so it doesn&amp;#8217;t always happen&lt;/li&gt;
		&lt;li&gt;A name is wrong, but it&amp;#8217;s a pain to update the build configuration, so it doesn&amp;#8217;t happen &amp;#8211; not all the time, just every so often&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Little by little, things get a bit more chaotic.&lt;/p&gt;


	&lt;p&gt;So now that we&amp;#8217;ve observed a problem &amp;#8211; some waste, we need to find a way to remove the need to update the build information and regenerate to even work.&lt;/p&gt;


I don&amp;#8217;t know what&amp;#8217;s going to happen with this group. They are hoping to perform some refactorings. Their system has quite a bit of coupling. One thing we can do to reduce coupling is:
	&lt;ul&gt;
	&lt;li&gt;Introduce interfaces&lt;/li&gt;
		&lt;li&gt;Inversion of Control&lt;/li&gt;
		&lt;li&gt;Identify seams and use some of Feather&amp;#8217;s stuff to introduce them&lt;/li&gt;
		&lt;li&gt;Etc., the usual stuff to introduce seams and break dependencies.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;But many of the refactorings they&amp;#8217;ll want to use will involve creating new classes. Since that takes a little bit longer, it will slow everything down &amp;#8211; or seem so daunting, it might not happen at all.&lt;/p&gt;


	&lt;p&gt;Here&amp;#8217;s a personal example. A few years ago, I built the security system for one applications and then a suite of applications with single sign on. When I initially introduced the security system, many people wrote tests that would forget to log out, causing problems in both the real system and the simulator.&lt;/p&gt;


	&lt;p&gt;I kept grumbling. I though, &amp;#8220;if people would just do it right, there wouldn&amp;#8217;t be a problem.&amp;#8221; If they just had a little discipline.&lt;/p&gt;


Independent of whose fault it was, it ended up being my problem &amp;#8211; and, quite frankly, it was my fault as well. The solution was actually pretty easy:
	&lt;ul&gt;
	&lt;li&gt;Create an abstract test base&lt;/li&gt;
		&lt;li&gt;Change tests to use it&lt;/li&gt;
		&lt;li&gt;In the setup, the base logged in&lt;/li&gt;
		&lt;li&gt;In the teardown, the base logged out&lt;/li&gt;
	&lt;/ul&gt;


You might think, &amp;#8220;Duh!&amp;#8221; and in retrospect, so did I. But that few minutes of effort:
	&lt;ul&gt;
	&lt;li&gt;Reduced code duplication&lt;/li&gt;
		&lt;li&gt;Increased the stability of the tests&lt;/li&gt;
		&lt;li&gt;Made it hard for people to mess up (so long as they used the correct test base &amp;#8211; and I updated all of the tests that needed it, so going forward, people had correct examples upon which to base their work).&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Ultimately, this removed a lot of my wasted time&lt;/p&gt;


	&lt;p&gt;Detecting waste is the first thing. Until you know it is a problem, you cannot do anything about it.&lt;/p&gt;


So, the next time you think something like:
	&lt;ul&gt;
	&lt;li&gt;If that person was only following &amp;#8220;the rules&amp;#8221; &lt;/li&gt;
		&lt;li&gt;If he/she just had a little more discipline&lt;/li&gt;
		&lt;li&gt;Stupid user, they should not have done that&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Ask yourself if it&amp;#8217;s possible that those statements are directed at the symptom, not the problem.&lt;/p&gt;</description>
      <pubDate>Sat, 01 Mar 2008 16:18:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:83bf0f26-2d34-4f54-bc32-b4487c1224ac</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2008/03/01/discipline-often-directed-at-the-symptom-not-the-cause</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>lean</category>
      <category>waste</category>
      <category>refactoring</category>
    </item>
    <item>
      <title>So just what does synchronized do?</title>
      <description>&lt;p&gt;&lt;b&gt;Synopsis&lt;/b&gt;
&lt;Blockquote&gt;Using synchronized turns a huge state space into a comparatively small one.
&lt;/blockquote&gt;
&lt;p&gt;Normally, the light from a star radiates out in all directions. But what happens when a star collapses? There are several possibilities depending on the mass of the star. Our sun will turn into a red giant and then later turn into a white dwarf, giving out light from its accumulated heat for many years after living on Earth has become unbearable; mostly because of all the traffic.&lt;/p&gt;&lt;/p&gt;


&lt;p&gt;If the mass of the star is around 10x our star, its destiny is just a bit different. It will begin to collapse. Along the way, it will probably have some temporary reprieves from its ultimate fate, to become a Neutron star, by consuming other heavier elements such as carbon and helium . However, the writing is on the wall. The center of star, already an extreme environment, becomes even more so; eventually, the pressure from the collapsing of material into the center of the star results in a massive explosion known as a nova or super nova &amp;#8211; depending on the mass of the star. What is left is a neutron star. A neutron star is the heart of a pulsar, able to spin at amazing rates without pulling itself apart.&lt;/p&gt;

&lt;P&gt;Another option is a black hole. A black hole is an often used metaphor for either the effort expended on support/fixing/updating a big ball of mud or what the development effort appears to be in most of the time. Either way, it is not considered a good thing if you&amp;#8217;re anywhere in the vicinity.&lt;/P&gt;

&lt;p&gt;I&amp;#8217;m a pessimist by nature. I see a project in decline, sucking in other resources, like a black holes eating neighboring galaxies, snuffing the light out of stars, just like projects can suck the life force out of individuals.&lt;/P&gt;

&lt;P&gt;However, energy can escape from a black hole, eventually leading to the demise of the black hole. Energy can escape along the axis of rotation in either direction. In a sense, if we see the expansion of the black hole as a bad thing, anything that diminishes a black hole is a good thing. Stephen Hawking theorized that at the event horizon of black holes, fluctuations in the space can cause the spontaneous creations of pairs of particles and their anti particles. This is another way it can appear that a black hole is losing energy since it gives off particles while the opposite particle goes into the black hole.&lt;/P&gt;

	&lt;p&gt;Now I&amp;#8217;m off track. I wanted to talk about how synchronized give a similar effect as the massive gravity of black hole. But instead of curving space-time, they invert the possible state space of code in the presence of threads. Let&amp;#8217;s take a look.&lt;/p&gt;


Here&amp;#8217;s a simple class:
&lt;FONT style="line-height:95%"&gt;&lt;code&gt;&lt;pre&gt;
public class X {
   int value;

   public synchronized void incrementValue() {
        ++value;
    }
}&lt;/pre&gt;&lt;/code&gt;&lt;/FONT&gt;
Let&amp;#8217;s say, for the sake of argument, two threads are trying to execute the single method in this class. If the method is written like this:
&lt;FONT style="line-height:95%"&gt;&lt;code&gt;&lt;pre&gt;
   public synchronized void incrementValue() {
        ++value;
    }
&lt;/pre&gt;&lt;/code&gt;&lt;/FONT&gt;
&lt;P&gt;Then there are only two orderings, Thread 1/Thread 2, or Thread 2/Thread 1. All of those paragraphs at the top were to make this analogy.&lt;/p&gt;

&lt;P&gt;OK, so if we use synchronized that that&amp;#8217;s the black hole. The number of possible paths through the code for N threads is N!. What&amp;#8217;s the opposite? What happens if we take off the keyword and then run two threads through it? In how many ways can that single line of code get executed?&lt;/P&gt;

	&lt;p&gt;Are you ready for it?&lt;/p&gt;


&lt;B&gt;&lt;Blockquote&gt;3,432 different ways&lt;/blockquote&gt;&lt;/B&gt;

	&lt;p&gt;Really? Well at least conceptually. In practice, the Just In Time compiler will probably turn the &lt;span class="caps"&gt;JVM&lt;/span&gt; instructions into native code, so the actual number of individual steps will probably be less. But there really are that many paths through the system. You might ask how?&lt;/p&gt;


	&lt;p&gt;That single line of code is represented in byte code as 7 lines. I could show you the disassembly, but really, it&amp;#8217;s 7. You can convince yourself by having a look at the byte-code using a nice &lt;a href="http://download.forge.objectweb.org/eclipse-update/"&gt; byte-code viewer&lt;/a&gt; plug-in for eclipse.&lt;/p&gt;


	&lt;p&gt;What happens if we change the int to a long? We still have 7 lines of byte-code, but with different instructions. We have a total of 4 long reads/writes. Each long read/write requires two individual 32-bit operations &amp;#8211; or at lest the &lt;span class="caps"&gt;JVM&lt;/span&gt; can implement it that way. The actual number of atomic operations after the Just In Time compiler has had its way with your byte-code will probably be less, but if we stick to byte-codes and the Java memory model, the number 3,432 is now a whopping 705,432!&lt;/p&gt;


	&lt;p&gt;Let&amp;#8217;s extend that just a bit more. What if you have several lines of code? Each line of Java results in many more lines of byte-code. What if we have have 3 lies of Java? We probably have something like 21 lines of byte-code. How many paths of execution would 21 lines of byte-code executed by two threads have? 538,257,874,440!&lt;/p&gt;


	&lt;p&gt;Where the first program ended up being a white dwarf, the version using longs was a nova. I&amp;#8217;m not sure what to call the thee line Java method, maybe a hyper-nova?&lt;/p&gt;


	&lt;p&gt;In practice, the actual number of paths through a method will end up being smaller. And, most of the paths do not have any negative side-effects. The problem, however, is that there are a small number of hard to find paths of execution that do cause problems and finding them is like looking for a needle in a haystack.&lt;/p&gt;


	&lt;p&gt;Remember what adding the keyword synchronized did? If we use it on a three line method, it turns 538,257,874,440 into 2. It collapses the number of paths into 2 for two threads. And 2 is less than 538,257,874,440, for even vary large values of 2.&lt;/p&gt;


	&lt;p&gt;How did I derive at these magic numbers? Two ways.&lt;/p&gt;


	&lt;p&gt;I wanted to know how many possible orderings there were for 7 instructions and two threads. I knew it had to do with combinations and permutations but I just wasn&amp;#8217;t smart enough to figure it out. Searching on Google didn&amp;#8217;t do much for me either. So I decided to write a program to numerically derive the result. I tested my way into a program that would calculate the result.&lt;/p&gt;


The basic algorithm is:
&lt;ol&gt;
&lt;li&gt;Determine all possible orderings of each of the unique &amp;#8220;nodes&amp;#8221; in a system. For example, if I have 2 threads and 2 instructions, I can generate a natural key (ugh!) to represent each of the different combinations of threads and instructions: &lt;span class="caps"&gt;T1S1 T1S2 T2S1 2S2&lt;/span&gt;.&lt;/li&gt;
&lt;li&gt;Produce all valid permutations of these four &amp;#8220;nodes&amp;#8221;.&lt;/li&gt;
&lt;li&gt;Remove any that have invalid orderings.&lt;/li&gt;
&lt;li&gt;Count the results.&lt;/li&gt;
&lt;/ol&gt;

	&lt;p&gt;Many of my first implementations for some of these steps were exercises in writing really inefficient code! But having those tests made it really easy to swap out better algorithms when my brain caught up with what I was doing.&lt;/p&gt;


	&lt;p&gt;What is an invalid ordering? The code generated by the single line using the pre increment operator has 7 steps. Those 7 steps are in a single sequence with no looping and no conditionals. That&amp;#8217;s like saying A is always before B. So if we generate a list of orderings that end up including that combination, we&amp;#8217;ve generated an ordering that cannot happen.&lt;/p&gt;


So you can describe your possible state space in a few steps:
&lt;ol&gt;
&lt;li&gt;Register a node for each thread, step combination. 7 threads, 4 steps = 28 nodes.&lt;/li&gt;
&lt;li&gt;Register dependences between steps. For example, if I have seven steps and two threads executing the same sequence, I could describe this as: &lt;span class="caps"&gt;T1S1&lt;/span&gt; -&amp;gt; &lt;span class="caps"&gt;T1S2&lt;/span&gt; -&amp;gt; &lt;span class="caps"&gt;T1S3&lt;/span&gt;, etc. And for the second thread: &lt;span class="caps"&gt;T2S1&lt;/span&gt; -&amp;gt; &lt;span class="caps"&gt;T2S2&lt;/span&gt; -&amp;gt; T2&amp;gt;S3. Since the name is arbitrary, I just used letters, so in fact I had: a -&amp;gt; b -&amp;gt; c -&amp;gt; d -&amp;gt; e -&amp;gt; f -&amp;gt; g for one set of dependencies and h -&amp;gt; i -&amp;gt; j -&amp;gt; k -&amp;gt; l -&amp;gt; m -&amp;gt; o
&lt;/ol&gt;
&lt;p&gt;In fact, here&amp;#8217;s the test I used to describe that exact space:&lt;/P&gt;
&lt;FONT style="line-height:95%"&gt;&lt;code&gt;&lt;pre&gt;
    @Test
    public void twoThreadsAndSevenSteps() {
        calculator = new PathCalculator(14);
        createLine('a', 'b', 'c', 'd', 'e', 'f', 'g');
        createLine('h', 'i', 'j', 'k', 'l', 'm', 'n');
        start();
        int totalPaths = calculator.totalPaths();
        stop(2, 4, totalPaths);
    }
&lt;/pre&gt;&lt;/code&gt;&lt;/FONT&gt;

&lt;P&gt;By the time I got to this point, I wrote some &amp;#8220;tests&amp;#8221; using JUnit as a harness to run my code and display timing information and a summary of the &lt;results. The output looked like this.&lt;/p&gt;
&lt;FONT style="line-height:95%"&gt;&lt;code&gt;&lt;pre&gt;
Time:        4ms -- Threads:  3, Opcodes:  2, Total paths:      90
Time:        1ms -- Threads:  2, Opcodes:  3, Total paths:      20
Time:       54ms -- Threads:  4, Opcodes:  2, Total paths:    2520
Time:        3ms -- Threads:  2, Opcodes:  4, Total paths:      70
Time:       61ms -- Threads:  2, Opcodes:  5, Total paths:     252
Time:     1248ms -- Threads:  2, Opcodes:  6, Total paths:     924
Time:    12819ms -- Threads: 10, Opcodes:  1, Total paths: 3628800
&lt;/pre&gt;&lt;/code&gt;&lt;/FONT&gt;

I then used this information to fit a cure to my data and derive a formula for various combinations. For 2 threads, I came up with the following formula. If you let N be the number of steps:
&lt;blockquote&gt;Total Paths = 252 * 3.6667 &lt;sup&gt;N-5&lt;/sup&gt; &lt;/blockquote&gt;

&lt;P&gt;The morning after, Uncle Bob sent an email, showing me his work on how he calculated.&lt;/P&gt;

If you let:
&lt;ol&gt;
&lt;li&gt;T be the number of threads&lt;/li&gt;
&lt;li&gt;N be the number of steps&lt;/li&gt;
&lt;/ol&gt;
&lt;blockquote&gt;Total = (N*T)! &amp;nbsp; / &amp;nbsp; N! &lt;sup&gt;T&lt;/sup&gt;&lt;/blockquote&gt;

	&lt;p&gt;When I plugged numbers into his formula, they fit my formula. His formula generated an exact result as opposed to my estimate based on fitting a curve. Another thing his solution has going for it is the algorithm I came up with, I believe, is NP-complete. The net effect was I that while I was able to calculate result for 2 threads and 6 steps, 2 threads and 7 steps took a long time before running out of memory with a 2GB heap space. Bob&amp;#8217;s formula gave me a so-called verifier (as did my formula &amp;#8211; only Bob&amp;#8217;s was better) and the algorithm seems to grow based on factorials and not polynomials.&lt;/p&gt;


&lt;p&gt;What&amp;#8217;s the point of all of this? The single, one-line program, is a demonstration of why going from one thread to two threads makes writing/debugging/testing programs so much harder. It also numerically demonstrates &lt;b&gt;why&lt;/b&gt; the single responsibility principle is even more important when we start writing concurrent programs. The more you put in one place, the large the state space. Larger state spaces:
&lt;ol&gt;
&lt;li&gt;Make it harder to find that one or few number of paths that can cause your program to die, under load, in production, while you are on vacation&lt;/li&gt;
&lt;li&gt;Make your efforts to test (which is a sampling technique anyway) for concurrency issues all the more difficult&lt;/li&gt;
&lt;li&gt;Make it harder to find what might actually have caused a failure once you&amp;#8217;ve notice it.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In a later post, I&amp;#8217;ll describe how we can improve our chances of covering this huge space of potential orderings.&lt;/P&gt;

&lt;p&gt;If you&amp;#8217;ve made it this far, wow! Congratulations!&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jan 2008 21:27:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:5b8ba16d-124b-4957-a36a-eb8359b589c0</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2008/01/03/so-just-what-does-synchronized-do</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>threading</category>
      <category>concurrency</category>
      <category>testing</category>
      <category>NP</category>
      <category>complete</category>
    </item>
    <item>
      <title>Generic Java Agent Registry</title>
      <description>&lt;p&gt;I&amp;#8217;m writing a Java Agent for the first time. Why? I&amp;#8217;m interested in using this tool called &lt;a href="http://www.haifa.ibm.com/projects/verification/contest/index.html"&gt;ConTest&lt;/a&gt; from &lt;span class="caps"&gt;IBM&lt;/span&gt;. It was originally written during &lt;span class="caps"&gt;JDK 1&lt;/span&gt;.3 days and now it requires &lt;span class="caps"&gt;JDK 1&lt;/span&gt;.4. It instruments class files looking for code that uses concurrent constructs such as synchronized blocks and inserts code to monitor and play that code back in ways that will more likely expose concurrent problems.&lt;/p&gt;


	&lt;p&gt;What&amp;#8217;s the problem?&lt;/p&gt;


	&lt;p&gt;It was written in the days when we would use a pre-processing stage to instrument code and then execute tests. This is fine if I wanted to work at the command line and use ant/maven to build. However, I want to work in an &lt;span class="caps"&gt;IDE&lt;/span&gt; that makes running unit tests easy (Eclipse, though they all do it now). But if I have to remember to instrument my classes before running my tests, that leads to human error. I don&amp;#8217;t want that, I want to just run my unit tests and have my classes dynamically instrumented. (This is not speculation, this comes from working in a group consisting of multiple teams, all of which were using some Aspects written using AspectJ and running unit tests in Eclipse &amp;#8211; when we introduced dynamic instrumentation &amp;#8211; pre &lt;span class="caps"&gt;JDK 1&lt;/span&gt;.5 and even working in WebSphere 5.x), it improved productivity.&lt;/p&gt;


	&lt;p&gt;What about a plug-in? Sure, there&amp;#8217;s one for Eclipse but I&amp;#8217;ve not been able to download it. It probably works fine &amp;#8211; after a class is compiled, it gets instrumented &amp;#8211; but if I&amp;#8217;m able to write a simple Java Agent, I can create a &lt;span class="caps"&gt;JVM&lt;/span&gt; configuration with a few parameters and every time I run my tests, viola, dynamic instrumentation with only a little one-time environment configuration. Also, I don&amp;#8217;t have to worry about waiting for a plug-in update to continue using the tool.&lt;/p&gt;


	&lt;p&gt;Will my tests run slower? Probably, but until I know how much slower, I&amp;#8217;m willing to risk it. (I&amp;#8217;ve used dynamic instrumentation when running over 1,000 tests on a workspace with &amp;gt; 1 Million lines of code, it was fine.) If it&amp;#8217;s an issue, I can imagine using a combination of annotations and the Java agent. Something like:&lt;/p&gt;


	&lt;p&gt;@TestInstrument &lt;br&gt;
public class SomeClassThatUsesThreading {}&lt;/p&gt;


	&lt;p&gt;This would allow the Java Agent to only instrument some classes, rather than all classes. This could cause problems if I forget the annotation, but it&amp;#8217;s an option if speed is an issue.&lt;/p&gt;


	&lt;p&gt;I would not do that unless it was necessary. First, most of my tests would be testing code that is not thread-related. Those tests would not require instrumentation. The tests that require instrumentation, would be somewhere else, and I&amp;#8217;d run them with a different frequency; I&amp;#8217;d run them longer, with more configurations and iterations, to increase my chances of finding threading-related issues.&lt;/p&gt;


	&lt;p&gt;There&amp;#8217;s another option. Copy what ConTest is already doing using &lt;span class="caps"&gt;AOP&lt;/span&gt;. I tried, and I cannot select the correct point-cuts using traditional point-cut syntax &amp;#8211; try selecting synchronized blocks and then every line within the block, that&amp;#8217;s not a typical point-cut usage scenario. I considered a combination of hand instrumentation and &lt;span class="caps"&gt;AOP&lt;/span&gt; &amp;#8211; it&amp;#8217;ll work but it makes the code ugly. I even considered using asm or cglib directly and at that point I knew it was more time than I wanted to spend when the developers of ConTest have years of experience instrumenting classes.&lt;/p&gt;


	&lt;p&gt;Anyway, I&amp;#8217;m hoping the team working on this tool will publish an &lt;span class="caps"&gt;API&lt;/span&gt; soon so I can give that a try. They &lt;a href="http://www-128.ibm.com/developerworks/forums/thread.jspa?messageID=14029192&amp;#38;tstart=0#14029192"&gt;mentioned&lt;/a&gt; they would at some point.&lt;/p&gt;


	&lt;p&gt;If you want more information on writing a Java Agent (and the class that actually registeres it), have a look at &lt;a href="http://schuchert.wikispaces.com/JavaAgent"&gt;Brett&amp;#8217;s Java Agent Notes&lt;/a&gt;.&lt;/p&gt;</description>
      <pubDate>Sat, 29 Dec 2007 22:44:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:8b0f0670-1ddb-45e5-8357-6bd7f56b04e1</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2007/12/29/generic-java-agent-registry</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>javaagent</category>
      <category>instrumentation</category>
      <category>concurrent</category>
      <category>threading</category>
      <category>AOP</category>
    </item>
    <item>
      <title>Strongly Typed Languages Considered Dangerous</title>
      <description>&lt;p&gt;Have you ever heard of covariance? Method parameters or returns are said to be covariant if, as you work your way down an inheritance hierarchy, the types of the formal parameters or return type in an overridden method can be sub-types of the formal parameters and return types in the superclass&amp;#8217; version of the  method.&lt;/p&gt;


	&lt;p&gt;Oh, and contravariance is just the opposite.&lt;/p&gt;


	&lt;p&gt;What?! Why should you care? Answer, you shouldn&amp;#8217;t. Yes C++ and Java both support covariant return types, but so what? Have you ever used them? OK, I have, but then I also used and liked C++ for about 7 years, over 10 years ago. We all learn to move on.&lt;/p&gt;


	&lt;p&gt;You ever notice how something meant to help often (typically?) turns out to do exactly the opposite? Even worse, it directly supports or enables another unfortunate behavior. This is just Weinberg&amp;#8217;s first rule of problem solving:&lt;/p&gt;


&lt;h1&gt;Every solution introduces new problems&lt;/h1&gt;
&lt;P&gt;
&lt;P&gt;

	&lt;p&gt;Here&amp;#8217;s an example I&amp;#8217;m guilty of. Several years ago I was working on a project where we had written many unit tests. We had not followed the &lt;span class="caps"&gt;FIRST&lt;/span&gt; principles, specifically R-Reliability. Our tests were hugely affected by the environment. We had copies of real databases that would get overridden without warning. We&amp;#8217;d have problems with MQ timeouts at certain times of the day or sometimes for days. And our tests would fail.&lt;/p&gt;


	&lt;p&gt;We wold generally have &amp;#8220;events&amp;#8221; that would cause tests to fail for some time. We were using continuous integration and so to &amp;#8220;fix&amp;#8221; the problem, I created a class we called &amp;#8220;TimeBomb&amp;#8221; &amp;#8211; turns out it was the right name for the wrong reason.&lt;/p&gt;


	&lt;p&gt;You&amp;#8217;d put a TimeBomb in a test and then comment out the test. The TimeBomb would be given a date. Until that date, the test would &amp;#8220;pass&amp;#8221; &amp;#8211; or rater be ignored. At some point in the future, the TimeBomb would expire and tests would start failing again.&lt;/p&gt;


	&lt;p&gt;I was so proud of it, I even took the time to write something up about it &lt;a href="http://schuchert.wikispaces.com/JUnit+4.xTimeBombGenericCodeExplained"&gt;here&lt;/a&gt;.
I had nothing but the best intentions. I wanted an active mechanism to remind us of work that needed to be done. We had so many todo&amp;#8217;s and warnings that anything short of an active reminder would simply be missed. I also wanted CI to &amp;#8220;work.&amp;#8221; But what eventually happened was that as our tests kept failing, we&amp;#8217;d simply keep moving the TimeBomb date out.&lt;/p&gt;


	&lt;p&gt;I wrote something that enabled our project to collect more design debt. As I said, my intentions were noble. But the road to Hell is paved with good intentions. Luckily I got the name right. The thing that was really blowing up, however, was the project itself.&lt;/p&gt;


	&lt;p&gt;What has all of this got to do with &amp;#8220;strongly typed languages&amp;#8221;?&lt;/p&gt;


	&lt;p&gt;If you&amp;#8217;re working with a strongly typed language, you will have discussions about covariance (well I do anyway). You&amp;#8217;ll discuss the merits of multiple inheritance (it really is a necessary feature &amp;#8211; let the flames rise, I&amp;#8217;m already in Hell from my good intentions). You&amp;#8217;ll also discuss templates/generics. The list goes on and on.&lt;/p&gt;


	&lt;p&gt;If you&amp;#8217;re working with a dynamically typed language (the first one I used professionally was Smalltalk but I also used Self, Objective-C, which lets you choose, and several other languages whose names I do not recall).&lt;/p&gt;


	&lt;p&gt;Covariance is not even an issue. The same can be said of generics/templates and yes, even multiple inheritance is less of an issue. In a strongly-typed languages, things like Multiple Inheritance&lt;b&gt;&lt;i&gt; are necessary&lt;/i&gt;&lt;/b&gt; if you want your type system to be complete. (If you don&amp;#8217;t believe me, read a copy of Object Oriented Software Construction, 2nd ed. by Bertrand Meyer &amp;#8211; an excellent read.)&lt;/p&gt;


	&lt;p&gt;Ever created a mock object in a typed language? You either need an interface or at least a non-final class. What about Ruby or Smalltalk? Nope. Neither language cares about a class&amp;#8217; interface until it executes. And neither language cares how a class is able respond to a particular message, just that it does. It&amp;#8217;s even possible in both languages to &lt;span class="caps"&gt;NOT&lt;/span&gt; have a method and still work if you mess with the meta-language protocol.&lt;/p&gt;


	&lt;p&gt;OK, but still, does this make typed languages bad?&lt;/p&gt;


	&lt;p&gt;Lets go back to that issue of enabling bad things.&lt;/p&gt;


	&lt;p&gt;Virtual Machines, like the &lt;span class="caps"&gt;JVM&lt;/span&gt; and &lt;span class="caps"&gt;CLR&lt;/span&gt;, have made amazing strides in the past few years. Reflection keeps getting faster. Just in time compilers keep getting smarter. The time required for intrinsic locks has improved and now a Java 5 compiler will support non-blocking, safe, multi-threaded updates. Modern processors support such operations using an optimistic approach. Heck, Java 6 even does some cool stuff with local object references to significantly improve Java&amp;#8217;s memory usage. Java runs pretty fast.&lt;/p&gt;


	&lt;p&gt;Dynamic languages, generally, are not there yet. I hope they get there, but they simply are not there. But so what?! If your system runs &amp;#8220;fast enough&amp;#8221; then it&amp;#8217;s fast enough. People used Smalltalk for real applications years ago &amp;#8211; and still do to some extent. Ruby is certainly fast enough for a large class of problems.&lt;/p&gt;


	&lt;p&gt;How is that? These languages force you to write well. If you do not, then you will write code that is not &amp;#8220;fast enough.&amp;#8221; I&amp;#8217;ve see very poor performing Smalltalk solutions. But it was never because of Smalltalk, it was because of poor programming practices. Are there things that won&amp;#8217;t currently perform fast enough in dynamically typed languages? Yes. Are most applications like that? Probably not.&lt;/p&gt;


	&lt;p&gt;You can&amp;#8217;t get away with as much in a dynamically typed language. That sounds ironic. On the one hand you have amazing power with dynamically typed languages. Of course Peter Parker learned that &amp;#8220;With great power comes great responsibility.&amp;#8221; This is just as true with Ruby and other dynamically typed languages.&lt;/p&gt;


	&lt;p&gt;You do not have as much to guide you in a dynamically typed language. Badly written, poorly organized code in a typed language is hard to follow but it&amp;#8217;s possible. In a language like Ruby or Smalltalk it&amp;#8217;s still possible but it&amp;#8217;s a lot harder. Such poor approaches will typically fail sooner. And thats &lt;span class="caps"&gt;GOOD&lt;/span&gt;! You&amp;#8217;ve wasted less money because you failed sooner. If you&amp;#8217;ve got crappy design, you&amp;#8217;re going to fail. The issue is how much time/money will you spend to get there.&lt;/p&gt;


	&lt;p&gt;Another thing that strongly typed languages offer is a false sense of security because of compiler errors. I have heard many people deride the need for unit tests because the compiler &amp;#8220;will catch it.&amp;#8221;&lt;/p&gt;


	&lt;p&gt;This misses a significant point that unit tests can serve as a&lt;b&gt;&lt;i&gt;  specification&lt;/b&gt;&lt;/i&gt; of behavior rather than just a validation of as-written code.&lt;/p&gt;


	&lt;p&gt;You cannot get away with as much in a dynamically typed language. Or put another way, a dynamically typed language does not enable you to be as sloppy. It&amp;#8217;s just a fact. In fact you can typically get away with a lot in a dynamically typed language, you just have to do it well.&lt;/p&gt;


	&lt;p&gt;Does this mean that dynamically typed languages are harder to work in? Maybe. But if you follow &lt;span class="caps"&gt;TDD&lt;/span&gt;, then the language is less important.&lt;/p&gt;


	&lt;p&gt;Do we need fast, typed languages? Clearly we do. There are applications where having such languages is necessary. Device drivers are not written in Ruby (maybe they are, I&amp;#8217;m just trying to be more balanced).&lt;/p&gt;


	&lt;p&gt;However, how many of you were around when games were written in assembly? C was not fast enough. Then C was fast enough but C++ was still a question mark. C++ and C became mainstream but Java was just too slow. Some games are getting written in Java now. Not many, but it&amp;#8217;s certainly possible. It is also possible to use multiple languages and put the time-critical stuff, which is generally a small part of your system, in one language and use another language for the rest of the system.&lt;/p&gt;


	&lt;p&gt;Back in the very early 90&amp;#8217;s I worked just a little bit with Self. At that time, their Just In Time compiler would create machine code from byte code for methods that got executed. They went one step further, however. Not only did they &lt;span class="caps"&gt;JIT&lt;/span&gt; compile a method for an object, they would actually do it for combinations of receivers and type parameters.&lt;/p&gt;


	&lt;p&gt;There&amp;#8217;s a name for this. In general it is called multi-dispatch (some languages support double-dispatch, the visitor pattern is a mechanism to turn standard polymorphism into a weak form of double dispatch, Smalltalk used a similar approach for handling numerical calculations).&lt;/p&gt;


	&lt;p&gt;Self was doing this not to support multi-dispatch but to improve performance. That means that a given method could have multiple compiled forms to handle commonly used methods on a receiver with commonly-used parameters. Yes it used more memory. But given what modern compilers do with code optimization, it just seems that this kind of technique could have huge benefits in the performance of dynamically typed languages. This is just one way a dynamic language can speed things up. There are others and they are happening &lt;span class="caps"&gt;NOW&lt;/span&gt;.&lt;/p&gt;


	&lt;p&gt;I&amp;#8217;m hoping that in the next few years dynamic languages will get more credit for what they have to offer. I believe they are the future. I still primarily develop in Java but that&amp;#8217;s just because I&amp;#8217;m waiting for the dust to settle a little bit and for a clear dynamic language to start to assert itself. I like Ruby (though its support for block closures is, &lt;span class="caps"&gt;IMO&lt;/span&gt;, weak). I&amp;#8217;m not convinced Ruby is the next big thing. I&amp;#8217;m working with it a little bit just in case, however.&lt;/p&gt;


	&lt;p&gt;What are you currently doing that enables yourself or your co-workers to maintain the status quo?&lt;/p&gt;</description>
      <pubDate>Thu, 23 Aug 2007 18:37:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:3775098f-f80a-440c-8f92-833f99de5296</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2007/08/23/strongly-typed-languages-considered-dangerous</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>dynamic</category>
      <category>languages</category>
      <category>Ruby</category>
      <category>strong</category>
      <category>typing</category>
    </item>
    <item>
      <title>Which came First?</title>
      <description>I like mnemonics. Many years ago, a colleague of mine, James, gave me a way to remember something. First I&amp;#8217;ll give you the letters:
	&lt;ul&gt;
	&lt;li&gt;   &lt;span class="caps"&gt;CCCCDPIPE&lt;/span&gt;&lt;/li&gt;
	&lt;/ul&gt;


These letters are a way to remember Craig Larman&amp;#8217;s &lt;span class="caps"&gt;GRASP&lt;/span&gt; patterns (version 1). This and knowing that in the second version of the &lt;span class="caps"&gt;GRASP&lt;/span&gt; patterns Craig replaced the D for P (D &#226;&#8364;&#8220; Don&amp;#8217;t talk to strangers &#226;&#8364;&#8220; the Law of Demeter, P &#226;&#8364;&#8220; Protected Variation). By the way, here are all of them:
	&lt;ul&gt;
	&lt;li&gt;Coupling (low)&lt;/li&gt;
		&lt;li&gt;Cohesion (high)&lt;/li&gt;
		&lt;li&gt;Creator&lt;/li&gt;
		&lt;li&gt;Controller&lt;/li&gt;
		&lt;li&gt;Don&amp;#8217;t talk to strangers (mentioned above and replaced with Protected Variation)&lt;/li&gt;
		&lt;li&gt;Polymorphism&lt;/li&gt;
		&lt;li&gt;Indirection&lt;/li&gt;
		&lt;li&gt;Pure Fabrication&lt;/li&gt;
		&lt;li&gt;Expert&lt;/li&gt;
	&lt;/ul&gt;


How do I remember the letters? Well walk through this bad pun with me:
	&lt;ul&gt;
	&lt;li&gt;&lt;span class="caps"&gt;CCCC&lt;/span&gt; (4 c&amp;#8217;s, foresees)&lt;/li&gt;
		&lt;li&gt;D (the)&lt;/li&gt;
		&lt;li&gt;&lt;span class="caps"&gt;PIPE&lt;/span&gt; (pipe)&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;So who foresees the pipe? The Psychic Plumber.&lt;/p&gt;


	&lt;p&gt;The Psychic Plumber??? I know, it&amp;#8217;s awful. However, I heard it once in something like 1999 and I&amp;#8217;ve never forgotten it.&lt;/p&gt;


	&lt;p&gt;That leads me to some other oldies but goodies: &lt;span class="caps"&gt;SOLID&lt;/span&gt;, INVEST, &lt;span class="caps"&gt;SMART&lt;/span&gt; and a relative new-comer: &lt;span class="caps"&gt;FIRST&lt;/span&gt;. While these are actually acronyms (not just abbreviations but real, dictionary-defined acronyms), they are also mnemonics.&lt;/p&gt;


	&lt;p&gt;You might be thinking otherwise. Typically what people call acronyms are actually just abbreviations. And in any case, they tend to obfuscate rather than elucidate. However, if you&amp;#8217;ll lower your guard for just a few more pages, you might find some of these helpful.&lt;/p&gt;


Your software should be &lt;span class="caps"&gt;SOLID&lt;/span&gt;:
	&lt;ul&gt;
	&lt;li&gt;Single Responsibility&lt;/li&gt;
		&lt;li&gt;Open/Closed Principle&lt;/li&gt;
		&lt;li&gt;Liskov Substitution Principle&lt;/li&gt;
		&lt;li&gt;Interface Segregation&lt;/li&gt;
		&lt;li&gt;Dependency Inversion Principle (not to be confused with Dependency Inversion)&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;I think we should change the spelling: &lt;span class="caps"&gt;SOLIDD&lt;/span&gt; and tack on &#226;&#8364;&#339;Demeter &#226;&#8364;&#8220; the Law Of. But that&amp;#8217;s just me. Of course if we do this, then it is no longer technically an acronym. That&amp;#8217;s OK, because my preference is for mnemonics, not acronyms.&lt;/p&gt;


When you&amp;#8217;re working on your user stories, make sure to &lt;span class="caps"&gt;INVEST&lt;/span&gt; in them:
	&lt;ul&gt;
	&lt;li&gt;Independent&lt;/li&gt;
		&lt;li&gt;Negotiable&lt;/li&gt;
		&lt;li&gt;Valuable&lt;/li&gt;
		&lt;li&gt;Estimable&lt;/li&gt;
		&lt;li&gt;Small        &lt;/li&gt;
		&lt;li&gt;Testable&lt;/li&gt;
	&lt;/ul&gt;


And if you&amp;#8217;re working on tasks, make sure to keep them &lt;span class="caps"&gt;SMART&lt;/span&gt;:
	&lt;ul&gt;
	&lt;li&gt;Specific&lt;/li&gt;
		&lt;li&gt;Measurable&lt;/li&gt;
		&lt;li&gt;Achievable&lt;/li&gt;
		&lt;li&gt;Relevant&lt;/li&gt;
		&lt;li&gt;Time-boxed&lt;/li&gt;
	&lt;/ul&gt;


What what is &lt;span class="caps"&gt;FIRST&lt;/span&gt;? Well have you ever heard Test Driven Development (TDD)? Some people call it by an older name, Test-First Programming (TFP). I don&amp;#8217;t think of these as the same thing but that&amp;#8217;s neither here nor there. What if the F in &lt;span class="caps"&gt;TFP&lt;/span&gt; really stands for &lt;span class="caps"&gt;FIRST&lt;/span&gt; (notice how I sneaked in the capitals)? If so, then here&amp;#8217;s one possible interpretation:
	&lt;ul&gt;
	&lt;li&gt;Fast &amp;#8211; tests should run fast.  We should be able to run all of the tests in seconds or minutes. Running the tests should never feel like a burden. If a developer ever hesitates to execute tests because of time, then the tests tests take too long.&lt;/li&gt;
		&lt;li&gt;Isolated &amp;#8211; A test is a sealed environment.  Tests should not depend on the results of  other tests, nor should they depend on external resources such as databases.&lt;/li&gt;
		&lt;li&gt;Repeatable &#226;&#8364;&#8220; when a test fails, it should fail because the production code is broken, not  because some external dependency failed (e.g. database unavailable, network  problems, etc.)&lt;/li&gt;
		&lt;li&gt;Self-Validating &amp;#8211; Manual interpretation of results does not scale. A test should * verify that it passed or failed. Going one step further, a test should report nothing but success or failure.&lt;/li&gt;
		&lt;li&gt;Timely &amp;#8211; tests should be written concurrently (and preferably before) with production code.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;So where does this acronym come from? A while back, a colleague of mine, Tim Ottinger, and I were working on some course notes. I had a list of four out of five of these ideas. We were working on the characteristics of a good unit test. At one point, Tim said to me &#226;&#8364;&#339;Add a T.&#226;&#8364;&#157;&lt;/p&gt;


	&lt;p&gt;I can be pretty dense fairly often. I didn&amp;#8217;t even understand what he was telling me to do. He had to repeat himself a few times. I understood the words, but not the meaning (luckily that doesn&amp;#8217;t happen to other people or we&amp;#8217;d have problems writing software). Anyway, I finally typed a &#226;&#8364;&#339;T&#226;&#8364;&#157;. And then I asked him &#226;&#8364;&#339;Why?&#226;&#8364;&#157; I didn&amp;#8217;t see the word. Apparently you don&amp;#8217;t want me on your unscramble team either.&lt;/p&gt;


	&lt;p&gt;Well eventually he led me to see the word &lt;span class="caps"&gt;FIRST&lt;/span&gt; and it just seemed to fit (not sure if that pun was intended).&lt;/p&gt;


	&lt;p&gt;Of course, you add all of these together and what do you get? The best I can come up with is: &lt;span class="caps"&gt;SFP&lt;/span&gt;-IS. I was hoping I could come up with a Roman numeral or something because then I could say developers should always wear &lt;span class="caps"&gt;SPF IS&lt;/span&gt; &amp;#8211; which is true because we say out of the sun and burn easily. Unfortunately that did not work. If you look at your phone, you can convert this to the number: 73747&lt;/p&gt;


	&lt;p&gt;If there are any numerol