<?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: Understanding Mock Objects &#8211; Better Design</title>
	<atom:link href="http://www.elilopian.com/2008/04/29/understanding-mock-objects-better-design/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.elilopian.com/2008/04/29/understanding-mock-objects-better-design/</link>
	<description>Creating better software</description>
	<lastBuildDate>Mon, 02 Jan 2012 09:09:26 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Eli Lopian</title>
		<link>http://www.elilopian.com/2008/04/29/understanding-mock-objects-better-design/comment-page-1/#comment-21301</link>
		<dc:creator>Eli Lopian</dc:creator>
		<pubDate>Mon, 05 May 2008 18:19:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.elilopian.com/2008/04/29/understanding-mock-objects-better-design/#comment-21301</guid>
		<description>Thanks ulu,
You are correct, This stresses the point that there is a need to *think* about the API, and not let the tests lead to wrong or over designed software.
In any case we might find it better to encapsulate the fact that GetImage() changes the image according to the time, and we might not want our client to pass a boolean time, we might in the future want to change the image every hour, or depending on geo-location. These are implementation details that should be encapsulated.</description>
		<content:encoded><![CDATA[<p>Thanks ulu,<br />
You are correct, This stresses the point that there is a need to *think* about the API, and not let the tests lead to wrong or over designed software.<br />
In any case we might find it better to encapsulate the fact that GetImage() changes the image according to the time, and we might not want our client to pass a boolean time, we might in the future want to change the image every hour, or depending on geo-location. These are implementation details that should be encapsulated.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ulu</title>
		<link>http://www.elilopian.com/2008/04/29/understanding-mock-objects-better-design/comment-page-1/#comment-21288</link>
		<dc:creator>ulu</dc:creator>
		<pubDate>Mon, 05 May 2008 08:44:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.elilopian.com/2008/04/29/understanding-mock-objects-better-design/#comment-21288</guid>
		<description>Hi,

Recently I discovered that perhaps dependency injection is a bit overused. Sometimes it&#039;s quite frustrating: you want to use someone else&#039;s class, and you have to figure out a lot of dependencies only to find out that the 6th in the chain is internal or something.

Anyway, you could have two completely independent classes here with two methods: 
bool DayService.IsDayTime(this DateTime time) 
and 
string ImageProvider.GetImage(bool gimmeTheDayImage)
Both classes can be tested without any mocks, and both can be reused in other places without any knowledge of each other, or any related interfaces. 

We still need a high-level API though, a class that glues these classes. How do we test it? We write an integration test. And that&#039;s where TypeMock can really help, since we can&#039;t use DI at this level. Too bad we can&#039;t mock mscorlib..</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Recently I discovered that perhaps dependency injection is a bit overused. Sometimes it&#8217;s quite frustrating: you want to use someone else&#8217;s class, and you have to figure out a lot of dependencies only to find out that the 6th in the chain is internal or something.</p>
<p>Anyway, you could have two completely independent classes here with two methods:<br />
bool DayService.IsDayTime(this DateTime time)<br />
and<br />
string ImageProvider.GetImage(bool gimmeTheDayImage)<br />
Both classes can be tested without any mocks, and both can be reused in other places without any knowledge of each other, or any related interfaces. </p>
<p>We still need a high-level API though, a class that glues these classes. How do we test it? We write an integration test. And that&#8217;s where TypeMock can really help, since we can&#8217;t use DI at this level. Too bad we can&#8217;t mock mscorlib..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eli Lopian</title>
		<link>http://www.elilopian.com/2008/04/29/understanding-mock-objects-better-design/comment-page-1/#comment-21016</link>
		<dc:creator>Eli Lopian</dc:creator>
		<pubDate>Wed, 30 Apr 2008 11:30:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.elilopian.com/2008/04/29/understanding-mock-objects-better-design/#comment-21016</guid>
		<description>Thanks Chris

Neil, Typemock is used on many projects that have GOOD - Well thought designs, albeit not bound to using ONLY the IoC Pattern.
These designs are a result of hard *thinking* in OO terms. Just because a developer doesn&#039;t have the correct tools to verify that his code is working, doesn&#039;t make his design bad or lacking.

About your design point: It is a valid point for this example, but not for the concept that I am trying to convey.
See, accepting DateTime as an argument is defying the encapsulation principal and perhaps the YAGNI principal too. 
Why should the client care about how we get the correct image? Why should he know that we are even asking for the time?</description>
		<content:encoded><![CDATA[<p>Thanks Chris</p>
<p>Neil, Typemock is used on many projects that have GOOD &#8211; Well thought designs, albeit not bound to using ONLY the IoC Pattern.<br />
These designs are a result of hard *thinking* in OO terms. Just because a developer doesn&#8217;t have the correct tools to verify that his code is working, doesn&#8217;t make his design bad or lacking.</p>
<p>About your design point: It is a valid point for this example, but not for the concept that I am trying to convey.<br />
See, accepting DateTime as an argument is defying the encapsulation principal and perhaps the YAGNI principal too.<br />
Why should the client care about how we get the correct image? Why should he know that we are even asking for the time?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Neil Mosafi</title>
		<link>http://www.elilopian.com/2008/04/29/understanding-mock-objects-better-design/comment-page-1/#comment-21015</link>
		<dc:creator>Neil Mosafi</dc:creator>
		<pubDate>Wed, 30 Apr 2008 10:34:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.elilopian.com/2008/04/29/understanding-mock-objects-better-design/#comment-21015</guid>
		<description>Hmm, I am not sure about this, and I don&#039;t think using TypeMock should be encouraged for this sort of solution.  I am seeing TypeMock used on more and more projects to hide bad/lack of design, when it was really built to enable testing of legacy components which cannot be refactored.

Still... I believe the whole assumption that a mock is required for any of this is incorrect.  Why do you need to mock in the first place?  If your ImageManagement.GetImage function simply accepts a DateTime as a dependency then you ahve removed the dependency on DateTime.Now.  Then you can test your method passing in a DateTime where the hour is less than 6pm and one where it is greater than 6pm.

Why assume that your consumer will always be interested in determining whether it is currently day or night?  For example, he may wish to perform a lookup on historical data.  You are making your service less useful by forcing the dependency on DateTime.Now.</description>
		<content:encoded><![CDATA[<p>Hmm, I am not sure about this, and I don&#8217;t think using TypeMock should be encouraged for this sort of solution.  I am seeing TypeMock used on more and more projects to hide bad/lack of design, when it was really built to enable testing of legacy components which cannot be refactored.</p>
<p>Still&#8230; I believe the whole assumption that a mock is required for any of this is incorrect.  Why do you need to mock in the first place?  If your ImageManagement.GetImage function simply accepts a DateTime as a dependency then you ahve removed the dependency on DateTime.Now.  Then you can test your method passing in a DateTime where the hour is less than 6pm and one where it is greater than 6pm.</p>
<p>Why assume that your consumer will always be interested in determining whether it is currently day or night?  For example, he may wish to perform a lookup on historical data.  You are making your service less useful by forcing the dependency on DateTime.Now.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Holmes</title>
		<link>http://www.elilopian.com/2008/04/29/understanding-mock-objects-better-design/comment-page-1/#comment-20996</link>
		<dc:creator>Chris Holmes</dc:creator>
		<pubDate>Tue, 29 Apr 2008 23:26:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.elilopian.com/2008/04/29/understanding-mock-objects-better-design/#comment-20996</guid>
		<description>Brilliant post Eli. I&#039;m a big believer in IoC, etc., helping lead the way toward a better design. But you&#039;re post showed that no matter how many tools and techniques you employ, you still have to actively *think* about design. The tools and techniques will only get us so far.</description>
		<content:encoded><![CDATA[<p>Brilliant post Eli. I&#8217;m a big believer in IoC, etc., helping lead the way toward a better design. But you&#8217;re post showed that no matter how many tools and techniques you employ, you still have to actively *think* about design. The tools and techniques will only get us so far.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

