Thursday, February 28, 2008

My First Groovy Experience

For a while now, several people in my office have been diving head first into the Groovy experience (James Lorenzen, Chad Gallemore, Joe Kueser, and Travis Chase). Thanks to these guys, my first Groovy experience went pretty well overall.

I do all of my development in IntelliJ IDEA and with Maven2. So, my first steps were to get the JetGroovy plugin, install Groovy, and get my Maven2 project setup to handle Groovy source. Other than a small hiccup getting the plugin, this all went relatively smoothly.

During this experience, I jumped right in using the StubFor class for some unit testing and XmlSlurper to parse through some XML. Both of these proved extremely easy to use and much better than their alternatives in Java.

So, now to what didn't go well. First, when I'm working on an individual unit or integration test, I just run it in IDEA. When I was writing my first Groovy class (and associated tests), I was having trouble with strange behavior with my unit test. After a short time of extreme confusion, it hit me what was happening. If I didn't make a change to the Groovy class between every test, IDEA would not actually use the class (if that makes any sense). I wasn't seeing any exceptions regarding missing classes, but the code would actually not be run. So, I had to make a change in the unit test class as well as the class under test if I wanted to run the test from IDEA. Fortunately, I confirmed with my coworkers that this problem did not exist in IDEA version 7.0.2 (I was running 7.0). A quick upgrade fixed my problem.

The only other thing I have to complain about is the customization of colors in IDEA for Groovy source. Unlike most, I use a very colorful scheme for development. I happen to be terribly color blind and find it much easier when different things in the code stand out. If you ever get the chance to see my screen, you'll see brown, blue, purple, yellow, red, white, grey, and shades of several of those. So, unfortunately for me, there's not quite as much customization available for Groovy source. Oh well. I'm sure I'll live.

At the end of the day, it was a good experience and gladly I'll continue use Groovy where it makes sense.

No comments: