<?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 case against Interfaces in TDD</title>
	<atom:link href="http://lostechies.com/jimmybogard/2010/12/02/the-case-against-interfaces-in-tdd/feed/" rel="self" type="application/rss+xml" />
	<link>http://lostechies.com/jimmybogard/2010/12/02/the-case-against-interfaces-in-tdd/</link>
	<description>Strong opinions, weakly held</description>
	<lastBuildDate>Sat, 25 May 2013 16:53: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: Robert</title>
		<link>http://lostechies.com/jimmybogard/2010/12/02/the-case-against-interfaces-in-tdd/#comment-5877</link>
		<dc:creator>Robert</dc:creator>
		<pubDate>Thu, 23 May 2013 23:40:00 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/12/02/the-case-against-interfaces-in-tdd.aspx#comment-5877</guid>
		<description>The title of your article doesn&#039;t match your articles.  I want my five minutes back.</description>
		<content:encoded><![CDATA[<p>The title of your article doesn&#8217;t match your articles.  I want my five minutes back.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bryan Watts</title>
		<link>http://lostechies.com/jimmybogard/2010/12/02/the-case-against-interfaces-in-tdd/#comment-2715</link>
		<dc:creator>Bryan Watts</dc:creator>
		<pubDate>Sun, 19 Dec 2010 09:53:51 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/12/02/the-case-against-interfaces-in-tdd.aspx#comment-2715</guid>
		<description>Writing a class instantly requires many decisions that interfaces defer:

Does the concept call for imposing inheritance?
Do I make a reference or value type?
Do I make the class abstract? Do I seal it?
Do I make its members abstract? Virtual?
Do I specify hierarchy-wide implementation details?
How will derived classes use and override these rules?
What state will each instance store? What state is static?
What problem was I solving again?

When we identify the need for a new type, we really uncover a dependency on some set of operations which is best left to another component. Choosing to model those newly-discovered capabilities with a class or struct places the emphasis square on the implementation. It&#039;s tempting to delve in and switch contexts.

Decoupled design is about isolation, and nothing isolates a dependency with fewer decisions and assumptions than an interface. They are a low-friction way to identify work for later while keeping the focus on the current problem.

In that respect, I call reverse YAGNI on @Harry M :-)

(I should qualify this by saying that I don&#039;t use entity interfaces. Abstraction in the model should only occur if it exists in the domain.)</description>
		<content:encoded><![CDATA[<p>Writing a class instantly requires many decisions that interfaces defer:</p>
<p>Does the concept call for imposing inheritance?<br />
Do I make a reference or value type?<br />
Do I make the class abstract? Do I seal it?<br />
Do I make its members abstract? Virtual?<br />
Do I specify hierarchy-wide implementation details?<br />
How will derived classes use and override these rules?<br />
What state will each instance store? What state is static?<br />
What problem was I solving again?</p>
<p>When we identify the need for a new type, we really uncover a dependency on some set of operations which is best left to another component. Choosing to model those newly-discovered capabilities with a class or struct places the emphasis square on the implementation. It&#8217;s tempting to delve in and switch contexts.</p>
<p>Decoupled design is about isolation, and nothing isolates a dependency with fewer decisions and assumptions than an interface. They are a low-friction way to identify work for later while keeping the focus on the current problem.</p>
<p>In that respect, I call reverse YAGNI on @Harry M <img src='http://lostechies.com/jimmybogard/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>(I should qualify this by saying that I don&#8217;t use entity interfaces. Abstraction in the model should only occur if it exists in the domain.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harry M</title>
		<link>http://lostechies.com/jimmybogard/2010/12/02/the-case-against-interfaces-in-tdd/#comment-2714</link>
		<dc:creator>Harry M</dc:creator>
		<pubDate>Wed, 08 Dec 2010 12:47:35 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/12/02/the-case-against-interfaces-in-tdd.aspx#comment-2714</guid>
		<description>@Chad :

If you are shipping assemblies for public consumption then you REALLY have to think about using interfaces vs assemblies (particularly given that adding a method or property to an interface requires that the consumer implement it, while you can add a property to a base class without forcing your consumer to update their code). 

If you aren&#039;t exposing the code to a third party (most of the lines of code I suspect most people write) then versioning etc. isn&#039;t a concern - when I need the flexibility to pass in different unrelated implementations I extract an interface - not before (YAGNI). </description>
		<content:encoded><![CDATA[<p>@Chad :</p>
<p>If you are shipping assemblies for public consumption then you REALLY have to think about using interfaces vs assemblies (particularly given that adding a method or property to an interface requires that the consumer implement it, while you can add a property to a base class without forcing your consumer to update their code). </p>
<p>If you aren&#8217;t exposing the code to a third party (most of the lines of code I suspect most people write) then versioning etc. isn&#8217;t a concern &#8211; when I need the flexibility to pass in different unrelated implementations I extract an interface &#8211; not before (YAGNI). </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vector</title>
		<link>http://lostechies.com/jimmybogard/2010/12/02/the-case-against-interfaces-in-tdd/#comment-2713</link>
		<dc:creator>vector</dc:creator>
		<pubDate>Sun, 05 Dec 2010 16:01:55 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/12/02/the-case-against-interfaces-in-tdd.aspx#comment-2713</guid>
		<description>interesting article... thanks</description>
		<content:encoded><![CDATA[<p>interesting article&#8230; thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: chadmyers</title>
		<link>http://lostechies.com/jimmybogard/2010/12/02/the-case-against-interfaces-in-tdd/#comment-2712</link>
		<dc:creator>chadmyers</dc:creator>
		<pubDate>Fri, 03 Dec 2010 16:54:02 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/12/02/the-case-against-interfaces-in-tdd.aspx#comment-2712</guid>
		<description>@Harry:

&quot;The interfaces certainly don&#039;t add flexibility to a system that you wouldn&#039;t get with a class (given that you can always extract an interface when you actually need one).&quot;

First, they do add flexibility because I can pass wildly different impls into a method that takes an interface in its signature vs. a class which forces me to either pass in that class or pass in an inherited class (if the base class even allows inheritance).  Interfaces allow for composition scenarios in ways that classes don&#039;t or only allow awkwardly.

Second, &quot;you can always extract an interface&quot; -- that is, until you ship in which case you now have versioning and compatibility problems.</description>
		<content:encoded><![CDATA[<p>@Harry:</p>
<p>&#8220;The interfaces certainly don&#8217;t add flexibility to a system that you wouldn&#8217;t get with a class (given that you can always extract an interface when you actually need one).&#8221;</p>
<p>First, they do add flexibility because I can pass wildly different impls into a method that takes an interface in its signature vs. a class which forces me to either pass in that class or pass in an inherited class (if the base class even allows inheritance).  Interfaces allow for composition scenarios in ways that classes don&#8217;t or only allow awkwardly.</p>
<p>Second, &#8220;you can always extract an interface&#8221; &#8212; that is, until you ship in which case you now have versioning and compatibility problems.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: chadmyers</title>
		<link>http://lostechies.com/jimmybogard/2010/12/02/the-case-against-interfaces-in-tdd/#comment-2711</link>
		<dc:creator>chadmyers</dc:creator>
		<pubDate>Fri, 03 Dec 2010 14:24:08 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/12/02/the-case-against-interfaces-in-tdd.aspx#comment-2711</guid>
		<description>@Carlos: 

&quot;I&#039;m not sure if you are agreeing with me, missing my point,...&quot;  it appears I was missing your point.

Interfaces on entities is an anti-pattern and part of what I was referring to earlier with people mis-using interfaces.

It seems in most of these discussions I get with people advocating abstract classes, they don&#039;t first understand how to use interfaces properly.  The problem is not interfaces vs. abstract classes usually, but rather bad interface usage vs. abstract classes. So abstract classes seems the more reasonable, logical alternative. But in a choice between bad and wrong, wrong seems not as bad.

But I propose good vs. wrong and good wins, at least in my book.</description>
		<content:encoded><![CDATA[<p>@Carlos: </p>
<p>&#8220;I&#8217;m not sure if you are agreeing with me, missing my point,&#8230;&#8221;  it appears I was missing your point.</p>
<p>Interfaces on entities is an anti-pattern and part of what I was referring to earlier with people mis-using interfaces.</p>
<p>It seems in most of these discussions I get with people advocating abstract classes, they don&#8217;t first understand how to use interfaces properly.  The problem is not interfaces vs. abstract classes usually, but rather bad interface usage vs. abstract classes. So abstract classes seems the more reasonable, logical alternative. But in a choice between bad and wrong, wrong seems not as bad.</p>
<p>But I propose good vs. wrong and good wins, at least in my book.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harry M</title>
		<link>http://lostechies.com/jimmybogard/2010/12/02/the-case-against-interfaces-in-tdd/#comment-2710</link>
		<dc:creator>Harry M</dc:creator>
		<pubDate>Fri, 03 Dec 2010 09:45:09 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/12/02/the-case-against-interfaces-in-tdd.aspx#comment-2710</guid>
		<description>@Bill P. I strongly suspect that all the interfaces with one implementation wouldn&#039;t exist if a different testing methodology was used. 

The interfaces certainly don&#039;t add flexibility to a system that you wouldn&#039;t get with a class (given that you can always extract an interface when you actually need one). 

While we&#039;re talking about the pain of interfaces, its a good time to tangentially pimp Nicolas Dorier&#039;s little-known-but-AWESOME Genuilder project, a pre-processor for msbuild (it&#039;s like PostSharp for source code) that can (amongst other amazing things) magically generate an interface for your classes by marking them up with an attribute.

http://genuilder.codeplex.com/documentation - see  the InterfaceExtrator magic. Genuilder blew a few minds at the London ALT.NET conference recently, where we did a code session and wrote an extension to mark all properties as virtual according to a convention.</description>
		<content:encoded><![CDATA[<p>@Bill P. I strongly suspect that all the interfaces with one implementation wouldn&#8217;t exist if a different testing methodology was used. </p>
<p>The interfaces certainly don&#8217;t add flexibility to a system that you wouldn&#8217;t get with a class (given that you can always extract an interface when you actually need one). </p>
<p>While we&#8217;re talking about the pain of interfaces, its a good time to tangentially pimp Nicolas Dorier&#8217;s little-known-but-AWESOME Genuilder project, a pre-processor for msbuild (it&#8217;s like PostSharp for source code) that can (amongst other amazing things) magically generate an interface for your classes by marking them up with an attribute.</p>
<p><a href="http://genuilder.codeplex.com/documentation" rel="nofollow">http://genuilder.codeplex.com/documentation</a> &#8211; see  the InterfaceExtrator magic. Genuilder blew a few minds at the London ALT.NET conference recently, where we did a code session and wrote an extension to mark all properties as virtual according to a convention.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dylan Smith</title>
		<link>http://lostechies.com/jimmybogard/2010/12/02/the-case-against-interfaces-in-tdd/#comment-2709</link>
		<dc:creator>Dylan Smith</dc:creator>
		<pubDate>Fri, 03 Dec 2010 00:06:58 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/12/02/the-case-against-interfaces-in-tdd.aspx#comment-2709</guid>
		<description>If your doing TDD then chances are that 95% of your interfaces have at least *2* implementations, the regular one and a mock/fake/stub.</description>
		<content:encoded><![CDATA[<p>If your doing TDD then chances are that 95% of your interfaces have at least *2* implementations, the regular one and a mock/fake/stub.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Carlos Ribas</title>
		<link>http://lostechies.com/jimmybogard/2010/12/02/the-case-against-interfaces-in-tdd/#comment-2708</link>
		<dc:creator>Carlos Ribas</dc:creator>
		<pubDate>Thu, 02 Dec 2010 21:10:29 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/12/02/the-case-against-interfaces-in-tdd.aspx#comment-2708</guid>
		<description>@Chad,

I&#039;m not sure if you are agreeing with me, missing my point, or avoiding the discussion.  

I was angling towards an entity.  I don&#039;t personally back my entities with interfaces except where polymorphism is desired.  I get the impression that many folks do, in the name of TDD (or whatever flavor).  This is the point I was making.  I would argue that entities without implementation rules are just typed data tables.

Substitute your own &quot;good&quot; example if necessary, so long as its not apples to oranges like your IDocumentProducer example, which is a service, not an entity.

</description>
		<content:encoded><![CDATA[<p>@Chad,</p>
<p>I&#8217;m not sure if you are agreeing with me, missing my point, or avoiding the discussion.  </p>
<p>I was angling towards an entity.  I don&#8217;t personally back my entities with interfaces except where polymorphism is desired.  I get the impression that many folks do, in the name of TDD (or whatever flavor).  This is the point I was making.  I would argue that entities without implementation rules are just typed data tables.</p>
<p>Substitute your own &#8220;good&#8221; example if necessary, so long as its not apples to oranges like your IDocumentProducer example, which is a service, not an entity.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: chadmyers</title>
		<link>http://lostechies.com/jimmybogard/2010/12/02/the-case-against-interfaces-in-tdd/#comment-2707</link>
		<dc:creator>chadmyers</dc:creator>
		<pubDate>Thu, 02 Dec 2010 20:57:05 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/12/02/the-case-against-interfaces-in-tdd.aspx#comment-2707</guid>
		<description>@Carlos:

Both INumber and IFiftyOrLess are bad examples because they imply implementation rules and so aren&#039;t good candidates for interfaces in the first place. A better example may be an IDocumentProducer that has a GetDocuments() method.

RE: Dynamic keyword: I admit I haven&#039;t had a lot of opportunity to play with this in C# yet. I&#039;d probably be tempted to treat it like I would a dynamic language and I&#039;d probably be disappointed by that, but I can&#039;t speak from experience, only speculation at this point.

But the point I was trying to make is that the way I use interfaces is to get the compiler to acknowledge that the passed-in object will have a Bar() method with the correct signature. 

I believe Jimmy is of the same or similar mindset here. It is common/normal to have many/most interfaces with only a single implementation.  This is because the interface is being used to satisfy the compiler&#039;s requirement of certifying that the passed-in object has the correct method signature for Bar(). </description>
		<content:encoded><![CDATA[<p>@Carlos:</p>
<p>Both INumber and IFiftyOrLess are bad examples because they imply implementation rules and so aren&#8217;t good candidates for interfaces in the first place. A better example may be an IDocumentProducer that has a GetDocuments() method.</p>
<p>RE: Dynamic keyword: I admit I haven&#8217;t had a lot of opportunity to play with this in C# yet. I&#8217;d probably be tempted to treat it like I would a dynamic language and I&#8217;d probably be disappointed by that, but I can&#8217;t speak from experience, only speculation at this point.</p>
<p>But the point I was trying to make is that the way I use interfaces is to get the compiler to acknowledge that the passed-in object will have a Bar() method with the correct signature. </p>
<p>I believe Jimmy is of the same or similar mindset here. It is common/normal to have many/most interfaces with only a single implementation.  This is because the interface is being used to satisfy the compiler&#8217;s requirement of certifying that the passed-in object has the correct method signature for Bar(). </p>
]]></content:encoded>
	</item>
</channel>
</rss>
