<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>.Hibri - development</title>
    <link>http://www.hibri.net/</link>
    <description>Thoughts on the craft of building software</description>
    <language>en-gb</language>
    <copyright>Hibri Marzook</copyright>
    <lastBuildDate>Mon, 17 May 2010 21:00:42 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.3.9074.18820</generator>
    <managingEditor>hibri@hibri.net</managingEditor>
    <webMaster>hibri@hibri.net</webMaster>
    <item>
      <trackback:ping>http://www.hibri.net/Trackback.aspx?guid=2d77debe-518d-4533-8175-339546de688d</trackback:ping>
      <pingback:server>http://www.hibri.net/pingback.aspx</pingback:server>
      <pingback:target>http://www.hibri.net/PermaLink,guid,2d77debe-518d-4533-8175-339546de688d.aspx</pingback:target>
      <dc:creator>Hibri</dc:creator>
      <wfw:comment>http://www.hibri.net/CommentView,guid,2d77debe-518d-4533-8175-339546de688d.aspx</wfw:comment>
      <wfw:commentRss>http://www.hibri.net/SyndicationService.asmx/GetEntryCommentsRss?guid=2d77debe-518d-4533-8175-339546de688d</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
There comes a time during every project, when someone in the team asks the question
“What is our branching strategy? “. Off we go trying to find out what is the current
branching best practice, what are other teams using ? , What is the Agile way ? We
may find solutions in <a href="http://martinfowler.com/bliki/FeatureBranch.html" target="_blank">feature
branching</a>, per story branches, <a href="http://svnbook.red-bean.com/en/1.5/svn.branchmerge.commonpatterns.html" target="_blank">release
branches</a> and so on.
</p>
        <p>
Let’s take a step back. Why do we need a branching strategy ? What is a branch ?
</p>
        <p>
We want to put some code in a source control branch, because the code contains the
risk of breaking the software in the mainline of development, trunk. 
</p>
        <p>
Are we 100% sure that the code in the branch won’t break what is in trunk ? We won’t
know for sure till we integrate the branch with trunk.  We won’t know, until
it goes through automated/manual testing, and all this after going through merge hell.
</p>
        <p>
We put code in a branch to reduce risk. However, we haven’t reduced that risk. The
risk is still there, and we bring it back into trunk. Why not look at methods of reducing
the risk in the first place ? 
</p>
        <p>
How do we reduce risk ?
</p>
        <p>
          <strong>1. Cut up a big piece of risk into smaller pieces of risk.</strong>
        </p>
        <p>
The bigger the risk the more chopping it needs. Now we have smaller things to work
on. We do those small pieces one by one, and if something breaks, we know which change
broke it. Easier to fix because it was a small change. 
</p>
        <p>
          <strong>2. Break down a big piece of risk, into parts that have no risk and parts
that have risk.</strong>
        </p>
        <p>
Analyze the problem, break it out in to parts that can be done without breaking our
software. This is interesting. The part which we thought would be a problem might
have become a non-issue. We’ve isolated it. We know exactly which change will break
our software. See 1 above
</p>
        <p>
          <strong>3. Write tests for things that can be broken by the risky bit of code and
continuously test.</strong>
        </p>
        <p>
We know what could break, by the new change. Before we make the change, let’s write
tests for our software so we know when it is broken.  Let’s make a change. Is
anything broken ? No. Did the next change break it ? yes. Fix it. Keep going.
</p>
        <p>
Instead of shoving off our risky code into a branch, we’ve learnt to manage the risk,
and reduce it. If the risk is so high that we can’t mitigate it by doing 1,2 and 3,
then let’s create a branch for the code. We have a branching strategy based on risk.
We create a branch only for code that is riskiest, and we haven’t been able to reduce
that risk by a divide and conquer approach.
</p>
        <p>
In my opinion this is a much better way than having a default branching strategy for
every piece of work/story/feature/MMF. Working continuously on trunk has benefits.
We can release a feature faster, get refactoring changes others have made quicker.
Not go through merge hell, and risk loosing code in the process. Along the way we’ve
learnt how to break up a problem into smaller pieces. We’ve got better at writing
tests. We’ve learnt how to structure our software so that one thing does not break
everything else and we get closer to the nirvana of <a href="http://toni.org/2010/05/19/in-praise-of-continuous-deployment-the-wordpress-com-story/" target="_blank">continuous
deployment</a>, because we have only one production line of code to deploy from.
</p>
        <p>
Do you need a branching strategy ? Think again.
</p>
        <p>
 
</p>
        <p>
 
</p>
        <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:f6aa0a36-a879-49f6-afe1-ead4480d5b94" class="wlWriterSmartContent">del.icio.us
Tags: <a href="http://del.icio.us/popular/%22branching+strategies%22" rel="tag">"branching
strategies"</a>,<a href="http://del.icio.us/popular/%22agile+branching%22" rel="tag">"agile
branching"</a>,<a href="http://del.icio.us/popular/branching" rel="tag">branching</a></div>
      </body>
      <title>Thoughts on branching strategies.</title>
      <guid isPermaLink="false">http://www.hibri.net/PermaLink,guid,2d77debe-518d-4533-8175-339546de688d.aspx</guid>
      <link>http://www.hibri.net/2010/05/17/ThoughtsOnBranchingStrategies.aspx</link>
      <pubDate>Mon, 17 May 2010 21:00:42 GMT</pubDate>
      <description>&lt;p&gt;
