Analytics

Sunday, October 31, 2010

Grails SpringOne 2GX Presentation Summary

This month I had the privilege of attending the SpringOne 2GX conference in Chicago. It was an amazing event for me where I got to meet the leaders in the field and learned many new things.  I primarily went to dive in deep into the latest Groovy and Grails developments, technologies, and trends. This blog serves as a housing place for my notes on each presentation I attended.  At the end of the blog, I have posted the original presentations and made them available.


Grails 1.3 Update
by Graeme Rocher

Industry Usage
  • Grails has 499 plugins
  • Lots of high profile sights such as eHarmony, LinkedIn, Wired, Walmart, Sky, SitOrSquat, Northwestern Memorial Hospital, Many Moons
Grails Tooling
  • Eclipse STS - much improved
  • Unit test improvements - see test reports in console, run integration tests
  • code completion, highlighting errors, gsp completion, tag attribute completion
  • grails command window, auto completion, create apps wizard

Thursday, October 28, 2010

Grails One to Many Mapping with Foreign Key

Grails is a fabulous light weight framework that operates by convention over configuration. This mode of operation results in significant developer productivity and a decrease in configuration headaches.  However, Grails conventions sometimes yield subtle unwanted results.  One example is the default one to many unidirectional mapping configuration, in a very specific scenario.  Grails maps the one to many relationship with a join table. This results in a problem when deleting the child when calling delete() on a child object.

One to Many Mapping Unidirectional Default

When mapping two objects with a one to many relationship and making that relationship unidirectional, grails provides a simple default way to map this to the database.  Take an example of Company and Employee. A Company can have many Employees. Here is a code snippet of how to map these objects.

Sunday, August 15, 2010

3 Common Ways to Use Groovy Closures

What is a Closure?

The concept of closures is an important part of the Groovy language. A closure resembles a function or method in many aspects of programming. For example a closure can take arguments, can have a return value, and can be executed from one or many clients. A closure is essentially a block of code that is defined and executed a later point. A closure can be assigned to a variable or remain anonymous.  You can create a closure, assign it to a variable, and then pass it around your program like any other variable.  For a more thorough explanation, see Groovy Formal Definition.

Use Groovy Closures

Closures enable the creation of creating concise, clean code when applied correctly. Although all programming problems can be solved without closures, a problem solved using closures will most likely contain less code, avoid repetition, and be more elegant.  This article will focus on some simple and common uses of closures. It is directed towards newcomers to Groovy, typically Java developers coming over to the dark side.  We will discover how closures can be used for: