<?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: Creating a fluent interface for Google Collections</title>
	<atom:link href="http://codemonkeyism.com/creating-a-fluent-interface-for-google-collections/feed/" rel="self" type="application/rss+xml" />
	<link>http://codemonkeyism.com/creating-a-fluent-interface-for-google-collections/</link>
	<description></description>
	<lastBuildDate>Wed, 09 May 2012 22:39:34 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: sandrar</title>
		<link>http://codemonkeyism.com/creating-a-fluent-interface-for-google-collections/comment-page-1/#comment-243249</link>
		<dc:creator>sandrar</dc:creator>
		<pubDate>Thu, 10 Sep 2009 13:38:03 +0000</pubDate>
		<guid isPermaLink="false">http://stephan.reposita.org/archives/2007/10/17/creating-a-fluent-interface-for-google-collections/#comment-243249</guid>
		<description>Hi! I was surfing and found your blog post... nice! I love your blog.  :) Cheers! Sandra. R.</description>
		<content:encoded><![CDATA[<p>Hi! I was surfing and found your blog post&#8230; nice! I love your blog.  :) Cheers! Sandra. R.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Ribeiro</title>
		<link>http://codemonkeyism.com/creating-a-fluent-interface-for-google-collections/comment-page-1/#comment-230170</link>
		<dc:creator>Daniel Ribeiro</dc:creator>
		<pubDate>Thu, 14 May 2009 00:25:38 +0000</pubDate>
		<guid isPermaLink="false">http://stephan.reposita.org/archives/2007/10/17/creating-a-fluent-interface-for-google-collections/#comment-230170</guid>
		<description>I also thought that Google Collections needed more &quot;fluency&quot;. Not only Google&#039;s, but also plain old java collections. Not to mention iteration abstraction. Therefore, I created a project called &lt;a href=&quot;http://code.google.com/p/fluentjava/&quot; rel=&quot;nofollow&quot;&gt;Fluent Java&lt;/a&gt; that makes up for it. Also, it is &lt;a href=&quot;http://code.google.com/p/fluentjava/wiki/GettingStarted#Combining_Google_Collections_And_Hamcrest_Into_One_Closure&quot; rel=&quot;nofollow&quot;&gt;compatible&lt;/a&gt; with any collections library out there, and Functions classes as well (such as those from Hamcrest, Google Predicates and Functions, and ForkJoin Common Ops).</description>
		<content:encoded><![CDATA[<p>I also thought that Google Collections needed more &#8220;fluency&#8221;. Not only Google&#8217;s, but also plain old java collections. Not to mention iteration abstraction. Therefore, I created a project called <a href="http://code.google.com/p/fluentjava/" rel="nofollow">Fluent Java</a> that makes up for it. Also, it is <a href="http://code.google.com/p/fluentjava/wiki/GettingStarted#Combining_Google_Collections_And_Hamcrest_Into_One_Closure" rel="nofollow">compatible</a> with any collections library out there, and Functions classes as well (such as those from Hamcrest, Google Predicates and Functions, and ForkJoin Common Ops).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stephan</title>
		<link>http://codemonkeyism.com/creating-a-fluent-interface-for-google-collections/comment-page-1/#comment-34814</link>
		<dc:creator>stephan</dc:creator>
		<pubDate>Fri, 19 Oct 2007 05:06:52 +0000</pubDate>
		<guid isPermaLink="false">http://stephan.reposita.org/archives/2007/10/17/creating-a-fluent-interface-for-google-collections/#comment-34814</guid>
		<description>Hi Jimmy, yes sure. I agree with you why fluent interfaces are becoming popular. Though I don&#039;t agree with the common opinion that fluent interfaces are a poor mans DSL. They are more than that (and less than that). They have different goals than DSLs. I guess I have to write a paper to make myself clear.

About RSpec and Watir: I&#039;ve been wrestling with an parser for Wiki syntax for the last 7 years without success. Writing parsers is currently very hard. Because of this, Radeox as a wiki engine has still a regex &#039;parser&#039; no real parser.

People like Ruby because they can create a language without a parser. When there are easy parser tools for the JVM or CLR - and Tatoo is certainly a first step - every developer can writer a parser which &#039;maps&#039; a DSL to a base language on the JVM or CLR. Then Ruby with it&#039;s language defining abilities will look much less adorable.

And after 15 years with dynamic languages (TCL, Perl, Python, Ruby) I it will be a very hard way to make great IDEs for them. The current Grails/Groovy support in IDEA is the best you can get - and it&#039;s nice. But poor compared to the Java support. They can gather runtime information to make the IDE understand the code better, though I guess there are some natural limits to that.</description>
		<content:encoded><![CDATA[<p>Hi Jimmy, yes sure. I agree with you why fluent interfaces are becoming popular. Though I don&#8217;t agree with the common opinion that fluent interfaces are a poor mans DSL. They are more than that (and less than that). They have different goals than DSLs. I guess I have to write a paper to make myself clear.</p>
<p>About RSpec and Watir: I&#8217;ve been wrestling with an parser for Wiki syntax for the last 7 years without success. Writing parsers is currently very hard. Because of this, Radeox as a wiki engine has still a regex &#8216;parser&#8217; no real parser.</p>
<p>People like Ruby because they can create a language without a parser. When there are easy parser tools for the JVM or CLR &#8211; and Tatoo is certainly a first step &#8211; every developer can writer a parser which &#8216;maps&#8217; a DSL to a base language on the JVM or CLR. Then Ruby with it&#8217;s language defining abilities will look much less adorable.</p>
<p>And after 15 years with dynamic languages (TCL, Perl, Python, Ruby) I it will be a very hard way to make great IDEs for them. The current Grails/Groovy support in IDEA is the best you can get &#8211; and it&#8217;s nice. But poor compared to the Java support. They can gather runtime information to make the IDE understand the code better, though I guess there are some natural limits to that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jimmy Bogard</title>
		<link>http://codemonkeyism.com/creating-a-fluent-interface-for-google-collections/comment-page-1/#comment-34759</link>
		<dc:creator>Jimmy Bogard</dc:creator>
		<pubDate>Thu, 18 Oct 2007 21:06:32 +0000</pubDate>
		<guid isPermaLink="false">http://stephan.reposita.org/archives/2007/10/17/creating-a-fluent-interface-for-google-collections/#comment-34759</guid>
		<description>I wouldn&#039;t say they&#039;re stupid per se, as I used them extensively when creating NBehave.  There are definitely some caveats with them, especially when trying to debug them.

At least in C#, an entire block of fluent interface code done through method chaining counts as one line of code to the debugger, so you don&#039;t know which method call in the chain is giving you issues.  This can get extremely annoying when you have particularly large fluent interface blocks.

I think fluent interfaces are becoming popular because:
- Building real (or external) DSLs is hard
- Still no solid cross-platform dynamic language support, i.e. JRuby or IronRuby
- Fluent interface APIs can be used with familiar languages like Java and C#

We use NUnit a lot, but get very jealous when we see our QA guys using RSpec and Watir.  All of the noise of the syntax goes away and it becomes much more readable.  But until these dynamic languages can run easily in the JVM or the CLR, and have great IDE support, fluent interfaces are definitely the way to go.</description>
		<content:encoded><![CDATA[<p>I wouldn&#8217;t say they&#8217;re stupid per se, as I used them extensively when creating NBehave.  There are definitely some caveats with them, especially when trying to debug them.</p>
<p>At least in C#, an entire block of fluent interface code done through method chaining counts as one line of code to the debugger, so you don&#8217;t know which method call in the chain is giving you issues.  This can get extremely annoying when you have particularly large fluent interface blocks.</p>
<p>I think fluent interfaces are becoming popular because:<br />
- Building real (or external) DSLs is hard<br />
- Still no solid cross-platform dynamic language support, i.e. JRuby or IronRuby<br />
- Fluent interface APIs can be used with familiar languages like Java and C#</p>
<p>We use NUnit a lot, but get very jealous when we see our QA guys using RSpec and Watir.  All of the noise of the syntax goes away and it becomes much more readable.  But until these dynamic languages can run easily in the JVM or the CLR, and have great IDE support, fluent interfaces are definitely the way to go.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stephan</title>
		<link>http://codemonkeyism.com/creating-a-fluent-interface-for-google-collections/comment-page-1/#comment-34723</link>
		<dc:creator>stephan</dc:creator>
		<pubDate>Thu, 18 Oct 2007 13:08:51 +0000</pubDate>
		<guid isPermaLink="false">http://stephan.reposita.org/archives/2007/10/17/creating-a-fluent-interface-for-google-collections/#comment-34723</guid>
		<description>Hi Brian,

I think a fluent interface uses several patterns and provides several solution. The solutions can be Building-of-objects or can be modelling business logic (mostly when used with closures). As Java does not support closures yet, most fluent interface applications currently fall into the builder domainBeside that another pattern fluent interfaces use is the Facade pattern. But fluent interfaces are more than variants on facades and builders. They are a mixture of DSL, builders, facades, readable APIs, context selection and other ideas. So yes in this case it&#039;s mainly a builder implementation. Not in other cases though.

I thought about the finish() method. Usually I use a create() or make() method and would like to use do() for executing filters (Java doesn&#039;t like do though). But sometimes I find it more fitting to exend the base class and drop the creation method call as a last call in the chain.</description>
		<content:encoded><![CDATA[<p>Hi Brian,</p>
<p>I think a fluent interface uses several patterns and provides several solution. The solutions can be Building-of-objects or can be modelling business logic (mostly when used with closures). As Java does not support closures yet, most fluent interface applications currently fall into the builder domainBeside that another pattern fluent interfaces use is the Facade pattern. But fluent interfaces are more than variants on facades and builders. They are a mixture of DSL, builders, facades, readable APIs, context selection and other ideas. So yes in this case it&#8217;s mainly a builder implementation. Not in other cases though.</p>
<p>I thought about the finish() method. Usually I use a create() or make() method and would like to use do() for executing filters (Java doesn&#8217;t like do though). But sometimes I find it more fitting to exend the base class and drop the creation method call as a last call in the chain.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Slesinsky</title>
		<link>http://codemonkeyism.com/creating-a-fluent-interface-for-google-collections/comment-page-1/#comment-34598</link>
		<dc:creator>Brian Slesinsky</dc:creator>
		<pubDate>Wed, 17 Oct 2007 15:40:46 +0000</pubDate>
		<guid isPermaLink="false">http://stephan.reposita.org/archives/2007/10/17/creating-a-fluent-interface-for-google-collections/#comment-34598</guid>
		<description>I think if you&#039;re going to do a fluent interface, it should be using a builder pattern:

Iterable filtered =  
    Iterables.with(names)  
     .addFilter(or(isEqualTo(&quot;Chris&quot;), isEqualTo(&quot;Miha&quot;)))  
     .addFilter(lengthLessThan(5))
     .finish();

The idea is that all the intermediate objects should be instances of IterableBuilder, which has the &quot;fluent&quot; methods.  The finish() method converts an IterableBuilder back to a plain Iterator.  This way the &quot;fluent&quot; methods don&#039;t clutter up the interface when you&#039;re not modifying the Iterable.

Also, if there is an IterableBuilder object then I think it&#039;s fine to modify-in-place rather than creating a new instance on each method call, which may be important for performance.</description>
		<content:encoded><![CDATA[<p>I think if you&#8217;re going to do a fluent interface, it should be using a builder pattern:</p>
<p>Iterable filtered =<br />
    Iterables.with(names)<br />
     .addFilter(or(isEqualTo(&#8220;Chris&#8221;), isEqualTo(&#8220;Miha&#8221;)))<br />
     .addFilter(lengthLessThan(5))<br />
     .finish();</p>
<p>The idea is that all the intermediate objects should be instances of IterableBuilder, which has the &#8220;fluent&#8221; methods.  The finish() method converts an IterableBuilder back to a plain Iterator.  This way the &#8220;fluent&#8221; methods don&#8217;t clutter up the interface when you&#8217;re not modifying the Iterable.</p>
<p>Also, if there is an IterableBuilder object then I think it&#8217;s fine to modify-in-place rather than creating a new instance on each method call, which may be important for performance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stephan</title>
		<link>http://codemonkeyism.com/creating-a-fluent-interface-for-google-collections/comment-page-1/#comment-34573</link>
		<dc:creator>stephan</dc:creator>
		<pubDate>Wed, 17 Oct 2007 10:29:38 +0000</pubDate>
		<guid isPermaLink="false">http://stephan.reposita.org/archives/2007/10/17/creating-a-fluent-interface-for-google-collections/#comment-34573</guid>
		<description>Hi Kevin,

To tell you a secret, I&#039;ve thought about the same thing. When writing about fluent interfaces for object creation

http://stephan.reposita.org/archives/2007/10/10/fluent-interface-and-reflection-for-object-building-in-java/

I was wondering if fluent interface is a concern of the Person bean which it creates or if it&#039;s a different concern. When this should be the case, a different class called PersonFluentInterface is good practice, as each class should encapsulate one concern, not different ones. This also makes the Person bean smaller and easier to understand. When being interested in the fluent interface, one could look into PersonFluentInterface and see the methods and code - and not be confused with the Person concerns.

&quot;Anyway, though, as time permits I’ll draw up a three-way comparison of the apis and see if we can shake out which one’s best.&quot;

That would be great and I would be interested in the result. Thanks for your comment.</description>
		<content:encoded><![CDATA[<p>Hi Kevin,</p>
<p>To tell you a secret, I&#8217;ve thought about the same thing. When writing about fluent interfaces for object creation</p>
<p><a href="http://stephan.reposita.org/archives/2007/10/10/fluent-interface-and-reflection-for-object-building-in-java/" rel="nofollow">http://stephan.reposita.org/archives/2007/10/10/fluent-interface-and-reflection-for-object-building-in-java/</a></p>
<p>I was wondering if fluent interface is a concern of the Person bean which it creates or if it&#8217;s a different concern. When this should be the case, a different class called PersonFluentInterface is good practice, as each class should encapsulate one concern, not different ones. This also makes the Person bean smaller and easier to understand. When being interested in the fluent interface, one could look into PersonFluentInterface and see the methods and code &#8211; and not be confused with the Person concerns.</p>
<p>&#8220;Anyway, though, as time permits I’ll draw up a three-way comparison of the apis and see if we can shake out which one’s best.&#8221;</p>
<p>That would be great and I would be interested in the result. Thanks for your comment.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kevin Bourrillion</title>
		<link>http://codemonkeyism.com/creating-a-fluent-interface-for-google-collections/comment-page-1/#comment-34569</link>
		<dc:creator>Kevin Bourrillion</dc:creator>
		<pubDate>Wed, 17 Oct 2007 10:09:09 +0000</pubDate>
		<guid isPermaLink="false">http://stephan.reposita.org/archives/2007/10/17/creating-a-fluent-interface-for-google-collections/#comment-34569</guid>
		<description>Tell you a secret, I&#039;ve hated Iterables.transform() and Iterables.filter() ever since about a month after I wrote em.  And your solution to the problem is an interesting one which I had not thought of.

The other fix that I had in mind:  make Function and Predicate into abstract classes which have the transform(), filter(), and other related methods right there on them.  To me, this is a much more sound idea from an OO perspective than saying you have to go call out to some static &quot;Iterables&quot; method (which is entirely nonobvious).

As well, it means that in the resulting code, filters and transforms appear in &quot;infix&quot;, not prefix form, which I find a lot easier to read.

The down side of all this:  *occasionally*, but not often, someone does want to implement Predicate/Function from an existing class that already has a superclass, thankyouverymuch. There are some ways we could deal with that, though.  Anyway, though, as time permits I&#039;ll draw up a three-way comparison of the apis and see if we can shake out which one&#039;s best.</description>
		<content:encoded><![CDATA[<p>Tell you a secret, I&#8217;ve hated Iterables.transform() and Iterables.filter() ever since about a month after I wrote em.  And your solution to the problem is an interesting one which I had not thought of.</p>
<p>The other fix that I had in mind:  make Function and Predicate into abstract classes which have the transform(), filter(), and other related methods right there on them.  To me, this is a much more sound idea from an OO perspective than saying you have to go call out to some static &#8220;Iterables&#8221; method (which is entirely nonobvious).</p>
<p>As well, it means that in the resulting code, filters and transforms appear in &#8220;infix&#8221;, not prefix form, which I find a lot easier to read.</p>
<p>The down side of all this:  *occasionally*, but not often, someone does want to implement Predicate/Function from an existing class that already has a superclass, thankyouverymuch. There are some ways we could deal with that, though.  Anyway, though, as time permits I&#8217;ll draw up a three-way comparison of the apis and see if we can shake out which one&#8217;s best.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Database Caching using disk

Served from: codemonkeyism.com @ 2012-05-17 09:59:11 -->