There comes a time during every project, when someone in the team asks the question
“What is our branching strategy? “. Off we go trying to find out what is the current
branching best practice, what are other teams using ? , What is the Agile way ? We
may find solutions in &lt;a href="http://martinfowler.com/bliki/FeatureBranch.html" target="_blank"&gt;feature
branching&lt;/a&gt;, per story branches, &lt;a href="http://svnbook.red-bean.com/en/1.5/svn.branchmerge.commonpatterns.html" target="_blank"&gt;release
branches&lt;/a&gt; and so on.
&lt;/p&gt;
&lt;p&gt;
Let’s take a step back. Why do we need a branching strategy ? What is a branch ?
&lt;/p&gt;
&lt;p&gt;
We want to put some code in a source control branch, because the code contains the
risk of breaking the software in the mainline of development, trunk. 
&lt;/p&gt;
&lt;p&gt;
Are we 100% sure that the code in the branch won’t break what is in trunk ? We won’t
know for sure till we integrate the branch with trunk.&amp;#160; We won’t know, until
it goes through automated/manual testing, and all this after going through merge hell.
&lt;/p&gt;
&lt;p&gt;
We put code in a branch to reduce risk. However, we haven’t reduced that risk. The
risk is still there, and we bring it back into trunk. Why not look at methods of reducing
the risk in the first place ? 
&lt;/p&gt;
&lt;p&gt;
How do we reduce risk ?
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;1. Cut up a big piece of risk into smaller pieces of risk.&lt;/strong&gt; 
&lt;/p&gt;
&lt;p&gt;
The bigger the risk the more chopping it needs. Now we have smaller things to work
on. We do those small pieces one by one, and if something breaks, we know which change
broke it. Easier to fix because it was a small change. 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;2. Break down a big piece of risk, into parts that have no risk and parts
that have risk.&lt;/strong&gt; 
&lt;/p&gt;
&lt;p&gt;
Analyze the problem, break it out in to parts that can be done without breaking our
software. This is interesting. The part which we thought would be a problem might
have become a non-issue. We’ve isolated it. We know exactly which change will break
our software. See 1 above
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;3. Write tests for things that can be broken by the risky bit of code and
continuously test.&lt;/strong&gt; 
&lt;/p&gt;
&lt;p&gt;
We know what could break, by the new change. Before we make the change, let’s write
tests for our software so we know when it is broken.&amp;#160; Let’s make a change. Is
anything broken ? No. Did the next change break it ? yes. Fix it. Keep going.
&lt;/p&gt;
&lt;p&gt;
Instead of shoving off our risky code into a branch, we’ve learnt to manage the risk,
and reduce it. If the risk is so high that we can’t mitigate it by doing 1,2 and 3,
then let’s create a branch for the code. We have a branching strategy based on risk.
We create a branch only for code that is riskiest, and we haven’t been able to reduce
that risk by a divide and conquer approach.
&lt;/p&gt;
&lt;p&gt;
In my opinion this is a much better way than having a default branching strategy for
every piece of work/story/feature/MMF. Working continuously on trunk has benefits.
We can release a feature faster, get refactoring changes others have made quicker.
Not go through merge hell, and risk loosing code in the process. Along the way we’ve
learnt how to break up a problem into smaller pieces. We’ve got better at writing
tests. We’ve learnt how to structure our software so that one thing does not break
everything else and we get closer to the nirvana of &lt;a href="http://toni.org/2010/05/19/in-praise-of-continuous-deployment-the-wordpress-com-story/" target="_blank"&gt;continuous
deployment&lt;/a&gt;, because we have only one production line of code to deploy from.
&lt;/p&gt;
&lt;p&gt;
Do you need a branching strategy ? Think again.
&lt;/p&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:f6aa0a36-a879-49f6-afe1-ead4480d5b94" class="wlWriterSmartContent"&gt;del.icio.us
Tags: &lt;a href="http://del.icio.us/popular/%22branching+strategies%22" rel="tag"&gt;&amp;quot;branching
strategies&amp;quot;&lt;/a&gt;,&lt;a href="http://del.icio.us/popular/%22agile+branching%22" rel="tag"&gt;&amp;quot;agile
branching&amp;quot;&lt;/a&gt;,&lt;a href="http://del.icio.us/popular/branching" rel="tag"&gt;branching&lt;/a&gt;
&lt;/div&gt;</description>
      <comments>http://www.hibri.net/CommentView,guid,2d77debe-518d-4533-8175-339546de688d.aspx</comments>
      <category>Agile</category>
      <category>development</category>
      <category>TDD</category>
    </item>
    <item>
      <trackback:ping>http://www.hibri.net/Trackback.aspx?guid=10aba050-9562-4f91-846b-e2e78ccc46ee</trackback:ping>
      <pingback:server>http://www.hibri.net/pingback.aspx</pingback:server>
      <pingback:target>http://www.hibri.net/PermaLink,guid,10aba050-9562-4f91-846b-e2e78ccc46ee.aspx</pingback:target>
      <dc:creator>Hibri</dc:creator>
      <wfw:comment>http://www.hibri.net/CommentView,guid,10aba050-9562-4f91-846b-e2e78ccc46ee.aspx</wfw:comment>
      <wfw:commentRss>http://www.hibri.net/SyndicationService.asmx/GetEntryCommentsRss?guid=10aba050-9562-4f91-846b-e2e78ccc46ee</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
The major highlight at XP Day 2009, was <a href="http://gojko.net/2009/12/07/improving-testing-practices-at-google/" target="_blank">Mark
Striebeck’s talk on unit testing practices at Google</a>.  What makes a good
test depends on experience , skill and school of thought. I had to agree when he said
that developers can be almost religious when it comes to the topic of what makes a
good test. This made them solve this problem the Google way, by gathering data. Let
the data speak. 
</p>
        <p>
He went on to describe metrics that they were collecting on tests and test code. 
A test that has never failed is likely to be a bad test. If the test was fixed to
make the test pass, then this is also an attribute of a bad test. A test can be a
good test if the code was fixed to make the test pass.
</p>
        <p>
This got me thinking. Generally I haven’t gathered metrics on test code. We have a
pretty good <a href="http://blog.robbowley.net/2009/10/28/visualising-the-internal-quality-of-software-part-1/" target="_blank">metrics
dashboard</a> for production code. What metrics can I gather on test code ? 
</p>
        <p>
Metrics on test code should also focus on the readability of the code. Having large
test methods is ok, but not too big. My opinion is that a test method with more than
20 lines is too big. 
</p>
        <p>
Tests should be concise, the assert should be obvious. Some code duplication is fine
to make the test readable. This is all fine, but how can I get these as metrics 
? Only way to judge this is to eyeball the tests, and there are differences of opinion. 
</p>
        <p>
However, there are ways to measure what a test should not be. These are test smells.
Test smells are described in <a href="http://www.amazon.co.uk/gp/product/0131495054?ie=UTF8&amp;tag=hibrinet-21&amp;linkCode=as2&amp;camp=1634&amp;creative=19450&amp;creativeASIN=0131495054" target="_blank">xUnit
Test Patterns</a></p>
        <p>
I’ve listed a few test smells and <a href="http://www.ndepend.com/Metrics.aspx" target="_blank">NDepend
CQL queries</a> find these smells. These can be automated in the build process and
flagged up.
</p>
        <p>
          <strong>Large Test Methods</strong>
        </p>
        <p>
These can be a chore to read. Tests should be written as simply as possible. These
also  point to too many responsibilities and dependencies in the code being tested,
as most of the test code is used to do setup for the test.
</p>
        <p>
          <em>SELECT METHODS WHERE HasAttribute "NUnit.Framework.TestAttribute" AND 
NbLinesOfCode &gt; 20</em>
        </p>
        <p>
          <strong>Large setup methods</strong>
        </p>
        <p>
Usually when unit testing the same code, we tend to have a common setup method, in
order to make the test more readable. What happens is, more and more code is moved
into the common setup method. We get blind to this after a while, and all the dependencies
for the test are hidden away. If you do have [Setup] methods, keep them small.
</p>
        <p>
          <em>SELECT METHODS WHERE HasAttribute "NUnit.Framework.SetUpAttribute" AND
NbLinesOfCode  &gt; 10</em>
        </p>
        <p>
          <strong>Deep inheritance trees in test fixtures</strong>
        </p>
        <p>
Again, common test code moved up to a base class and the base class is used in many
tests. Then more base classes are created. This creates more tight coupling between
test classes. Which makes tests harder to change. Low coupling and high cohesion applies
to test code as well. Make each unit test class as independent as possible.
</p>
        <p>
          <em>SELECT TYPES WHERE HasAttribute "NUnit.Framework.TestFixtureAttribute" 
AND DepthOfInheritance &gt;2</em>
        </p>
        <p>
          <strong>Test fixture setup</strong>
        </p>
        <p>
