<?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: The Power of the Predicate&lt;T&gt;</title>
	<atom:link href="http://RandyPatterson.com/index.php/2007/09/19/the-power-of-the-predicatet/feed/" rel="self" type="application/rss+xml" />
	<link>http://RandyPatterson.com/index.php/2007/09/19/the-power-of-the-predicatet/</link>
	<description>Code To Live, Live To Code</description>
	<lastBuildDate>Sat, 17 Oct 2009 18:28:47 -0400</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Jeff P</title>
		<link>http://RandyPatterson.com/index.php/2007/09/19/the-power-of-the-predicatet/comment-page-1/#comment-47</link>
		<dc:creator>Jeff P</dc:creator>
		<pubDate>Sat, 20 Dec 2008 17:34:07 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/2007/09/19/ThePowerOfThePredicateltTgt.aspx#comment-47</guid>
		<description>Exactly what I was looking for.  Thanks for posting this, Randy!
I couldn&#039;t figure out the &quot;Predicate&quot; idea...was sorting through my List Collection from top to bottom.
This idea dramatically sped things up.
I did get a little snagged because I wanted to use a FIND.
Kept trying to put the findings to a LIST, but it needed to return one of the List&#039;s objects.

I had already figured out the use of Sorting delegates a couple days ago.
I have a delegate with 6 levels of sorting and it is very fast.
I&#039;m still a little baffled on how the Sort &quot;works&quot;...I&#039;m just glad I don&#039;t have to write it.
I remember writing those routines in CompSci.  Ugh!

