<?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: Anti-Patterns and Worst Practices – Heisenbugs</title>
	<atom:link href="http://lostechies.com/chrismissal/2009/05/30/anti-patterns-and-worst-practices-heisenbugs/feed/" rel="self" type="application/rss+xml" />
	<link>http://lostechies.com/chrismissal/2009/05/30/anti-patterns-and-worst-practices-heisenbugs/</link>
	<description>Thoughts while working and playing as a Software Developer</description>
	<lastBuildDate>Mon, 10 Jun 2013 15:59: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: Sorin</title>
		<link>http://lostechies.com/chrismissal/2009/05/30/anti-patterns-and-worst-practices-heisenbugs/#comment-104</link>
		<dc:creator>Sorin</dc:creator>
		<pubDate>Tue, 02 Jun 2009 10:26:32 +0000</pubDate>
		<guid isPermaLink="false">/blogs/chrismissal/archive/2009/05/30/anti-patterns-and-worst-practices-heisenbugs.aspx#comment-104</guid>
		<description>What do you think about something like:
...
private int? _cachedValue = null;
public int CachedValue
{
   get {
        if(!_cachedValue.HasValue)
             _cachedValue = repository.GetValue();
        return _cachedValue.Value;
   }
}

...
    private void ResetCache()
    {
         _cachedValue = null;
    }