TestFixtureSetup is bad. The <a href="http://www.nunit.org/index.php?p=fixtureSetup&amp;r=2.2.10" target="_blank">TestFixtureSetup</a> is
run once before all tests. This leads to fragile tests and inadvertently leads to
using some shared state. Use Setup instead
</p>
        <p>
          <em>SELECT METHODS WHERE HasAttribute "NUnit.Framework.TestFixtureSetUpAttribute"</em>
        </p>
        <p>
          <strong>Tests that fail when they are run in a different order</strong>
        </p>
        <p>
The <a href="http://xunit.codeplex.com/wikipage?title=Comparisons&amp;referringTitle=Home" target="_blank">xUnit</a> test
runner helps with this, by randomizing the order tests are run.
</p>
        <p>
          <strong>Ignored tests</strong>
        </p>
        <p>
Ignored tests are like comments. Dead code that doesn’t do anything. Either fix them
or delete them.
</p>
        <p>
I have yet to find some way of detecting duplicated tests, shared state in tests and
multiple asserts in tests. What other ways can I find test smells ? 
</p>
      </body>
      <title>Test Smells and Test Code Quality Metrics</title>
      <guid isPermaLink="false">http://www.hibri.net/PermaLink,guid,10aba050-9562-4f91-846b-e2e78ccc46ee.aspx</guid>
      <link>http://www.hibri.net/2009/12/09/TestSmellsAndTestCodeQualityMetrics.aspx</link>
      <pubDate>Wed, 09 Dec 2009 22:15:58 GMT</pubDate>
      <description>&lt;p&gt;
The major highlight at XP Day 2009, was &lt;a href="http://gojko.net/2009/12/07/improving-testing-practices-at-google/" target="_blank"&gt;Mark
Striebeck’s talk on unit testing practices at Google&lt;/a&gt;.&amp;#160; What makes a good
test depends on experience , skill and school of thought. I had to agree when he said
that developers can be almost religious when it comes to the topic of what makes a
good test. This made them solve this problem the Google way, by gathering data. Let
the data speak. 
&lt;/p&gt;
&lt;p&gt;
He went on to describe metrics that they were collecting on tests and test code.&amp;#160;
A test that has never failed is likely to be a bad test. If the test was fixed to
make the test pass, then this is also an attribute of a bad test. A test can be a
good test if the code was fixed to make the test pass.
&lt;/p&gt;
&lt;p&gt;
This got me thinking. Generally I haven’t gathered metrics on test code. We have a
pretty good &lt;a href="http://blog.robbowley.net/2009/10/28/visualising-the-internal-quality-of-software-part-1/" target="_blank"&gt;metrics
dashboard&lt;/a&gt; for production code. What metrics can I gather on test code ? 
&lt;/p&gt;
&lt;p&gt;
Metrics on test code should also focus on the readability of the code. Having large
test methods is ok, but not too big. My opinion is that a test method with more than
20 lines is too big. 
&lt;/p&gt;
&lt;p&gt;
Tests should be concise, the assert should be obvious. Some code duplication is fine
to make the test readable. This is all fine, but how can I get these as metrics&amp;#160;
? Only way to judge this is to eyeball the tests, and there are differences of opinion. 
&lt;/p&gt;
&lt;p&gt;
However, there are ways to measure what a test should not be. These are test smells.
Test smells are described in &lt;a href="http://www.amazon.co.uk/gp/product/0131495054?ie=UTF8&amp;amp;tag=hibrinet-21&amp;amp;linkCode=as2&amp;amp;camp=1634&amp;amp;creative=19450&amp;amp;creativeASIN=0131495054" target="_blank"&gt;xUnit
Test Patterns&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
I’ve listed a few test smells and &lt;a href="http://www.ndepend.com/Metrics.aspx" target="_blank"&gt;NDepend
CQL queries&lt;/a&gt; find these smells. These can be automated in the build process and
flagged up.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Large Test Methods&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
These can be a chore to read. Tests should be written as simply as possible. These
also&amp;#160; point to too many responsibilities and dependencies in the code being tested,
as most of the test code is used to do setup for the test.
&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;SELECT METHODS WHERE HasAttribute &amp;quot;NUnit.Framework.TestAttribute&amp;quot; AND&amp;#160;
NbLinesOfCode &amp;gt; 20&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Large setup methods&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Usually when unit testing the same code, we tend to have a common setup method, in
order to make the test more readable. What happens is, more and more code is moved
into the common setup method. We get blind to this after a while, and all the dependencies
for the test are hidden away. If you do have [Setup] methods, keep them small.
&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;SELECT METHODS WHERE HasAttribute &amp;quot;NUnit.Framework.SetUpAttribute&amp;quot; AND
NbLinesOfCode&amp;#160; &amp;gt; 10&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Deep inheritance trees in test fixtures&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Again, common test code moved up to a base class and the base class is used in many
tests. Then more base classes are created. This creates more tight coupling between
test classes. Which makes tests harder to change. Low coupling and high cohesion applies
to test code as well. Make each unit test class as independent as possible.
&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;SELECT TYPES WHERE HasAttribute &amp;quot;NUnit.Framework.TestFixtureAttribute&amp;quot;&amp;#160;
AND DepthOfInheritance &amp;gt;2&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Test fixture setup&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
TestFixtureSetup is bad. The &lt;a href="http://www.nunit.org/index.php?p=fixtureSetup&amp;amp;r=2.2.10" target="_blank"&gt;TestFixtureSetup&lt;/a&gt; is
run once before all tests. This leads to fragile tests and inadvertently leads to
using some shared state. Use Setup instead
&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;SELECT METHODS WHERE HasAttribute &amp;quot;NUnit.Framework.TestFixtureSetUpAttribute&amp;quot;&lt;/em&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Tests that fail when they are run in a different order&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
The &lt;a href="http://xunit.codeplex.com/wikipage?title=Comparisons&amp;amp;referringTitle=Home" target="_blank"&gt;xUnit&lt;/a&gt; test
runner helps with this, by randomizing the order tests are run.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Ignored tests&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Ignored tests are like comments. Dead code that doesn’t do anything. Either fix them
or delete them.
&lt;/p&gt;
&lt;p&gt;
I have yet to find some way of detecting duplicated tests, shared state in tests and
multiple asserts in tests. What other ways can I find test smells ? 
&lt;/p&gt;</description>
      <comments>http://www.hibri.net/CommentView,guid,10aba050-9562-4f91-846b-e2e78ccc46ee.aspx</comments>
      <category>Agile</category>
      <category>development</category>
      <category>TDD</category>
    </item>
    <item>
      <trackback:ping>http://www.hibri.net/Trackback.aspx?guid=64d23b3c-0a4e-47e2-b83f-e022f4abdf8c</trackback:ping>
      <pingback:server>http://www.hibri.net/pingback.aspx</pingback:server>
      <pingback:target>http://www.hibri.net/PermaLink,guid,64d23b3c-0a4e-47e2-b83f-e022f4abdf8c.aspx</pingback:target>
      <dc:creator>Hibri</dc:creator>
      <wfw:comment>http://www.hibri.net/CommentView,guid,64d23b3c-0a4e-47e2-b83f-e022f4abdf8c.aspx</wfw:comment>
      <wfw:commentRss>http://www.hibri.net/SyndicationService.asmx/GetEntryCommentsRss?guid=64d23b3c-0a4e-47e2-b83f-e022f4abdf8c</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
 
</p>
        <p>
