<?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: Closure Time for Java</title>
	<atom:link href="http://www.blog.dannynet.net/archives/39/feed" rel="self" type="application/rss+xml" />
	<link>http://www.blog.dannynet.net/archives/39</link>
	<description>Pondering Programming and Poetry</description>
	<pubDate>Thu, 28 Aug 2008 23:03:48 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
		<item>
		<title>By: Danny&#8217;s Blog &#187; Blog Archive &#187; How Java is Ruby?</title>
		<link>http://www.blog.dannynet.net/archives/39#comment-479</link>
		<dc:creator>Danny&#8217;s Blog &#187; Blog Archive &#187; How Java is Ruby?</dc:creator>
		<pubDate>Tue, 28 Mar 2006 12:46:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.blog.dannynet.net/?p=39#comment-479</guid>
		<description>[...] Following up on my recent post on Ruby and Rails&#8217; enterprise-readiness, we might want to rethink any strategies comparing or opposing Ruby with Java. Don&#8217;t get me wrong: Ruby is a breeze where Java is a mouldy draught; Ruby is a butterfly where Java is an ostrich; Ruby makes you smile where Java is often a maniacal grin. But also they&#8217;re both gusts of air, both have wings, both evoke emotion. Both are object oriented languages, both have classes, and methods, and instance variables, and structured in-code documentation, and closures (more or less), both are pass-by-reference-by-value, both have apis for Lists and Maps and Files and Regexps&#8230; The list goes on and on. [...]</description>
		<content:encoded><![CDATA[<p>[...] Following up on my recent post on Ruby and Rails&#8217; enterprise-readiness, we might want to rethink any strategies comparing or opposing Ruby with Java. Don&#8217;t get me wrong: Ruby is a breeze where Java is a mouldy draught; Ruby is a butterfly where Java is an ostrich; Ruby makes you smile where Java is often a maniacal grin. But also they&#8217;re both gusts of air, both have wings, both evoke emotion. Both are object oriented languages, both have classes, and methods, and instance variables, and structured in-code documentation, and closures (more or less), both are pass-by-reference-by-value, both have apis for Lists and Maps and Files and Regexps&#8230; The list goes on and on. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Danny</title>
		<link>http://www.blog.dannynet.net/archives/39#comment-473</link>
		<dc:creator>Danny</dc:creator>
		<pubDate>Sat, 25 Mar 2006 08:59:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.blog.dannynet.net/?p=39#comment-473</guid>
		<description>Ivan: I totally agree with your conclusion. I'm not completely sure about your solution (to create a new class instead of the anonymous inner class), but I'll certainly try how it works out. It won't be one-liners though if you need to get data into and out of the closure...</description>
		<content:encoded><![CDATA[<p>Ivan: I totally agree with your conclusion. I&#8217;m not completely sure about your solution (to create a new class instead of the anonymous inner class), but I&#8217;ll certainly try how it works out. It won&#8217;t be one-liners though if you need to get data into and out of the closure&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ivan</title>
		<link>http://www.blog.dannynet.net/archives/39#comment-472</link>
		<dc:creator>Ivan</dc:creator>
		<pubDate>Sat, 25 Mar 2006 00:06:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.blog.dannynet.net/?p=39#comment-472</guid>
		<description>I just saw this article from the net, and I want to jump in here to say you don't have to use anonymous inner classes.  Just create a new class and place it on the file system like any other.  This shouldn't be such an "evil", it promotes reusability, and if you think about the idea of closures, that they are very atomic bits of functionality, you'll realize this is a great thing.

Also, the Java Commons Collections API can go a bit above inlining hard-coded closures, for instance, the chained closure facility:
Closure[] closures = { printer, counter, prefixer };
Closure  execute = ClosureUtils.chainedClosure(closures);
CollectionUtils.forAllDo(somearraylist,execute);

Good to go :)

Ideally you could use alot of closures in succession or under custom designations to implement your business rules.

I do like my Python list comprehensions, but I'm for reusability ;)

The only thing that has to happen now is for common collections to take it's api to the generics level, so we avoid the object cast on it's way in.

Neils, you are wrong in suggesting that those are the only other options in terms of getting items out of the closure.  You can implement any type of retrieving/extra method you might want. Why not as the primitive instead?  Just because you're in Java doens't mean you *have* to use an object wrapper at every point.

The key focal point is that you begin to see collections as things to operate on, instead of things to manually loop through, and then suddenly, the world of Java is full of one-liners ;)</description>
		<content:encoded><![CDATA[<p>I just saw this article from the net, and I want to jump in here to say you don&#8217;t have to use anonymous inner classes.  Just create a new class and place it on the file system like any other.  This shouldn&#8217;t be such an &#8220;evil&#8221;, it promotes reusability, and if you think about the idea of closures, that they are very atomic bits of functionality, you&#8217;ll realize this is a great thing.</p>
<p>Also, the Java Commons Collections API can go a bit above inlining hard-coded closures, for instance, the chained closure facility:<br />
Closure[] closures = { printer, counter, prefixer };<br />
Closure  execute = ClosureUtils.chainedClosure(closures);<br />
CollectionUtils.forAllDo(somearraylist,execute);</p>
<p>Good to go <img src='http://www.blog.dannynet.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Ideally you could use alot of closures in succession or under custom designations to implement your business rules.</p>
<p>I do like my Python list comprehensions, but I&#8217;m for reusability <img src='http://www.blog.dannynet.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>The only thing that has to happen now is for common collections to take it&#8217;s api to the generics level, so we avoid the object cast on it&#8217;s way in.</p>
<p>Neils, you are wrong in suggesting that those are the only other options in terms of getting items out of the closure.  You can implement any type of retrieving/extra method you might want. Why not as the primitive instead?  Just because you&#8217;re in Java doens&#8217;t mean you *have* to use an object wrapper at every point.</p>
<p>The key focal point is that you begin to see collections as things to operate on, instead of things to manually loop through, and then suddenly, the world of Java is full of one-liners <img src='http://www.blog.dannynet.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Gardner</title>
		<link>http://www.blog.dannynet.net/archives/39#comment-457</link>
		<dc:creator>Chris Gardner</dc:creator>
		<pubDate>Tue, 21 Mar 2006 12:59:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.blog.dannynet.net/?p=39#comment-457</guid>
		<description>I posted a closure solution in my one and only blog entry:

http://cgardner.blogspot.com/2006/03/implementing-typesafe-closures-in-java.html</description>
		<content:encoded><![CDATA[<p>I posted a closure solution in my one and only blog entry:</p>
<p><a href="http://cgardner.blogspot.com/2006/03/implementing-typesafe-closures-in-java.html" rel="nofollow">http://cgardner.blogspot.com/2006/03/implementing-typesafe-closures-in-java.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Code Fu &#187; Closures in Java</title>
		<link>http://www.blog.dannynet.net/archives/39#comment-300</link>
		<dc:creator>Code Fu &#187; Closures in Java</dc:creator>
		<pubDate>Mon, 20 Feb 2006 19:57:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.blog.dannynet.net/?p=39#comment-300</guid>
		<description>[...] My search lead me to the Apache Jakarta project, which offers many, many useful tools and libraries. One of these libraries is the Commons Collections. The special thing about this library is that it provides closures to Java through two basic Objects; Closure, and CollectionUtils. I believe that the best way to illustrate is to just give a small example. For this example we only need a few classes. import java.util.List; import org.apache.commons.collections.Closure; import org.apache.commons.collections.CollectionUtils; Say you have a list of Strings and you merely want to print them out. Now, you could do it the standard way through a for loop: for( int i = 0; i &#60; list.size(); i++ ) { &#160;&#160;&#160;&#160;System.out.println( ( String ) list.get( i ) ); } Or, you can introduce a closure: CollectionUtils.forAllDo( list, new Closure() { &#160;&#160;&#160;&#160;public void execute( Object o ) &#160;&#160;&#160;&#160;{ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;System.out.println( o ); &#160;&#160;&#160;&#160;} } ); The code may seem verbose when you simply want to print out the values in your list and might be better applied as a method that will print any list. public static void printList( final List list ) { &#160;&#160;&#160;&#160;CollectionUtils.forAllDo( list, new Closure() &#160;&#160;&#160;&#160;{ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;public void execute( Object o ) &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;{ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;System.out.println( o ); &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;} &#160;&#160;&#160;&#160;} ); } A more practical example might be the processing of orders from an e-commerce application. We&#8217;ll define a closure in our OrderProcessor that saves an Order to the database and logs order number and each of the items included in the order to our server logs using Log4J. We&#8217;ll assume that Order, OrderItem, and OrderUtils are classes that we&#8217;ve already defined for the sake of brevity. import java.util.List; import org.apache.commons.collections.Closure; import org.apache.commons.collections.CollectionUtils; import org.apache.log4j.Logger; &#160; public class OrderProcessor { &#160;&#160;&#160;&#160;private static Logger logger = Logger.getLogger( OrderProcessor.class ); &#160; &#160;&#160;&#160;&#160;protected Closure processOrderItem = new Closure() &#160;&#160;&#160;&#160;{ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;public void execute( Object o ) &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;{ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; final OrderItem orderItem = ( OrderItem ) o; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; logger.info( orderItem ); &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;} &#160;&#160;&#160;&#160;}; &#160; &#160;&#160;&#160;&#160;protected Closure processOrder = new Closure() &#160;&#160;&#160;&#160;{ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;public void execute( Object o ) &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;{ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;final Order order = ( Order ) o; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;OrderUtils.saveOrder( order ); &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;logger.info( order.getOrderNumber() ); &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;final List orderItems = order.getOrderItems(); &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;CollectionUtils.forAllDo( orderItems, processOrderItem ); &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;} &#160;&#160;&#160;&#160;}; &#160; &#160;&#160;&#160;&#160;public void processOrders( final List&#60;Order&#62; orders ) &#160;&#160;&#160;&#160;{ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;CollectionUtils.forAllDo( orders, processOrder ); &#160;&#160;&#160;&#160;} &#160; &#160;&#160;&#160;&#160;public static void main( String[] args ) &#160;&#160;&#160;&#160;{ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;OrderProcessor orderProcessor = new OrderProcessor(); &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;final List&#60;Order&#62; newOrders = OrderUtils.getNewOrders(); &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;orderProcessor.processOrders( newOrders ); &#160;&#160;&#160;&#160;} }  The example above is just one way that closures can be used, but note the readability it provides. This leaves the methods to do one thing well, and you can easily change the closure definition without having to go to each method to change the way an order is processed. I think that this helps code readability greatly. Another way I have applied the Closure object that I&#8217;ve found particularly useful is in building XML documents. I&#8217;ll save that for a later time. I won&#8217;t delve into all the ways that closures can be applied to programming problems here. There are many more knowledgable developers out there who have written on this. This is a tool to keep handy, but obviously isn&#8217;t suited for every task, as it does have limitations in the Java environment, although there are always workarounds. [...]</description>
		<content:encoded><![CDATA[<p>[...] My search lead me to the Apache Jakarta project, which offers many, many useful tools and libraries. One of these libraries is the Commons Collections. The special thing about this library is that it provides closures to Java through two basic Objects; Closure, and CollectionUtils. I believe that the best way to illustrate is to just give a small example. For this example we only need a few classes. import java.util.List; import org.apache.commons.collections.Closure; import org.apache.commons.collections.CollectionUtils; Say you have a list of Strings and you merely want to print them out. Now, you could do it the standard way through a for loop: for( int i = 0; i &lt; list.size(); i++ ) { &nbsp;&nbsp;&nbsp;&nbsp;System.out.println( ( String ) list.get( i ) ); } Or, you can introduce a closure: CollectionUtils.forAllDo( list, new Closure() { &nbsp;&nbsp;&nbsp;&nbsp;public void execute( Object o ) &nbsp;&nbsp;&nbsp;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println( o ); &nbsp;&nbsp;&nbsp;&nbsp;} } ); The code may seem verbose when you simply want to print out the values in your list and might be better applied as a method that will print any list. public static void printList( final List list ) { &nbsp;&nbsp;&nbsp;&nbsp;CollectionUtils.forAllDo( list, new Closure() &nbsp;&nbsp;&nbsp;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public void execute( Object o ) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println( o ); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;} ); } A more practical example might be the processing of orders from an e-commerce application. We&#8217;ll define a closure in our OrderProcessor that saves an Order to the database and logs order number and each of the items included in the order to our server logs using Log4J. We&#8217;ll assume that Order, OrderItem, and OrderUtils are classes that we&#8217;ve already defined for the sake of brevity. import java.util.List; import org.apache.commons.collections.Closure; import org.apache.commons.collections.CollectionUtils; import org.apache.log4j.Logger; &nbsp; public class OrderProcessor { &nbsp;&nbsp;&nbsp;&nbsp;private static Logger logger = Logger.getLogger( OrderProcessor.class ); &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;protected Closure processOrderItem = new Closure() &nbsp;&nbsp;&nbsp;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public void execute( Object o ) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; final OrderItem orderItem = ( OrderItem ) o; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; logger.info( orderItem ); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;}; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;protected Closure processOrder = new Closure() &nbsp;&nbsp;&nbsp;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public void execute( Object o ) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;final Order order = ( Order ) o; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OrderUtils.saveOrder( order ); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;logger.info( order.getOrderNumber() ); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;final List orderItems = order.getOrderItems(); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CollectionUtils.forAllDo( orderItems, processOrderItem ); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;}; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;public void processOrders( final List&lt;Order&gt; orders ) &nbsp;&nbsp;&nbsp;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CollectionUtils.forAllDo( orders, processOrder ); &nbsp;&nbsp;&nbsp;&nbsp;} &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;public static void main( String[] args ) &nbsp;&nbsp;&nbsp;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OrderProcessor orderProcessor = new OrderProcessor(); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;final List&lt;Order&gt; newOrders = OrderUtils.getNewOrders(); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;orderProcessor.processOrders( newOrders ); &nbsp;&nbsp;&nbsp;&nbsp;} }  The example above is just one way that closures can be used, but note the readability it provides. This leaves the methods to do one thing well, and you can easily change the closure definition without having to go to each method to change the way an order is processed. I think that this helps code readability greatly. Another way I have applied the Closure object that I&#8217;ve found particularly useful is in building XML documents. I&#8217;ll save that for a later time. I won&#8217;t delve into all the ways that closures can be applied to programming problems here. There are many more knowledgable developers out there who have written on this. This is a tool to keep handy, but obviously isn&#8217;t suited for every task, as it does have limitations in the Java environment, although there are always workarounds. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Code Fu &#187; Closures in Java</title>
		<link>http://www.blog.dannynet.net/archives/39#comment-297</link>
		<dc:creator>Code Fu &#187; Closures in Java</dc:creator>
		<pubDate>Mon, 20 Feb 2006 06:27:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.blog.dannynet.net/?p=39#comment-297</guid>
		<description>[...] One way I have applied the Closure object that I&#8217;ve found particularly useful is in building XML documents, but I won&#8217;t delve into all the ways that closures can be applied to programming problems here. There are many more knowledgable developers out there who have written on this. This is a tool to keep handy, but obviously isn&#8217;t suited for every task, as it does have limitations in the Java environment. [...]</description>
		<content:encoded><![CDATA[<p>[...] One way I have applied the Closure object that I&#8217;ve found particularly useful is in building XML documents, but I won&#8217;t delve into all the ways that closures can be applied to programming problems here. There are many more knowledgable developers out there who have written on this. This is a tool to keep handy, but obviously isn&#8217;t suited for every task, as it does have limitations in the Java environment. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michiel de Mare</title>
		<link>http://www.blog.dannynet.net/archives/39#comment-217</link>
		<dc:creator>Michiel de Mare</dc:creator>
		<pubDate>Wed, 01 Feb 2006 23:44:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.blog.dannynet.net/?p=39#comment-217</guid>
		<description>I used to work with the common-functor package for this purpose. It works pretty well - really bringing functional programming to Java. Of course, it's Java so you need anonymous inner classes everywhere, making your code illegible, and confusing the hell out of your non-functional fellow-programmers. But it's still cool. Take for example a look at this class: http://jakarta.apache.org/commons/sandbox/functor/apidocs/org/apache/commons/functor/generator/Generator.html

Rings any bells?</description>
		<content:encoded><![CDATA[<p>I used to work with the common-functor package for this purpose. It works pretty well - really bringing functional programming to Java. Of course, it&#8217;s Java so you need anonymous inner classes everywhere, making your code illegible, and confusing the hell out of your non-functional fellow-programmers. But it&#8217;s still cool. Take for example a look at this class: <a href="http://jakarta.apache.org/commons/sandbox/functor/apidocs/org/apache/commons/functor/generator/Generator.html" rel="nofollow">http://jakarta.apache.org/commons/sandbox/functor/apidocs/org/apache/commons/functor/generator/Generator.html</a></p>
<p>Rings any bells?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Lindsey</title>
		<link>http://www.blog.dannynet.net/archives/39#comment-208</link>
		<dc:creator>John Lindsey</dc:creator>
		<pubDate>Mon, 30 Jan 2006 02:58:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.blog.dannynet.net/?p=39#comment-208</guid>
		<description>Bruce Eckel had a similar thread not too long ago about wedging Mixins into java.

http://www.artima.com/forums/flat.jsp?forum=106&#38;thread=133171

My reply to that thread will serve equally well for this one... :)

-----
Hmm, I don't like it. It goes against the GrainOfTheLanguage.

http://www.c2.com/cgi/wiki?GrainOfTheLanguage

Unfortunately, we can't use all of our favorite styles, techniques, and tricks in every language. To me, this example smells like a case where, even though we want Mixins, it would be better to just shrug it off and continue to write idiomatic java that everyone understands.</description>
		<content:encoded><![CDATA[<p>Bruce Eckel had a similar thread not too long ago about wedging Mixins into java.</p>
<p><a href="http://www.artima.com/forums/flat.jsp?forum=106&amp;thread=133171" rel="nofollow">http://www.artima.com/forums/flat.jsp?forum=106&amp;thread=133171</a></p>
<p>My reply to that thread will serve equally well for this one&#8230; <img src='http://www.blog.dannynet.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>&#8212;&#8211;<br />
Hmm, I don&#8217;t like it. It goes against the GrainOfTheLanguage.</p>
<p><a href="http://www.c2.com/cgi/wiki?GrainOfTheLanguage" rel="nofollow">http://www.c2.com/cgi/wiki?GrainOfTheLanguage</a></p>
<p>Unfortunately, we can&#8217;t use all of our favorite styles, techniques, and tricks in every language. To me, this example smells like a case where, even though we want Mixins, it would be better to just shrug it off and continue to write idiomatic java that everyone understands.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Danny</title>
		<link>http://www.blog.dannynet.net/archives/39#comment-188</link>
		<dc:creator>Danny</dc:creator>
		<pubDate>Wed, 25 Jan 2006 20:14:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.blog.dannynet.net/?p=39#comment-188</guid>
		<description>Most of these alternative solutions (thanks!) involve creating an extra class or interface; which is what I hoped to avoid. So I especially like Tom Hawtin's hack, very clever indeed. And thanks for the link to jga; that looks interesting also.</description>
		<content:encoded><![CDATA[<p>Most of these alternative solutions (thanks!) involve creating an extra class or interface; which is what I hoped to avoid. So I especially like Tom Hawtin&#8217;s hack, very clever indeed. And thanks for the link to jga; that looks interesting also.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom Hawtin</title>
		<link>http://www.blog.dannynet.net/archives/39#comment-187</link>
		<dc:creator>Tom Hawtin</dc:creator>
		<pubDate>Wed, 25 Jan 2006 19:57:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.blog.dannynet.net/?p=39#comment-187</guid>
		<description>You could write it as:
&lt;pre class="alt"&gt;
int sum = new Closure() {
    int sum;
    {
        CollectionUtils.forAllDo(items, this);
    }
    public void execute(Item item) {
        sum += item.amount;
    }
}.sum;
&lt;/pre&gt;
A hack, but possibly worth it if you do lots of it.</description>
		<content:encoded><![CDATA[<p>You could write it as:</p>
<pre class="alt">
int sum = new Closure() {
    int sum;
    {
        CollectionUtils.forAllDo(items, this);
    }
    public void execute(Item item) {
        sum += item.amount;
    }
}.sum;
</pre>
<p>A hack, but possibly worth it if you do lots of it.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
