<?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: Clear comparisons</title>
	<atom:link href="http://www.taylor.se/blog/2006/03/23/clear-comparisons/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.taylor.se/blog/2006/03/23/clear-comparisons/</link>
	<description>Smart consulting</description>
	<lastBuildDate>Tue, 08 Jun 2010 05:02:39 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Jim Bolla</title>
		<link>http://www.taylor.se/blog/2006/03/23/clear-comparisons/comment-page-1/#comment-7412</link>
		<dc:creator>Jim Bolla</dc:creator>
		<pubDate>Fri, 23 Mar 2007 18:43:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.taylor.se/blog/2006/03/23/clear-comparisons/#comment-7412</guid>
		<description>I agree with comments 2 and 3 about putting HasChanged() on the class of the activity object (if possible). If you can&#039;t modify that class (such as DataSet), and HasChanged() and its kin are showing up throughout your code, then consider the Decorator or Adapter pattern to put those methods on another class that wrap the DataSet.

In response to comment 2, Resharper will get you from the initial code in 2 refactorings.

Step 1: Highlight the original conditional and Extract method. This should create the following method in the same class as the containing method.

private static bool HasChanged(DataSet activity)
{
    return activity.GetChanges() != null;
}

Step 2: (Let&#039;s pretend we can modify the DataSet class.) Put the text cursor on HasChanged and choose &quot;Make Method Non-Static&quot; which will move the method onto DataSet as such...

public bool HasChanged()
{
    return GetChanges() != null;
}

...plus all references to the original method will be updated!</description>
		<content:encoded><![CDATA[<p>I agree with comments 2 and 3 about putting HasChanged() on the class of the activity object (if possible). If you can&#8217;t modify that class (such as DataSet), and HasChanged() and its kin are showing up throughout your code, then consider the Decorator or Adapter pattern to put those methods on another class that wrap the DataSet.</p>
<p>In response to comment 2, Resharper will get you from the initial code in 2 refactorings.</p>
<p>Step 1: Highlight the original conditional and Extract method. This should create the following method in the same class as the containing method.</p>
<p>private static bool HasChanged(DataSet activity)<br />
{<br />
    return activity.GetChanges() != null;<br />
}</p>
<p>Step 2: (Let&#8217;s pretend we can modify the DataSet class.) Put the text cursor on HasChanged and choose &#8220;Make Method Non-Static&#8221; which will move the method onto DataSet as such&#8230;</p>
<p>public bool HasChanged()<br />
{<br />
    return GetChanges() != null;<br />
}</p>
<p>&#8230;plus all references to the original method will be updated!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andres</title>
		<link>http://www.taylor.se/blog/2006/03/23/clear-comparisons/comment-page-1/#comment-189</link>
		<dc:creator>Andres</dc:creator>
		<pubDate>Mon, 27 Mar 2006 13:04:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.taylor.se/blog/2006/03/23/clear-comparisons/#comment-189</guid>
		<description>Tobias:
In this example that I took from a real application, activity is a DataSet, which makes it kind of hard to change. But if activity was of a class that I controlled, I fully agree with you.

-andrés</description>
		<content:encoded><![CDATA[<p>Tobias:<br />
In this example that I took from a real application, activity is a DataSet, which makes it kind of hard to change. But if activity was of a class that I controlled, I fully agree with you.</p>
<p>-andrés</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tobias Fjälling</title>
		<link>http://www.taylor.se/blog/2006/03/23/clear-comparisons/comment-page-1/#comment-183</link>
		<dc:creator>Tobias Fjälling</dc:creator>
		<pubDate>Sat, 25 Mar 2006 18:01:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.taylor.se/blog/2006/03/23/clear-comparisons/#comment-183</guid>
		<description>Yepp. I agree. More readable, but I would prefer encapsulating the logic within activity:

if (activity.HasChanged())

Which to me looks even more readable in an OO manner. Can someone give me that refactoring tool? :)</description>
		<content:encoded><![CDATA[<p>Yepp. I agree. More readable, but I would prefer encapsulating the logic within activity:</p>
<p>if (activity.HasChanged())</p>
<p>Which to me looks even more readable in an OO manner. Can someone give me that refactoring tool? <img src='http://www.taylor.se/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stefan Andersson</title>
		<link>http://www.taylor.se/blog/2006/03/23/clear-comparisons/comment-page-1/#comment-176</link>
		<dc:creator>Stefan Andersson</dc:creator>
		<pubDate>Fri, 24 Mar 2006 05:42:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.taylor.se/blog/2006/03/23/clear-comparisons/#comment-176</guid>
		<description>Also, one of my favourite refactoring tool features is &#039;reverse conditional&#039; that swaps the if and else blocks by iverting the conditional statement. As a side bonus, often when you see the inverted logic you get to go &#039;wtf? that can&#039;t be right? less than?&#039; and catch yourself a case-bug.</description>
		<content:encoded><![CDATA[<p>Also, one of my favourite refactoring tool features is &#8216;reverse conditional&#8217; that swaps the if and else blocks by iverting the conditional statement. As a side bonus, often when you see the inverted logic you get to go &#8216;wtf? that can&#8217;t be right? less than?&#8217; and catch yourself a case-bug.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