When you are in the zone, and want to add a reference to Rhino, NUnit or any other
common reference, adding it via the Add Reference dialog can be painfully slow. Fortunately
VS has a good automation interface, which lets you to write macros.
</p>
        <p>
I wrote a simple macro to add a NUnit reference to the current project. Add this to
your Macros project in Visual Studio, map a button or a shortcut key to it. This way
you can add those common references pretty quick. 
</p>
        <p>
This is a cleaned up version of the sample here <a title="http://msdn.microsoft.com/en-us/library/vslangproj80.reference3%28VS.80%29.aspx" href="http://msdn.microsoft.com/en-us/library/vslangproj80.reference3%28VS.80%29.aspx">http://msdn.microsoft.com/en-us/library/vslangproj80.reference3%28VS.80%29.aspx</a></p>
        <p>
 
</p>
        <div class="csharpcode">
          <pre>
            <span class="lnum"> 1: </span>
            <span class="kwrd">Sub</span> AddNUnitReference()</pre>
          <pre>
            <span class="lnum"> 2: </span> AddNewReference(DTE, <span class="str">"C:\Tools\NUnit\nunit.framework.dll"</span>)</pre>
          <pre>
            <span class="lnum"> 3: </span>
            <span class="kwrd">End</span>
            <span class="kwrd">Sub</span>
          </pre>
          <pre>
            <span class="lnum"> 4: </span> </pre>
          <pre>
            <span class="lnum"> 5: </span>
            <span class="kwrd">Sub</span> AddNewReference(<span class="kwrd">ByVal</span> dte <span class="kwrd">As</span> DTE2, <span class="kwrd">ByVal</span> referencePath <span class="kwrd">As</span><span class="kwrd">String</span>)</pre>
          <pre>
            <span class="lnum"> 6: </span>
            <span class="kwrd">Dim</span> aProject <span class="kwrd">As</span> Project</pre>
          <pre>
            <span class="lnum"> 7: </span>
            <span class="kwrd">Dim</span> aVSProject <span class="kwrd">As</span> VSProject</pre>
          <pre>
            <span class="lnum"> 8: </span> </pre>
          <pre>
            <span class="lnum"> 9: </span> aProject = dte.ActiveDocument.ProjectItem.ContainingProject</pre>
          <pre>
            <span class="lnum"> 10: </span> </pre>
          <pre>
            <span class="lnum"> 11: </span> aVSProject = <span class="kwrd">CType</span>(dte.ActiveDocument.ProjectItem.ContainingProject.<span class="kwrd">Object</span>,
VSProject)</pre>
          <pre>
            <span class="lnum"> 12: </span>
            <span class="rem">' Add an Assembly reference
and display its type and additional</span>
          </pre>
          <pre>
            <span class="lnum"> 13: </span>
            <span class="rem">' information.</span>
          </pre>
          <pre>
            <span class="lnum"> 14: </span>
            <span class="kwrd">Dim</span> newRef <span class="kwrd">As</span> Reference</pre>
          <pre>
            <span class="lnum"> 15: </span> newRef = aVSProject.References.Add(referencePath)</pre>
          <pre>
            <span class="lnum"> 16: </span> </pre>
          <pre>
            <span class="lnum"> 17: </span>
            <span class="kwrd">End</span> Sub</pre>
        </div>
        <style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
      </body>
      <title>Avoid the slow Add Reference dialog box in Visual Studio 2008</title>
      <guid isPermaLink="false">http://www.hibri.net/PermaLink,guid,64d23b3c-0a4e-47e2-b83f-e022f4abdf8c.aspx</guid>
      <link>http://www.hibri.net/2009/11/28/AvoidTheSlowAddReferenceDialogBoxInVisualStudio2008.aspx</link>
      <pubDate>Sat, 28 Nov 2009 13:31:31 GMT</pubDate>
      <description>&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
When you are in the zone, and want to add a reference to Rhino, NUnit or any other
common reference, adding it via the Add Reference dialog can be painfully slow. Fortunately
VS has a good automation interface, which lets you to write macros.
&lt;/p&gt;
&lt;p&gt;
I wrote a simple macro to add a NUnit reference to the current project. Add this to
your Macros project in Visual Studio, map a button or a shortcut key to it. This way
you can add those common references pretty quick. 
&lt;/p&gt;
&lt;p&gt;
This is a cleaned up version of the sample here &lt;a title="http://msdn.microsoft.com/en-us/library/vslangproj80.reference3%28VS.80%29.aspx" href="http://msdn.microsoft.com/en-us/library/vslangproj80.reference3%28VS.80%29.aspx"&gt;http://msdn.microsoft.com/en-us/library/vslangproj80.reference3%28VS.80%29.aspx&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;div class="csharpcode"&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 1: &lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt; AddNUnitReference()&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 2: &lt;/span&gt; AddNewReference(DTE, &lt;span class="str"&gt;&amp;quot;C:\Tools\NUnit\nunit.framework.dll&amp;quot;&lt;/span&gt;)&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 3: &lt;/span&gt; &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 4: &lt;/span&gt;&amp;#160;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 5: &lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt; AddNewReference(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; dte &lt;span class="kwrd"&gt;As&lt;/span&gt; DTE2, &lt;span class="kwrd"&gt;ByVal&lt;/span&gt; referencePath &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt;)&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 6: &lt;/span&gt; &lt;span class="kwrd"&gt;Dim&lt;/span&gt; aProject &lt;span class="kwrd"&gt;As&lt;/span&gt; Project&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 7: &lt;/span&gt; &lt;span class="kwrd"&gt;Dim&lt;/span&gt; aVSProject &lt;span class="kwrd"&gt;As&lt;/span&gt; VSProject&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 8: &lt;/span&gt;&amp;#160;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 9: &lt;/span&gt; aProject = dte.ActiveDocument.ProjectItem.ContainingProject&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 10: &lt;/span&gt;&amp;#160;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 11: &lt;/span&gt; aVSProject = &lt;span class="kwrd"&gt;CType&lt;/span&gt;(dte.ActiveDocument.ProjectItem.ContainingProject.&lt;span class="kwrd"&gt;Object&lt;/span&gt;,
VSProject)&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 12: &lt;/span&gt; &lt;span class="rem"&gt;' Add an Assembly reference
and display its type and additional&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 13: &lt;/span&gt; &lt;span class="rem"&gt;' information.&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 14: &lt;/span&gt; &lt;span class="kwrd"&gt;Dim&lt;/span&gt; newRef &lt;span class="kwrd"&gt;As&lt;/span&gt; Reference&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 15: &lt;/span&gt; newRef = aVSProject.References.Add(referencePath)&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 16: &lt;/span&gt;&amp;#160;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 17: &lt;/span&gt; &lt;span class="kwrd"&gt;End&lt;/span&gt; Sub&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;</description>
      <comments>http://www.hibri.net/CommentView,guid,64d23b3c-0a4e-47e2-b83f-e022f4abdf8c.aspx</comments>
      <category>.Net General</category>
      <category>development</category>
      <category>TDD</category>
    </item>
    <item>
      <trackback:ping>http://www.hibri.net/Trackback.aspx?guid=e0c7269b-6a03-4cc6-be2a-419f19709f9d</trackback:ping>
      <pingback:server>http://www.hibri.net/pingback.aspx</pingback:server>
      <pingback:target>http://www.hibri.net/PermaLink,guid,e0c7269b-6a03-4cc6-be2a-419f19709f9d.aspx</pingback:target>
      <dc:creator>Hibri</dc:creator>
      <wfw:comment>http://www.hibri.net/CommentView,guid,e0c7269b-6a03-4cc6-be2a-419f19709f9d.aspx</wfw:comment>
      <wfw:commentRss>http://www.hibri.net/SyndicationService.asmx/GetEntryCommentsRss?guid=e0c7269b-6a03-4cc6-be2a-419f19709f9d</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
