<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Deliberating On Software Development</title>
	<atom:link href="http://deliberatingsoftwaredevelopment.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://deliberatingsoftwaredevelopment.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Tue, 09 Mar 2010 01:57:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='deliberatingsoftwaredevelopment.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Deliberating On Software Development</title>
		<link>http://deliberatingsoftwaredevelopment.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://deliberatingsoftwaredevelopment.wordpress.com/osd.xml" title="Deliberating On Software Development" />
	<atom:link rel='hub' href='http://deliberatingsoftwaredevelopment.wordpress.com/?pushpress=hub'/>
		<item>
		<title>IoC Containers and Transient Instances</title>
		<link>http://deliberatingsoftwaredevelopment.wordpress.com/2010/03/07/ioc-containers-and-transient-instances/</link>
		<comments>http://deliberatingsoftwaredevelopment.wordpress.com/2010/03/07/ioc-containers-and-transient-instances/#comments</comments>
		<pubDate>Sun, 07 Mar 2010 14:27:55 +0000</pubDate>
		<dc:creator>x97mdr</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ninject ioc-container ioc dependency-injection]]></category>

		<guid isPermaLink="false">http://deliberatingsoftwaredevelopment.wordpress.com/?p=12</guid>
		<description><![CDATA[As seems to be the case on this blog,  I’m about to confess to something foolish that I’ve done so as to better inform you dear reader! There are many IoC containers out there in the .Net-o-sphere that are quite excellent.  Personally, I use Ninject because I love its simple syntax and its powerful contextual [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deliberatingsoftwaredevelopment.wordpress.com&amp;blog=12427014&amp;post=12&amp;subd=deliberatingsoftwaredevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As seems to be the case on this blog,  I’m about to confess to something foolish that I’ve done so as to better inform you dear reader!</p>
<p>There are many IoC containers out there in the .Net-o-sphere that are quite excellent.  Personally, I use Ninject because I love its simple syntax and its powerful contextual binding.  When I first came across Ninject some time ago (shortly after 1.0 was released) I read everything I could about it and IoC in general and then said to myself “IoC … whatever! I don’t need that crap! … way too complex”.  A startling lack of vision on my part.  Then I started getting deep into my program’s re-design from C to C#.  We have a Settings object that contains the settings the user has entered from the command-line and/or a parameter file.  Lots of objects need the Settings but sometimes these objects are fairly deep in the object graph and to get the settings I used the Singleton instance of it.  As you develop in a more object-oriented way many other circumstances like this turn up.</p>
<p>As I started unit testing I discovered that Ninject was born and raised for just this sort of activity: injecting objects deep into the object graph when you want them and it gets rid of the ugly Singleton instances that are such a pain when you are unit testing.  It was like I was born-again.  Praise the Ninject!  I used Ninject to create everything … and I mean everything!  I was passing parameters to the kernel to help resolve bindings, using providers where I thought I needed more complicated logic, you name it.  If I could have used Ninject to inject my lunch into my bag every day I would have.</p>
<p>Then it came time to performance test my application.  When I ran the performance tests they were incredibly slow … like I could have done the calculations without the computer slower.  I did some research on the net and found that <a href="http://www.codinginstinct.com/2008/04/ioc-benchmark-revisited-ninject.html" target="_blank">there was a performance bug in Ninject 1.0</a> that <a href="http://www.codinginstinct.com/2008/05/ioc-container-benchmark-rerevisted.html" target="_blank">was resolved in 1.5 and 2.0</a> but when I tried replacing 1.0 with 1.5 or 2.0 the performance was barely affected and still very slow.</p>
<p>I was perplexed so of course <a href="http://groups.google.com/group/ninject/browse_thread/thread/41ec03527da9f0f8/48e974f12032880f?lnk=gst&amp;q=x97mdr#48e974f12032880f" target="_blank">I went to the Ninject user group and posted a question</a>.  The answers sort of slapped me in the face a bit.  As one of my friends at work says: I was trying to be holier than the pope!  Basically IoC containers are intended to be used to resolve long-lived instances.  This is, in fact, <a href="http://code.google.com/p/autofac/" target="_blank">why some containers set the default lifetime of objects to singleton rather than transient</a>.  To resolve large numbers of transient objects you should use <a href="http://en.wikipedia.org/wiki/Factory_method_pattern" target="_blank">the factory pattern</a>, make the IoC Container resolve the factory as a singleton and inject any dependencies that the transient objects need into the factory.  I don’t have many types of transient objects that need to be created, only a few classes, so I created factories for them and my performance problems melted like an arctic ice pack.</p>
<p>So how could I have avoided this problem?  I should have been more diligent about asking questions on best practices when I first started using Ninject (or really any other piece of technology).  Most worthwhile open source projects have newsgroups or forums that are active and have some informative users who are willing to lend a hand.  In my own defense though, while doing research on IoC (and I read quite a few articles on this) never once did I come across best practices for using the tools, it was mostly the nuts and bolts of how to use a tool that documentation focuses on.  This particular problem never seemed to be discussed, though if I’m wrong maybe someone will point me to where it is discussed.  That’s the main reason I wrote this article though, to help anyone else who may have been in the same situation as me.</p>
<p>IoC FTW!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/deliberatingsoftwaredevelopment.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/deliberatingsoftwaredevelopment.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/deliberatingsoftwaredevelopment.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/deliberatingsoftwaredevelopment.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/deliberatingsoftwaredevelopment.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/deliberatingsoftwaredevelopment.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/deliberatingsoftwaredevelopment.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/deliberatingsoftwaredevelopment.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/deliberatingsoftwaredevelopment.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/deliberatingsoftwaredevelopment.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/deliberatingsoftwaredevelopment.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/deliberatingsoftwaredevelopment.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/deliberatingsoftwaredevelopment.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/deliberatingsoftwaredevelopment.wordpress.com/12/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deliberatingsoftwaredevelopment.wordpress.com&amp;blog=12427014&amp;post=12&amp;subd=deliberatingsoftwaredevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://deliberatingsoftwaredevelopment.wordpress.com/2010/03/07/ioc-containers-and-transient-instances/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a025f89612e842303971820862b4b51e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">x97mdr</media:title>
		</media:content>
	</item>
		<item>
		<title>Using Ninject 2 to resolve conditional bindings with a kernel</title>
		<link>http://deliberatingsoftwaredevelopment.wordpress.com/2010/03/07/using-ninject-2-to-resolve-conditional-bindings-with-a-kernel/</link>
		<comments>http://deliberatingsoftwaredevelopment.wordpress.com/2010/03/07/using-ninject-2-to-resolve-conditional-bindings-with-a-kernel/#comments</comments>
		<pubDate>Sun, 07 Mar 2010 00:25:01 +0000</pubDate>
		<dc:creator>x97mdr</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://deliberatingsoftwaredevelopment.wordpress.com/?p=5</guid>
		<description><![CDATA[A while ago I saw that Nate Kohari was working on a beta version of Ninject, called Ninject 2.&#160; I use Ninject 1.0 in my projects and I’m really happy.&#160; It has a clean API and is very lightweight.&#160; Since once of the projects I use Ninject in is a batch program that has a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deliberatingsoftwaredevelopment.wordpress.com&amp;blog=12427014&amp;post=5&amp;subd=deliberatingsoftwaredevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A while ago I saw that Nate Kohari was <a href="http://kohari.org/2009/02/25/ninject-2-reaches-beta/" target="_blank">working on a beta version of Ninject, called Ninject 2</a>.&#160; I use Ninject 1.0 in my projects and I’m really happy.&#160; It has a clean API and is very lightweight.&#160; Since once of the projects I use Ninject in is a batch program that has a large number of user settings I often use Ninject to configure the particular object I get based on these settings, which I keep in an object called, not surprisingly, Settings. So here is an example of what I might do:</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:034ce380-3de4-47c0-8095-b83d059e7d3d" class="wlWriterEditableSmartContent">
<pre>
<pre class="brush: csharp; pad-line-numbers: true;">
Bind&lt;IEngineSession&gt;()
	.To&lt;DeriveEngineSession&gt;()
	.OnlyIf(context =&gt; context.Kernel.Get&lt;Settings&gt;().Session == SessionType.Derive);

Bind&lt;IEngineSession&gt;()
	.To&lt;DonorEngineSession&gt;()
	.OnlyIf(context =&gt; context.Kernel.Get&lt;Settings&gt;().Session == SessionType.Donor);

Bind&lt;IEngineSession&gt;()
	.To&lt;EditEngineSession&gt;()
	.OnlyIf(context =&gt; context.Kernel.Get&lt;Settings&gt;().Session == SessionType.Edit);
</pre>
</pre>
</div>
<p>Note that inside of the conditional binding I resolve an instance of the Settings object and use it.&#160; Well, when I tried to do this with Ninject 2 I ran into some big problems because the IContext is not part of the conditional binding syntax now, it is replaced by IRequest which does not have access to the Kernel.&#160; I was quite perplexed and put off for a while until <a href="http://kohari.org/2010/02/25/ninject-forever/" target="_blank">I saw that Ninject 2 was officially released</a>.&#160; I thought perhaps the bug was resolved so I eagerly downloaded Ninject to try it out, only to be disappointed.&#160; There was no IKernel as part of IRequest and the ParentContext field of IRequest was null on the initial bind so I couldn’t use that to get an IKernel object to resolve my objects.</p>
<p>Perplexed, <a href="http://groups.google.com/group/ninject/browse_thread/thread/9d86c37e576d0926#" target="_blank">I posted a question to the Ninject newsgroup asking if this was a bug</a>.&#160; One of the things I love about Ninject is that either Nate or Ian get back to you with lightning speed and efficiency and always have an answer at the ready.&#160; As Ian pointed out, the binding itself has a property called Kernel that I can use, rather than getting it from the binding, like so:</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:5f2d717b-79b3-4e31-beab-b687019f09fe" class="wlWriterEditableSmartContent">
<pre>
<pre class="brush: csharp;">
Bind&lt;IEngineSession&gt;()
	.To&lt;DeriveEngineSession&gt;()
	.When(request =&gt; Kernel.Get&lt;Settings&gt;().Session == SessionType.Derive);

Bind&lt;IEngineSession&gt;()
	.To&lt;DonorEngineSession&gt;()
	.When(request =&gt; Kernel.Get&lt;Settings&gt;().Session == SessionType.Donor);

Bind&lt;IEngineSession&gt;()
	.To&lt;EditEngineSession&gt;()
	.When(request =&gt; Kernel.Get&lt;Settings&gt;().Session == SessionType.Edit);

</pre>
</pre>
</div>
<p>I am pleased as can be now since this problem was the only thing preventing me from making the switch in all of my projects!&#160; Thanks to Nate Kohari, Ian Davis, et al. for pouring so much love into this framework and making it a shining example.&#160; I even gave my team a tour of the repository because, unlike some open source projects, it is very well laid out and easy to use … I maybe have even stolen some ideas (like embedding NAnt directly into the working folder and providing a script to build the project on demand) into my own projects!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/deliberatingsoftwaredevelopment.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/deliberatingsoftwaredevelopment.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/deliberatingsoftwaredevelopment.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/deliberatingsoftwaredevelopment.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/deliberatingsoftwaredevelopment.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/deliberatingsoftwaredevelopment.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/deliberatingsoftwaredevelopment.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/deliberatingsoftwaredevelopment.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/deliberatingsoftwaredevelopment.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/deliberatingsoftwaredevelopment.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/deliberatingsoftwaredevelopment.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/deliberatingsoftwaredevelopment.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/deliberatingsoftwaredevelopment.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/deliberatingsoftwaredevelopment.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deliberatingsoftwaredevelopment.wordpress.com&amp;blog=12427014&amp;post=5&amp;subd=deliberatingsoftwaredevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://deliberatingsoftwaredevelopment.wordpress.com/2010/03/07/using-ninject-2-to-resolve-conditional-bindings-with-a-kernel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a025f89612e842303971820862b4b51e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">x97mdr</media:title>
		</media:content>
	</item>
		<item>
		<title>Why should I continuously integrate? (or &#8230; how I learned to love claps and cheers)</title>
		<link>http://deliberatingsoftwaredevelopment.wordpress.com/2010/03/06/why-should-i-continuously-integrate-or-how-i-learned-to-love-claps-and-cheers/</link>
		<comments>http://deliberatingsoftwaredevelopment.wordpress.com/2010/03/06/why-should-i-continuously-integrate-or-how-i-learned-to-love-claps-and-cheers/#comments</comments>
		<pubDate>Sat, 06 Mar 2010 23:55:49 +0000</pubDate>
		<dc:creator>x97mdr</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[continuous-integration hudson subversion jira nant msbuild nunit fxcop stylecop rake specflow fitnesse]]></category>

		<guid isPermaLink="false">http://deliberatingsoftwaredevelopment.wordpress.com/?p=4</guid>
		<description><![CDATA[One of the practices I consider essential for any development team is to continuously integrate their code.&#160; There is a good discussion of continuous integration out there already but in short continuous integration means that every time you commit to your version control repository a fully-fledged build of your project occurs.&#160; These builds should have [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deliberatingsoftwaredevelopment.wordpress.com&amp;blog=12427014&amp;post=4&amp;subd=deliberatingsoftwaredevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>One of the practices I consider essential for any development team is to continuously integrate their code.&#160; <a href="http://martinfowler.com/articles/continuousIntegration.html" target="_blank">There is a good discussion of continuous integration out there already</a> but in short continuous integration means that every time you commit to your version control repository a fully-fledged build of your project occurs.&#160; These builds should have various features:</p>
<ul>
<li>Have a meaningful version number.&#160; For example major.minor.build.revision where revision is the revision of your version control repository. </li>
<li>Build a clean copy of the source code each time (delete + svn checkout as opposed to svn update) </li>
<li>Perform unit and/or integration tests to determine the quality of the build </li>
<li>Gather the various deployable pieces of your application into an archive (or set of archives) that the anyone can retrieve with little trouble </li>
</ul>
<p>While it is not necessary, some other nice things you can do as part of a continuous integration process are</p>
<ul>
<li>Perform static analysis of your code and produce reports on this for every build </li>
<li>Perform code coverage analysis of your code and produce reports on every build </li>
<li>Run integration tests using tools like <a href="http://www.cukes.info" target="_blank">Cucumber</a>, <a href="http://www.specflow.org" target="_blank">SpecFlow</a> or <a href="http://www.fitnesse.org" target="_blank">Fitnesse</a>. </li>
<li>Link build numbers back to your activity management tool (Bugzilla, Trac, Jira, TFS Work Items) </li>
<li>Track who breaks builds, etc. </li>
</ul>
<h4>Real Life Continuous Integration</h4>
<p>On my team we have been doing full-fledged continuous integration on all projects for over a year now.&#160; We use a combination of tools to support the trinity of activities involved in configuration management.</p>
<ul>
<li><a href="http://subversion.apache.org" target="_blank">Subversion</a> – Version Control tool </li>
<li><a href="http://www.atlassian.com/software/jira/" target="_blank">Atlassian Jira</a> – Activity Management tool </li>
<li><a href="http://hudson-ci.org/" target="_blank">Hudson</a> – Continuous Integration tool </li>
</ul>
<p>I have tried a few different continuous integration tools (<a href="http://www.kinook.com/VisBuildPro/" target="_blank">VisualBuildPro</a>, <a href="http://www-01.ibm.com/software/awdtools/buildforge/" target="_blank">IBM Rational BuildForge</a> and <a href="http://www.jetbrains.com/teamcity/" target="_blank">JetBrains’ TeamCity</a>) and found Hudson to be the best among them.&#160; There is a plethora of plug-ins available, an active user and developer support group and its open source!&#160; Does a tool get any better?&#160; TeamCity comes a close second but its lack of support for trend charts and plugins was a real downer.&#160; It does have pre-flight builds but this feature wasn’t enough to win me over.&#160; IBM Rational Build Forge was ridiculously over priced for the functionality, required a lot of manual configuration and had a confusing set of terminology (as is common with IBM Rational products).&#160; Avoid it at all costs.&#160; All that being said, in the end we chose Hudson and every build in Hudson has some key ingredients:</p>
<ul>
<li>We monitor the Subversion repositories for change every 5 minutes. </li>
<li>When a change is detected Hudson deletes the old working copy and gets a fresh copy from Subversion (no svn update!!) </li>
<li>The actual build is done with an NAnt script
<ul>
<li>You could use <a href="http://en.wikipedia.org/wiki/MSBuild" target="_blank">MSBuild</a>, <a href="http://rake.rubyforge.org/" target="_blank">Rake</a> or <a href="http://code.google.com/p/psake/" target="_blank">PSake</a> instead. </li>
<li>The NAnt script builds the solution with MSBuild, runs any unit tests, calls FxCop to produce a report for some static analysis and then packages the results of the build.&#160; For some projects we use ILMerge to reduce the number of assemblies we need to deploy as I am a heavy user of open source tools. </li>
<li>Hudson creates environment variables BUILD_NUMBER and SVN_REVISION that we use in our build script to generate the version numbers.&#160; These get put into the AssemblyInfo.cs files and cause the Version property of the assembly to reflect the&#160; </li>
</ul>
</li>
<li><a href="http://wiki.hudson-ci.org/display/HUDSON/NUnit+Plugin" target="_blank">NUnit</a> plugin to read the <a href="http://www.nunit.org" target="_blank">NUnit</a> results report and produce a trend chart on </li>
<li><a href="http://wiki.hudson-ci.org/display/HUDSON/Violations" target="_blank">Violations</a> plugin to read the FxCop results and produce a trend chart on possible code violations </li>
<li><a href="http://wiki.hudson-ci.org/display/HUDSON/Warnings+Plugin" target="_blank">Warnings</a> plugin to parse the MSBuild log file and produce a trend chart on compiler violations </li>
<li><a href="http://wiki.hudson-ci.org/display/HUDSON/Task+Scanner+Plugin" target="_blank">Task Scanner</a> plugin parses the class files (*.cs) looking for those //TODO and // HACK (or whatever else you tell it) comments and then makes a nice report on them </li>
<li>The <a href="http://wiki.hudson-ci.org/display/HUDSON/JIRA+Plugin" target="_blank">Jira</a> plugin is probably the nicest feature.&#160; It parses the commit comments from Subversion for each build for tags in Jira format (i.e. PROJECT-19) and if it finds one it puts a comment in the relevant Jira issue with a link back to the Hudson build.&#160; This is an awesome way for our users to be notified when an issue that they created has been worked on! </li>
<li>A zip archive is produced with all of the materials for using the product (the executable, configuration files, etc.) </li>
</ul>
<p>When used in conjunction with <a href="http://deliberatingsoftwaredevelopment.wordpress.com/2010/03/06/when-should-you-commit-source-code/" target="_blank">“Commit early, commit often”</a> Hudson becomes the heartbeat of our team.&#160; Anytime someone performs a commit we get a pile of useful trend charts and reports indicating the health of the project.&#160; With the Jira plugin we get connection to the activity management tool so users know what build their issue has been worked on and Hudson keeps track of the source code changes for every build … in other words complete traceability!&#160; If a user encounters a problem we can tell immediately what the version is that they’re using and whether they are up to date or not.&#160; We can tell what has changed since the last build to determine if merely upgrading will resolve their problem.&#160; We can point a user to a Hudson build and they can get everything they need from a single page since everything is archived in one place.</p>
<p>One important thing that I have found out is that it is important to have a way to build your project exactly like Hudson would, but do it locally.&#160; This was the main reason I chose NAnt as the build script.&#160; In my source control repository there is a .build file containing the NAnt script, a copy of the NAnt executable and </p>
<h4>Good for you smarty-pants … but how long does it take to get all that setup if I know nothing about continuous integration?</h4>
<p>To get my setup running it took me a solid week (spread out over time).&#160; I started off very small, with no plug-ins and Hudson simply building the solution file.&#160; I would add a plugin, get it working and then expand.&#160; I think this is a good way for a newbie to start because even if you are only building the project it can catch a lot of errors.&#160; one of the most common mistakes I find on my team is when someone adds a file to the solution file in Visual Studio but forgets to add the file to Subversion.&#160; When they commit the change set MSBuild barfs when it cannot find the file that is not in Subversion.&#160; This is an easy and effective way of ensuring that the source control tree is always in a buildable state.&#160; I love this because one of my pet peeves is checking out a project only to discover it doesn’t actually build.&#160; It’s little mistakes like these that upset the rhythm of a team and affect productivity.</p>
<p>In terms of tools for newcomers I would highly recommended Hudson because it is such a simple point-and-click Web 2.0 interface and has great help built right in where you need it.&#160; Hudson is ridiculously easy to install and use, even installing it as a Windows service is built right into the package now, and installing plug-ins, etc. is downright simple.</p>
<p>If you’re still unconvinced you will see some payback from continuous integration (despite the evidence to the contrary) then look at the relatively minimal investment of a few days to a week as something that you can bring to every project in the future.</p>
<h4>The Future</h4>
<p>I would like to expand our setup to include code coverage metrics and possibly use a tool like <a href="http://code.msdn.microsoft.com/sourceanalysis" target="_blank">StyleCop</a> to measure how well the source code is formatted.&#160; I have in the past attempted to integrate trend charts for a Fitnesse wiki but gave up because the restriction of having a wiki server up and running to perform the tests was tedious and error-prone.&#160; We’re moving our specification tests to SpecFlow anyway and this should be considerably easier to use since its just NUnit under the hood.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/deliberatingsoftwaredevelopment.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/deliberatingsoftwaredevelopment.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/deliberatingsoftwaredevelopment.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/deliberatingsoftwaredevelopment.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/deliberatingsoftwaredevelopment.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/deliberatingsoftwaredevelopment.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/deliberatingsoftwaredevelopment.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/deliberatingsoftwaredevelopment.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/deliberatingsoftwaredevelopment.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/deliberatingsoftwaredevelopment.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/deliberatingsoftwaredevelopment.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/deliberatingsoftwaredevelopment.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/deliberatingsoftwaredevelopment.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/deliberatingsoftwaredevelopment.wordpress.com/4/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deliberatingsoftwaredevelopment.wordpress.com&amp;blog=12427014&amp;post=4&amp;subd=deliberatingsoftwaredevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://deliberatingsoftwaredevelopment.wordpress.com/2010/03/06/why-should-i-continuously-integrate-or-how-i-learned-to-love-claps-and-cheers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a025f89612e842303971820862b4b51e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">x97mdr</media:title>
		</media:content>
	</item>
		<item>
		<title>When should you commit source code?</title>
		<link>http://deliberatingsoftwaredevelopment.wordpress.com/2010/03/06/when-should-you-commit-source-code/</link>
		<comments>http://deliberatingsoftwaredevelopment.wordpress.com/2010/03/06/when-should-you-commit-source-code/#comments</comments>
		<pubDate>Sat, 06 Mar 2010 23:52:39 +0000</pubDate>
		<dc:creator>x97mdr</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[subversion bazaar version-control]]></category>

		<guid isPermaLink="false">http://deliberatingsoftwaredevelopment.wordpress.com/?p=3</guid>
		<description><![CDATA[Are you just starting out with source control?&#160; Have you ever had a hard drive fry with two days worth of work on it? Have you ever tried to merge two branches and had to spend a day working out the kinks?&#160; If so, then hopefully this post is for you! Tale of woe There [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deliberatingsoftwaredevelopment.wordpress.com&amp;blog=12427014&amp;post=3&amp;subd=deliberatingsoftwaredevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Are you just starting out with source control?&#160; Have you ever had a hard drive fry with two days worth of work on it? Have you ever tried to merge two branches and had to spend a day working out the kinks?&#160; If so, then hopefully this post is for you!</p>
<h4>Tale of woe</h4>
<p>There is a tale of woe that is a background to this story.&#160; The version control environment I use is a combination of <a href="http://subversion.apache.org/" target="_blank">Subversion</a> on the server with <a href="http://bazaar.canonical.com/en/" target="_blank">Bazaar</a> locally.&#160; This is sort of an advanced setup but I prefer it because it lets other members of my team who are more comfortable with Subversion to stick with it but lets me use the advanced features of a a <a href="http://en.wikipedia.org/wiki/Distributed_revision_control" target="_blank">Distributed Version Control (DVCS)</a> tool like Bazaar.&#160; </p>
<p>Now one day recently I was working away on a project that had to be done quickly.&#160; I had been working on this project for about 2 days solid, so there was a lost of changes.&#160;&#160; I realized at one point that I had modified a file I shouldn’t have and I went to revert this file using Bazaar.&#160; I used <a href="http://wiki.bazaar.canonical.com/TortoiseBzr" target="_blank">TortoiseBzr</a>, right-clicked the file in Windows Explorer, selected only the single file and pressed OK.&#160; I bet you can’t guess what happened next!&#160; For reasons a Bazaar neophyte like myself were unaware of, the entire repository reverted.&#160; Two days of work … gone!&#160; … or so I thought.&#160; After a full-on panic I finally got my head about me and I filed a <a href="https://bugs.launchpad.net/bugs/531352" target="_blank">bug report</a> and got a really fast and informative reply, was able to recover my lost data and move on.&#160; Major kudos to the Bazaar development team here, they were helpful and knowledgeable.&#160; However, this caused me nearly 4 hours of panic-ridden stress … so how could I have avoided this faithful reader?</p>
<h4>Commit Early, Commit Often</h4>
<p>This mantra is repeated all over the internety-thing <a href="http://blog.red-bean.com/sussman/?p=96" target="_blank">here</a>, <a href="http://stackoverflow.com/questions/107264/how-often-to-commit-changes-to-source-control" target="_blank">here</a> and <a href="http://damonpoole.blogspot.com/2005/07/check-in-early-and-check-in-often.html" target="_blank">here</a>.&#160; The biggest mistake that programmers make when working with a version control system is waiting long periods of time before checking in their code.&#160; This was the problem that caused me all that stress and it was completely avoidable.&#160; Had I committed at least a few times a day I would have lost at most a few hours work rather than two days worth.&#160; The next obvious question you’re going to ask me is : “What is the smallest chunk to commit”?</p>
<h4>What do I commit?</h4>
<p>When developers ask me this question I usually tell them something like this: If it relates to a single activity (bug, feature, task), it compiles and it passes unit tests then commit it.&#160; It takes some experience and experimenting to come up with your own formula but I personally find if I make a few classes with their accompanying tests then that’s a unit small enough for me to check in.&#160; This could take 20 minutes or it could take 2 hours but I try to commit at least two to three times per day at a minimum.&#160; I really like the <a href="http://stackoverflow.com/questions/107264/how-often-to-commit-changes-to-source-control" target="_blank">first answer in this stack overflow question</a> where he states that he usually commits a “complete thought”.&#160; It’s fairly abstract again, there is no concrete rule after all, but another possible guidance.</p>
<h4>Benefits</h4>
<p>There are a lot of benefits to committing code in small rather than large chunks.&#160; Most of these become apparent when you work with another developer on the same branch.&#160; It is much easier to resolve merge conflicts with another developer in the same branch there the merge conflict is related to just a few files rather than dozens of files.&#160; Additionally, committing in small chunks means that if there are conflicts then you are making the scope of the problem that you have to resolve much smaller.&#160; If you commit 2 dozen files after 4 days there could be several small conflicts that need to be resolved and worked out, all intermingling with each other.&#160; Trust me, this is the stuff of nightmares!&#160; If you commit in penny-packets your merge conflicts will be more coherent and less entangled.</p>
<p>If you use continuous integration to build your project, and you run unit and/or integration tests as part of that build, then you will get even more benefit out of using your version control tool and committing early and often.&#160; The continuous integration system can use unit tests&#160; to make an independent verification that every commit meets a certain set of criteria.&#160; This knowledge can be very comforting to all involved in the project.</p>
<p>You may also find that you develop a rhythm while working this way.&#160; You make a few changes, test them then commit them and watch the build pass.&#160; While I have no data to say that this process makes you more productive, I can say anecdotally that it makes me more productive because I spend less time getting held up by common mistakes.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/deliberatingsoftwaredevelopment.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/deliberatingsoftwaredevelopment.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/deliberatingsoftwaredevelopment.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/deliberatingsoftwaredevelopment.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/deliberatingsoftwaredevelopment.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/deliberatingsoftwaredevelopment.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/deliberatingsoftwaredevelopment.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/deliberatingsoftwaredevelopment.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/deliberatingsoftwaredevelopment.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/deliberatingsoftwaredevelopment.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/deliberatingsoftwaredevelopment.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/deliberatingsoftwaredevelopment.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/deliberatingsoftwaredevelopment.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/deliberatingsoftwaredevelopment.wordpress.com/3/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deliberatingsoftwaredevelopment.wordpress.com&amp;blog=12427014&amp;post=3&amp;subd=deliberatingsoftwaredevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://deliberatingsoftwaredevelopment.wordpress.com/2010/03/06/when-should-you-commit-source-code/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a025f89612e842303971820862b4b51e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">x97mdr</media:title>
		</media:content>
	</item>
	</channel>
</rss>
