<?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: Extension Methods, Fluent Interfaces, and the evils of API Pollution</title>
	<atom:link href="http://unhandled-exceptions.com/blog/index.php/2008/11/18/extension-methods-fluent-interfaces-and-the-evils-of-api-pollution/feed/" rel="self" type="application/rss+xml" />
	<link>http://unhandled-exceptions.com/blog/index.php/2008/11/18/extension-methods-fluent-interfaces-and-the-evils-of-api-pollution/</link>
	<description>Miscellaneous musings on life, .NET development, and related things that don't really matter</description>
	<pubDate>Thu, 17 May 2012 21:30:56 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Hosting forum</title>
		<link>http://unhandled-exceptions.com/blog/index.php/2008/11/18/extension-methods-fluent-interfaces-and-the-evils-of-api-pollution/comment-page-6/#comment-127617</link>
		<dc:creator>Hosting forum</dc:creator>
		<pubDate>Thu, 15 Mar 2012 06:27:23 +0000</pubDate>
		<guid isPermaLink="false">http://unhandled-exceptions.com/blog/index.php/2008/11/18/extension-methods-fluent-interfaces-and-the-evils-of-api-pollution/#comment-127617</guid>
		<description>This blog is excellent because information provided though this article is very nice.I like to visit such blogs.</description>
		<content:encoded><![CDATA[<p>This blog is excellent because information provided though this article is very nice.I like to visit such blogs.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bryan Watts</title>
		<link>http://unhandled-exceptions.com/blog/index.php/2008/11/18/extension-methods-fluent-interfaces-and-the-evils-of-api-pollution/comment-page-1/#comment-10445</link>
		<dc:creator>Bryan Watts</dc:creator>
		<pubDate>Sun, 08 Feb 2009 06:45:03 +0000</pubDate>
		<guid isPermaLink="false">http://unhandled-exceptions.com/blog/index.php/2008/11/18/extension-methods-fluent-interfaces-and-the-evils-of-api-pollution/#comment-10445</guid>
		<description>I agree, but for a different reason: these APIs generally take an OO approach to a functional problem.

What we're talking about is a C# specification monad, striving to do for the individual what LINQ does for the many. Pattern matching is about as functional as it gets; constructing an object tree (IConstraint) goes against the grain.

Imagine, instead of Assert.That() having 2 parameters, it were to return something like IConstrainable. This would allow us to write assertions of arbitrary complexity, something like:

Assert.That(text).IsEmailAddress().WithLength(1, 200);

or

Assert.That(customer).IsPreferred();

Now, as we move away from simply renaming well-known constructs, extension methods start to make things simpler. Contrast:

Assert.IsTrue(n % 2 == 0);

with

Assert.That(n).IsEven();

- or -

Assert.IsTrue(n &#62;= 0 &#38;&#38; n &#60;= 100);

with

Assert.That(n).IsPercentage();

Within a framework like this, the "basic" operations are needed to maintain a consistent level of abstraction:

Assert.That(n).IsEven().IsInRange(0, 42).IsNotEqualTo(21);

Just some things to think about.

(Full disclosure: I am working on just such a project)

BTW first time reading the blog, am really enjoying the content.</description>
		<content:encoded><![CDATA[<p>I agree, but for a different reason: these APIs generally take an OO approach to a functional problem.</p>
<p>What we&#8217;re talking about is a C# specification monad, striving to do for the individual what LINQ does for the many. Pattern matching is about as functional as it gets; constructing an object tree (IConstraint) goes against the grain.</p>
<p>Imagine, instead of Assert.That() having 2 parameters, it were to return something like IConstrainable. This would allow us to write assertions of arbitrary complexity, something like:</p>
<p>Assert.That(text).IsEmailAddress().WithLength(1, 200);</p>
<p>or</p>
<p>Assert.That(customer).IsPreferred();</p>
<p>Now, as we move away from simply renaming well-known constructs, extension methods start to make things simpler. Contrast:</p>
<p>Assert.IsTrue(n % 2 == 0);</p>
<p>with</p>
<p>Assert.That(n).IsEven();</p>
<p>- or -</p>
<p>Assert.IsTrue(n &gt;= 0 &amp;&amp; n &lt;= 100);</p>
<p>with</p>
<p>Assert.That(n).IsPercentage();</p>
<p>Within a framework like this, the &#8220;basic&#8221; operations are needed to maintain a consistent level of abstraction:</p>
<p>Assert.That(n).IsEven().IsInRange(0, 42).IsNotEqualTo(21);</p>
<p>Just some things to think about.</p>
<p>(Full disclosure: I am working on just such a project)</p>
<p>BTW first time reading the blog, am really enjoying the content.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sbohlen</title>
		<link>http://unhandled-exceptions.com/blog/index.php/2008/11/18/extension-methods-fluent-interfaces-and-the-evils-of-api-pollution/comment-page-1/#comment-6357</link>
		<dc:creator>sbohlen</dc:creator>
		<pubDate>Wed, 17 Dec 2008 21:08:51 +0000</pubDate>
		<guid isPermaLink="false">http://unhandled-exceptions.com/blog/index.php/2008/11/18/extension-methods-fluent-interfaces-and-the-evils-of-api-pollution/#comment-6357</guid>
		<description>@wekempf:

I do concede your point that this has a place; I am really just arguing for some consistency across syntax so that when unfamiliar people view the code, its understandable.

I'm all in favor of 'fluent' interfaces but only so long as they are actually ALSO 'comprehensible' intefaces.  IMO fluency is about ease of SPEAKING something and comprehension is about ease of READING something and we all know that code gets read many more times than it gets written.  So long as 'ease of coding' doesn't lead to 'difficulty in reading', I'm all for the introduction of these things.

But I really feel strongly that 'extension-method-enabled API pollution' needs to be recognized as a very real threat to the approachability and readability (and by this I really mean COMPREHENSION) of code -- a balance needs to be struck here and that's really all I'm aruging for (some reasonable restraint) :D

Thanks for the comment~!</description>
		<content:encoded><![CDATA[<p>@wekempf:</p>
<p>I do concede your point that this has a place; I am really just arguing for some consistency across syntax so that when unfamiliar people view the code, its understandable.</p>
<p>I&#8217;m all in favor of &#8216;fluent&#8217; interfaces but only so long as they are actually ALSO &#8216;comprehensible&#8217; intefaces.  IMO fluency is about ease of SPEAKING something and comprehension is about ease of READING something and we all know that code gets read many more times than it gets written.  So long as &#8216;ease of coding&#8217; doesn&#8217;t lead to &#8216;difficulty in reading&#8217;, I&#8217;m all for the introduction of these things.</p>
<p>But I really feel strongly that &#8216;extension-method-enabled API pollution&#8217; needs to be recognized as a very real threat to the approachability and readability (and by this I really mean COMPREHENSION) of code &#8212; a balance needs to be struck here and that&#8217;s really all I&#8217;m aruging for (some reasonable restraint) <img src='http://unhandled-exceptions.com/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>Thanks for the comment~!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: wekempf</title>
		<link>http://unhandled-exceptions.com/blog/index.php/2008/11/18/extension-methods-fluent-interfaces-and-the-evils-of-api-pollution/comment-page-1/#comment-6345</link>
		<dc:creator>wekempf</dc:creator>
		<pubDate>Wed, 17 Dec 2008 17:00:13 +0000</pubDate>
		<guid isPermaLink="false">http://unhandled-exceptions.com/blog/index.php/2008/11/18/extension-methods-fluent-interfaces-and-the-evils-of-api-pollution/#comment-6345</guid>
		<description>Sorry, can't agree with you.  There's a number of reasons to use a fluent assertion API.

1. Extending (adding assertions) doesn't cause name overload issues.  What should I name the static class?  What class do I find the "AllInstancesShouldNotBeNull" assertion on? With extension methods I just have to add a using and call "Assert.That(foo).ShouldNotHaveNullItems()". When adding assertions I don't have to care about the class name, as generally the user won't be exposed to it.

2. It helps intellisense.  All assertions start with "Assert.That(foo)".  Then intellisense will let me know what assertions are available for the specific type I'm asserting on.

Traditional assertion APIs are clumsy to use in comparison to the fluent APIs.  So much so, that I don't think a unit test framework developed today would include any assertions that are not fluent in nature.</description>
		<content:encoded><![CDATA[<p>Sorry, can&#8217;t agree with you.  There&#8217;s a number of reasons to use a fluent assertion API.</p>
<p>1. Extending (adding assertions) doesn&#8217;t cause name overload issues.  What should I name the static class?  What class do I find the &#8220;AllInstancesShouldNotBeNull&#8221; assertion on? With extension methods I just have to add a using and call &#8220;Assert.That(foo).ShouldNotHaveNullItems()&#8221;. When adding assertions I don&#8217;t have to care about the class name, as generally the user won&#8217;t be exposed to it.</p>
<p>2. It helps intellisense.  All assertions start with &#8220;Assert.That(foo)&#8221;.  Then intellisense will let me know what assertions are available for the specific type I&#8217;m asserting on.</p>
<p>Traditional assertion APIs are clumsy to use in comparison to the fluent APIs.  So much so, that I don&#8217;t think a unit test framework developed today would include any assertions that are not fluent in nature.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sbohlen</title>
		<link>http://unhandled-exceptions.com/blog/index.php/2008/11/18/extension-methods-fluent-interfaces-and-the-evils-of-api-pollution/comment-page-1/#comment-5365</link>
		<dc:creator>sbohlen</dc:creator>
		<pubDate>Thu, 20 Nov 2008 00:55:04 +0000</pubDate>
		<guid isPermaLink="false">http://unhandled-exceptions.com/blog/index.php/2008/11/18/extension-methods-fluent-interfaces-and-the-evils-of-api-pollution/#comment-5365</guid>
		<description>@Ed:

I think that its entirely likely that many of the "shoulds" and "ought-to's" that I am seeing out there are indeed the result of (reasonably) well-meaning BDD-focused individuals as my own experience suggests that it tends to be the BDD-ers that are most obssessed with the language used to describe their tests (and assertions).

I actually think that BDD as a thought process has a lot to offer in re: the way it makes you focus on the behavior of your softare rather than its 'outputs'.  And as a guide to help developers focus on testing 'what matters' rather than over-spefifying brittle tests of things that don't, I am inclined to give a nod to BDD as being helpful there.

But I also firmly believe that one can successfully practice BDD by stating test methods in terms of desired behaviors rather than convoluted assertions.  Assertions like .ShouldEqual(), .ShouldBe(), and others aren't really that useful to me when compared against the API pollution that I was alluding to here.  A test method called 'Should_Prevent_User_from_Logging_On()' is useful to me as a BDD-friendly syntax so that I can see what's passing/failing in a result report.  But Assert.That(actual).ShouldBe(expected) is starting to trend towards API self-flaggelation in my book and adds little value to the assertion/failure process (IMHO).

My experience with lovers of such language contortions is the same as my experience with many of the DDD-minded set out there: many tend to accept BDD (or DDD) as some kind of 'religion' that must be fervently adhered to in all ways, no matter the cost.  When people start quoting scripture to me (even if its Evans instead of Matthew or Luke) I tend to tune them out :)</description>
		<content:encoded><![CDATA[<p>@Ed:</p>
<p>I think that its entirely likely that many of the &#8220;shoulds&#8221; and &#8220;ought-to&#8217;s&#8221; that I am seeing out there are indeed the result of (reasonably) well-meaning BDD-focused individuals as my own experience suggests that it tends to be the BDD-ers that are most obssessed with the language used to describe their tests (and assertions).</p>
<p>I actually think that BDD as a thought process has a lot to offer in re: the way it makes you focus on the behavior of your softare rather than its &#8216;outputs&#8217;.  And as a guide to help developers focus on testing &#8216;what matters&#8217; rather than over-spefifying brittle tests of things that don&#8217;t, I am inclined to give a nod to BDD as being helpful there.</p>
<p>But I also firmly believe that one can successfully practice BDD by stating test methods in terms of desired behaviors rather than convoluted assertions.  Assertions like .ShouldEqual(), .ShouldBe(), and others aren&#8217;t really that useful to me when compared against the API pollution that I was alluding to here.  A test method called &#8216;Should_Prevent_User_from_Logging_On()&#8217; is useful to me as a BDD-friendly syntax so that I can see what&#8217;s passing/failing in a result report.  But Assert.That(actual).ShouldBe(expected) is starting to trend towards API self-flaggelation in my book and adds little value to the assertion/failure process (IMHO).</p>
<p>My experience with lovers of such language contortions is the same as my experience with many of the DDD-minded set out there: many tend to accept BDD (or DDD) as some kind of &#8216;religion&#8217; that must be fervently adhered to in all ways, no matter the cost.  When people start quoting scripture to me (even if its Evans instead of Matthew or Luke) I tend to tune them out <img src='http://unhandled-exceptions.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ed</title>
		<link>http://unhandled-exceptions.com/blog/index.php/2008/11/18/extension-methods-fluent-interfaces-and-the-evils-of-api-pollution/comment-page-1/#comment-5356</link>
		<dc:creator>Ed</dc:creator>
		<pubDate>Wed, 19 Nov 2008 21:43:07 +0000</pubDate>
		<guid isPermaLink="false">http://unhandled-exceptions.com/blog/index.php/2008/11/18/extension-methods-fluent-interfaces-and-the-evils-of-api-pollution/#comment-5356</guid>
		<description>Hi Steve,

What about the concept of BDD vs. TDD?  I would like to hear you thoughts on BDD, do you believe that BDD is designed to get you to think correctly about what you are testing?  Would you consider this methodology?
Just curious :).

Thanks.</description>
		<content:encoded><![CDATA[<p>Hi Steve,</p>
<p>What about the concept of BDD vs. TDD?  I would like to hear you thoughts on BDD, do you believe that BDD is designed to get you to think correctly about what you are testing?  Would you consider this methodology?<br />
Just curious :).</p>
<p>Thanks.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

