Thursday, May 08, 2008

JavaOne: The power of Groovy Builders

I attended two talks on Groovy Builders yesterday that clearly illustrated this power feature of the Groovy language.

The basics on builders was covered in a late night BOF "Cooking Your Own Groovy Builder: A Step Forward into Domain-Specific Languages" given by Andres Almiray and Ixchel Ruiz. They reviewed builders for Swing, Java2D and the generic ObjectGraphBuilder which help to take a significant amount of toil out of working with Swing, Java2D, or creating generic object graphs for testing. Builders are also used for creating HTML or XML documents using syntax like:

html { head { title "My HTML Document" } body { h1 "Hello World  p "Isn't this nice?"} }

That's a useful way to express structure using a syntax that is essentially added to the language by implementing a Builder. Builders are not limited to just generating code or data. In "Groovy on a Cloud: Testing Java™ Platform, Enterprise Edition (Java EE Platform) Applications on Amazon EC2", Chris Richardson showed how he created a domain specific language, using Builders, which can be used to provision Amazon EC2 instances by describing them in the DSL. The technique is described in a blog post. Really impressive stuff.

Labels: , ,

1 Comments:

Blogger Andres Almiray said...

Glad you liked it, keep on Groovying!

3:10 PM  

Post a Comment

Subscribe to Post Comments [Atom]

<< Home