A while back I organised a coding session during an internal training day at work. 
The aim of the session was to introduce practices  from the <a href="http://www.amazon.co.uk/gp/product/0132350882?ie=UTF8&amp;tag=hibrinet-21&amp;linkCode=as2&amp;camp=1634&amp;creative=19450&amp;creativeASIN=0132350882">Clean
Code</a> book, to make code a little bit cleaner and practice the <a href="http://www.informit.com/articles/article.aspx?p=1235624&amp;seqNum=6">boy
scout rule</a>.  I’ve tried to include the important points from the book, though
everything in the book is equally important. 
</p>
        <p>
I’m sharing the slides and the code. Feel free to use it and improve on it. The code
is a Sudoku solver from the <a href="http://www.parlezuml.com/softwarecraftsmanship/sessions/programming_in_the_small.htm">Programming
In the Small</a> session at SC ‘09. I’ve converted the Java code to C#. The code includes
acceptance tests, so you can fearlessly refactor without breaking it.
</p>
        <p>
          <a href="http://www.hibri.net/content/binary/cleancode.zip">http://www.hibri.net/content/binary/cleancode.zip</a>
        </p>
        <p>
The session was planned for 90 minutes. It includes slides introducing clean code
concepts, with coding exercises to practice them. I recommend 10-15 minutes for the
coding exercises.
</p>
      </body>
      <title>Slides and code from my Clean Code session</title>
      <guid isPermaLink="false">http://www.hibri.net/PermaLink,guid,e0c7269b-6a03-4cc6-be2a-419f19709f9d.aspx</guid>
      <link>http://www.hibri.net/2009/09/05/SlidesAndCodeFromMyCleanCodeSession.aspx</link>
      <pubDate>Sat, 05 Sep 2009 17:43:29 GMT</pubDate>
      <description>&lt;p&gt;
A while back I organised a coding session during an internal training day at work.&amp;#160;
The aim of the session was to introduce practices&amp;#160; from the &lt;a href="http://www.amazon.co.uk/gp/product/0132350882?ie=UTF8&amp;amp;tag=hibrinet-21&amp;amp;linkCode=as2&amp;amp;camp=1634&amp;amp;creative=19450&amp;amp;creativeASIN=0132350882"&gt;Clean
Code&lt;/a&gt; book, to make code a little bit cleaner and practice the &lt;a href="http://www.informit.com/articles/article.aspx?p=1235624&amp;amp;seqNum=6"&gt;boy
scout rule&lt;/a&gt;.&amp;#160; I’ve tried to include the important points from the book, though
everything in the book is equally important. 
&lt;/p&gt;
&lt;p&gt;
I’m sharing the slides and the code. Feel free to use it and improve on it. The code
is a Sudoku solver from the &lt;a href="http://www.parlezuml.com/softwarecraftsmanship/sessions/programming_in_the_small.htm"&gt;Programming
In the Small&lt;/a&gt; session at SC ‘09. I’ve converted the Java code to C#. The code includes
acceptance tests, so you can fearlessly refactor without breaking it.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.hibri.net/content/binary/cleancode.zip"&gt;http://www.hibri.net/content/binary/cleancode.zip&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
The session was planned for 90 minutes. It includes slides introducing clean code
concepts, with coding exercises to practice them. I recommend 10-15 minutes for the
coding exercises.
&lt;/p&gt;</description>
      <comments>http://www.hibri.net/CommentView,guid,e0c7269b-6a03-4cc6-be2a-419f19709f9d.aspx</comments>
      <category>Agile</category>
      <category>Books</category>
      <category>development</category>
    </item>
    <item>
      <trackback:ping>http://www.hibri.net/Trackback.aspx?guid=2791fd76-95ee-4223-a657-1a8691ab86ec</trackback:ping>
      <pingback:server>http://www.hibri.net/pingback.aspx</pingback:server>
      <pingback:target>http://www.hibri.net/PermaLink,guid,2791fd76-95ee-4223-a657-1a8691ab86ec.aspx</pingback:target>
      <dc:creator>Hibri</dc:creator>
      <wfw:comment>http://www.hibri.net/CommentView,guid,2791fd76-95ee-4223-a657-1a8691ab86ec.aspx</wfw:comment>
      <wfw:commentRss>http://www.hibri.net/SyndicationService.asmx/GetEntryCommentsRss?guid=2791fd76-95ee-4223-a657-1a8691ab86ec</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
        </p>
        <p>
Seriously, do yourself a favour and go buy this. Keep it on your desk, have it while
pairing, use it to bash sense into someone.
</p>
        <p>
          <a target="_blank" href="http://www.amazon.co.uk/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1221600238&amp;sr=8-1">Clean
Code: A Handbook of Agile Software Craftsmanship</a> . There’s a pretty good review
of the book here <a href="http://www.markhneedham.com/blog/2008/09/15/clean-code-book-review/">http://www.markhneedham.com/blog/2008/09/15/clean-code-book-review/</a></p>
        <p>
Related Posts: 
<br /><a href="http://www.hibri.net/2008/03/20/MartinFowlerTalk.aspx">Martin Fowler Talk</a></p>
      </body>
      <title>Clean Code: A Handbook of Agile Software Craftsmanship</title>
      <guid isPermaLink="false">http://www.hibri.net/PermaLink,guid,2791fd76-95ee-4223-a657-1a8691ab86ec.aspx</guid>
      <link>http://www.hibri.net/2008/09/17/CleanCodeAHandbookOfAgileSoftwareCraftsmanship.aspx</link>
      <pubDate>Wed, 17 Sep 2008 02:26:00 GMT</pubDate>
      <description>&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
