<?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 for Fluffyelephant</title>
	<atom:link href="http://fluffyelephant.com/comments/feed/" rel="self" type="application/rss+xml" />
	<link>http://fluffyelephant.com</link>
	<description>Photography and Technology</description>
	<lastBuildDate>Wed, 21 Dec 2011 08:18:38 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>Comment on Robot-arm på sonen by toy helicopter</title>
		<link>http://fluffyelephant.com/2011/12/robot-arm-pa-sonen/comment-page-1/#comment-69</link>
		<dc:creator>toy helicopter</dc:creator>
		<pubDate>Wed, 21 Dec 2011 08:18:38 +0000</pubDate>
		<guid isPermaLink="false">http://fluffyelephant.com/?p=147#comment-69</guid>
		<description>Glad to visit this blog, keep it going.</description>
		<content:encoded><![CDATA[<p>Glad to visit this blog, keep it going.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Return this by Ruudjah</title>
		<link>http://fluffyelephant.com/2011/06/return-this/comment-page-1/#comment-12</link>
		<dc:creator>Ruudjah</dc:creator>
		<pubDate>Sun, 26 Jun 2011 20:02:50 +0000</pubDate>
		<guid isPermaLink="false">http://fluffyelephant.com/?p=41#comment-12</guid>
		<description>This solution I think is mainly going beyond the goal of fluent interfaces. You can find more solutions for this problem on the web, but the &#039;fluent&#039; part then becomes not so fluent anymore. The syntactical additions you&#039;d need for this to work properly are not worth the effort to maintain fluency in the code.</description>
		<content:encoded><![CDATA[<p>This solution I think is mainly going beyond the goal of fluent interfaces. You can find more solutions for this problem on the web, but the &#8216;fluent&#8217; part then becomes not so fluent anymore. The syntactical additions you&#8217;d need for this to work properly are not worth the effort to maintain fluency in the code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Return this by Matt</title>
		<link>http://fluffyelephant.com/2011/06/return-this/comment-page-1/#comment-11</link>
		<dc:creator>Matt</dc:creator>
		<pubDate>Sun, 26 Jun 2011 16:51:13 +0000</pubDate>
		<guid isPermaLink="false">http://fluffyelephant.com/?p=41#comment-11</guid>
		<description>Formatting ate my generics:


	interface FooFluent&lt;T extends FooFluent&lt;T&gt;&gt; {
	class FooConcrete implements FooFluent&lt;FooConcrete&gt; {</description>
		<content:encoded><![CDATA[<p>Formatting ate my generics:</p>
<p>	interface FooFluent&lt;T extends FooFluent&lt;T&gt;&gt; {<br />
	class FooConcrete implements FooFluent&lt;FooConcrete&gt; {</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Return this by Hristo Deshev</title>
		<link>http://fluffyelephant.com/2011/06/return-this/comment-page-1/#comment-10</link>
		<dc:creator>Hristo Deshev</dc:creator>
		<pubDate>Sun, 26 Jun 2011 16:33:05 +0000</pubDate>
		<guid isPermaLink="false">http://fluffyelephant.com/?p=41#comment-10</guid>
		<description>Smalltalkers have been doing this for years (and actually that&#039;s where the technique came from). I&#039;d advise readers to play for a bit with that language. You&#039;ll gain tons of insight about object-oriented programming and your Java will get better. A lot better.

I hear Pharo is a cool and friendly Smalltalk implementation you can start with: http://www.pharo-project.org/home</description>
		<content:encoded><![CDATA[<p>Smalltalkers have been doing this for years (and actually that&#8217;s where the technique came from). I&#8217;d advise readers to play for a bit with that language. You&#8217;ll gain tons of insight about object-oriented programming and your Java will get better. A lot better.</p>
<p>I hear Pharo is a cool and friendly Smalltalk implementation you can start with: <a href="http://www.pharo-project.org/home" rel="nofollow">http://www.pharo-project.org/home</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Return this by Matt</title>
		<link>http://fluffyelephant.com/2011/06/return-this/comment-page-1/#comment-9</link>
		<dc:creator>Matt</dc:creator>
		<pubDate>Sun, 26 Jun 2011 16:15:54 +0000</pubDate>
		<guid isPermaLink="false">http://fluffyelephant.com/?p=41#comment-9</guid>
		<description>You can still do this with concrete classes by adding a generic argument to your interface&#039;s type that takes a subtype of itself:
&lt;pre&gt;
	interface FooFluent {
		T setFoo(int foo);
		T setBar(int bar);
	}

	class FooConcrete implements FooFluent {
		public FooConcrete setFoo(int foo) {
			return this;
		}

		public FooConcrete setBar(int bar) {
			return this;
		}
	}
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>You can still do this with concrete classes by adding a generic argument to your interface&#8217;s type that takes a subtype of itself:</p>
<pre>
	interface FooFluent {
		T setFoo(int foo);
		T setBar(int bar);
	}

	class FooConcrete implements FooFluent {
		public FooConcrete setFoo(int foo) {
			return this;
		}

		public FooConcrete setBar(int bar) {
			return this;
		}
	}
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Return this by Paul Keeble</title>
		<link>http://fluffyelephant.com/2011/06/return-this/comment-page-1/#comment-7</link>
		<dc:creator>Paul Keeble</dc:creator>
		<pubDate>Sun, 26 Jun 2011 15:36:45 +0000</pubDate>
		<guid isPermaLink="false">http://fluffyelephant.com/?p=41#comment-7</guid>
		<description>Cloning rarely costs enough to matter. But by cloning the object we ensure that multiple users of the object aren&#039;t impacted by the changes. Strings being very much treated as values are an example of objects where changing them with clones makes far more sense, not because its the fastest implementation (although it can be) but because its much safer.

Concurrency is here and being used. Immutability is a sure fire way to make your objects work properly under multiple threads.

In a nuttshell the cost of cloning is normally so small you should ignore the performance impact and instead treat values as immutable. Life will be easier in the long run, they are certainly easier to debug than chains of modifiers.</description>
		<content:encoded><![CDATA[<p>Cloning rarely costs enough to matter. But by cloning the object we ensure that multiple users of the object aren&#8217;t impacted by the changes. Strings being very much treated as values are an example of objects where changing them with clones makes far more sense, not because its the fastest implementation (although it can be) but because its much safer.</p>
<p>Concurrency is here and being used. Immutability is a sure fire way to make your objects work properly under multiple threads.</p>
<p>In a nuttshell the cost of cloning is normally so small you should ignore the performance impact and instead treat values as immutable. Life will be easier in the long run, they are certainly easier to debug than chains of modifiers.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Return this by hmottestad</title>
		<link>http://fluffyelephant.com/2011/06/return-this/comment-page-1/#comment-6</link>
		<dc:creator>hmottestad</dc:creator>
		<pubDate>Sun, 26 Jun 2011 15:23:38 +0000</pubDate>
		<guid isPermaLink="false">http://fluffyelephant.com/?p=41#comment-6</guid>
		<description>True. In some cases you would have to make a choice between polymorphism and fluent interfaces (btw, thanks for letting me know what it&#039;s called).</description>
		<content:encoded><![CDATA[<p>True. In some cases you would have to make a choice between polymorphism and fluent interfaces (btw, thanks for letting me know what it&#8217;s called).</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Return this by Ross Bonner</title>
		<link>http://fluffyelephant.com/2011/06/return-this/comment-page-1/#comment-5</link>
		<dc:creator>Ross Bonner</dc:creator>
		<pubDate>Sun, 26 Jun 2011 15:22:37 +0000</pubDate>
		<guid isPermaLink="false">http://fluffyelephant.com/?p=41#comment-5</guid>
		<description>The pattern you refer to is commonly known as a fluent interface, see ... &lt;a href=&quot;http://en.wikipedia.org/wiki/Fluent_interface&quot; rel=&quot;nofollow&quot;&gt;http://en.wikipedia.org/wiki/Fluent_interface&lt;/a&gt;.</description>
		<content:encoded><![CDATA[<p>The pattern you refer to is commonly known as a fluent interface, see &#8230; <a href="http://en.wikipedia.org/wiki/Fluent_interface" rel="nofollow">http://en.wikipedia.org/wiki/Fluent_interface</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Return this by hmottestad</title>
		<link>http://fluffyelephant.com/2011/06/return-this/comment-page-1/#comment-4</link>
		<dc:creator>hmottestad</dc:creator>
		<pubDate>Sun, 26 Jun 2011 15:19:28 +0000</pubDate>
		<guid isPermaLink="false">http://fluffyelephant.com/?p=41#comment-4</guid>
		<description>How about now?</description>
		<content:encoded><![CDATA[<p>How about now?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Return this by Ruudjah</title>
		<link>http://fluffyelephant.com/2011/06/return-this/comment-page-1/#comment-3</link>
		<dc:creator>Ruudjah</dc:creator>
		<pubDate>Sun, 26 Jun 2011 14:00:08 +0000</pubDate>
		<guid isPermaLink="false">http://fluffyelephant.com/?p=41#comment-3</guid>
		<description>This technique is called fluent interfaces (http://en.wikipedia.org/wiki/Fluent_interface). This technique has a problem in Java: polymorphism. Suppose you have an interface SomeInterface, with a getter/setter Name (getName, setName). In the setter, you&#039;d require implementors to return the interface type. Now, when you write something like

SomeInterface someInstance = new ConcreteClass().setName(&quot;I has a name&quot;);

It works, because setName is part of the interface specification. ConcreteClass now has a getter/setter for amount, getAmount and setAmount. When constructing, you might want to also set the amount, so you&#039;ll endup with

SomeInterface someInstance = new ConcreteClass().setName(&quot;I has a name&quot;).setAmount(42);

This won&#039;t work, because amount is a property of the concrete class, not for the interface. You either have to not use polymorphism or ditch the fluent interface concept.</description>
		<content:encoded><![CDATA[<p>This technique is called fluent interfaces (<a href="http://en.wikipedia.org/wiki/Fluent_interface" rel="nofollow">http://en.wikipedia.org/wiki/Fluent_interface</a>). This technique has a problem in Java: polymorphism. Suppose you have an interface SomeInterface, with a getter/setter Name (getName, setName). In the setter, you&#8217;d require implementors to return the interface type. Now, when you write something like</p>
<p>SomeInterface someInstance = new ConcreteClass().setName(&#8220;I has a name&#8221;);</p>
<p>It works, because setName is part of the interface specification. ConcreteClass now has a getter/setter for amount, getAmount and setAmount. When constructing, you might want to also set the amount, so you&#8217;ll endup with</p>
<p>SomeInterface someInstance = new ConcreteClass().setName(&#8220;I has a name&#8221;).setAmount(42);</p>
<p>This won&#8217;t work, because amount is a property of the concrete class, not for the interface. You either have to not use polymorphism or ditch the fluent interface concept.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

