<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: C#: Builder pattern still useful for test data</title>
	<atom:link href="http://www.markhneedham.com/blog/2009/01/21/c-builder-pattern-still-useful-for-test-data/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.markhneedham.com/blog/2009/01/21/c-builder-pattern-still-useful-for-test-data/</link>
	<description>Thoughts on Software Development</description>
	<lastBuildDate>Sat, 11 Feb 2012 23:17:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Anonymous</title>
		<link>http://www.markhneedham.com/blog/2009/01/21/c-builder-pattern-still-useful-for-test-data/comment-page-1/#comment-125730</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Wed, 26 Oct 2011 16:23:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=870#comment-125730</guid>
		<description>What you are really replacing here is the Setter pattern, not the Builder pattern.  The big difference is that with a builder I can have private variables within the object that are initialized via the builder, but then are immutable.  There is no set property and no chance of having the value changed down the road.  This can allow me the avoid situations where the object might be in an inconsistent state.</description>
		<content:encoded><![CDATA[<p>What you are really replacing here is the Setter pattern, not the Builder pattern.  The big difference is that with a builder I can have private variables within the object that are initialized via the builder, but then are immutable.  There is no set property and no chance of having the value changed down the road.  This can allow me the avoid situations where the object might be in an inconsistent state.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rodrigo Jordao</title>
		<link>http://www.markhneedham.com/blog/2009/01/21/c-builder-pattern-still-useful-for-test-data/comment-page-1/#comment-124601</link>
		<dc:creator>Rodrigo Jordao</dc:creator>
		<pubDate>Sun, 03 Jul 2011 13:38:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=870#comment-124601</guid>
		<description>I think you could still use the object initializer syntax for the builder. Just have the builder constructor do the value defaulting. Couple this with an implicit conversion operator and you get:

Foo foo = new FooBuilder { Bar = &quot;bar&quot; };</description>
		<content:encoded><![CDATA[<p>I think you could still use the object initializer syntax for the builder. Just have the builder constructor do the value defaulting. Couple this with an implicit conversion operator and you get:</p>
<p>Foo foo = new FooBuilder { Bar = &#8220;bar&#8221; };</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nitin</title>
		<link>http://www.markhneedham.com/blog/2009/01/21/c-builder-pattern-still-useful-for-test-data/comment-page-1/#comment-65366</link>
		<dc:creator>Nitin</dc:creator>
		<pubDate>Fri, 26 Nov 2010 08:57:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=870#comment-65366</guid>
		<description>One more advantage is, it allows user to plugin their own custom implementation into framework. Please refer the following blog.

http://xeon2k.wordpress.com</description>
		<content:encoded><![CDATA[<p>One more advantage is, it allows user to plugin their own custom implementation into framework. Please refer the following blog.</p>
<p><a href="http://xeon2k.wordpress.com" rel="nofollow">http://xeon2k.wordpress.com</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Philip Schwarz</title>
		<link>http://www.markhneedham.com/blog/2009/01/21/c-builder-pattern-still-useful-for-test-data/comment-page-1/#comment-31205</link>
		<dc:creator>Philip Schwarz</dc:creator>
		<pubDate>Sun, 31 Jan 2010 01:58:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=870#comment-31205</guid>
		<description>The second item in &#039;Effective Java (2nd edition)&#039; is &#039;Consider a builder when faced with many constructor parameters&#039;.

And this advice is aimed at all code, not just test code. One of the points Joshua Bloch makes is that rather than using the following

NutritionFacts cocaCola = new NutritionFacts(240,8,100,0,35,27)

which is hard to write, and harder still to read, we can us the builder pattern 

NutritionFacts cocaCola = NutritionFacts.Builder(240,8).calories(100).sodium(35).carbohydrate(27).build()

which simulates named optional parameters (required parameters, e.g. 240 and 8, are passed in to the Builder&#039;s constructor).

The Builder is an inner class, so it is easy to locate.</description>
		<content:encoded><![CDATA[<p>The second item in &#8216;Effective Java (2nd edition)&#8217; is &#8216;Consider a builder when faced with many constructor parameters&#8217;.</p>
<p>And this advice is aimed at all code, not just test code. One of the points Joshua Bloch makes is that rather than using the following</p>
<p>NutritionFacts cocaCola = new NutritionFacts(240,8,100,0,35,27)</p>
<p>which is hard to write, and harder still to read, we can us the builder pattern </p>
<p>NutritionFacts cocaCola = NutritionFacts.Builder(240,8).calories(100).sodium(35).carbohydrate(27).build()</p>
<p>which simulates named optional parameters (required parameters, e.g. 240 and 8, are passed in to the Builder&#8217;s constructor).</p>
<p>The Builder is an inner class, so it is easy to locate.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: TDD: Keeping test intent when using test builders at Mark Needham</title>
		<link>http://www.markhneedham.com/blog/2009/01/21/c-builder-pattern-still-useful-for-test-data/comment-page-1/#comment-22775</link>
		<dc:creator>TDD: Keeping test intent when using test builders at Mark Needham</dc:creator>
		<pubDate>Sun, 20 Sep 2009 02:23:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=870#comment-22775</guid>
		<description>[...] the test data builder pattern is quite a useful one for simplifying the creation of test data in our tests I think we [...]</description>
		<content:encoded><![CDATA[<p>[...] the test data builder pattern is quite a useful one for simplifying the creation of test data in our tests I think we [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Coding: Make it obvious at Mark Needham</title>
		<link>http://www.markhneedham.com/blog/2009/01/21/c-builder-pattern-still-useful-for-test-data/comment-page-1/#comment-18685</link>
		<dc:creator>Coding: Make it obvious at Mark Needham</dc:creator>
		<pubDate>Mon, 15 Jun 2009 12:04:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=870#comment-18685</guid>
		<description>[...] one that was only recently pointed out to me by Dave when discussing the way I had implemented the builder pattern in our code [...]</description>
		<content:encoded><![CDATA[<p>[...] one that was only recently pointed out to me by Dave when discussing the way I had implemented the builder pattern in our code [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Coding: Putting code where people can find it at Mark Needham</title>
		<link>http://www.markhneedham.com/blog/2009/01/21/c-builder-pattern-still-useful-for-test-data/comment-page-1/#comment-18060</link>
		<dc:creator>Coding: Putting code where people can find it at Mark Needham</dc:creator>
		<pubDate>Tue, 02 Jun 2009 13:37:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=870#comment-18060</guid>
		<description>[...] previously written about the builder pattern which I think is a very useful pattern for helping to setup [...]</description>
		<content:encoded><![CDATA[<p>[...] previously written about the builder pattern which I think is a very useful pattern for helping to setup [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: TDD: Design tests for failure at Mark Needham</title>
		<link>http://www.markhneedham.com/blog/2009/01/21/c-builder-pattern-still-useful-for-test-data/comment-page-1/#comment-5739</link>
		<dc:creator>TDD: Design tests for failure at Mark Needham</dc:creator>
		<pubDate>Tue, 27 Jan 2009 14:49:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=870#comment-5739</guid>
		<description>[...] it turns out all is fine then the builder pattern is a really good way for ensuring we don&#039;t run into this problem [...]</description>
		<content:encoded><![CDATA[<p>[...] it turns out all is fine then the builder pattern is a really good way for ensuring we don&#8217;t run into this problem [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Needham</title>
		<link>http://www.markhneedham.com/blog/2009/01/21/c-builder-pattern-still-useful-for-test-data/comment-page-1/#comment-4766</link>
		<dc:creator>Mark Needham</dc:creator>
		<pubDate>Thu, 22 Jan 2009 20:36:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=870#comment-4766</guid>
		<description>@joe I thought the implicit operator needs to go on the target class although just trying out what you suggested does seem to work which is really cool!

I&#039;m sure I tried that a few times before I posted and couldn&#039;t get it to work but it certainly seems to work now - thanks for the tip</description>
		<content:encoded><![CDATA[<p>@joe I thought the implicit operator needs to go on the target class although just trying out what you suggested does seem to work which is really cool!</p>
<p>I&#8217;m sure I tried that a few times before I posted and couldn&#8217;t get it to work but it certainly seems to work now &#8211; thanks for the tip</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: joe</title>
		<link>http://www.markhneedham.com/blog/2009/01/21/c-builder-pattern-still-useful-for-test-data/comment-page-1/#comment-4751</link>
		<dc:creator>joe</dc:creator>
		<pubDate>Thu, 22 Jan 2009 19:17:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=870#comment-4751</guid>
		<description>oops C&amp;P error:

return new Foo {Bar = current.bar, Baz = current.baz, Bling = current.bling};</description>
		<content:encoded><![CDATA[<p>oops C&amp;P error:</p>
<p>return new Foo {Bar = current.bar, Baz = current.baz, Bling = current.bling};</p>
]]></content:encoded>
	</item>
</channel>
</rss>

