<?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"
	>
<channel>
	<title>Comments on: Resolved: interfaces should not implement Serializable</title>
	<atom:link href="http://cafe.elharo.com/blogroll/resolved-interfaces-should-not-implement-serializable/feed/" rel="self" type="application/rss+xml" />
	<link>http://cafe.elharo.com/blogroll/resolved-interfaces-should-not-implement-serializable/</link>
	<description>Longer than a blog; shorter than a book</description>
	<pubDate>Sun, 12 Oct 2008 05:02:02 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
		<item>
		<title>By: morganusvitus</title>
		<link>http://cafe.elharo.com/blogroll/resolved-interfaces-should-not-implement-serializable/#comment-73043</link>
		<dc:creator>morganusvitus</dc:creator>
		<pubDate>Thu, 05 Apr 2007 10:21:11 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/resolved-interfaces-should-not-implement-serializable/#comment-73043</guid>
		<description>The site looks great ! Thanks for all your help ( past, present and future !)</description>
		<content:encoded><![CDATA[<p>The site looks great ! Thanks for all your help ( past, present and future !)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: beders</title>
		<link>http://cafe.elharo.com/blogroll/resolved-interfaces-should-not-implement-serializable/#comment-4064</link>
		<dc:creator>beders</dc:creator>
		<pubDate>Fri, 16 Jun 2006 11:22:41 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/resolved-interfaces-should-not-implement-serializable/#comment-4064</guid>
		<description>Please use a more robust comment solution.
Mine has also been deleted for no apparent reason.
Thank you</description>
		<content:encoded><![CDATA[<p>Please use a more robust comment solution.<br />
Mine has also been deleted for no apparent reason.<br />
Thank you</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sporadic reader</title>
		<link>http://cafe.elharo.com/blogroll/resolved-interfaces-should-not-implement-serializable/#comment-3747</link>
		<dc:creator>sporadic reader</dc:creator>
		<pubDate>Wed, 14 Jun 2006 07:29:39 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/resolved-interfaces-should-not-implement-serializable/#comment-3747</guid>
		<description>Elliotte, please note :

1. Classes IMPLEMENT interfaces
2. Interfaces EXTEND interfaces</description>
		<content:encoded><![CDATA[<p>Elliotte, please note :</p>
<p>1. Classes IMPLEMENT interfaces<br />
2. Interfaces EXTEND interfaces</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Elliotte Rusty Harold</title>
		<link>http://cafe.elharo.com/blogroll/resolved-interfaces-should-not-implement-serializable/#comment-3660</link>
		<dc:creator>Elliotte Rusty Harold</dc:creator>
		<pubDate>Tue, 13 Jun 2006 12:58:27 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/resolved-interfaces-should-not-implement-serializable/#comment-3660</guid>
		<description>Possibly I accidentally deleted your comment while cleaning spam. That's been happening a lot lately. I'm working on a more reliable spam filtering solution.</description>
		<content:encoded><![CDATA[<p>Possibly I accidentally deleted your comment while cleaning spam. That&#8217;s been happening a lot lately. I&#8217;m working on a more reliable spam filtering solution.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Horaci</title>
		<link>http://cafe.elharo.com/blogroll/resolved-interfaces-should-not-implement-serializable/#comment-3655</link>
		<dc:creator>Horaci</dc:creator>
		<pubDate>Tue, 13 Jun 2006 11:37:05 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/resolved-interfaces-should-not-implement-serializable/#comment-3655</guid>
		<description>I wrote another comment suggesting "Iâ€™d think the same applies to synchronized methods on interfaces" should be "Iâ€™d think the same applies to synchronized keyword on overrideable methods", as interfaces don't allow synchronized keyword.

This comment seems to be lost, although I could see it in the website right after adding it... am I missing something here ?</description>
		<content:encoded><![CDATA[<p>I wrote another comment suggesting &#8220;Iâ€™d think the same applies to synchronized methods on interfaces&#8221; should be &#8220;Iâ€™d think the same applies to synchronized keyword on overrideable methods&#8221;, as interfaces don&#8217;t allow synchronized keyword.</p>
<p>This comment seems to be lost, although I could see it in the website right after adding it&#8230; am I missing something here ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Horaci</title>
		<link>http://cafe.elharo.com/blogroll/resolved-interfaces-should-not-implement-serializable/#comment-3151</link>
		<dc:creator>Horaci</dc:creator>
		<pubDate>Fri, 09 Jun 2006 11:47:54 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/resolved-interfaces-should-not-implement-serializable/#comment-3151</guid>
		<description>I see Serializable as an implementation detail and not part of the contract a class should adhere to. 
As such I wouldn't use Serializable in an interface; I'd use it in a class. I'd think the same applies to synchronized methods on interfaces.

Maybe the line between what's contract and what's implementation is not always clear, but given marking an interface Serializable doesn't give you any guarantees about the classes implementing it I would prefer not to use it at all. 

So how can an application enforce 3rd party implementations of APIs are serializable ? They just can't do it at compile time. All they can do is try to handle NotSerializableExceptions if the class doesn't implement Serializable or just fail if class does implement Serializable but hasn't coded properly for serialization. In any case it won't be the application's problem if an implementation is broken.</description>
		<content:encoded><![CDATA[<p>I see Serializable as an implementation detail and not part of the contract a class should adhere to.<br />
As such I wouldn&#8217;t use Serializable in an interface; I&#8217;d use it in a class. I&#8217;d think the same applies to synchronized methods on interfaces.</p>
<p>Maybe the line between what&#8217;s contract and what&#8217;s implementation is not always clear, but given marking an interface Serializable doesn&#8217;t give you any guarantees about the classes implementing it I would prefer not to use it at all. </p>
<p>So how can an application enforce 3rd party implementations of APIs are serializable ? They just can&#8217;t do it at compile time. All they can do is try to handle NotSerializableExceptions if the class doesn&#8217;t implement Serializable or just fail if class does implement Serializable but hasn&#8217;t coded properly for serialization. In any case it won&#8217;t be the application&#8217;s problem if an implementation is broken.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex Blewitt</title>
		<link>http://cafe.elharo.com/blogroll/resolved-interfaces-should-not-implement-serializable/#comment-3052</link>
		<dc:creator>Alex Blewitt</dc:creator>
		<pubDate>Thu, 08 Jun 2006 17:34:54 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/resolved-interfaces-should-not-implement-serializable/#comment-3052</guid>
		<description>Getting serializable right may be difficult, but getting it wrong is easy. Anything that isn't serializable can't be used in a serializable mechanism, and you only need one tooth breaking off a cog to make an entire machine grind to a halt.

If you've got control over both the client and the server, then it's not really much of an issue -- if you get a serialisation error, then you update the classpath on both and bounce. If you're dealing with a more separated system where you maybe don't have control, you probably shouldn't be using serialization anyway, and using something independent like XML to transfer data.

If your interface is something that needs to be used in a Serializable context, then marking that interface extend Serializable is a good way of enforcing the contract to implementors of that interface. Let's face it, if you have a method called bar() in the interface, you're expecting that classes that implement the interface called bar() do it properly, right? And if it was a super interface that defined foo() (which the class also had to implement) that it would do it correctly too, that it would also be done properly? Or implementing toString() or equals() that come from a superclass?

So why is it any different from Serializable, just because there's no method? You're stating a requirement by implementing the interface, and subclasses should respect that. If they don't, they are broken.</description>
		<content:encoded><![CDATA[<p>Getting serializable right may be difficult, but getting it wrong is easy. Anything that isn&#8217;t serializable can&#8217;t be used in a serializable mechanism, and you only need one tooth breaking off a cog to make an entire machine grind to a halt.</p>
<p>If you&#8217;ve got control over both the client and the server, then it&#8217;s not really much of an issue &#8212; if you get a serialisation error, then you update the classpath on both and bounce. If you&#8217;re dealing with a more separated system where you maybe don&#8217;t have control, you probably shouldn&#8217;t be using serialization anyway, and using something independent like XML to transfer data.</p>
<p>If your interface is something that needs to be used in a Serializable context, then marking that interface extend Serializable is a good way of enforcing the contract to implementors of that interface. Let&#8217;s face it, if you have a method called bar() in the interface, you&#8217;re expecting that classes that implement the interface called bar() do it properly, right? And if it was a super interface that defined foo() (which the class also had to implement) that it would do it correctly too, that it would also be done properly? Or implementing toString() or equals() that come from a superclass?</p>
<p>So why is it any different from Serializable, just because there&#8217;s no method? You&#8217;re stating a requirement by implementing the interface, and subclasses should respect that. If they don&#8217;t, they are broken.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Cowan</title>
		<link>http://cafe.elharo.com/blogroll/resolved-interfaces-should-not-implement-serializable/#comment-3042</link>
		<dc:creator>John Cowan</dc:creator>
		<pubDate>Thu, 08 Jun 2006 15:46:36 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/resolved-interfaces-should-not-implement-serializable/#comment-3042</guid>
		<description>Er, for "extending SomeInterface" read "implementing SomeInterface", of course.  You &lt;i&gt;really&lt;/i&gt; need a "Preview Comment" button.</description>
		<content:encoded><![CDATA[<p>Er, for &#8220;extending SomeInterface&#8221; read &#8220;implementing SomeInterface&#8221;, of course.  You <i>really</i> need a &#8220;Preview Comment&#8221; button.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Cowan</title>
		<link>http://cafe.elharo.com/blogroll/resolved-interfaces-should-not-implement-serializable/#comment-3041</link>
		<dc:creator>John Cowan</dc:creator>
		<pubDate>Thu, 08 Jun 2006 15:45:31 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/resolved-interfaces-should-not-implement-serializable/#comment-3041</guid>
		<description>I think you are quite right, but I would put the argument another way (hopefully clearer):

What is in fact serializable is not a class or an interface but an instance.  Classes have instances, so it makes sense to say that the instances of SomeClass extend Serializable.  Interfaces as such don't have instances (instances conform to interfaces), so it does not make sense.

For SomeInterface to extend Serializable is essentially to demand that any class extending SomeInterface have serializable instances.  Unfortunately, since Serializable is a marker interface, there is no way for the compiler to check whether the instances are truly serializable or not.  Therefore, having SomeInterface extend Serializable makes promises that may or may not be kept.

Exactly the same arguments apply to Cloneable, to the nonstandard interface Immutable, and indeed to any other marker interface.  In any case, the only operation you can perform on a marker interface is to ask whether an object is an instance of it, a function which can now be performed better with annotations.  IMHO, annotations should supersede marker interfaces in future designs.</description>
		<content:encoded><![CDATA[<p>I think you are quite right, but I would put the argument another way (hopefully clearer):</p>
<p>What is in fact serializable is not a class or an interface but an instance.  Classes have instances, so it makes sense to say that the instances of SomeClass extend Serializable.  Interfaces as such don&#8217;t have instances (instances conform to interfaces), so it does not make sense.</p>
<p>For SomeInterface to extend Serializable is essentially to demand that any class extending SomeInterface have serializable instances.  Unfortunately, since Serializable is a marker interface, there is no way for the compiler to check whether the instances are truly serializable or not.  Therefore, having SomeInterface extend Serializable makes promises that may or may not be kept.</p>
<p>Exactly the same arguments apply to Cloneable, to the nonstandard interface Immutable, and indeed to any other marker interface.  In any case, the only operation you can perform on a marker interface is to ask whether an object is an instance of it, a function which can now be performed better with annotations.  IMHO, annotations should supersede marker interfaces in future designs.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