...</description>
		<content:encoded><![CDATA[<p>What do you think about something like:<br />
&#8230;<br />
private int? _cachedValue = null;<br />
public int CachedValue<br />
{<br />
   get {<br />
        if(!_cachedValue.HasValue)<br />
             _cachedValue = repository.GetValue();<br />
        return _cachedValue.Value;<br />
   }<br />
}</p>
<p>&#8230;<br />
    private void ResetCache()<br />
    {<br />
         _cachedValue = null;<br />
    }<br />
&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Missal</title>
		<link>http://lostechies.com/chrismissal/2009/05/30/anti-patterns-and-worst-practices-heisenbugs/#comment-103</link>
		<dc:creator>Chris Missal</dc:creator>
		<pubDate>Tue, 02 Jun 2009 05:34:02 +0000</pubDate>
		<guid isPermaLink="false">/blogs/chrismissal/archive/2009/05/30/anti-patterns-and-worst-practices-heisenbugs.aspx#comment-103</guid>
		<description>@Jacob

That&#039;s a very good point. While in my example the name of the method was a giveaway as to what was going on, there&#039;s nothing wrong with that name. Since I wasn&#039;t doing concurrent operations in my sample code, the name seemed to give something away. If you are doing this type of transaction, something along the lines of a Unit of Work implementation is probably more suited to your needs. Really, anything transactional could encounter situations like this. I&#039;ll be honest, I don&#039;t work in these types of environments, so I don&#039;t always keep them in mind.</description>
		<content:encoded><![CDATA[<p>@Jacob</p>
<p>That&#8217;s a very good point. While in my example the name of the method was a giveaway as to what was going on, there&#8217;s nothing wrong with that name. Since I wasn&#8217;t doing concurrent operations in my sample code, the name seemed to give something away. If you are doing this type of transaction, something along the lines of a Unit of Work implementation is probably more suited to your needs. Really, anything transactional could encounter situations like this. I&#8217;ll be honest, I don&#8217;t work in these types of environments, so I don&#8217;t always keep them in mind.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jacob Stanley</title>
		<link>http://lostechies.com/chrismissal/2009/05/30/anti-patterns-and-worst-practices-heisenbugs/#comment-102</link>
		<dc:creator>Jacob Stanley</dc:creator>
		<pubDate>Tue, 02 Jun 2009 04:07:43 +0000</pubDate>
		<guid isPermaLink="false">/blogs/chrismissal/archive/2009/05/30/anti-patterns-and-worst-practices-heisenbugs.aspx#comment-102</guid>
		<description>Aren&#039;t methods with semantics like GetNextNotification() required in a concurrent environment? That is, an environment where you need to atomically execute a command as the result of a query.

How would you handle this kind of operation in a concurrent system without breaking the rules?</description>
		<content:encoded><![CDATA[<p>Aren&#8217;t methods with semantics like GetNextNotification() required in a concurrent environment? That is, an environment where you need to atomically execute a command as the result of a query.</p>
<p>How would you handle this kind of operation in a concurrent system without breaking the rules?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: colinjack</title>
		<link>http://lostechies.com/chrismissal/2009/05/30/anti-patterns-and-worst-practices-heisenbugs/#comment-101</link>
		<dc:creator>colinjack</dc:creator>
		<pubDate>Sat, 30 May 2009 19:23:22 +0000</pubDate>
		<guid isPermaLink="false">/blogs/chrismissal/archive/2009/05/30/anti-patterns-and-worst-practices-heisenbugs.aspx#comment-101</guid>
		<description>@Joe
Its a query but it doesn&#039;t mean we&#039;re breaking tell dont ask. Agree its not great code, I wouldn&#039;t put this sort of code inside a setter for a start, but I just didn&#039;t see it as particularly violating CQS is all.

@Chris
Definitely that makes perfect sense and agree on getters/setters.</description>
		<content:encoded><![CDATA[<p>@Joe<br />
Its a query but it doesn&#8217;t mean we&#8217;re breaking tell dont ask. Agree its not great code, I wouldn&#8217;t put this sort of code inside a setter for a start, but I just didn&#8217;t see it as particularly violating CQS is all.</p>
<p>@Chris<br />
Definitely that makes perfect sense and agree on getters/setters.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Missal</title>
		<link>http://lostechies.com/chrismissal/2009/05/30/anti-patterns-and-worst-practices-heisenbugs/#comment-100</link>
		<dc:creator>Chris Missal</dc:creator>
		<pubDate>Sat, 30 May 2009 15:31:49 +0000</pubDate>
		<guid isPermaLink="false">/blogs/chrismissal/archive/2009/05/30/anti-patterns-and-worst-practices-heisenbugs.aspx#comment-100</guid>
		<description>@Colin

I should have shown the bad code I wanted to avoid altogether, logic inside the getter (code shown is of the object being called). This would be breaking CQS. I opted to show more realistic code that does some work inside the setter. This is more common in my experience, but in my opinion is just as bad as putting command logic in the getter. Getters/setters serve as a way of, just that, getting values or setting values. When they do more than what is on the surface there are usually problems. While you could consider my setter example above in no way breaking CQS, I&#039;d like to point out that it isn&#039;t as discoverable as it should be as @Joe also points out. Hopefully this clears up some ambiguity.</description>
		<content:encoded><![CDATA[<p>@Colin</p>
<p>I should have shown the bad code I wanted to avoid altogether, logic inside the getter (code shown is of the object being called). This would be breaking CQS. I opted to show more realistic code that does some work inside the setter. This is more common in my experience, but in my opinion is just as bad as putting command logic in the getter. Getters/setters serve as a way of, just that, getting values or setting values. When they do more than what is on the surface there are usually problems. While you could consider my setter example above in no way breaking CQS, I&#8217;d like to point out that it isn&#8217;t as discoverable as it should be as @Joe also points out. Hopefully this clears up some ambiguity.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe Moore</title>
		<link>http://lostechies.com/chrismissal/2009/05/30/anti-patterns-and-worst-practices-heisenbugs/#comment-99</link>
		<dc:creator>Joe Moore</dc:creator>
		<pubDate>Sat, 30 May 2009 14:50:32 +0000</pubDate>
		<guid isPermaLink="false">/blogs/chrismissal/archive/2009/05/30/anti-patterns-and-worst-practices-heisenbugs.aspx#comment-99</guid>
		<description>Maybe Chris considers &quot;value.IsValidFor(this)&quot; a query?  It certainly does appear to query the current object, though a lot of my methods would also fail CQS horribly for the same reasons.

The first couple examples smell regardless because they fail the Rule of Least Surprise.</description>
		<content:encoded><![CDATA[<p>Maybe Chris considers &#8220;value.IsValidFor(this)&#8221; a query?  It certainly does appear to query the current object, though a lot of my methods would also fail CQS horribly for the same reasons.</p>
<p>The first couple examples smell regardless because they fail the Rule of Least Surprise.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Missal</title>
		<link>http://lostechies.com/chrismissal/2009/05/30/anti-patterns-and-worst-practices-heisenbugs/#comment-98</link>
		<dc:creator>Chris Missal</dc:creator>
		<pubDate>Sat, 30 May 2009 14:35:25 +0000</pubDate>
		<guid isPermaLink="false">/blogs/chrismissal/archive/2009/05/30/anti-patterns-and-worst-practices-heisenbugs.aspx#comment-98</guid>
		<description>@Colin

My mistake, if you&#039;re *not* careful, thanks. :)</description>
		<content:encoded><![CDATA[<p>@Colin</p>
<p>My mistake, if you&#8217;re *not* careful, thanks. :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: colinjack</title>
		<link>http://lostechies.com/chrismissal/2009/05/30/anti-patterns-and-worst-practices-heisenbugs/#comment-97</link>
		<dc:creator>colinjack</dc:creator>
		<pubDate>Sat, 30 May 2009 14:03:38 +0000</pubDate>
		<guid isPermaLink="false">/blogs/chrismissal/archive/2009/05/30/anti-patterns-and-worst-practices-heisenbugs.aspx#comment-97</guid>
		<description>&quot;If you do, good for you; this is the kind of code that breaks CQS guidelines and can creep into your codebase if you’re careful. &quot;

I&#039;m missing something, why do you say this is breaking CQS? 

As you say later if it was in the getter that&#039;d be different, and its not great code either way, but I&#039;m missing why its a CQS violation.</description>
		<content:encoded><![CDATA[<p>&#8220;If you do, good for you; this is the kind of code that breaks CQS guidelines and can creep into your codebase if you’re careful. &#8221;</p>
<p>I&#8217;m missing something, why do you say this is breaking CQS? </p>
<p>As you say later if it was in the getter that&#8217;d be different, and its not great code either way, but I&#8217;m missing why its a CQS violation.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
