<?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 &#8220;single implementation&#8221; paradox</title>
	<atom:link href="http://blog.codeaholics.org/2011/the-single-implementation-paradox/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.codeaholics.org/2011/the-single-implementation-paradox/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-single-implementation-paradox</link>
	<description>addicted to codeahol since 1985</description>
	<lastBuildDate>Fri, 26 Apr 2013 08:18:25 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>By: Stephen</title>
		<link>http://blog.codeaholics.org/2011/the-single-implementation-paradox/#comment-32</link>
		<dc:creator>Stephen</dc:creator>
		<pubDate>Sat, 16 Jul 2011 00:30:09 +0000</pubDate>
		<guid isPermaLink="false">http://blog.codeaholics.org/?p=59#comment-32</guid>
		<description>I have two thoughts about the single-implementation problem:

1) In my experience, code bases that have lots of single-implementation interfaces have generally been really bad. Over-engineered, pointless layers, etc. I&#039;m sure this isn&#039;t the case for all projects that use them (especially yours, of course :-), it&#039;s just my experience.

2) Stepping back, in some ways I think the distinction between classes and interfaces is no longer useful and instead becoming a hindrance. AFAIK the perf for method dispatch is the same, so why not have all classes have interfaces? Except you don&#039;t declare them, it just happens.

E.g. &quot;class Foo&quot; gets a &quot;Foo&quot; interface and &quot;Foo$&quot; implementation. Whenever you do &quot;new Foo&quot;, the compiler knows to do &quot;new Foo$&quot; but the variable type stays &quot;Foo&quot;. Now you can mock/whatever Foo to your heart&#039;s content.

If, for some reason, Foo really shouldn&#039;t get an interface, perhaps you could add a java.lang.NoImplicitInterface annotation, which would tell the compiler to behave in the current/standard way (not that such a drastic change in compiler behavior would ever make it into Java itself).

A little while ago I was feeling out an architecture that used single-impl interfaces, and so built an annotation processor that does basically this:

https://github.com/stephenh/interfacegen

So you write Foo, add @GenInterface, and it will automatically create/update as-you-save an IFoo.

I&#039;m not saying it&#039;s perfect (and annotation processors in general can be finicky--especially this one, IIRC), but if you really want single-impl interfaces, it seems like a good compromise compared to maintaining both by hand.</description>
		<content:encoded><![CDATA[<p>I have two thoughts about the single-implementation problem:</p>
<p>1) In my experience, code bases that have lots of single-implementation interfaces have generally been really bad. Over-engineered, pointless layers, etc. I&#8217;m sure this isn&#8217;t the case for all projects that use them (especially yours, of course <img src="http://blog.codeaholics.org/wp-includes/images/smilies/icon_smile.gif?d7148e" alt=':-)' class='wp-smiley' /> , it&#8217;s just my experience.</p>
<p>2) Stepping back, in some ways I think the distinction between classes and interfaces is no longer useful and instead becoming a hindrance. AFAIK the perf for method dispatch is the same, so why not have all classes have interfaces? Except you don&#8217;t declare them, it just happens.</p>
<p>E.g. &#8220;class Foo&#8221; gets a &#8220;Foo&#8221; interface and &#8220;Foo$&#8221; implementation. Whenever you do &#8220;new Foo&#8221;, the compiler knows to do &#8220;new Foo$&#8221; but the variable type stays &#8220;Foo&#8221;. Now you can mock/whatever Foo to your heart&#8217;s content.</p>
<p>If, for some reason, Foo really shouldn&#8217;t get an interface, perhaps you could add a java.lang.NoImplicitInterface annotation, which would tell the compiler to behave in the current/standard way (not that such a drastic change in compiler behavior would ever make it into Java itself).</p>
<p>A little while ago I was feeling out an architecture that used single-impl interfaces, and so built an annotation processor that does basically this:</p>
<p><a href="https://github.com/stephenh/interfacegen" rel="nofollow">https://github.com/stephenh/interfacegen</a></p>
<p>So you write Foo, add @GenInterface, and it will automatically create/update as-you-save an IFoo.</p>
<p>I&#8217;m not saying it&#8217;s perfect (and annotation processors in general can be finicky&#8211;especially this one, IIRC), but if you really want single-impl interfaces, it seems like a good compromise compared to maintaining both by hand.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Symphonious &#187; The Single Implementation Fallacy</title>
		<link>http://blog.codeaholics.org/2011/the-single-implementation-paradox/#comment-3</link>
		<dc:creator>Symphonious &#187; The Single Implementation Fallacy</dc:creator>
		<pubDate>Sat, 18 Jun 2011 17:42:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.codeaholics.org/?p=59#comment-3</guid>
		<description>[...] WebKit UpdateThe Single Implementation Fallacy As my colleague and favorite debating opponent Danny Yates noted: We got into a bit of a debate at work recently. It went a bit like this: “Gah! Why do we have [...]</description>
		<content:encoded><![CDATA[<p>[...] WebKit UpdateThe Single Implementation Fallacy As my colleague and favorite debating opponent Danny Yates noted: We got into a bit of a debate at work recently. It went a bit like this: “Gah! Why do we have [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using apc
Database Caching 1/4 queries in 0.001 seconds using disk: basic
Object Caching 324/325 objects using disk: basic

 Served from: blog.codeaholics.org @ 2013-05-20 09:58:16 by W3 Total Cache -->