<?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/"
	>

<channel>
	<title>Deployment Zone &#187; Programming</title>
	<atom:link href="http://www.deploymentzone.com/category/computers/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.deploymentzone.com</link>
	<description></description>
	<lastBuildDate>Thu, 29 Jul 2010 19:28:15 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Andy Hunt/Pragmatic Thinking and Learning Presentation @ RJUG</title>
		<link>http://www.deploymentzone.com/2009/10/22/andy-huntpragmatic-thinking-and-learning-presentation-rjug/</link>
		<comments>http://www.deploymentzone.com/2009/10/22/andy-huntpragmatic-thinking-and-learning-presentation-rjug/#comments</comments>
		<pubDate>Thu, 22 Oct 2009 05:02:07 +0000</pubDate>
		<dc:creator>Chuck</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.deploymentzone.com/2009/10/22/andy-huntpragmatic-thinking-and-learning-presentation-rjug/</guid>
		<description><![CDATA[ I attended Andy Hunt's “Refactor Your Wetware: Pragmatic Thinking and Learning” presentation given for the Richmond Java User Group/Central VA Ruby User Group October meeting Wednesday night.&#160; Having just completed this book in September I was very interested in reinforcing what I have learned (and began practicing, ahem, mind mapping) and excited to see [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.amazon.com/Pragmatic-Thinking-Learning-Refactor-Programmers/dp/1934356050/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1256185862&amp;sr=8-1"><img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="image" border="0" alt="image" align="left" src="http://www.deploymentzone.com/wp-content/uploads/2009/10/image.png" width="240" height="240" /></a> I attended <a href="http://andy.pragprog.com/">Andy Hunt's</a> “Refactor Your Wetware: Pragmatic Thinking and Learning” presentation given for the <a href="http://www.richmondjug.com/event/pragmatic-thinking-and-learning-andy-hunt-pragmatic-programmer">Richmond Java User Group</a>/Central VA Ruby User Group October meeting Wednesday night.&#160; Having just completed this book in September I was very interested in reinforcing what I have learned (and began practicing, ahem, mind mapping) and excited to see the author present this material.</p>
<p>I was impressed with the professional atmosphere and organization at this event.</p>
<p>Andy’s presentation centered around <a href="http://www.pragprog.com/titles/ahptl/pragmatic-thinking-and-learning">the book</a>, touching on several highlights over the two hour period.&#160; This was largely a rehash for me, which was very good, with a little bit of new material thrown in.&#160; (There is a new <a href="http://www.pragprog.com/news/pomodoro-technique-illustrated-grails-in-print">Pomodoro book pragprog is publishing</a> so there was a brief overview of Pomodoro included with a plug – which I fully support at free/sponsored events; I had just read the RSS post earlier in the day so I would have been disappointed if it were skipped!)&#160; His slides were good – not distracting – and the presentation was delivered with animation and some really well placed humor.</p>
<p>Points [I remember]:</p>
<p><a href="http://en.wikipedia.org/wiki/Dreyfus_model_of_skill_acquisition">Dreyfus Model of Skill Acquisition</a></p>
<p><a href="http://en.wikipedia.org/wiki/Mind_mapping">Mind mapping</a> (easily my favorite technique I learned from the book)</p>
<p>You cannot execute a great idea if you don’t exercise your brain to get it to produce them – write down your ideas, all of them</p>
<p>Meditation</p>
<p>How context switching and multitasking damages productivity</p>
<p>Have a personal wiki</p>
<p><a href="http://en.wikipedia.org/wiki/Study_group">Book study groups</a> – going to suggest replacing our low value formal code reviews with this in an on-going basis</p>
<p>&#160;</p>
<p>Finally Andy said it may be possible in the near future to get some of <a href="http://www.pragprog.com/">pragprog</a>’s non-code books in an audio book format which for anyone who has a long commute is very good news.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.deploymentzone.com/2009/10/22/andy-huntpragmatic-thinking-and-learning-presentation-rjug/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I&#8217;m Dangerous with Ruby!</title>
		<link>http://www.deploymentzone.com/2009/10/22/im-dangerous-with-ruby/</link>
		<comments>http://www.deploymentzone.com/2009/10/22/im-dangerous-with-ruby/#comments</comments>
		<pubDate>Thu, 22 Oct 2009 04:24:14 +0000</pubDate>
		<dc:creator>Chuck</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.deploymentzone.com/2009/10/22/im-dangerous-with-ruby/</guid>
		<description><![CDATA[My solution was selected as the winning solution for RubyLearning.com’s RPCFN #2 “Average Arrival Time for A Flight.”
This challenge involved averaging times of the day without the actual day in the context.&#160; When I first started to tackle the problem I thought to myself that this will be very easy.&#160; Then I hit the “no [...]]]></description>
			<content:encoded><![CDATA[<p>My solution was selected as the winning solution for <a href="http://www.rubylearning.com">RubyLearning.com’s</a> <acronym title="Ruby Programming Challenge For Newbies">RPCFN</acronym> #2 “<a href="http://rubylearning.com/blog/2009/10/08/rpcfn-average-arrival-time-for-a-flight-2/">Average Arrival Time for A Flight</a>.”</p>
<p>This challenge involved averaging times of the day without the actual day in the context.&#160; When I first started to tackle the problem I thought to myself that this will be very easy.&#160; Then I hit the “no day” context and realized that this problem was much tougher than I anticipated.&#160; When I finally saw the posted solutions including <a href="https://gist.github.com/4f6807eef49064027a3c">Chris Strom’s</a> (<a href="http://japhr.blogspot.com/">blog</a>) it was like decades old high school math came rushing back to me.&#160; I would have never thought of plotting points on a graph but now that I’ve been exposed I’m certain I will never forget it!</p>
<p>My friend [and commuting body] Matt and I talked through the problem during our drive home as we sat in Virginia I-495 outer loop and I-95S traffic.&#160; He had some ideas about plotting the problem linearly around 0 but ultimately I ended up going with making assumptions about how close the provided times were to midday and midnight.</p>
<pre class="brush: ruby;">require 'time'

SECONDS_IN_DAY = 86400
MIDNIGHT = Time.parse(&quot;12:00AM&quot;).to_i
MIDDAY = Time.parse(&quot;12:00PM&quot;).to_i

def average_time_of_day(times)
  seconds = []
  times.each {|time| seconds &lt;&lt; Time.parse(time).to_i}
  seconds.sort!
  if (seconds.first - MIDNIGHT) &lt; (seconds.last - MIDDAY)
    seconds.map! {|s| s &lt; MIDDAY ? s += SECONDS_IN_DAY : s }
  end
  Time.at(seconds.inject { |sum,n| sum += n }.to_f / seconds.length).strftime(&quot;%I:%M%p&quot;).downcase
end</pre>
<p>&#160;</p>
<p>Gist: <a title="https://gist.github.com/5b371226faf83af50d7e" href="https://gist.github.com/5b371226faf83af50d7e">https://gist.github.com/5b371226faf83af50d7e</a></p>
<p>Interview: <a title="http://rubylearning.com/blog/2009/10/22/charles-feduke-winner-rpcfn-2/" href="http://rubylearning.com/blog/2009/10/22/charles-feduke-winner-rpcfn-2/">http://rubylearning.com/blog/2009/10/22/charles-feduke-winner-rpcfn-2/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.deploymentzone.com/2009/10/22/im-dangerous-with-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Temp Files and Ruby 1.8.6 on Windows</title>
		<link>http://www.deploymentzone.com/2009/09/29/temp-files-and-ruby-1-8-6-on-windows/</link>
		<comments>http://www.deploymentzone.com/2009/09/29/temp-files-and-ruby-1-8-6-on-windows/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 05:56:30 +0000</pubDate>
		<dc:creator>Chuck</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.deploymentzone.com/2009/09/29/temp-files-and-ruby-1-8-6-on-windows/</guid>
		<description><![CDATA[Working on the RPCFN: Shift Subtitle I found myself having to work with files input as a stream (or anyway that’s how I wanted to approach the problem; streams are efficient to me).&#160; In order to give my code any sort of unit testing justice I needed to mock the file system.&#160; The challenge expressly [...]]]></description>
			<content:encoded><![CDATA[<p>Working on the <a href="http://rubylearning.com/blog/2009/09/24/rpcfn-shift-subtitle-1/">RPCFN: Shift Subtitle</a> I found myself having to work with files input as a stream (or anyway that’s how I wanted to approach the problem; streams are <em>efficient</em> to me).&#160; In order to give my code any sort of unit testing justice I needed to mock the file system.&#160; The challenge expressly forbids any Ruby gems from being used in the script itself – and maybe by extension the unit tests as well – but I could not see devoting the time necessary to write a mocking framework for the file system.</p>
<p>I found a gem that does precisely what I needed named <a href="http://devver.net/blog/2009/08/unit-testing-filesystem-interaction/">Construct</a>.&#160; Unfortunately there is a <a href="http://redmine.ruby-lang.org/issues/show/1494">bug with Ruby 1.8.6 on Windows</a> in regards to clean up of temp files.&#160; The problem is that when attempting to clean up a Errno::EACCES is raised causing the unit test to fail (or you to write a lot of rescue blocks).</p>
<p>A workaround I came up with was to replace the rmtree method in the Pathname class within my unit test to perform no clean up.&#160; Not the best approach I am sure, but it let me get on with my work.</p>
<pre class="brush: ruby;"># something_test.rb
require &quot;test/unit&quot;
require 'construct'
require 'something'

class Pathname
  # windows has problems with temp files created by Ruby
  # http://redmine.ruby-lang.org/issues/show/1494
  def rmtree
    nil
  end
end

class SomethingTest &lt; Test::Unit::TestCase
   # test methods...
end</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.deploymentzone.com/2009/09/29/temp-files-and-ruby-1-8-6-on-windows/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Ruby: Mocking Kernel Exit</title>
		<link>http://www.deploymentzone.com/2009/09/26/ruby-mocking-kernel-exit/</link>
		<comments>http://www.deploymentzone.com/2009/09/26/ruby-mocking-kernel-exit/#comments</comments>
		<pubDate>Sat, 26 Sep 2009 14:45:03 +0000</pubDate>
		<dc:creator>Chuck</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[mock]]></category>
		<category><![CDATA[rspec]]></category>

		<guid isPermaLink="false">http://www.deploymentzone.com/2009/09/26/ruby-mocking-kernel-exit/</guid>
		<description><![CDATA[I’m working on the RubyLearning blog’s Ruby Programming Challenge for Newbies #1 to learn the language – I’ve done a bit with Rails and some admin scripts so I could use the exposure.&#160; Since I love TDD approaching Ruby development through RSpec is only natural, but it was a pain in the ass trying to [...]]]></description>
			<content:encoded><![CDATA[<p>I’m working on the RubyLearning blog’s <a href="http://rubylearning.com/blog/2009/09/24/rpcfn-shift-subtitle-1/">Ruby Programming Challenge for Newbies #1</a> to learn the language – I’ve done a bit with Rails and some admin scripts so I could use the exposure.&#160; Since I love TDD approaching Ruby development through RSpec is only natural, but it was a pain in the ass trying to find how I could have RSpec verify that my program properly exited when certain conditions were met.&#160; <a href="http://stackoverflow.com/questions/1480537/how-can-i-validate-exits-and-aborts-in-rspec">Here’s how I solved it</a>, reposted here:</p>
<pre class="brush: ruby;"># something.rb
class Something
    def initialize(kernel=Kernel)
        @kernel = kernel
    end

    def process_arguments(args)
        @kernel.exit
    end
end

# something_spec.rb
require 'something'
describe Something do
    before :each do
        @mock_kernel = mock(Kernel)
        @mock_kernel.stub!(:exit)
    end

    it &quot;should exit cleanly&quot; do
        s = Something.new(@mock_kernel)
        @mock_kernel.should_receive(:exit)
        s.process_arguments([&quot;-h&quot;])
    end
end</pre>
<p>What I learned was that you can define a constructor with optional arguments (in this case, initialize(kernel=Kernel) and then proceed to use @kernel’s methods instead of the methods that Kernel provides when you do not specify a class instance.&#160; With a properly mocked and stubbed exit method in my spec things operate as expected.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.deploymentzone.com/2009/09/26/ruby-mocking-kernel-exit/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Side Effect Free Retrieval Pattern</title>
		<link>http://www.deploymentzone.com/2009/07/16/side-effect-free-retrieval-pattern/</link>
		<comments>http://www.deploymentzone.com/2009/07/16/side-effect-free-retrieval-pattern/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 21:11:00 +0000</pubDate>
		<dc:creator>Chuck</dc:creator>
				<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://www.deploymentzone.com/2009/07/16/side-effect-free-retrieval-pattern/</guid>
		<description><![CDATA[A colleague of mine and I were discussing good verb replacements for “GetOrCreate” data retrieval patterns, where the “Create” part is responsible for the instantiation of a new instance of something.&#160; While the pattern I present here did not solve his particular problem, its at least worth sharing.&#160; Its obvious, and probably in use commonly [...]]]></description>
			<content:encoded><![CDATA[<p>A colleague of mine and I were discussing good verb replacements for “GetOrCreate” data retrieval patterns, where the “Create” part is responsible for the instantiation of a new instance of something.&#160; While the pattern I present here did not solve his particular problem, its at least worth sharing.&#160; Its obvious, and probably in use commonly already, but I figure its worth noting.</p>
<p>Essentially the goal is to get away from a “GetOrCreate” master method call and just have two methods: Get(args) and Get(args, Foo default) and then leave the responsibility of default generation up to Foo.&#160; This way there’s no unintended side effects and you don’t have to explicitly coalesce (though with this pattern you could as easily coalesce; strictly speaking it isn’t as “discoverable”)…</p>
<pre class="brush: csharp; toolbar: false;">var foo = FooService.Get(23) ?? new Foo { ... };</pre>
<p>So here’s the pattern defined in code:</p>
<pre class="brush: csharp;">public class Foo : ICloneable
{
    private readonly static Foo __default =
        new Foo { Bar = &quot;...&quot;, Baz = Int32.MinValue };

    public string Bar { get; set; }
    public int Baz { get; set; }

    public static Foo Default()
    {
        return (Foo)__default.Clone();
    }

    public object Clone()
    {
        return new Foo { Bar = this.Bar, Baz = this.Baz };
    }
}

public class FooService
{
    public Foo Get(int baz)
    {
        // retrieve from data store...
        return null;
    }

    public Foo Get(int baz, Func&lt;Foo&gt; @default)
    {
        return Get(baz) ?? @default.Invoke();
    }
}</pre>
<p>You’ll see that any associated overhead with Clone only occurs if Get(baz) returns null.&#160; I have specifically stepped around the common naming standard of “GetDefault()” for the function – its named like a property - because its intended usage is as follows:</p>
<pre class="brush: csharp; toolbar: false;">var foo = new FooService().Get(12, Foo.Default);</pre>
<p>
  <br />An ICloneable reference type is pretty much required, <a href="http://www.stevecooper.org/2009/07/14/immutable-objects-in-c/">though any immutable reference type</a> could get by without cloning because any changes gives you a new copy of that type.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.deploymentzone.com/2009/07/16/side-effect-free-retrieval-pattern/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Trying out SyntaxHighligher and PreCode</title>
		<link>http://www.deploymentzone.com/2009/04/29/trying-out-syntaxhighligher-and-precode/</link>
		<comments>http://www.deploymentzone.com/2009/04/29/trying-out-syntaxhighligher-and-precode/#comments</comments>
		<pubDate>Wed, 29 Apr 2009 18:10:03 +0000</pubDate>
		<dc:creator>Chuck</dc:creator>
				<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://www.deploymentzone.com/2009/04/29/trying-out-syntaxhighligher-and-precode/</guid>
		<description><![CDATA[Just making sure this is correct.&#160; By this I mean PreCode (requires Windows Live Writer 2009) with SyntaxHighligher setup.&#160; PreCode is also a stand alone program.
&#160;
public bool Validate(IValidationDictionary modelState, string prefix)
{
    // xVal example code
    var dataAnnotationErrors = from prop in TypeDescriptor.GetProperties(_entity).Cast&#60;PropertyDescriptor&#62;()
        [...]]]></description>
			<content:encoded><![CDATA[<p>Just making sure this is correct.&#160; By this I mean <a href="http://precode.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=25426#ReleaseFiles">PreCode</a> (requires <a href="http://windowslivewriter.spaces.live.com/">Windows Live Writer 2009</a>) with <a href="http://alexgorbatchev.com/wiki/SyntaxHighlighter">SyntaxHighligher</a> setup.&#160; PreCode is also a stand alone program.</p>
<p>&#160;</p>
<pre class="brush: csharp;">public bool Validate(IValidationDictionary modelState, string prefix)
{
    // xVal example code
    var dataAnnotationErrors = from prop in TypeDescriptor.GetProperties(_entity).Cast&lt;PropertyDescriptor&gt;()
           from attribute in prop.Attributes.OfType&lt;ValidationAttribute&gt;()
           where !attribute.IsValid(prop.GetValue(_entity))
           select new ErrorInfo(prop.Name, attribute.FormatErrorMessage(string.Empty), _entity);

    var brokenRules = GetBrokenRules();

    if (!String.IsNullOrEmpty(prefix))
        prefix += &quot;.&quot;;

    if (dataAnnotationErrors.Any())
        dataAnnotationErrors.ForEach(ei =&gt; modelState.AddError(prefix + ei.PropertyName, ei.ErrorMessage));
    if (brokenRules.Any())
        brokenRules.ForEach(rule =&gt; modelState.AddError(prefix + rule.Property, rule.Message));

    return modelState.IsValid;
}</pre>
<p>&#160;</p>
<p>There is a “Fix Indentation” button in PreCode.&#160; I am in love.</p>
<p><strike>Now just to setup the clipboard SWF thing.</strike></p>
<p>I should seriously consider a theme with a wider content area.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.deploymentzone.com/2009/04/29/trying-out-syntaxhighligher-and-precode/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Web Application csproj =&gt; Mvc csproj</title>
		<link>http://www.deploymentzone.com/2009/04/15/web-application-csproj-mvc-csproj/</link>
		<comments>http://www.deploymentzone.com/2009/04/15/web-application-csproj-mvc-csproj/#comments</comments>
		<pubDate>Wed, 15 Apr 2009 15:07:33 +0000</pubDate>
		<dc:creator>Chuck</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.deploymentzone.com/2009/04/15/web-application-csproj-mvc-csproj/</guid>
		<description><![CDATA[Since you can run classic web forms along side MVC its useful to know how to update your *.csproj project file so Visual Studio shows you the MVC items you can add to your project when you add a new item.&#160; To do this, after installing MVC (and .NET 3.5 SP1 if you haven't yet):

Unload [...]]]></description>
			<content:encoded><![CDATA[<p>Since you can run classic web forms along side MVC its useful to know how to update your *.csproj project file so Visual Studio shows you the MVC items you can add to your project when you add a new item.&#160; To do this, after installing MVC (and .NET 3.5 SP1 if you haven't yet):</p>
<ol>
<li>Unload your project through Solution Explorer (right-click, unload)</li>
<li>Edit your *.csproj (yes you can do this in Visual Studio, right click the unloaded project node in Solution Explorer, Edit *.proj)</li>
<li>In the &lt;ProjectTypeGuids /&gt; node add the GUID {603c0e0b-db56-11dc-be95-000d561079b0}; (the semi-colon is important if you prepend it to the exiting list, which is what I did)</li>
<li>Add &lt;MvcBuildViews&gt;false&lt;/MvcBuildViews&gt; as a sibling of the &lt;ProjectTypeGuids /&gt; node</li>
<li>Reload the project</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.deploymentzone.com/2009/04/15/web-application-csproj-mvc-csproj/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hudson Continuous Integration</title>
		<link>http://www.deploymentzone.com/2009/04/15/hudson-continuous-integration/</link>
		<comments>http://www.deploymentzone.com/2009/04/15/hudson-continuous-integration/#comments</comments>
		<pubDate>Wed, 15 Apr 2009 05:34:57 +0000</pubDate>
		<dc:creator>Chuck</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.deploymentzone.com/2009/04/15/hudson-continuous-integration/</guid>
		<description><![CDATA[So Java is good for something other than an abstract white coffee cup on an orange background in my system tray after all!
I am working with a friend on an attempt at best practices MVC development using the whole nine yards (DI, TDD, CI, git, SVN).&#160; I had sort of dreaded the part where I [...]]]></description>
			<content:encoded><![CDATA[<p>So Java is good for something other than an abstract white coffee cup on an orange background in my system tray after all!</p>
<p>I am working with a friend on an attempt at best practices MVC development using the whole nine yards (DI, TDD, CI, git, SVN).&#160; I had sort of dreaded the part where I had to setup CruiseControl.NET because, well, I hate editing XML files and I hate configuring CC.NET.&#160; Then I stumbled across <a href="http://callport.blogspot.com/2009/02/hudson-for-net-projects.html">Chris Allport's blog post on Hudson for .NET Projects</a>.&#160; Hudson is a continuous integration server written in Java and its trivially easy to install, setup, and get running.&#160; On my workstation it took less than 15 minutes to have a working build.&#160; My Windows Home Server (Windows Server 2003) it was a bit more taxing as I had no build environment so I'll detail the steps shortly.</p>
<p>Some of the advantages I see from Hudson, other than very easy to setup and configure:</p>
<ul>
<li>not a lot of hand editing XML files (you could I suppose)</li>
<li>plugins - loads and loads - install from the web UI, no manual steps necessary</li>
<li>has built in &quot;install as Windows service&quot; option</li>
<ul>
<li>if you do this, do it first for optimal user experience - if you set your hudson directory to something like &quot;c:\hudson&quot; and install as a Windows Service your previous settings will appear to be lost (but they aren't, they are just under the ~\.hudson folder Hudson uses by default)</li>
</ul>
<li>easy to manage security or for the masochistic LDAP integrated security</li>
<li>very clean, responsive UI</li>
<li>build reports, trends, status</li>
<li>RSS feeds for build statuses per project plus email notification</li>
<li>integrated textual help on just about everything</li>
</ul>
<p>Its rare to find a software package that just feels enjoyable to use.&#160; Hudson is one of those software packages.&#160; It absolutely has displaced CC.NET for CI for me.</p>
<p>&#160;</p>
<p><a href="http://www.deploymentzone.com/wp-content/uploads/2009/04/image1.png"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="170" alt="image" src="http://www.deploymentzone.com/wp-content/uploads/2009/04/image-thumb1.png" width="244" border="0" /></a>&#160;</p>
<p>So on my bare Windows Server 2003 I had to install the following things (download links may not work due to session identifiers but you should be able to find everything after a cursory search):</p>
<ul>
<li>Java Runtime Environment 1.6 (1.5+ is required) [<a href="http://dl8-cdn-09.sun.com/s/ESD7/JSCDL/jdk/6u13-b03/jre-6u13-windows-i586-p-iftw.exe?e=1239757767314&amp;h=2901eea4f74b6fb723dacb725011940f/&amp;filename=jre-6u13-windows-i586-p-iftw.exe">download</a>]</li>
<li>.NET Framework 3.5 with SP1 [<a href="http://download.microsoft.com/download/2/0/e/20e90413-712f-438c-988e-fdaa79a8ac3d/dotnetfx35.exe">download</a>] (required a reboot)</li>
<li>Hudson (latest stable) [<a href="https://hudson.dev.java.net/files/documents/2402/132188/hudson.war">download</a> - can go out of date, look for the latest on the <a href="https://hudson.dev.java.net/servlets/ProjectDocumentList?folderID=2761&amp;expandFolder=2761&amp;folderID=0">Hudson releases page</a>]</li>
<ul>
<li>I placed the <font face="Lucida Console" size="1">hudson.war</font> file in <font face="Lucida Console" size="1">c:\hudson</font> and gave the local system (Network Service) account privileges to this folder</li>
</ul>
<li>Ruby (for Rake, optional if you use NAnt or something else) [<a href="http://de.mirror.rubyforge.org/rubyinstaller/ruby186-26.exe">download</a> - this link can easily go out of date, you'll want the latest version of Ruby as always]</li>
<ul>
<li>after installation, Command Prompt and cd <font face="Lucida Console" size="1">c:\ruby</font> then <font face="Lucida Console" size="1">gem install rake</font></li>
</ul>
<li>Windows SDK for Windows Server 2008 and .NET Framework 3.5 [<a href="http://download.microsoft.com/download/2/3/f/23f86204-39ee-4cd7-9a51-db19c9a8f8c4/Setup.exe">download</a>]</li>
<ul>
<li>Supported platforms: Windows Server 2003, amongst many others - <em>don't let the name fool you!</em></li>
<li>There is an ISO version and web installer - I went for the web installer and paired down the installed components to just the .NET SDK stuff</li>
</ul>
<li>(Optional) ASP.NET MVC if you are compiling an MVC application [<a href="http://download.microsoft.com/download/A/6/8/A68968AE-DE1D-4FA4-A98A-B74042C6090D/AspNetMVC1.msi">download</a>]</li>
<li>(Optional) Visual Studio for C# Express [<a href="http://www.microsoft.com/express/vcsharp/">home page</a>]</li>
</ul>
<p>I also had to copy my workstation's <a href="http://www.deploymentzone.com/downloads/msbuildtargets.zip">MS Build targets</a> (found, on Vista 64 by default at: <font face="Lucida Console" size="1">C:\Program Files (x86)\MSBuild\Microsoft</font> and ended up on my Windows 2003 Server 32-bit at <font face="Lucida Console"><font size="1">Program Files\MSBuild\Microsoft </font></font>[<a href="http://www.deploymentzone.com/downloads/msbuildtargets.zip">download</a>]</p>
<p>After you're all setup, you can start Hudson by running:</p>
<blockquote><p><font face="Lucida Console" size="1">java -jar c:\hudson\hudson.war*</font></p>
</blockquote>
<p>then you can browse to <a href="http://localhost:8080">http://localhost:8080</a> and begin your configuration - but if you're going to <a href="http://wiki.hudson-ci.org/display/HUDSON/Installing+Hudson+as+a+Windows+service">install Hudson as a Windows Service</a> make sure to turn that on first so you don't waste time double configuring!&#160; Installing as a service was very easy but I did have to go to Computer Management &gt; Services and manually restart Hudson due to a Java NullPointerException caused when the web UI tried to launch the service manually.&#160; No big deal.</p>
<p>I installed the Rake plugin and the NUnit plugin.&#160; Once doing this I restarted the service (there is a button after plugin installation to do this, and restarting the service from the service hosted HTTP server works fine).</p>
<p>After fiddling around with some settings (specifically email - I created a gmail account and used smtp.gmail.com over SSL for my build server) I moved onto configuring a job.&#160; Some settings I made for my build were:</p>
<ul>
<li>Advanced Project Options &gt; Use custom workspace - I created <font face="Lucida Console" size="1">c:\hudson\workspaces\specialorder</font> and choose that as my custom workspace.&#160; Be foreward: this ended up causing my repository to be placed under <font face="Lucida Console" size="1">c:\hudson\workspaces\specialorder\specialorder</font> since I also set the Source Code Management &gt; Local module directory (optional) value to &quot;specialorder&quot;</li>
<li>For building I used rake because, well, its ridiculously easy.&#160; I used the <a href="http://callport.blogspot.com/2009/03/getting-started-with-rake-on-net.html">example Rakefile.rb found on Chris Allport's blog &quot;Getting Started with Rake on .NET Projects&quot;</a> as my basis, the resulting Rakefile.rb was placed in my source control repository's <font face="Lucida Console" size="1">trunk\</font> directory and checked in.</li>
</ul>
<pre class="csharpcode">task :<span class="kwrd">default</span> =&gt; :build

task :build =&gt; [:clean, :compile, :test]

task :clean do
  FileUtils.rm_rf(<span class="str">&quot;build&quot;</span>) </pre>
<pre class="csharpcode">  <span class="rem"># this doesn't do anything for me yet - have to conf. projects to &quot;..&quot;</span>
<span class="kwrd">end</span>

task :compile do
params = <span class="str">'/t:Rebuild /nologo /v:m /p:Configuration=&quot;Debug&quot; src\SiameseHead.SpecialOrder.sln'</span>
msbuid = <span class="str">'C:\\WINDOWS\\Microsoft.NET\\Framework\\v3.5\\MSBuild.exe'</span>
sh <span class="str">&quot;#{msbuid} #{params}&quot;</span>
<span class="kwrd">end</span>

task :test do
  <span class="rem"># FileUtils.cd 'build\\Debug'</span>
  <span class="rem"># exec &quot;..\\..\\tools\\nunit\\nunit-console.exe TestStuffInDotNet.dll&quot;</span>
end</pre>
<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>
<p>You can see I haven't tried setting up automatic unit testing yet, but I will shortly.</p>
<ul>
<li>For Build &gt; Advanced I specified the full path to the <font face="Lucida Console" size="1">Rakefile.rb</font> (<font face="Lucida Console" size="1">C:\hudson\workspaces\specialorder\specialorder\trunk\Rakefile.rb</font>) and the full path for the Rake working directory (<font face="Lucida Console" size="1">C:\hudson\workspaces\specialorder\specialorder\trunk\</font>); I was getting &quot;invalid path&quot; errors from Rake otherwise</li>
</ul>
<p>Once you've saved your job you should be able to build it using the &quot;Build Now&quot; link and work your way through any errors (just click on failed builds then look for the &quot;Console Output&quot; link on the left side of the page).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.deploymentzone.com/2009/04/15/hudson-continuous-integration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Lightweight Test Automation Framework</title>
		<link>http://www.deploymentzone.com/2009/03/30/using-lightweight-test-automation-framework/</link>
		<comments>http://www.deploymentzone.com/2009/03/30/using-lightweight-test-automation-framework/#comments</comments>
		<pubDate>Mon, 30 Mar 2009 12:09:33 +0000</pubDate>
		<dc:creator>Chuck</dc:creator>
				<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://www.deploymentzone.com/2009/03/30/using-lightweight-test-automation-framework/</guid>
		<description><![CDATA[The Lightweight Test Automation Framework is a browser automation framework like WatiN and Selenium RC that allows you to create automated integration tests.&#160; Its a beta release from MS and can be found on Codeplex at:
http://aspnet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=22739
I first read about it from Steve Sanderson's blog where he describes how to use it with an ASP.NET MVC [...]]]></description>
			<content:encoded><![CDATA[<p>The Lightweight Test Automation Framework is a browser automation framework like <a href="http://watin.sourceforge.net/">WatiN</a> and <a href="http://seleniumhq.org/projects/remote-control/">Selenium RC</a> that allows you to create automated integration tests.&#160; Its a beta release from MS and can be found on <a href="http://www.codeplex.com">Codeplex</a> at:</p>
<p><a title="http://aspnet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=22739" href="http://aspnet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=22739">http://aspnet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=22739</a></p>
<p>I first read about it from <a href="http://blog.codeville.net/2009/03/27/first-steps-with-lightweight-test-automation-framework/">Steve Sanderson's blog</a> where he describes how to use it with an ASP.NET MVC project.</p>
<p>I am supporting a legacy web forms application and have a typical web application setup so I'll explain what I did to get up and running in a matter of minutes with LTAF.</p>
<ol>
<li>Download <a href="http://aspnet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=22739">LTAF</a>; you can use the &quot;... for ASP.NET Samples&quot; link and pull the *.dll out of the Bin folder and the contents of the Test folder, or you could build from source using the &quot;... for ASP.NET Source&quot;</li>
<li>Create a new Class Library project in your solution and name it appropriately - <em>Company.Tests.Integration.Site</em> - for example</li>
<ol>
<li>For this project's properties alter the output assembly's name to begin with <em>App_Code</em> - this will slightly speed up web test load times and can help solve problems you may experience if your web application references tons of assemblies, i.e. <em>App_CodeCompany.Tests.Integration.Site</em></li>
</ol>
<li>Add a reference to <em>Microsoft.Web.Testing.Light.dll </em>to your <em>Company.Tests.Integration.Site</em> project</li>
<li><strong>Copy </strong>and add to your <em>web project (Company.Site)</em> the <em>Test</em> folder; you can name the folder anything you want and you don't strictly have to add it to your project but I did for convenience for Start &gt; Debug</li>
<ol>
<li>Remember to alter your build process to remove the <em>Test</em> folder for production releases</li>
</ol>
<li>Alter the <em>web.config</em> file for your <em>Company.Site</em> to allow anonymous access to the <em>Test</em> folder:</li>
<pre class="code"><span style="color: blue">&lt;</span><span style="color: #a31515">location </span><span style="color: red">path</span><span style="color: blue">=</span>&quot;<span style="color: blue">Test</span>&quot;<span style="color: blue">&gt;
  &lt;</span><span style="color: #a31515">system.web</span><span style="color: blue">&gt;
    &lt;</span><span style="color: #a31515">authorization</span><span style="color: blue">&gt;
      &lt;</span><span style="color: #a31515">allow </span><span style="color: red">users</span><span style="color: blue">=</span>&quot;<span style="color: blue">*</span>&quot; <span style="color: blue">/&gt;
    &lt;/</span><span style="color: #a31515">authorization</span><span style="color: blue">&gt;
  &lt;/</span><span style="color: #a31515">system.web</span><span style="color: blue">&gt;
&lt;/</span><span style="color: #a31515">location</span><span style="color: blue">&gt;</span></pre>
<p>  <a href="http://11011.net/software/vspaste"></a></p>
<ol>
<li>Again, remember to alter your build process to eliminate this node from your production web.config</li>
</ol>
<li>Add a reference to your integration test project, <em>Company.Tests.Integration.Site</em>, to your web application, <em>Company.Site</em></li>
<li>Let's test the login page (here I assume that &quot;Login.aspx&quot; is the name of your login page and its in the root of the application and you've used an &lt;asp:Login /&gt; control)...</li>
<ol>
<li>Create a new class <em>LoginTests </em>in your <em>Company.Tests.Integration.Site</em> project and <strong>eliminate</strong> the file's contents - it is very important that all tests exist <strong>outside</strong> of a namespace</li>
<li>Paste this code into the body of your <em>LoginTests.cs</em> file:</li>
<pre class="code"><span style="color: blue">using </span>Microsoft.Web.Testing.Light;

[<span style="color: #2b91af">WebTestClass</span>]
<span style="color: blue">public class </span><span style="color: #2b91af">LoginTests
</span>{
    [<span style="color: #2b91af">WebTestMethod</span>]
    <span style="color: blue">public void </span>SignInAndSignOut()
    {
        <span style="color: blue">var </span>page = <span style="color: blue">new </span><span style="color: #2b91af">HtmlPage</span>(<span style="color: #a31515">&quot;Login.aspx&quot;</span>);

        page.Elements.Find(<span style="color: #a31515">&quot;UserName&quot;</span>).SetText(<span style="color: #a31515">&quot;someuser&quot;</span>);
        page.Elements.Find(<span style="color: #a31515">&quot;Password&quot;</span>).SetText(<span style="color: #a31515">&quot;yourPW&quot;</span>);
        page.Elements.Find(<span style="color: #a31515">&quot;LoginButton&quot;</span>).Click(<span style="color: #2b91af">WaitFor</span>.Postback);

        <span style="color: green">// you'll need to determine what a good landmark for your
        // application is upon successful login
        </span><span style="color: blue">var </span>logoutLink = page.Elements.Find(<span style="color: #a31515">&quot;LogoutHyperlink&quot;</span>);
        <span style="color: #2b91af">Assert</span>.AreEqual(<span style="color: #a31515">&quot;[Logout]&quot;</span>, logoutLink.GetInnerText());

        logoutLink.Click(<span style="color: #2b91af">WaitFor</span>.Postback);

        <span style="color: #2b91af">Assert</span>.IsNotNull(page.Elements.Find(<span style="color: #a31515">&quot;LoginButton&quot;</span>));
    }
}</pre>
<p>    <a href="http://11011.net/software/vspaste"></a></ol>
<li>Set your <em>Company.Site</em> as the startup project if its not already, and <em>Tests/Default.aspx</em> as the startup page; run from Visual Studio</li>
</ol>
<p>Magic!&#160; This is my first use of a browser automation framework for integration testing and while it has its pitfalls, it does work and looks very promising.</p>
<h5>Notes</h5>
<ul>
<li>Looks like all your integration tests must exist in the same assembly</li>
<ul>
<li>Source code for LTAF is available so making this a configuration option is a possibility</li>
</ul>
<li>All tests must exist outside of namespaces</li>
<li>Prefixing your integration tests assembly with <em>App_Code </em>can help work around assembly loading problems as the test runner searches for <em>WebTestClass</em> attributes</li>
<li>Remember to have your production build process eliminate the <em>Tests</em> folder and associated integration test assembly</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.deploymentzone.com/2009/03/30/using-lightweight-test-automation-framework/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Cheap Deep Copy</title>
		<link>http://www.deploymentzone.com/2009/01/08/cheap-deep-copy/</link>
		<comments>http://www.deploymentzone.com/2009/01/08/cheap-deep-copy/#comments</comments>
		<pubDate>Thu, 08 Jan 2009 22:38:36 +0000</pubDate>
		<dc:creator>Chuck</dc:creator>
				<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://www.deploymentzone.com/2009/01/08/cheap-deep-copy/</guid>
		<description><![CDATA[So I had written a SmtpClientWrapper for System.Net.SmtpClient because the aforementioned class implements no interface making it impossible to perform dependency injection using it (as anyone who has to unit test any sort of email functionality can attest to).&#160; Then I had the idea that during production we may want to mirror email messages sent [...]]]></description>
			<content:encoded><![CDATA[<p>So I had written a SmtpClientWrapper for System.Net.SmtpClient because the aforementioned class implements no interface making it impossible to perform dependency injection using it (as anyone who has to unit test any sort of email functionality can attest to).&nbsp; Then I had the idea that during production we may want to mirror email messages sent to a debugging email address so I also made a MirrorSmtpClientDecorator.&nbsp; Herein lies the problem - System.Net.MailMessage does not implement ICloneable and the MirrorSmtpClientDecorator.Send(MailMessage) either needs a copy or its going adversely affect MailMessage with a side affect (by altering the MailMessage.To MailAddressCollection for a second message sent to the debugging email addresses).&nbsp; I explored numerous ways to copy MailMessage and eventually I resorted to some brute force extension methods (to ObjectModel.Collection&lt;T&gt;; ShallowCopy and Replace, suck I know) but during my research I discovered some older MemoryStream serialization I refactored and felt its worth sharing.</p>
<p>The problem with this approach is that the class you want to deep copy requires that it be marked with the SerializableAttribute.&nbsp; I've noticed that a portion of my time is spent writing hackarounds for classes in the .NET BCL and MailMessage is no exception - yup no ICloneable and no SerializableAttribute either.</p>
<pre class="code"><span style="color: blue">public class </span><span style="color: #2b91af">Serializer
</span>{
    <span style="color: blue">public static void </span>Serialize(<span style="color: #2b91af">Stream </span>target, <span style="color: blue">object </span>source)
    {
        <span style="color: blue">var </span>formatter = <span style="color: blue">new </span><span style="color: #2b91af">BinaryFormatter</span>();
        formatter.Serialize(target, source);
    }

    <span style="color: blue">public static </span>T Deserialize&lt;T&gt;(<span style="color: #2b91af">Stream </span>source) <span style="color: blue">where </span>T : <span style="color: blue">class
    </span>{
        <span style="color: blue">var </span>formatter = <span style="color: blue">new </span><span style="color: #2b91af">BinaryFormatter</span>();
        <span style="color: blue">var </span>obj = (T)formatter.Deserialize(source);
        <span style="color: blue">return </span>obj;
    }<br>}</pre>
<pre class="code">&nbsp;</pre>
<pre class="code"><span style="color: blue">public class </span><span style="color: #2b91af">MemorySerializer</span>&lt;T&gt; : <span style="color: #2b91af">IDisposable </span><span style="color: blue">where </span>T : <span style="color: blue">class
</span>{
    <span style="color: blue">#region </span>Member Variables
    <span style="color: blue">private readonly </span><span style="color: #2b91af">MemoryStream </span>_ms;
    <span style="color: blue">#endregion

    #region </span>Constructors
    <span style="color: blue">public </span>MemorySerializer(<span style="color: #2b91af">MemoryStream </span>ms)
    {
        _ms = ms;
    }

    <span style="color: blue">public </span>MemorySerializer()
    {
        _ms = <span style="color: blue">new </span><span style="color: #2b91af">MemoryStream</span>();
    }
    <span style="color: blue">#endregion

    #region </span>Methods
    <span style="color: blue">public </span><span style="color: #2b91af">MemorySerializer</span>&lt;T&gt; Serialize(T obj)
    {
        <span style="color: #2b91af">Serializer</span>.Serialize(_ms, obj);
        _ms.Position = 0;
        <span style="color: blue">return this</span>;
    }
    <span style="color: blue">public </span>T Deserialize()
    {
        <span style="color: blue">return </span><span style="color: #2b91af">Serializer</span>.Deserialize&lt;T&gt;(_ms);
    }
    <span style="color: blue">#endregion

    #region </span>Implementation of IDisposable
    <span style="color: blue">public void </span>Dispose()
    {
        <span style="color: blue">if </span>(_ms == <span style="color: blue">null</span>)
            <span style="color: blue">return</span>;
        <span style="color: blue">try
        </span>{
            _ms.Close();
        }
        <span style="color: blue">finally
        </span>{
            _ms.Dispose();
        }
    }
    <span style="color: blue">#endregion
</span>}</pre>
<p><a href="http://11011.net/software/vspaste"></a>
<pre class="code"><span style="color: blue">public static class </span><span style="color: #2b91af">ObjectUtility
</span>{
    <span style="color: gray">/// &lt;summary&gt;
    /// </span><span style="color: green">Creates a deep copy of an object for any object which
    </span><span style="color: gray">/// </span><span style="color: green">supports binary serialization.
    </span><span style="color: gray">/// &lt;/summary&gt;
    /// &lt;typeparam name="T"&gt;</span><span style="color: green">Type to serialize/deserialize.</span><span style="color: gray">&lt;/typeparam&gt;
    /// &lt;param name="source"&gt;</span><span style="color: green">Object to deep copy.</span><span style="color: gray">&lt;/param&gt;
    /// &lt;returns&gt;</span><span style="color: green">New instance of the object with all properties and
    </span><span style="color: gray">/// </span><span style="color: green">fields that support serialization copied.</span><span style="color: gray">&lt;/returns&gt;
    /// &lt;remarks&gt;</span><span style="color: green">This method isn't as fast as a provided Clone method
    </span><span style="color: gray">/// </span><span style="color: green">but when ICloneable is not implemented on a BCL class its a
    </span><span style="color: gray">/// </span><span style="color: green">pretty close substitute.</span><span style="color: gray">&lt;/remarks&gt;
    </span><span style="color: blue">public static </span>T DeepCopy&lt;T&gt;(<span style="color: blue">this </span>T source) <span style="color: blue">where </span>T : <span style="color: blue">class
    </span>{
        T ret;
        <span style="color: blue">using </span>(<span style="color: blue">var </span>ms = <span style="color: blue">new </span><span style="color: #2b91af">MemorySerializer</span>&lt;T&gt;())
        {
            ret = ms.Serialize(source).Deserialize();
        }

       <span style="color: blue">return </span>ret;
    }
}</pre>
<p><a href="http://11011.net/software/vspaste"></a><a href="http://11011.net/software/vspaste"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.deploymentzone.com/2009/01/08/cheap-deep-copy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
