I first ran across an explanation of this new buzzword for Java 7 in the JavaLobby front page. I saw Rick’s comments about Neal’s ability to describe complex topics easily so I went ahead and clicked over to his explanation of what colsures are and why I should care. 10 minutes later I was completely baffled at what his examples were suppose to show and more importantly… what the hell was a closure? Aparently Neal’s code snippet down on the bottom of the page under Abstracting the loop with Closures was suppose to tell me, but it didn’t… I don’t even know what I’m looking at because the sample code is complex enough that I got too caught up trying to figure out what he is actually trying to accomplish.
The problem here, Neal, is that I’m a little slow. I need new concepts spoon fed to me using a very small safety spoon while I wear my foam helmet. Luckily over on JavaLobby Ray Cromwell stepped up to the plate and gave this snippet of code to explain closures that for some reason clicked immediately with me.
So closures, to simplify, are like blocks of code you can pass around like objects. This is certainly interesting, as interesting as generics and the new enhanced for-loop in Java were but critical? I’m not sure, I don’t see myself needing these immediately.
I did see an interesting comment and confirmation of the comment on JavaLobby that closures provide a way for developers to solve problems in a more thoughtful manner. While most (bad?) programmers will completely ignore the new construct, more creative and advanced developers will be able to leverage the functionality to think outside the box. I don’t know if I agree with this again, but considering that I need to wear a foam helmet when I program, maybe they are right? Maybe I will ignore this feature until I need it (become a good programmer). I certainly didn’t jump on the generics bandwagon until just recently because of the syntax complexities it introduced. I still look at some of these method headers with T’s everywhere and don’t quite understand what I’m looking at, but it’s sinking in slowly and surely. (Digg this)



















September 3rd, 2006 at 3:46 pm
Perhaps my “use cases for closures” blog post will be more helpful?
http://gafter.blogspot.com/2006/08/use-cases-for-closures.html
January 1st, 2007 at 10:11 pm
OK, this should help: http://www.bejug.org/confluenceBeJUG/display/PARLEYS/Closures+for+Java
January 1st, 2007 at 10:24 pm
Neal,
Thank you for posting that.