<?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: SystemTime versus ISystemClock – dependencies revisited</title>
	<atom:link href="http://lostechies.com/jimmybogard/2008/11/09/systemtime-versus-isystemclock-dependencies-revisited/feed/" rel="self" type="application/rss+xml" />
	<link>http://lostechies.com/jimmybogard/2008/11/09/systemtime-versus-isystemclock-dependencies-revisited/</link>
	<description>Strong opinions, weakly held</description>
	<lastBuildDate>Thu, 20 Jun 2013 08:29:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
	<item>
		<title>By: bogardj</title>
		<link>http://lostechies.com/jimmybogard/2008/11/09/systemtime-versus-isystemclock-dependencies-revisited/#comment-1027</link>
		<dc:creator>bogardj</dc:creator>
		<pubDate>Wed, 19 May 2010 15:50:01 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2008/11/09/systemtime-versus-isystemclock-dependencies-revisited.aspx#comment-1027</guid>
		<description>@Nathan

We wound up using SystemClock in our entities, and ISystemClock in DI-enabled services.  I&#039;ve never actually run into a test that fails because I forgot to reset SystemClock though, my tests always set up their own data.</description>
		<content:encoded><![CDATA[<p>@Nathan</p>
<p>We wound up using SystemClock in our entities, and ISystemClock in DI-enabled services.  I&#8217;ve never actually run into a test that fails because I forgot to reset SystemClock though, my tests always set up their own data.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nathan Alden</title>
		<link>http://lostechies.com/jimmybogard/2008/11/09/systemtime-versus-isystemclock-dependencies-revisited/#comment-1026</link>
		<dc:creator>Nathan Alden</dc:creator>
		<pubDate>Wed, 19 May 2010 14:55:40 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2008/11/09/systemtime-versus-isystemclock-dependencies-revisited.aspx#comment-1026</guid>
		<description>Two reasons I would avoid the service locator approach:

The first is that I have to remember to replace the delegate with the original one (() =&gt; DateTime.Now) in all my tests. Setting and relying on static things in tests often leads to hard-to-track-down test failures, or even false passes.

The second is I actually prefer to know that my objects are relying on the system clock. Injecting ISystemClock into their constructors makes this obvious.</description>
		<content:encoded><![CDATA[<p>Two reasons I would avoid the service locator approach:</p>
<p>The first is that I have to remember to replace the delegate with the original one (() => DateTime.Now) in all my tests. Setting and relying on static things in tests often leads to hard-to-track-down test failures, or even false passes.</p>
<p>The second is I actually prefer to know that my objects are relying on the system clock. Injecting ISystemClock into their constructors makes this obvious.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nightshade427</title>
		<link>http://lostechies.com/jimmybogard/2008/11/09/systemtime-versus-isystemclock-dependencies-revisited/#comment-1025</link>
		<dc:creator>nightshade427</dc:creator>
		<pubDate>Mon, 10 Nov 2008 02:30:51 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2008/11/09/systemtime-versus-isystemclock-dependencies-revisited.aspx#comment-1025</guid>
		<description>ya i would agree as well.</description>
		<content:encoded><![CDATA[<p>ya i would agree as well.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bogardj</title>
		<link>http://lostechies.com/jimmybogard/2008/11/09/systemtime-versus-isystemclock-dependencies-revisited/#comment-1024</link>
		<dc:creator>bogardj</dc:creator>
		<pubDate>Mon, 10 Nov 2008 01:09:20 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2008/11/09/systemtime-versus-isystemclock-dependencies-revisited.aspx#comment-1024</guid>
		<description>@nightshade427

Yep, exactly!  It&#039;s an assumption that _every_ dependency resolver needs to be through dependency injection.  I think global dependencies like this one are prime candidates for service location.</description>
		<content:encoded><![CDATA[<p>@nightshade427</p>
<p>Yep, exactly!  It&#8217;s an assumption that _every_ dependency resolver needs to be through dependency injection.  I think global dependencies like this one are prime candidates for service location.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nightshade427</title>
		<link>http://lostechies.com/jimmybogard/2008/11/09/systemtime-versus-isystemclock-dependencies-revisited/#comment-1023</link>
		<dc:creator>nightshade427</dc:creator>
		<pubDate>Mon, 10 Nov 2008 00:16:27 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2008/11/09/systemtime-versus-isystemclock-dependencies-revisited.aspx#comment-1023</guid>
		<description>Isn&#039;t SystemTime is just using a simplified  serviceLocator type approach?</description>
		<content:encoded><![CDATA[<p>Isn&#8217;t SystemTime is just using a simplified  serviceLocator type approach?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bogardj</title>
		<link>http://lostechies.com/jimmybogard/2008/11/09/systemtime-versus-isystemclock-dependencies-revisited/#comment-1022</link>
		<dc:creator>bogardj</dc:creator>
		<pubDate>Sun, 09 Nov 2008 19:01:54 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2008/11/09/systemtime-versus-isystemclock-dependencies-revisited.aspx#comment-1022</guid>
		<description>@colin

I really haven&#039;t had a problem so far - I do have a Reset() method to reset the Now back to DateTime.Now.  But if I&#039;m testing behavior that uses SystemTime.Now(), I&#039;ll have to do something with it, or the test will fail.  The only thing not resetting will do is affect other tests.  It won&#039;t affect debugging, running locally or production, since those run in different AppDomains.</description>
		<content:encoded><![CDATA[<p>@colin</p>
<p>I really haven&#8217;t had a problem so far &#8211; I do have a Reset() method to reset the Now back to DateTime.Now.  But if I&#8217;m testing behavior that uses SystemTime.Now(), I&#8217;ll have to do something with it, or the test will fail.  The only thing not resetting will do is affect other tests.  It won&#8217;t affect debugging, running locally or production, since those run in different AppDomains.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Colin jack</title>
		<link>http://lostechies.com/jimmybogard/2008/11/09/systemtime-versus-isystemclock-dependencies-revisited/#comment-1021</link>
		<dc:creator>Colin jack</dc:creator>
		<pubDate>Sun, 09 Nov 2008 18:22:06 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2008/11/09/systemtime-versus-isystemclock-dependencies-revisited.aspx#comment-1021</guid>
		<description>Great stuff. Didn&#039;t really Ayende had used that sort of solution but thats pretty much what I&#039;ve started doing. 

My implementation was a bit differrent as I&#039;ve used an IClock interface (with one member Now) with two implementations Clock and StubClock but Clock (your SystemClock) also has a static member that lets you replace the instance. Same idea just a slightly different implementation (not sure I explained it well, no matter).

Only *slight* issue I&#039;ve had is leaivng the DateTime in SystemClock behind in tests. My work around was to have a time_senstive_context_base and have it make sure we put back the real clock at the end. You doing something similiar?</description>
		<content:encoded><![CDATA[<p>Great stuff. Didn&#8217;t really Ayende had used that sort of solution but thats pretty much what I&#8217;ve started doing. </p>
<p>My implementation was a bit differrent as I&#8217;ve used an IClock interface (with one member Now) with two implementations Clock and StubClock but Clock (your SystemClock) also has a static member that lets you replace the instance. Same idea just a slightly different implementation (not sure I explained it well, no matter).</p>
<p>Only *slight* issue I&#8217;ve had is leaivng the DateTime in SystemClock behind in tests. My work around was to have a time_senstive_context_base and have it make sure we put back the real clock at the end. You doing something similiar?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