Seriously, do yourself a favour and go buy this. Keep it on your desk, have it while
pairing, use it to bash sense into someone.
&lt;/p&gt;
&lt;p&gt;
&lt;a target="_blank" href="http://www.amazon.co.uk/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882/ref=sr_1_1?ie=UTF8&amp;amp;s=books&amp;amp;qid=1221600238&amp;amp;sr=8-1"&gt;Clean
Code: A Handbook of Agile Software Craftsmanship&lt;/a&gt; . There’s a pretty good review
of the book here &lt;a href="http://www.markhneedham.com/blog/2008/09/15/clean-code-book-review/"&gt;http://www.markhneedham.com/blog/2008/09/15/clean-code-book-review/&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Related Posts: 
&lt;br /&gt;
&lt;a href="http://www.hibri.net/2008/03/20/MartinFowlerTalk.aspx"&gt;Martin Fowler Talk&lt;/a&gt;
&lt;/p&gt;</description>
      <comments>http://www.hibri.net/CommentView,guid,2791fd76-95ee-4223-a657-1a8691ab86ec.aspx</comments>
      <category>Agile</category>
      <category>Books</category>
      <category>development</category>
    </item>
    <item>
      <trackback:ping>http://www.hibri.net/Trackback.aspx?guid=f42342d6-8bc2-402a-9db7-7268ce3facd6</trackback:ping>
      <pingback:server>http://www.hibri.net/pingback.aspx</pingback:server>
      <pingback:target>http://www.hibri.net/PermaLink,guid,f42342d6-8bc2-402a-9db7-7268ce3facd6.aspx</pingback:target>
      <dc:creator>Hibri</dc:creator>
      <wfw:comment>http://www.hibri.net/CommentView,guid,f42342d6-8bc2-402a-9db7-7268ce3facd6.aspx</wfw:comment>
      <wfw:commentRss>http://www.hibri.net/SyndicationService.asmx/GetEntryCommentsRss?guid=f42342d6-8bc2-402a-9db7-7268ce3facd6</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
When to make design decisions is a touchy subject when doing iterative software development. 
Ever since starting to do TDD, I’ve seen how TDD can drive the design. I’ve also seen
how bad it is when a team gets caught in the trap of doing a big up front design.
Two bits of advice that have helped me a lot in my current project are;
</p>
        <p>
Doing the simplest thing that could possibly work
</p>
        <p>
Defer decisions till the last possible moment.
</p>
        <p>
What I’m still trying to learn  is;
</p>
        <p>
What is the simplest thing that could work, but doesn’t increase the cost of change
later. What is the simplest thing I could do, but still gives me a foundation to build
upon ?
</p>
        <p>
How long can I defer a decision ? How do I avoid leaving a decision till too late
? 
</p>
        <p>
        </p>
        <p>
        </p>
        <p>
        </p>
        <p>
        </p>
        <p>
        </p>
        <p>
        </p>
        <p>
        </p>
        <p>
A panel discussion led by Martin Fowler sheds some light on this. <a title="Modifiability? Or is there Design in Agility" href="http://www.infoq.com/presentations/modifiability-fowler">You
can watch it here</a>, and it is a must see. The panel talks about  these two
topics and their experiences.
</p>
        <p>
What I gleaned from this is , doing the simplest thing does not mean doing the stupidest
thing. Doing the simplest thing possible is under the constraints of proper separation
of concerns, encapsulation and having tests to cover what is written.
</p>
        <p>
Doing the simplest thing does not mean you can dump your business logic, persistance
and presentation logic all in the code behind file of an ASP .Net page. Keep doing
the simplest thing possible by using existing design patterns that reduce the cost
of change later. The simplest thing is not an excuse for writing bad code. Having
proper separation of concerns in the design ensures that changes can be made in 
the simplest thing that was done earlier without adversely affecting the rest of the
system.  
</p>
        <p>
The domain model should not be aware of the persistance or presentation logic. Design
decisions don’t affect the domain model design as frequently as other parts of the
system. The domain model reflects the business and the decisions are usually made
long before the project is begun. 
</p>
        <p>
Doing the simplest thing that could possibly work usually means, how to persist a
certain part of the domain model ? how to present domain model data ? and how to pass
the data from the domain model to and from the different layers. It is how to implement
a certain business requirement in domain model code.
</p>
        <p>
A key safeguard here is having tests (unit and acceptance tests ).  While doing
the simplest thing possible do write good unit tests.
</p>
        <p>
Martin Fowler talks about reversibility in design decisions. A good design decision
is one that you can reverse and go back to the point before the decision was made.
He stresses encapsulation again.  Design decisions that are encapsulated are
not expensive to change. If your persistance medium is changed, this decision should
not affect the rest of the system. Proper separation of concerns isolates design decisions.
The panel also stresses the importance of spiking. If you have choices to make, try
those choices with a scaffold or a simple prototype and explore the options. It’s
much more cost effective to make a decision through spiking than to undo a choice
made to production code. Again the emphasis is made on tests. Tests protect the system,
they tell you how much you are likely to break.  
</p>
        <p>
During the past week a colleague of mine, did a fairly big refactoring of key parts
of the code. He did it in a separate branch, and made sure that all the existing tests
passed and wrote new tests where needed. Impressive. His design decisions do not affect
the trunk, till we are sure that we are happy with it and it hasn’t broken any part
of the system. 
</p>
        <p>
In my current project I defer decisions till the first hint of pain of not making
that decision appears. I make  the choice just about when we are starting to
hurt by not making it. I keep postponing it till then.
</p>
        <p>
To sum it all up;
</p>
        <p>
Do the simplest thing that could possibly work, do not repeat yourself defer decisions
till the last possible moment, but still do write the best code you can, and drive
the design with tests.
</p>
      </body>
      <title>Agile development and design decisions</title>
      <guid isPermaLink="false">http://www.hibri.net/PermaLink,guid,f42342d6-8bc2-402a-9db7-7268ce3facd6.aspx</guid>
      <link>http://www.hibri.net/2008/08/17/AgileDevelopmentAndDesignDecisions.aspx</link>
      <pubDate>Sun, 17 Aug 2008 19:15:10 GMT</pubDate>
      <description>&lt;p&gt;
