<?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: Tell, Don&#8217;t Ask &#8211; Part 2</title>
	<atom:link href="http://ketan.padegaonkar.name/2009/09/04/tell-dont-ask-part-2.html/feed" rel="self" type="application/rss+xml" />
	<link>http://ketan.padegaonkar.name/2009/09/04/tell-dont-ask-part-2.html</link>
	<description>Where he blogs about his eclipse musings</description>
	<lastBuildDate>Wed, 30 Nov 2011 05:37:57 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
	<item>
		<title>By: Colin Jack</title>
		<link>http://ketan.padegaonkar.name/2009/09/04/tell-dont-ask-part-2.html/comment-page-1#comment-353</link>
		<dc:creator>Colin Jack</dc:creator>
		<pubDate>Sun, 06 Sep 2009 16:44:10 +0000</pubDate>
		<guid isPermaLink="false">http://ketan.padegaonkar.name/?p=404#comment-353</guid>
		<description>@ketan
I think you are missing Brians point, he is saying your unmocked test is not realistic and provides a better example. Its not that he doesn&#039;t understand that mocking allows you to replace dependencies :P

I&#039;d also argue that it is worth focussing on the key advantages of mocking. It isn&#039;t just about making it easier to test, its about pushing forward your design. See mockobjects.com or &quot;Mock Roles, Not Objects&quot;.

Having said that to me mocking domain objects, like dog/owner here, is often a mistak. I might well use state based testing in this sort of situation even if keeping PetOwner/Dog very loosely coupled is important, but thats a seperate discussion.</description>
		<content:encoded><![CDATA[<p>@ketan<br />
I think you are missing Brians point, he is saying your unmocked test is not realistic and provides a better example. Its not that he doesn&#8217;t understand that mocking allows you to replace dependencies <img src='http://ketan.padegaonkar.name/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>I&#8217;d also argue that it is worth focussing on the key advantages of mocking. It isn&#8217;t just about making it easier to test, its about pushing forward your design. See mockobjects.com or &#8220;Mock Roles, Not Objects&#8221;.</p>
<p>Having said that to me mocking domain objects, like dog/owner here, is often a mistak. I might well use state based testing in this sort of situation even if keeping PetOwner/Dog very loosely coupled is important, but thats a seperate discussion.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ketan</title>
		<link>http://ketan.padegaonkar.name/2009/09/04/tell-dont-ask-part-2.html/comment-page-1#comment-348</link>
		<dc:creator>Ketan</dc:creator>
		<pubDate>Fri, 04 Sep 2009 21:36:53 +0000</pubDate>
		<guid isPermaLink="false">http://ketan.padegaonkar.name/?p=404#comment-348</guid>
		<description>@Brian,

With a mock dog, the owner need not have a real dog to feed to test if the owner can actually perform an operation.</description>
		<content:encoded><![CDATA[<p>@Brian,</p>
<p>With a mock dog, the owner need not have a real dog to feed to test if the owner can actually perform an operation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ketan</title>
		<link>http://ketan.padegaonkar.name/2009/09/04/tell-dont-ask-part-2.html/comment-page-1#comment-342</link>
		<dc:creator>Ketan</dc:creator>
		<pubDate>Fri, 04 Sep 2009 19:43:56 +0000</pubDate>
		<guid isPermaLink="false">http://ketan.padegaonkar.name/?p=404#comment-342</guid>
		<description>@Nick,

Thanks for catching this. The example is supposed to be using constructor based injection. I&#039;ve updated the post accordingly.</description>
		<content:encoded><![CDATA[<p>@Nick,</p>
<p>Thanks for catching this. The example is supposed to be using constructor based injection. I&#8217;ve updated the post accordingly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Swan</title>
		<link>http://ketan.padegaonkar.name/2009/09/04/tell-dont-ask-part-2.html/comment-page-1#comment-346</link>
		<dc:creator>Brian Swan</dc:creator>
		<pubDate>Fri, 04 Sep 2009 08:54:33 +0000</pubDate>
		<guid isPermaLink="false">http://ketan.padegaonkar.name/?p=404#comment-346</guid>
		<description>I&#039;m not a big fan of Mocks but the non mocked example test seems overly contrived. There is no reason to not use constructor injection in the first example or to have a Dog class that needs two phase construction. From Tell, Don&#039;t Ask - Part 1 we know that the Dog has an isHungry query method, so I would have written the following test with no need for mocking.

void testOwnerCanFeedDog(){
    Dog dog = new Dog();
    PetOwner owner = new PetOwner(dog);
    owner.feedDog(food);

    assertFalse(dog.isHungry())
}</description>
		<content:encoded><![CDATA[<p>I&#8217;m not a big fan of Mocks but the non mocked example test seems overly contrived. There is no reason to not use constructor injection in the first example or to have a Dog class that needs two phase construction. From Tell, Don&#8217;t Ask &#8211; Part 1 we know that the Dog has an isHungry query method, so I would have written the following test with no need for mocking.</p>
<p>void testOwnerCanFeedDog(){<br />
    Dog dog = new Dog();<br />
    PetOwner owner = new PetOwner(dog);<br />
    owner.feedDog(food);</p>
<p>    assertFalse(dog.isHungry())<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nick Stolwijk</title>
		<link>http://ketan.padegaonkar.name/2009/09/04/tell-dont-ask-part-2.html/comment-page-1#comment-341</link>
		<dc:creator>Nick Stolwijk</dc:creator>
		<pubDate>Fri, 04 Sep 2009 06:14:59 +0000</pubDate>
		<guid isPermaLink="false">http://ketan.padegaonkar.name/?p=404#comment-341</guid>
		<description>In your second test, how does the PetOwner know of the mocked Dog?</description>
		<content:encoded><![CDATA[<p>In your second test, how does the PetOwner know of the mocked Dog?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

