<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" version="2.0">

<channel>
	<title>Deployment Zone</title>
	
	<link>http://www.deploymentzone.com</link>
	<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>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/deploymentzone" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="deploymentzone" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://add.my.yahoo.com/rss?url=http%3A%2F%2Ffeeds.feedburner.com%2Fdeploymentzone" src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif">Subscribe with My Yahoo!</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2Fdeploymentzone" src="http://www.newsgator.com/images/ngsub1.gif">Subscribe with NewsGator</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.bloglines.com/sub/http://feeds.feedburner.com/deploymentzone" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.netvibes.com/subscribe.php?url=http%3A%2F%2Ffeeds.feedburner.com%2Fdeploymentzone" src="http://www.netvibes.com/img/add2netvibes.gif">Subscribe with Netvibes</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://fusion.google.com/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2Fdeploymentzone" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><item>
		<title>F# Survival Guide</title>
		<link>http://www.deploymentzone.com/2010/07/29/f-survival-guide/</link>
		<comments>http://www.deploymentzone.com/2010/07/29/f-survival-guide/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 19:28:15 +0000</pubDate>
		<dc:creator>Chuck</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.deploymentzone.com/2010/07/29/f-survival-guide/</guid>
		<description><![CDATA[While doing some research on what options are available to eliminate deeply nested branching, I stumbled across this:
http://www.ctocorner.com/fsharp/book/default.aspx
I’ve been reading it when I have a moment here and there and so far its been great.&#160; 
]]></description>
			<content:encoded><![CDATA[<p>While doing some research on what options are available to eliminate deeply nested branching, I stumbled across this:</p>
<p><a href="http://www.ctocorner.com/fsharp/book/default.aspx">http://www.ctocorner.com/fsharp/book/default.aspx</a></p>
<p>I’ve been reading it when I have a moment here and there and so far its been great.&#160; </p>
]]></content:encoded>
			<wfw:commentRss>http://www.deploymentzone.com/2010/07/29/f-survival-guide/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AMD SB700 RAID Drivers</title>
		<link>http://www.deploymentzone.com/2010/03/25/amd-sb700-raid-drivers/</link>
		<comments>http://www.deploymentzone.com/2010/03/25/amd-sb700-raid-drivers/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 23:51:50 +0000</pubDate>
		<dc:creator>Chuck</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[amd southbridge sb700 raid sb7xx]]></category>

		<guid isPermaLink="false">http://www.deploymentzone.com/2010/03/25/amd-sb700-raid-drivers/</guid>
		<description><![CDATA[I recently replaced my aging Intel Core2 Duo 1.86GHz with an AMD Phenom II Black and a BioStar TA70GXE 128M motherboard (which is a real piece of shit, I would not recommend it to anyone).&#160; I could not find RAID drivers that allowed me to install Windows 7 64-bit (or even 32-bit), scouring the Internet [...]]]></description>
			<content:encoded><![CDATA[<p>I recently replaced my aging Intel Core2 Duo 1.86GHz with an AMD Phenom II Black and a BioStar TA70GXE 128M motherboard (which is a real piece of shit, I would not recommend it to anyone).&#160; I could not find RAID drivers that allowed me to install Windows 7 64-bit (or even 32-bit), scouring the Internet led to a lot of perplexed posts about why it would not work.&#160; One suggestion that apparently works is to install Windows XP 32-bit with the supplied RAID drivers, then upgrade to Windows 7 64-bit.&#160; I was about to do that but I stumbled across an older set of AMD SB7XX RAID drivers today that caused Windows 7 setup to FINALLY detect my RAID/0 array.&#160; Here’s hoping to no stability problems.</p>
<p>&#160;</p>
<p>The drivers I found can be downloaded from my web site: <a href="http://www.deploymentzone.com/resources/ATI_SB700_SATA_Slipstream.zip">ATI_SB700_SATA_Slipstream.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.deploymentzone.com/2010/03/25/amd-sb700-raid-drivers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Amazon Kindle for eBooks on a Jailbroken iPhone</title>
		<link>http://www.deploymentzone.com/2009/11/19/amazon-kindle-for-ebooks-on-a-jailbroken-iphone/</link>
		<comments>http://www.deploymentzone.com/2009/11/19/amazon-kindle-for-ebooks-on-a-jailbroken-iphone/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 15:44:53 +0000</pubDate>
		<dc:creator>Chuck</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.deploymentzone.com/2009/11/19/amazon-kindle-for-ebooks-on-a-jailbroken-iphone/</guid>
		<description><![CDATA[Until November 25th Pragmatic Press is offering 40% off all their existing print and upcoming print books.&#160; I took advantage of this and picked up a few print books, but one of the books I wanted was eBook only.&#160; No problem, except… no Kindle.&#160; So:
&#160;

Jailbreak iPhone if you haven’t done so already.&#160; Very important to [...]]]></description>
			<content:encoded><![CDATA[<p>Until November 25th <a href="http://www.pragprog.com/news/40-off-thanksgiving-pragsale-now-through-1125?900443">Pragmatic Press is offering 40% off</a> all their existing print and upcoming print books.&#160; I took advantage of this and picked up a few print books, but one of the books I wanted was eBook only.&#160; No problem, except… no Kindle.&#160; So:</p>
<p>&#160;</p>
<ol>
<li>Jailbreak iPhone if you haven’t done so already.&#160; Very important to change your root and mobile user passwords – root’s password by default is `alpine’ - either by installing Cydia’s Terminal application or sshing into your phone.&#160; (Jailbreaking is a time consuming process and I feel guilty about putting it as a single step.) </li>
<ol>
<li>You will need to install OpenSSH so you can copy files to the phone; you will probably also want to install Terminal.&#160; Both of these applications are available for free within Cydia, just search for them and install.&#160; It will take a long time for your very first ssh connection to your phone to connect as its generating encryption keys.</li>
</ol>
<li>Install the free Kindle app on the iPhone from the iTunes store.
<ol>
<li>The Kindle stores its books in an `eBooks’ folder buried in the `/var/mobile/Applications/…/Documents/eBooks’ where the `…’ is a GUID identifying the application. </li>
</ol>
</li>
<li>SSH (preferably a client where you can copy and paste) or Terminal.      <br /> 
<pre class="brush: bash;">find -type d /var/mobile/Applications -name 'eBooks'</pre>
<ol>
<li>a. Copy the GUID, and you’ll want to end up with the path in 2.1, above, but where the `…’ is replaced by the GUID.&#160; (On my device the GUID was <font size="2" face="conso">127DF7F1-9B49-423B-9FA9-77AB87775E24</font> but I don’t know if this is the same across devices; probably not.) </li>
</ol>
</li>
<li>This is purely for convenience, mainly because I want to use <a href="http://winscp.net/eng/index.php">WinSCP</a> to copy files from my Windows 7 PC to my iPhone and I don’t want to remember the GUID for the Amazon application every time I want to do this.&#160; (You can also use command line scp, but you’ll likely still want to create a symlink.) (You may also want to use `/private/var/root/Media/eBooks’ if you prefer a better organizational hierarchy.)
<p></p>
<pre class="brush: bash;">ln -s /var/mobile/Applications/YOUR_GUID/Documents/eBooks \
/private/var/root/eBooks</pre>
</li>
<li>Now you can use WinSCP or scp to copy *.mobi files directly into your device’s `/private/var/root/eBooks’ directory; books you copy here will be available in the Amazon Kindle iPhone app next time you launch it. </li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.deploymentzone.com/2009/11/19/amazon-kindle-for-ebooks-on-a-jailbroken-iphone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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’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>Khorne Berzerkers</title>
		<link>http://www.deploymentzone.com/2009/06/04/khorne-berzerkers/</link>
		<comments>http://www.deploymentzone.com/2009/06/04/khorne-berzerkers/#comments</comments>
		<pubDate>Thu, 04 Jun 2009 06:16:12 +0000</pubDate>
		<dc:creator>Chuck</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.deploymentzone.com/?p=126</guid>
		<description><![CDATA[Some Khorne Berzerkers I finished up after having them assembled and sitting in a box for over six years.  Also trying out my new camera and figuring out how to take pictures.
 
 
]]></description>
			<content:encoded><![CDATA[<p>Some Khorne Berzerkers I finished up after having them assembled and sitting in a box for over six years.  Also trying out my new camera and figuring out how to take pictures.</p>
<p> <br />
<a class="tt-flickr tt-flickr tt-flickr-Small" title="Khorne Berzerkers" href="http://farm4.static.flickr.com/3662/3593413231_cac5728bd6_b.jpg"><img src="http://farm4.static.flickr.com/3662/3593413231_cac5728bd6_m.jpg" border="0" alt="Khorne Berzerkers" width="240" height="180" /></a> <a class="tt-flickr tt-flickr tt-flickr-Small" title="Khorne Berzerkers (All)" href="http://farm4.static.flickr.com/3097/3593413419_a2fba133b4_b.jpg"><img src="http://farm4.static.flickr.com/3097/3593413419_a2fba133b4_m.jpg" border="0" alt="Khorne Berzerkers (All)" width="240" height="180" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.deploymentzone.com/2009/06/04/khorne-berzerkers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hordes: Lord of the Feast</title>
		<link>http://www.deploymentzone.com/2009/05/26/hordes-lord-of-the-feast/</link>
		<comments>http://www.deploymentzone.com/2009/05/26/hordes-lord-of-the-feast/#comments</comments>
		<pubDate>Tue, 26 May 2009 20:29:27 +0000</pubDate>
		<dc:creator>Chuck</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[hordes painting]]></category>

		<guid isPermaLink="false">http://www.deploymentzone.com/?p=124</guid>
		<description><![CDATA[One of the coolest Hordes models and also one of the weakest.  I painted this a long time ago and its one of the funnest paint jobs I've done.  When I use this model its only because it looks awesome and intimidating.
 
Update: a much better photo.
]]></description>
			<content:encoded><![CDATA[<p>One of the coolest Hordes models and also one of the weakest.  I painted this a long time ago and its one of the funnest paint jobs I've done.  When I use this model its only because it looks awesome and intimidating.</p>
<p><a class="tt-flickr tt-flickr tt-flickr-Small" title="Lord of the Feast" href="http://farm4.static.flickr.com/3568/3594344930_eddf93f12a_b.jpg"><img src="http://farm4.static.flickr.com/3568/3594344930_eddf93f12a_m.jpg" border="0" alt="Lord of the Feast" width="240" height="180" /></a> </p>
<p>Update: a much better photo.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.deploymentzone.com/2009/05/26/hordes-lord-of-the-feast/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