When to make design decisions is a touchy subject when doing iterative software development.&amp;#160;
Ever since starting to do TDD, I’ve seen how TDD can drive the design. I’ve also seen
how bad it is when a team gets caught in the trap of doing a big up front design.
Two bits of advice that have helped me a lot in my current project are;
&lt;/p&gt;
&lt;p&gt;
Doing the simplest thing that could possibly work
&lt;/p&gt;
&lt;p&gt;
Defer decisions till the last possible moment.
&lt;/p&gt;
&lt;p&gt;
What I’m still trying to learn&amp;#160; is;
&lt;/p&gt;
&lt;p&gt;
What is the simplest thing that could work, but doesn’t increase the cost of change
later. What is the simplest thing I could do, but still gives me a foundation to build
upon ?
&lt;/p&gt;
&lt;p&gt;
How long can I defer a decision ? How do I avoid leaving a decision till too late
? 
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
A panel discussion led by Martin Fowler sheds some light on this. &lt;a title="Modifiability? Or is there Design in Agility" href="http://www.infoq.com/presentations/modifiability-fowler"&gt;You
can watch it here&lt;/a&gt;, and it is a must see. The panel talks about&amp;#160; these two
topics and their experiences.
&lt;/p&gt;
&lt;p&gt;
What I gleaned from this is , doing the simplest thing does not mean doing the stupidest
thing. Doing the simplest thing possible is under the constraints of proper separation
of concerns, encapsulation and having tests to cover what is written.
&lt;/p&gt;
&lt;p&gt;
Doing the simplest thing does not mean you can dump your business logic, persistance
and presentation logic all in the code behind file of an ASP .Net page. Keep doing
the simplest thing possible by using existing design patterns that reduce the cost
of change later. The simplest thing is not an excuse for writing bad code. Having
proper separation of concerns in the design ensures that changes can be made in&amp;#160;
the simplest thing that was done earlier without adversely affecting the rest of the
system.&amp;#160; 
&lt;/p&gt;
&lt;p&gt;
The domain model should not be aware of the persistance or presentation logic. Design
decisions don’t affect the domain model design as frequently as other parts of the
system. The domain model reflects the business and the decisions are usually made
long before the project is begun. 
&lt;/p&gt;
&lt;p&gt;
Doing the simplest thing that could possibly work usually means, how to persist a
certain part of the domain model ? how to present domain model data ? and how to pass
the data from the domain model to and from the different layers. It is how to implement
a certain business requirement in domain model code.
&lt;/p&gt;
&lt;p&gt;
A key safeguard here is having tests (unit and acceptance tests ).&amp;#160; While doing
the simplest thing possible do write good unit tests.
&lt;/p&gt;
&lt;p&gt;
Martin Fowler talks about reversibility in design decisions. A good design decision
is one that you can reverse and go back to the point before the decision was made.
He stresses encapsulation again.&amp;#160; Design decisions that are encapsulated are
not expensive to change. If your persistance medium is changed, this decision should
not affect the rest of the system. Proper separation of concerns isolates design decisions.
The panel also stresses the importance of spiking. If you have choices to make, try
those choices with a scaffold or a simple prototype and explore the options. It’s
much more cost effective to make a decision through spiking than to undo a choice
made to production code. Again the emphasis is made on tests. Tests protect the system,
they tell you how much you are likely to break.&amp;#160; 
&lt;/p&gt;
&lt;p&gt;
During the past week a colleague of mine, did a fairly big refactoring of key parts
of the code. He did it in a separate branch, and made sure that all the existing tests
passed and wrote new tests where needed. Impressive. His design decisions do not affect
the trunk, till we are sure that we are happy with it and it hasn’t broken any part
of the system. 
&lt;/p&gt;
&lt;p&gt;
In my current project I defer decisions till the first hint of pain of not making
that decision appears. I make&amp;#160; the choice just about when we are starting to
hurt by not making it. I keep postponing it till then.
&lt;/p&gt;
&lt;p&gt;
To sum it all up;
&lt;/p&gt;
&lt;p&gt;
Do the simplest thing that could possibly work, do not repeat yourself defer decisions
till the last possible moment, but still do write the best code you can, and drive
the design with tests.
&lt;/p&gt;</description>
      <comments>http://www.hibri.net/CommentView,guid,f42342d6-8bc2-402a-9db7-7268ce3facd6.aspx</comments>
      <category>Agile</category>
      <category>development</category>
    </item>
    <item>
      <trackback:ping>http://www.hibri.net/Trackback.aspx?guid=450dce18-c378-45dd-b727-15bd74b534c3</trackback:ping>
      <pingback:server>http://www.hibri.net/pingback.aspx</pingback:server>
      <pingback:target>http://www.hibri.net/PermaLink,guid,450dce18-c378-45dd-b727-15bd74b534c3.aspx</pingback:target>
      <dc:creator>Hibri</dc:creator>
      <wfw:comment>http://www.hibri.net/CommentView,guid,450dce18-c378-45dd-b727-15bd74b534c3.aspx</wfw:comment>
      <wfw:commentRss>http://www.hibri.net/SyndicationService.asmx/GetEntryCommentsRss?guid=450dce18-c378-45dd-b727-15bd74b534c3</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
In the past two months I've been introducing new practices to my team. An important
one was a branching strategy.  My team works on several user stories in a sprint.
A sprint lasts 2 weeks ( 10 days).  I wanted to release regularly at the end
of each sprint.  
</p>
        <p>
Prior to implementing the branching strategy,  the team worked off the trunk
and released from it.  This made the trunk less stable with in-complete features. 
The code was unit tested but not complete. 
</p>
        <p>
We wanted to have better control of what we were releasing for acceptance testing
and to the production environment.  Releasing the latest version in the trunk
caused in-complete code go into a production environment. The strategy I introduced
is <a title="Version Control For Multiple Agile Teams" href="http://www.infoq.com/articles/agile-version-control" target="_blank">explained
very well in this article</a>. I highly recommend reading this and using it as a starting
point if you are working in an agile manner. 
</p>
        <p>
To summarise;
</p>
        <blockquote>
          <p>
All development work is done in a development branch. For example, when developing 
a story, the work is done in a branch for the story. The branch is merged back into
trunk when the story is complete (acceptance tested, unit tested, as long as it has
met the requirements and is relatively bug free with no show stoppers).  During
development the developers working on the story branch pull down from the trunk so
that they are always in synch with the trunk. When the story is done, the branch is
merged back into the trunk and killed off.  Several stories can be in development
in parallel branches too.
</p>
        </blockquote>
        <p>
The advantage of this approach is that the trunk is kept relatively clean and has
feature complete code ready to release. This makes life much easier for the testers
as they have complete stories to test. 
</p>
        <p>
Now this all sounds fine, but it didn't go smoothly as I expected. 
</p>
        <p>
First off, most of my team had a steep learning curve in trying to branch and merge.
We were working with TFS (Team Foundation Server) at the time. Creating a branch with
TFS was a time consuming task. It took a good 10 to 15 minutes to create a new branch
from the trunk and commit it back in to TFS.
</p>
        <p>
The next biggest stumbling block for my team was the actual act of merging. Some found
it hard to be disciplined and pull down from the trunk regularly, and to always do
this first when merging a branch back into the trunk. 
</p>
        <p>
TFS wasn't very helpful in when resolving conflicts, it tends get confused when the
merge contained renamed files. 
</p>
        <p>
A drawback of such an aggressive branching strategy was sharing code was hard. Improvements
or refactored code made in one branch code not be shared by other branches. The code
had to go into the trunk first before being pulled down by the other branches.
</p>
        <p>
So at the end of two months where am I ?
</p>
        <p>
I decided not to branch so aggressively. Each story did not have to have a branch
of its own. The general policy when creating branches is;
</p>
        <p>
1. Does the story depend on other stories in development ? If yes, use an existing
branch.
</p>
        <p>
2. Will starting a new piece of work impact the release of an existing story ? Will
it cause the release of one story to contain an incomplete feature of another story
? If yes, the new piece of work belongs in a new branch.
</p>
        <p>
3. Is the new work a bug fix ? Bug fixes on code already released are always in the
trunk.
</p>
        <p>
In general, we have settled on "work branches". Branches that can have independent
releasable pieces of work. At most we have two branches at any given point in time.
Usually there is a branch with work carried over from the previous sprint and all
the new work for the current sprint is done in a new branch.
</p>
        <p>
We also ditched TFS and moved to Subversion. This move was done last week, and my
team is still settling into it. Creating branches with subversion is a snap. It was
very easy to switch Cruise Control .Net to use subversion. We haven't still moved
to <a title="Subversion Merge Tracking" href="http://subversion.tigris.org/merge-tracking/" target="_blank">subversion
1.5</a> and have to track the merge revision numbers manually.
</p>
        <p>
 
</p>
        <p>
If you don't have a branching strategy, first consider if you really need one. If
you do, and you are working in an agile manner start off with the approaches in this <a href="http://www.infoq.com/articles/agile-version-control" target="_blank">article</a>. 
</p>
        <p>
1. Enforce strict discipline and synchronise branches regularly.
</p>
        <p>
2.No branch should go without merging back into the trunk at-least once every two
days. 
</p>
        <p>