Jeff P.</description>
		<content:encoded><![CDATA[<p>Exactly what I was looking for.  Thanks for posting this, Randy!<br />
I couldn&#8217;t figure out the &quot;Predicate&quot; idea&#8230;was sorting through my List Collection from top to bottom.<br />
This idea dramatically sped things up.<br />
I did get a little snagged because I wanted to use a FIND.<br />
Kept trying to put the findings to a LIST, but it needed to return one of the List&#8217;s objects.</p>
<p>I had already figured out the use of Sorting delegates a couple days ago.<br />
I have a delegate with 6 levels of sorting and it is very fast.<br />
I&#8217;m still a little baffled on how the Sort &quot;works&quot;&#8230;I&#8217;m just glad I don&#8217;t have to write it.<br />
I remember writing those routines in CompSci.  Ugh!</p>
<p>Jeff P.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Randy Patterson</title>
		<link>http://RandyPatterson.com/index.php/2007/09/19/the-power-of-the-predicatet/comment-page-1/#comment-46</link>
		<dc:creator>Randy Patterson</dc:creator>
		<pubDate>Fri, 21 Sep 2007 11:28:28 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/2007/09/19/ThePowerOfThePredicateltTgt.aspx#comment-46</guid>
		<description>It is not a requirement to use anonymous methods for Predicate&lt;T&gt; or Comparison&lt;T&gt; parameters but, when it makes sense, it produces concise and easily readable code.  However, when anonymous methods are misused it can produce code that is difficult to maintain.  Like most features, the “trick” is determining when it becomes a benefit and when it becomes the bane of your existence.

When to use Anonymous methods:

1.	Single use code snippet
2.	Logic is less than 5 lines of code. 
3.	The intent can clearly be seen in the code, otherwise a method name would better express intent (i.e method name of SortByLastNameThenFirstName)

When &lt;B&gt;not&lt;/B&gt; to use Anonymous methods:

1.	Code is used multiple times.
2.	Requires a Unit Test
3.	Code is complex enough to obfuscate intent with a quick review.

These are just guidelines and you will, no doubt, amend them as you become more comfortable using anonymous methods
</description>
		<content:encoded><![CDATA[<p>It is not a requirement to use anonymous methods for Predicate&lt;T&gt; or Comparison&lt;T&gt; parameters but, when it makes sense, it produces concise and easily readable code.  However, when anonymous methods are misused it can produce code that is difficult to maintain.  Like most features, the “trick” is determining when it becomes a benefit and when it becomes the bane of your existence.</p>
<p>When to use Anonymous methods:</p>
<p>1.	Single use code snippet<br />
2.	Logic is less than 5 lines of code.<br />
3.	The intent can clearly be seen in the code, otherwise a method name would better express intent (i.e method name of SortByLastNameThenFirstName)</p>
<p>When &lt;B&gt;not&lt;/B&gt; to use Anonymous methods:</p>
<p>1.	Code is used multiple times.<br />
2.	Requires a Unit Test<br />
3.	Code is complex enough to obfuscate intent with a quick review.</p>
<p>These are just guidelines and you will, no doubt, amend them as you become more comfortable using anonymous methods</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: AJ.NET</title>
		<link>http://RandyPatterson.com/index.php/2007/09/19/the-power-of-the-predicatet/comment-page-1/#comment-45</link>
		<dc:creator>AJ.NET</dc:creator>
		<pubDate>Fri, 21 Sep 2007 09:08:35 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/2007/09/19/ThePowerOfThePredicateltTgt.aspx#comment-45</guid>
		<description>I agree that this is a most compelling feature and will reduce code amount and complexity. However I wonder whether the code becomes too simple. E.g. what about null checks (will NullReferenceException replace ArgumentNullException?). What about consistency (e.g. in one place using case sensitive comparison, case insensitive in the other. Identifying a person by name in onle place. Also checking the birth date in the other.)

Due to lambdas we _will_ see this code more often. To the good or the bad? I don&#039;t know.</description>
		<content:encoded><![CDATA[<p>I agree that this is a most compelling feature and will reduce code amount and complexity. However I wonder whether the code becomes too simple. E.g. what about null checks (will NullReferenceException replace ArgumentNullException?). What about consistency (e.g. in one place using case sensitive comparison, case insensitive in the other. Identifying a person by name in onle place. Also checking the birth date in the other.)</p>
<p>Due to lambdas we _will_ see this code more often. To the good or the bad? I don&#8217;t know.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David</title>
		<link>http://RandyPatterson.com/index.php/2007/09/19/the-power-of-the-predicatet/comment-page-1/#comment-44</link>
		<dc:creator>David</dc:creator>
		<pubDate>Thu, 20 Sep 2007 19:24:36 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/2007/09/19/ThePowerOfThePredicateltTgt.aspx#comment-44</guid>
		<description>Another thing to remember when using anonymous methods, is that Debug-Continue will not work in Visual Studio. Just something to keep in mind</description>
		<content:encoded><![CDATA[<p>Another thing to remember when using anonymous methods, is that Debug-Continue will not work in Visual Studio. Just something to keep in mind</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Roy Lawson</title>
		<link>http://RandyPatterson.com/index.php/2007/09/19/the-power-of-the-predicatet/comment-page-1/#comment-43</link>
		<dc:creator>Roy Lawson</dc:creator>
		<pubDate>Thu, 20 Sep 2007 17:44:29 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/2007/09/19/ThePowerOfThePredicateltTgt.aspx#comment-43</guid>
		<description>How would you go about unit testing delegate methods?  


&quot;People.RemoveAll(delegate(Person person) { return person.Age &gt; 12 &amp;&amp; person.Age &lt; 20; });&quot;

Using your example, what we have is a simple way to prevent creating a new method (ie the IsTeen(person) method).  But, as the delegate methods get complex it becomes difficult to read, debug, or test.  At what point does it become too complex to use this approach?  Is there a rule of thumb?</description>
		<content:encoded><![CDATA[<p>How would you go about unit testing delegate methods?  </p>
<p>&quot;People.RemoveAll(delegate(Person person) { return person.Age &gt; 12 &amp;&amp; person.Age &lt; 20; });&quot;</p>
<p>Using your example, what we have is a simple way to prevent creating a new method (ie the IsTeen(person) method).  But, as the delegate methods get complex it becomes difficult to read, debug, or test.  At what point does it become too complex to use this approach?  Is there a rule of thumb?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott</title>
		<link>http://RandyPatterson.com/index.php/2007/09/19/the-power-of-the-predicatet/comment-page-1/#comment-42</link>
		<dc:creator>Scott</dc:creator>
		<pubDate>Thu, 20 Sep 2007 16:47:36 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/2007/09/19/ThePowerOfThePredicateltTgt.aspx#comment-42</guid>
		<description>Can you show me how to do it in Visual Basic?</description>
		<content:encoded><![CDATA[<p>Can you show me how to do it in Visual Basic?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott</title>
		<link>http://RandyPatterson.com/index.php/2007/09/19/the-power-of-the-predicatet/comment-page-1/#comment-41</link>
		<dc:creator>Scott</dc:creator>
		<pubDate>Thu, 20 Sep 2007 16:46:07 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/2007/09/19/ThePowerOfThePredicateltTgt.aspx#comment-41</guid>
		<description>This is all wrong man.  Unreal dude.</description>
		<content:encoded><![CDATA[<p>This is all wrong man.  Unreal dude.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott</title>
		<link>http://RandyPatterson.com/index.php/2007/09/19/the-power-of-the-predicatet/comment-page-1/#comment-40</link>
		<dc:creator>Scott</dc:creator>
		<pubDate>Thu, 20 Sep 2007 16:44:26 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/2007/09/19/ThePowerOfThePredicateltTgt.aspx#comment-40</guid>
		<description>This is all wrong man.</description>
		<content:encoded><![CDATA[<p>This is all wrong man.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: anonymous</title>
		<link>http://RandyPatterson.com/index.php/2007/09/19/the-power-of-the-predicatet/comment-page-1/#comment-39</link>
		<dc:creator>anonymous</dc:creator>
		<pubDate>Thu, 20 Sep 2007 16:05:51 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/2007/09/19/ThePowerOfThePredicateltTgt.aspx#comment-39</guid>
		<description>that&#039;s brillant</description>
		<content:encoded><![CDATA[<p>that&#8217;s brillant</p>
]]></content:encoded>
	</item>
</channel>
</rss>