3. Listen to the pain points of the team. 
</p>
        <p>
4.I highly recommend paring with another developer when merging back into the trunk.
Have a merge buddy. 
</p>
        <p>
5. Always merge locally and not on the server, run unit tests and then check back
in. 
</p>
        <p>
6. The chances of a merge going wrong and loosing both the unit test and  the
code being tested is very little. A compile error will always spot this. 
</p>
        <p>
7. Run CI on each branch. Treat each branch with the same respect as the trunk.  
</p>
        <p>
8. Don't let your team treat a branch as place to check-in untested code. 
</p>
        <p>
9. If your tools are giving you pain, change them.
</p>
        <p>
Most of all listen to the pain the team is having but stick with the process. Don't
drop it because it's hard. 
</p>
        <p>
Listen and adapt. 
</p>
      </body>
      <title>Branching, Merging and avoiding the pain..</title>
      <guid isPermaLink="false">http://www.hibri.net/PermaLink,guid,450dce18-c378-45dd-b727-15bd74b534c3.aspx</guid>
      <link>http://www.hibri.net/2008/07/27/BranchingMergingAndAvoidingThePain.aspx</link>
      <pubDate>Sun, 27 Jul 2008 20:41:29 GMT</pubDate>
      <description>&lt;p&gt;
In the past two months I've been introducing new practices to my team. An important
one was a branching strategy.&amp;nbsp; My team works on several user stories in a sprint.
A sprint lasts 2 weeks ( 10 days).&amp;nbsp; I wanted to release regularly at the end
of each sprint.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
Prior to implementing the branching strategy,&amp;nbsp; the team worked off the trunk
and released from it.&amp;nbsp; This made the trunk less stable with in-complete features.&amp;nbsp;
The code was unit tested but not complete. 
&lt;/p&gt;
&lt;p&gt;
We wanted to have better control of what we were releasing for acceptance testing
and to the production environment.&amp;nbsp; Releasing the latest version in the trunk
caused in-complete code go into a production environment. The strategy I introduced
is &lt;a title="Version Control For Multiple Agile Teams" href="http://www.infoq.com/articles/agile-version-control" target="_blank"&gt;explained
very well in this article&lt;/a&gt;. I highly recommend reading this and using it as a starting
point if you are working in an agile manner. 
&lt;/p&gt;
&lt;p&gt;
To summarise;
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
All development work is done in a development branch. For example, when developing&amp;nbsp;
a story, the work is done in a branch for the story. The branch is merged back into
trunk when the story is complete (acceptance tested, unit tested, as long as it has
met the requirements and is relatively bug free with no show stoppers).&amp;nbsp; During
development the developers working on the story branch pull down from the trunk so
that they are always in synch with the trunk. When the story is done, the branch is
merged back into the trunk and killed off.&amp;nbsp; Several stories can be in development
in parallel branches too.
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
The advantage of this approach is that the trunk is kept relatively clean and has
feature complete code ready to release. This makes life much easier for the testers
as they have complete stories to test. 
&lt;/p&gt;
&lt;p&gt;
Now this all sounds fine, but it didn't go smoothly as I expected. 
&lt;/p&gt;
&lt;p&gt;
First off, most of my team had a steep learning curve in trying to branch and merge.
We were working with TFS (Team Foundation Server) at the time. Creating a branch with
TFS was a time consuming task. It took a good 10 to 15 minutes to create a new branch
from the trunk and commit it back in to TFS.
&lt;/p&gt;
&lt;p&gt;
The next biggest stumbling block for my team was the actual act of merging. Some found
it hard to be disciplined and pull down from the trunk regularly, and to always do
this first when merging a branch back into the trunk. 
&lt;/p&gt;
&lt;p&gt;
TFS wasn't very helpful in when resolving conflicts, it tends get confused when the
merge contained renamed files. 
&lt;/p&gt;
&lt;p&gt;
A drawback of such an aggressive branching strategy was sharing code was hard. Improvements
or refactored code made in one branch code not be shared by other branches. The code
had to go into the trunk first before being pulled down by the other branches.
&lt;/p&gt;
&lt;p&gt;
So at the end of two months where am I ?
&lt;/p&gt;
&lt;p&gt;
I decided not to branch so aggressively. Each story did not have to have a branch
of its own. The general policy when creating branches is;
&lt;/p&gt;
&lt;p&gt;
1. Does the story depend on other stories in development ? If yes, use an existing
branch.
&lt;/p&gt;
&lt;p&gt;
2. Will starting a new piece of work impact the release of an existing story ? Will
it cause the release of one story to contain an incomplete feature of another story
? If yes, the new piece of work belongs in a new branch.
&lt;/p&gt;
&lt;p&gt;
3. Is the new work a bug fix ? Bug fixes on code already released are always in the
trunk.
&lt;/p&gt;
&lt;p&gt;
In general, we have settled on "work branches". Branches that can have independent
releasable pieces of work. At most we have two branches at any given point in time.
Usually there is a branch with work carried over from the previous sprint and all
the new work for the current sprint is done in a new branch.
&lt;/p&gt;
&lt;p&gt;
We also ditched TFS and moved to Subversion. This move was done last week, and my
team is still settling into it. Creating branches with subversion is a snap. It was
very easy to switch Cruise Control .Net to use subversion. We haven't still moved
to &lt;a title="Subversion Merge Tracking" href="http://subversion.tigris.org/merge-tracking/" target="_blank"&gt;subversion
1.5&lt;/a&gt; and have to track the merge revision numbers manually.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
If you don't have a branching strategy, first consider if you really need one. If
you do, and you are working in an agile manner start off with the approaches in this &lt;a href="http://www.infoq.com/articles/agile-version-control" target="_blank"&gt;article&lt;/a&gt;. 
&lt;/p&gt;
&lt;p&gt;
1. Enforce strict discipline and synchronise branches regularly.
&lt;/p&gt;
&lt;p&gt;
2.No branch should go without merging back into the trunk at-least once every two
days. 
&lt;/p&gt;
&lt;p&gt;
3. Listen to the pain points of the team. 
&lt;/p&gt;
&lt;p&gt;
4.I highly recommend paring with another developer when merging back into the trunk.
Have a merge buddy. 
&lt;/p&gt;
&lt;p&gt;
5. Always merge locally and not on the server, run unit tests and then check back
in. 
&lt;/p&gt;
&lt;p&gt;
6. The chances of a merge going wrong and loosing both the unit test and&amp;nbsp; the
code being tested is very little. A compile error will always spot this. 
&lt;/p&gt;
&lt;p&gt;
7. Run CI on each branch. Treat each branch with the same respect as the trunk.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
8. Don't let your team treat a branch as place to check-in untested code. 
&lt;/p&gt;
&lt;p&gt;
9. If your tools are giving you pain, change them.
&lt;/p&gt;
&lt;p&gt;
Most of all listen to the pain the team is having but stick with the process. Don't
drop it because it's hard. 
&lt;/p&gt;
&lt;p&gt;
Listen and adapt. 
&lt;/p&gt;</description>
      <comments>http://www.hibri.net/CommentView,guid,450dce18-c378-45dd-b727-15bd74b534c3.aspx</comments>
      <category>Agile</category>
      <category>development</category>
    </item>
  </channel>
</rss>