Saturday, December 26, 2009

GroovyMag Plugin Corner: Feeds Plugin

The following post is a reprint of the Plugin Corner article for the January 2009 issue of GroovyMag. You can find this and other past issues at http://groovymag.com.


RSS and Atom feeds are becoming more popular and consequently more important to include in our applications. The battle for mindshare among our users or potential users is constant, and having a feed available is one of our more effective weapons.

But feeds are complicated, right? There are so many different formats and versions and then there's all that XML- don't get me started on XML! Not to worry; some of the smart people at Sun came up with the ROME API that encapsulates and simplifies much of what goes into an RSS/Atom feed. So, all we have to do is learn a new Java API. NOT! This is Grails we're talking about. In steps Groovy Award winner Marc Palmer with the Feeds Plugin.

This plugin wraps the ROME API and gives us the very groovy FeedBuilder with its powerful yet simple DSL. Once installed, the Feeds Plugin gives us a new version of the familiar render() method. Now we can just “render" a feed instead of a view. Let's get started.

For our example, we are going to build a book of the month feed. We already have a Book domain class with corresponding controller and views.

First install the plugin:

grails install-plugin feeds

That was pretty painless. Now we will add a new action to our controller:

def monthly = {
render(feedType:"atom"){
title="Book of the Month"
link="http://localhost:8080/bom/book/monthly/feed"
description="A monthly book recommendation"
def book = bookOfTheMonth() //complex algorithm here :)
if(book){
entry{
title = book.title
link="${g.createLink(action:''show'', id:book.id)}"
}
}
}
}

The render() method now takes a feedType parameter. It is this parameter that tells the plugin that this is indeed a feed. If that parameter is there, we can also include a version parameter to specify the version of the feed format we are using. The defaults are 2.0 for RSS and 1.0 for Atom. Next the render() method takes a closure where we can set the various properties of our feed and entries. In our example we are setting the title, link, and description properties on our feed and then including one entry for the book of the month. Since the FeedBuilder DSL is still Groovy code, we can handle any logic that is needed. Here, for example, we are only creating an entry if our book is not null.

Next we create our entry. The entry node also takes a closure where we will set the various properties of the entry. All we are doing with our entry is giving it a title (the book's title) and a link to the show page for that book. Now if we run our application and subscribe to the feed at http://localhost:8080/bom/book/monthly we will get
something like this:



I know- kind of boring. Let's add another feed to our application that will give us a bit more to look at. Some of us are more voracious readers than others so we might want to have a list of books all at once rather than one each month. Here's a new controller action that will give us just that:

def booklist={
render(feedType:"atom"){
title="Groovy Books"
link="http://localhost:8080/bom/book/booklist/feed"
description="A listing of Groovy and Grails books"
def books = Book.list()
books.each{book ->
entry(book.title){
link="${g.createLink(action:''show'', id:book.id)}"
}
}
}
}

Now if we subscribe to http://localhost:8080/bom/book/monthly we will get a bit more content from our feed:



There is a great deal more that can be done with the Feeds Plugin than what we demonstrated here, so when you're ready to dig deeper, the official documentation is at http://grails.org/plugin/feeds. You can also find lots of information on the ROME API at the java.net site: http://rome.dev.java.net. As always, another excellent source of information is the plugin source itself. The Feeds Plugin source can be found in plugins/feedsx.x/ Much of the meat of the plugin is in src/groovy/feedplugin/FeedBuilder.groovy.

Even without digging in to the docs or source, you can see how easy it is to add basic RSS/Atom feeds to your application with the Feeds plugin. Now you can set your mind to work on finding new and innovative ways to use them. Once again Grails and Grails plugins take away the drudgery and leave us with the fun!

Tuesday, December 8, 2009

Pomodoro Technique Illustrated - A Brief Review


If you would like to be more productive and you haven't looked into the Pomodoro technique, you need to get a hold of the new Pragmatic Bookshelf book, Pomodoro Technique Illustrated, by Staffan Nöteberg.

I had heard about the Pomodoro technique, and knew it had something to do with a kitchen timer, but that was about the extent of my understanding of this powerful technique. Staffan Nöteberg not only shows us how we can become much more productive with the Pomodoro technique, but he also shows us just how much we can learn from a cucumber and an artichoke. (You'll just have to read the book to understand that one.) Staffan's writing style and illustrations make this book easy and fun to read, but it's the simplicity and the "why didn't I think of that" nature of the technique that really pulls you in.

We may have hours in a day to spend to accomplish a task, but it's nearly impossible (for some of us, entirely impossible) to spend that time focused on that task without distractions and interruptions. The Pomodoro technique takes that into account with the obvious (in hindsight) observation that though we may not be able to focus on one thing for a lengthy period, we probably can for a short one.

Using a timer to discipline ourselves to focus on one thing for a short time (typically 25 minutes, but you can start smaller) is a key component of the technique, but there's more to it than that. It is a whole system of capturing, prioritizing, tracking and accomplishing what we want to get done. All of this is done with the simplest of tools: a timer, a piece of paper, and a pencil.

It's kind of like breaking your work day into a series of 25 minute iterations, complete with a micro-retrospective after each one. Then a break - to clear your mind, check email, Twitter, Groovyblogs, etc. Then back to it again for another iteration.

Just like with a development process, you may get some benefit from using pieces of the technique, like the timer, but you'll get much more if you use the whole thing. This book is a great way to get started. Once you do, you'll want to give it some time to get into the habit. I'm still working on it myself, and I have already seen an improvement.

Pomodoro Technique Illustrated is now shipping. You can get your copy and get started at http://pragprog.com.

There goes the timer. Finished just in time!

Tuesday, December 1, 2009

GroovyMag Plugin Corner: Testing

In the December 2008 issue of GroovyMag, I covered the Grails Testing plugin. This plugin provided the new Grails 1.1 testing features to 1.0.x applications. With that in mind, this may seem a bit out of date. But I happen to know that there are still some applications being developed in Grails 1.0.4, and the classes and methods described here, though built-into Grails 1.1 and above, are still applicable. So, just to be clear: If you are using Grails 1.1 or above, you can still use these classes / methods, but you don't have to install the plugin.

When writing unit tests, the goal is to test a single class in isolation, with any collaborating objects being replaced by mocks or stubs. This will lead to less fragile code that can work with different implementations of collaborating objects, and it will help to isolate bugs when they appear. Unit tests are also much faster to run, since they don’t require resource-intensive services and containers to be loaded. However, with all of the functionality that Grails magically adds to your domain classes, controllers, services, and taglibs, it can be quite difficult to write unit tests for these artifacts. It can be done, and I know several determined developers who have, but many others just take the easy (and slow) road and write only integration tests. Some take the dead-end road and write no tests at all. Integration tests test a class with its collaborators, which means that the Grails goodness is all there for you. These tests are important to have, but they should not take the place of unit tests. Another concern with integration tests as your only automated tests is that they take much longer to run, which means that they will likely be run less often.

Well, now there is no excuse not to write unit tests for your Grails applications. In this Plugin Corner we will see how the Testing plugin, by Peter Ledbrook, makes it plain easy to write unit tests for Grails artifacts (domain classes, controllers, services and taglibs). This plugin does for unit testing what GORM does for persistence. It provides mock implementations of almost all of the dynamic methods added to your artifacts by Grails. The plugin includes four new TestCase classes that all descend from GroovyTestCase, which itself extends from JUnit’s TestCase.



GrailsUnitTestCase introduces most of the powerful meta-programming magic in this plugin, and it will be sufficient for testing domain classes and services that use domain classes. For testing controllers and TagLibs you can probably guess which classes to use.

Let’s take a look at just how easy-to-use and powerful this plugin is. First we’ll install it:


grails install-plugin testing


Now to take advantage of the goodness this plugin gives us, we just need to have our unit tests extend one of the new TestCase classes. In the following example we’ll extend the ControllerUnitTestCase class.


class BookControllerTests extends grails.test.ControllerUnitTestCase{
def b1, b2

void setUp(){
super.setUp()
controller = new BookController()
b1 = new Book(title:’Programming Groovy’, author:’Venkat Subramaniam’)
b2 = new Book(title:’Grails in Action’, author:’Glen Smith’)
mockDomain(Book, [b1, b2])
}


ControllerUnitTestCase has a protected controller property. In our setup() method we set this property to a new instance of our BookController. Then we create a couple Book instances and call the uber cool mockDomain() method. This method takes a class (Book) and a list ([b1, b2]). Once this method has been called, we can call methods like list(), get(), save(), delete(), and even findAllByXXX(). The list becomes an in-memory database. In our example we passed two existing instances in the list. When we called mockDomain(), the object instances in the list were “saved” to the list. Alternatively, we could have passed in an empty list and added the instances by calling save(). In either case, the objects are assigned id values based on the order they are added. This is important, because most of the actions in a standard Grails controller use the id property to find objects.


void testShow(){
controller.params.id = 1
def model = controller.show()
assertEquals(b1, model.bookInstance)
}


When we call our controller’s show action it will call Book.get(). This will be performed by the mock implementation of get() that was added to Book when we called mockDomain(), which will retrieve the instance from the list. I point this out because the Testing plugin makes working with domain classes so seamless that it sometimes feels like we’re still writing integration tests.


void testBookNotFound(){
controller.params.id = 3
controller.show()
assertEquals(“Book not found with id 3”, mockFlash.message)
}


In our second test we set params.id to a number we know does not exist, to ensure that the proper error message is stored in the flash scope. Notice that what we check is not flash but mockFlash. mockFlash is a Map that is declared in the MVCUnitTestCase, the super class of the ControllerUnitTestCase. MVCUnitTestCase also introduces mockRequest, mockResponse, mockSession, and more.

A unit test for the scaffolded actions is of questionable value, so let’s try a unit test for a custom service. Our service method creates a batch of Publishers and Books from XML data. Here’s the test:


class BatchServiceTests extends GrailsUnitTestCase {
def batchService
def bookInstances = []
def publisherInstances = []

void setUp(){
super.setUp()
mockDomain(Book, bookInstances)
mockDomain(Publisher, publisherInstances)
batchService = new BatchService()
}


This test class extends GrailsUnitTestCase because we need the domain class mocking, but we do not need the features introduced in MVCUnitTestCase or later. We are defining the lists that will be passed to mockDomain() ahead of time, since we are not creating any domain instances in our test. Notice also that we are mocking both the Publisher and the Book domains. This will enable us to mock the relationship logic as well. Finally we create an instance of the service that we are going to test.


void testLoadBooks() {
def data = “””
      <publishers>

        <publisher name=”Apress”>

          <book title=”Definitive Guide to Grails” author=”Graeme Rocher”/>

          <book title=”Beginning Groovy and Grails” author=”Christopher Judd”/>

        </publisher>

        <publisher name=”Manning”>

          <book title=”Groovy in Action” author=”Dierk Koenig”/>

        </publisher>

      </publishers>
“””

batchService.loadBooks(data)
def p = Publisher.findByName(‘Apress’)
assertEquals(2, p.books.size())
assertEquals(“Groovy in Action”, Book.findByAuthor(“Dierk Koenig”).title)
}


After calling our service’s loadBooks() we are able to call Publisher.findByName() to verify that the two books by Apress are there. We also verify that Dierk’s classic work is there by calling Book.findByAuthor(). These finder methods are not available in unit tests, but the Testing plugin is providing mock implementations of them using object instances held in lists.

Here’s a snippet of our BatchService.loadBooks() method:


def loadBooks(String data) {
def publishers = new XmlSlurper().parseText(data)
publishers.publisher.each {pub ->
def p = new Publisher(name:pub.@name.text())
pub.book.each{book ->
def b = new Book(title:book.@title.text(), author:book.@author.text())
p.addToBooks(b)
}
p.save()


Notice how we are calling Publisher.addToBooks() to place the Book instances in the Publisher’s books collection and finally calling p.save(). These methods are also being mocked by the Testing plugin. Again it’s easy to forget that we’re writing unit tests and not integration tests, that is until we see how fast they run!

The documentation on the Testing plugin is pretty good, but still leaves some holes. If you want to take full advantage of the plugin I recommend reading through the source code that is included in your project once you install the plugin. It’s mostly Groovy code so, of course, it reads like a good novel. There are also some other resources on the web to help you get going.

With this plugin there is really no need to fear unit testing your Grails artifacts. So, if you’ve been writing integration tests instead of unit tests or if you are not writing any tests
at all, then run (don’t walk) to your nearest Grails project and install this plugin. You’ll be glad you did and so will your team mates, your manager, your customers, your spouse, your neighbors...

Resources
Official Plugin Documentation: http://grails.org/Testing+Plugin

Mike Hugo’s presentation to the Groovy Users of Minnesota: http://www.piragua.com/2008/11/12/testing-plugin-presentation

Robert Fletcher’s very helpful blog post:
http://stateyourbizness.blogspot.com/2008/08/unit-testing-controllers-with-testing.html

Wednesday, November 25, 2009

GroovyMag Plugin Corner: Searchable

Over the next few months, I will be reprinting some of the Plugin Corners that I've written for GroovyMag. Hopefully this will give you a taste of what you can find in GroovyMag each month (and keep my blog from being so dead). Enjoy!

From November 2008 issue

One of the most powerful Grails plugins is also one of the easiest to use. The Searchable plugin brings the power of the Compass search engine into Grails in a very Groovy way. If you haven’t tried the Searchable plugin yet, it’s time to stop making excuses and stop wasting time building complex search forms for your projects. Let’s get started.

The first step to using any plugin is to install it. From the root of your Grails project execute the following command:


grails install-plugin searchable


Now the fun begins. To make a domain class searchable, just add the static searchable flag to the class. Here’s our Book class, for example:


class Book {
static Searchable = true
String title
Integer pages
Author author

String toString(){title}
}


We’ve already generated the scaffolding for this class, so now let’s add a search action to our BookController like this:


def search = {
def bookList = Book.search(params.
query).results
render(view:’list’, model:[bookList:
bookList])
}


In order to call our new search action we will need a form, so we’ll add one to the generated list view. Put the following block of code right before the opening <table> tag in list.gsp:


<div class=”nav”>

<g:form name=”search” action=’search’>

Search:

<input type=”text” name=”query” value=”${query}”/>

<input type=”submit” value=”Search”/>

</g:form>

</div>


Now if we run our application - with a little data thrown in via the bootstrap - we’ll get something like this:



We can now search for any string value across any of the properties of our Book instances from a single input field. We can search the String properties as well as the Integers. For example, if we had a book called “200 Reasons to Use Grails,” and we searched for the value 200, we would find
that book along with any books that had exactly 200 pages.

Although the default behavior is to search across all the properties, we can search a specific property by prefacing the search value with propertyName: (eg: author:Rocher).

I should point out that the code we have right now will blow up if the user doesn’t enter any search value before submitting the form. Don’t worry - this is easy to fix. The dynamic search method that is added to our Book class by the Searchable plugin returns an instance of the SearchResult class. This class contains a property called ‘results’, which is an ArrayList. This is why we can so easily return it in the model to our list view. So if there is no search value we can just call Book.list() and return that instead. Let’s modify our search action to look more like this:


def search = {
def bookList
if (params.query)
bookList = Book.search(params.query).results
else
bookList = Book.list()
render(view:’list’, model:[bookList:bookList])
}


We’re not using any additional parameters here, but the search() method takes all the same parameters that the list() method takes - which is important when it comes to sorting and pagination. In order to make pagination work with the Searchable plugin, we need to make a few simple changes. First we’ll need to pass a couple extra pieces of information to the view. The SearchResult returned by the search() method will be used to determine the total number of objects found, and the query parameter will be passed back to the view so that it can be reused when loading subsequent pages. So now our search action will look like this:


def search = {
def bookList
if (params.query){
def searchResult = Book.search(params.query)
bookList = searchResult.results
}
else
bookList = Book.list()
render(view:’list’, model:[bookList:bookList, searchResult:searchResult, query:params.query])
}


Now we will modify list.gsp, but since we are using the same view for both the list and search actions, we will put our changes within a g:if tag. If we are viewing search results we will modify the g:paginate tag to make use of the new values we passed in on the model. Otherwise, we will use the original g:paginate tag.


<g:if test=”${searchResult}”>

  <g:paginate total=”${searchResult.total}” params=”[query:query]” />

</g:if>

<g:else>

  <g:paginate total=”${Book.count()}”/>

</g:else>


In keeping with the Grails way, the Searchable plugin gives you sensible defaults for most settings but allows for much more customization if needed. To add this, just install the SearchableConfiguration.groovy file by executing the following command:


grails install-searchable-config


You can get more details about what you can do with this file as well as excellent documentation on the Searchable plugin page at grails.org (see references). Hopefully this tutorial will give you enough to get you going. Once you get started, more questions will undoubtedly arise, so I’ve included a list of references below.

The Searchable plugin makes including powerful full text searching so easy to do that there’s really no reason to not take advantage of it. So dig in and have fun!

References:
http://grails.org/Searchable+Plugin
http://www.grails.org/Searchable+Plugin+-+Configuration
http://www.grails.org/Searchable+Plugin+-+Searching
http://www.compass-project.org/
http://lucene.apache.org/

Wednesday, November 18, 2009

Slaying Hallway Zombies

For the past few months, I have been working on a project for a division of Boeing. It was a bit of a culture shock, going from a small, dynamic, family feeling company like Contegix to one of the largest companies in the world. But it's a Grails project, and the prospect of helping all of those oppressed Boeing Java devs get into Grails is well worth the cross-cultural experience. :-)

So, what does that have to do with zombies? Well, when working for a huge company, one often ends up in a huge building. And in huge buildings, we often find very long hallways. The building I work in has hallways that are several hundred feet long (almost 150 meters). Something strange happens to (otherwise friendly) people when they walk down long hallways. They become hallway zombies. Hallway zombies aren't like other zombies — they aren't decaying (usually), and they don't try eat your brains. But if you’re not careful, they will rob your joy. There’s something unnatural about walking directly past another person and not even acknowledging that they exist. But if you don’t fight it, it will start to become natural to you. And then you will have become a hallway zombie yourself!

Hallway zombies can be defeated, though, and fortunately you don't even have to decapitate them. (How would that look on a reference letter?) Some hallway zombies can be defeated with a simple smile. Some may take repeated smiles. The first smiles may seem to bounce right off of them, but if you keep it up, you will start to break through. Others are tougher and may require more drastic action, such as a full round-house “Good morning!”

Those are the basic weapons for fighting hallway zombies — and fight you must, or your fate is sealed. But these weapons are much more effective with a good technique. If you spot a hallway zombie coming towards you a couple hundred feet away and you start smiling at them right away, they will be able to defend against it. It's best to catch them by surprise. Let them think you’re one of them. Look straight ahead, or down at the floor. (Don't be tempted to take furtive glances into open office doors or down a row of cubicles. That's a dead give-away.) Then, when you are within 15 to 20 feet of passing, strike quickly with your best smile and even a nod of the head. If you're pulling out the big guns, you can start a bit sooner, just in case you see an opening for a “How’s it going?” to follow up on your “Good morning!”

I’m not yet convinced that any hallway zombie is beyond reach, but there are a few here that are proving quite challenging. I’m working on some new attack strategies, just in case. On the other hand, there have been some successes that are quite encouraging. Slaying hallway zombies is hard work, but it’s very rewarding. So I keep fighting.

You may not work in this type of environment, but chances are that you will find yourself somewhere, at some point in time, where you are faced with a hallway zombie. Don’t panic. Steady your nerves, hold your ground, and… Smile!

Tuesday, October 27, 2009

Yet Another 2GX Wrap-up

Finally after more than a year of waiting and nagging, the second 2GX conference was held in New Orleans last week. It was almost as good as the first one. Well, in some ways it was better but in other ways... well, we'll get to that in a bit. But first, I wanted to say how great it was to see so many people from the Groovy community. It is so cool to be able to put real faces to so many on-line friends. I know conference people always say that "the attendees are what really makes the conference great", but as a speaker and part-time staff member at this conference, I can say that it's really true. The questions during the sessions and the discussions between sessions and at meals were the best part of the whole thing. Even better than the Rod Johnson bobble-head dolls. :-)

Speaking of staff, I also want to tip my hat (if I had one) to the guys that pulled it all off. Jay Zimmerman did as good of a job with the 500+ person event as he does with the NoFluffJustStuff conferences and his two volunteers (and one sales guy :), and my co-workers, Erik Weibust, Todd Crone, and Paul Luttrell were tireless in their efforts to keep things running smoothly. It was great working with you guys!

One thing I want to highlight here was how excited I was to see some relative new comers speaking at 2GX. These guys aren't new to Groovy or Grails, but I think this was the first conference appearance for each of them and they were awesome! Matt Taylor, Hamlet D'arcy, Scott Vlaminck (the 'n' is silent), and Burt Beckwith (actually I'm not sure if Burt has spoken at other conferences, so forgive me if I'm wrong)

Matt spoke on Grails UI, the YUI based Grails plugin that he developed and maintains as well as his experiences using Grails "in the wild". I caught his GrailsUI talk and was very impressed, along with the rest of the room who all gave him the coveted "green cards".

I didn't catch any of Hamlet's sessions but from what I heard from other attendees and on Twitter, he was a hit! He gave four presentations altogether: OSGi and Groovy, Functional Groovy, Compiler Metaprogramming with AST transformations, and Legacy Code and Groovy. Rumor has it that he even had Venkat Subramaniam impressed.

Scott Vlaminck, from Refactr, gave talks on Metaprogramming in Groovy and Grails, and AOP in Grails. Again, I wasn't able to catch any of these talks in person, but the feedback was quite good and in fact I happened to be in the room next to one of Scott's talks and the speaker was almost drowned out by the applause!

Burt also gave four presentations. He spoke on Spring Security in Grails, GORM performance, UI performance, and Clustering Grails apps. I only caught the GORM performance talk, but it was one of my favorites. I am already putting things I learned there to use in my day job.

Of course the usual awesome Groovy/Grails/Griffon speakers were there and they were terrific as usual, but you've already heard about them and many others have or will blog about the cool Griffon sessions, or the Grails internals, or the power of Grails plugins, or the DSLs and Groovy testing magic, etc. So I wanted to take a moment to congratulate these guys on a job well done. I look forward to seeing them present at future events.

Now, as to why I don't think this 2GX was quite as good as the first one. The full name of the conference is a clue: SpringOne 2GX. SpringOne is a good conference, but 2GX is a great conference! (or a GR8 conference :) So, when combined we ended up with a more than good but not quite great conference. Spring technology is cool. Much of it (though not all) is behind some of the power of Grails. And I do very much appreciate the support that SpringSource is giving to Groovy and Grails, but I think they just gave a bit of a "corporate feel" to the conference.

I don't want to end on a downer though. There were some distinct benefits of having the two events combined. One was that SpringOne had some very good content and some exceptional speakers to add to the mix. Another is that more than a few Spring users got to glimpse the goodness of Groovy, Grails and Griffon for the first time. The oohs and ahhs were music to my ears! It serves as a reminder to just be patient and hang in there... it's only a matter of time until they'll be holding the Groovy, Grails, Griffon and Spring conference!

Wednesday, September 16, 2009

10 Reasons to attend SpringOne 2GX

I was going to come up with one of those clever top 10 lists but when I went to the SpringOne/2GX home page, I saw 10 great reasons to attend staring me in the face.



The early bird discount ends Friday, September 18th, but even at full price this event is less expensive than JavaOne and will contain way more good technical content. Check out the rest of the speakers and the awesome session list at http://springone2gx.com

If you're interested in Groovy, Grails, Griffon, (or related technologies) or if you use Spring in any of it's myriad forms, or, for that matter, if you use Java, you won't want to miss this conference!

See you there!

Monday, August 17, 2009

New Blog for Grails: A Quick-Start Guide

I'd like to announce a new blog for Grails: A Quick-Start Guide. You can find it at http://gquick.blogspot.com. In this blog, I'll continue to build on the example app in the book, and offer tips and techniques that didn't make it into the book.

The first post covers displaying an image property of a domain class in a GSP. In the GQuick example application, there is a Sponsor class that has a logo property. We never had a chance to show how to properly render that logo image to a page in the book.

If you've read the beta of GQuick and have anything else you would like to see discussed, post a comment here, on gquick.blogspot.com, or at the book forum at pragprog.com.

I'd also like to take this opportunity to thank the beta ebook readers. Your feedback has been a huge help!

Monday, August 3, 2009

Grails: The Official Web Framework for Java.next

In the August issue of GroovyMag, guest plugin-corner columnist Keith Cochran covers the new Clojure plugin by Jeff Brown. This plugin allows you to include Clojure source code in src/clj and then access that code in your Grails application. More details on the Clojure plugin can be found at http://grails.org/plugin/clojure.

A while back Vaclav Pech came out with a similar Grails plugin for Scala. This one hasn't been covered in GroovyMag... yet. Anyhow, you can find out more about this plugin at http://grails.org/plugin/scala.

So now in a Grails application you can have Groovy code (all over the place), Scala code in src/scala, and Clojure code in src/clj. That's pretty impressive! As I was marveling at these recent developments, I realized that Grails now supports 3 out of the four languages covered in Stu Halloway's paradigm-shifting blog series on Java.next (Groovy, Scala and Clojure - no JRuby... yet).

So unless something else comes along that as easily supports all four, I think we can safely call Grails the "Official Web Framework for Java.next".


P.S. Lest I forget, Griffon (the official Swing MVC framework for Java.next?) has quickly followed suit on supporting these languages. See Andres Almiray's blog for juicy details.

Thursday, July 23, 2009

We have a US Groovy/Grails/Griffon Conference!

But let's not blow it!

A while back I wrote about the need for a US conference dedicated to the G3 technologies. Well, now there's one scheduled! You've probably already heard about the SpringOne 2GX (I know it should be 3GX, but names are hard to change sometimes, so we'll cut them some slack :-).

This conference will be a two-for-one deal. You can sign up for either the SpringOne or the 2GX (Groovy / Grails Experience) and you get to go to both. Which means that there will be 8 concurrent sessions to choose from. Ouch! That's going to hurt when I try to split myself into pieces to go to more than one at a time.

The speaker line-up is fantastic. I won't try to list all of them all here, but the three Gs are well represented, with 20 different speakers on the Groovy / Grails / Griffon side and even more on the Spring side. You can see the full list on the website.

But the sessions are only part of the picture. The interaction with speakers and other attendees during breaks and meals is the part that just can't be reproduced or replaced. You may be able to find a book that covers some of the topics, but you won't find a book that contains that great conversation you had with the creator of your favorite tool or framework.

So why did I start this post off with the warning to not blow it? Well, you may have noticed that the economy isn't doing all that great lately. You may have also noticed that many conferences and training events have been canceled due to lack of attendance. I don't think that would happen with the SpringOne 2GX -- but why take the chance? If we want these types of events to continue, we need to support them. So if you haven't registered yet, head over to http://springone2gx.com and register. The early bird pricing, which will save you $400, ends July 31st! Why wait? You can save a good chunk of change while at the same time telling the organizers that they might as well start planning the next one!

You can also help by getting the word out. Tell your co-workers, colleagues, friends, neighbors, etc.

This is going to be an excellent conference. It will be way less crowded than JavaOne, and with much better sessions and overall experience. And it's cheaper to boot! There's just no good reason to miss this event. I hope to see you there!

Tuesday, June 30, 2009

It's Official: Grails has a DZone Refcard!

The Grails Refcard is now available for download at http://refcardz.dzone.com

Writing a refcard was a bit more challenging than I thought it would be. The main difficulty being determining what it should have in it. I put the question out here and on the Grails mailing lists and got some good ideas but no help in narrowing it down. Should it be solely a reference for experienced Grails users? An easy getting started guide for new Grails users? Should it just be a copy of the docs in a smaller font?!

I leaned more towards it being a reference for existing users but I know there are still many poor souls out there who don't yet know how much better their jobs could be with Grails. So, I settled on a hybrid approach. The first section is a brief introduction to Grails and some of it's key benefits. I could have done so much more here but hopefully it's enough to convince those not yet using Grails to take a second look. The rest of the card is dedicated to some of the concepts and details that I and others I know of have had to lookup most frequently. I know I didn't hit everyone's key points but hopefully I covered enough of them to make it useful.

Download it and take a look. The download is free and feedback is always welcome.

I would like to thank the folks at DZone for giving me this opportunity and even more for their support of the G3 community with first the Groovy Refcard and now the Grails Refcard. There's no Griffon Refcard yet, but they do listen so send them an email to let them know you'd like to see one or better yet, offer to write it. It's a fun and challenging experience.

Tuesday, June 2, 2009

Grails Enterprise Integration Strategies BOF

I will be leading a Grails BOF (Birds of a Feather session) this Thursday at JavaOne.  The BOF is from 6:30 to 7:20 pm in Esplanade 307-310.  

I hope to make this more like a traditional Birds of a Feather.  I will get the ball rolling by talking about some of my experiences using Grails in an EJB/JSF/Oracle/WebLogic shop and also a bit about ideas I've heard from others in other enterprise environments.  But then we'll open it up to the attendees to talk about what they've tried. What worked.  What didn't.  What they're currently dealing with.

Hopefully, we'll get a good discussion going and then to cap it all off, the Grails Podcast BOF, with Sven Haiges and Glen Smith is in the same room at 7:30.  It should be a GR8 night!  If you're at JavaOne come on out and join in.

Groovy Buzz at JavaOne

As suspected the G3 buzz at JavaOne is much higher than indicated by the technical session list.  You hear it in the hallway conversations; you hear it in the attendees questions at other sessions; and you heard it loud and clear at the Scripting Bowl (aka, the Alternative JVM Languages Bowl).  The contenders were Jython, Groovy, Clojure, Scala and JRuby.  The clear winner was Groovy!  Dick Wall, of Java Posse fame, came in second with Scala but based on audience feedback Groovy was the one!  

Guillaume Laforge was the Groovy representative and he showed off some cool demos with help from the grooviest guys in desktop development, Danno Ferrin, James Williams and Andres Almiray.  It was a great community effort and a great opportunity to show folks how powerful, easy to use and just plain fun Groovy is.

Wednesday, May 27, 2009

Grails: A Quick-Start Guide Beta

I am thrilled to announce that the Pragmatic Programmer's first Grails book is now in beta! You can find more details here: http://pragprog.com/titles/dkgrails/grails

Grails: A Quick-Start Guide (also known as GQuick) is aimed at helping developers learn Grails in a hurry. I got the idea for this book through my experience working with a team of Java web developers who were new to Grails. This book would have been a great help to us then and I'm hoping it will be a help to others in similar situations. I am also looking at this book as a contribution to humanity: helping all those poor souls who are struggling day in and day out with JSP, Struts, or (as I was) with JSF & EJB. So, if you know someone like that, go to the Prags website, download a copy and change a life!

The beta means that you can purchase an eBook which contains the first 2/3 of the book and get regular updates as it gets completed. You can also post errors and suggestions to help make the book better. When it's all finished you get the complete edited eBook. There is also an option to pre-purchase the paper book which should ship later this year (I'm hoping for September or October).

One last word about the Pragmatic Programmer's ebooks in general. They are awesome! You don't just get a PDF. Your Prag ebook is available in PDF, epub (for iPhone) or mobi (for the Kindle). You don't have to choose just one either, you can download a copy in any or all the formats. I have several Pragmatic Programmer's titles on my iPhone and they look great.

Wednesday, April 29, 2009

We need a US Groovy/Grails/Griffon Conference

It's been over a year since the best conference I've ever attended. The Groovy/Grails Experience was held in February 2008 near Washington DC. It was an awesome experience. For the nostalgic and those with too much time on their hands you can read my review of it here.

But we are way overdue for another. The folks that put that conference together, Jay Zimmerman and Scott Davis, both heroes of mine, tried to organize another but when the economy took a turn for the worse they decided to hold off. I understand their concerns. One only has to look at the desperate attempts at drawing attendees the JavaOne organizers are going through to realize that this is a tough climate for conferences. But hey we're talking about Groovy, Grails and Griffon here.

These are technologies that transcend tumultuous times.
While other conferences are being scaled back or cancelled, The GR8 conference, dedicated to G3 technologies, has had to move to a larger venue! And from what I've heard, the turnouts at the growing number of Groovy and Grails training classes haven't been too shabby. The G3 user group community continues to grow. The Grails podcast audience is climbing. We even have a G3 dedicated magazine. We are ready for a G3 Experience.

So, what are we going to do about it? We could get together and put one on ourselves but I still have faith in Jay and Scott. Anyone who has been to a NoFluffJustStuff or related conference knows that nobody does it better. So, let's let them know that it's time. Here's a few steps you can take:

  • Go to the 2GX website: http://groovygrails.com/gg/2gexperience and use the form there to register your interest.

  • Go to the NoFluffJustStuff feedback form and tell them it's time. You can even plead for your favorite city.

  • Send Jay and/or Scott an email (I'll leave it as an exercise for the reader to track down their email addresses)

  • Repeat this urgent plea on mailing lists, news groups, forums, at user groups, at work, in letters to the editor, etc.

  • Finally, if you are attending an upcoming NFJS event (coming to Atlanta, Denver, Dallas, Columbus) tell Jay or Scott that it's time for another G3 Experience.


Let's get to work, we can make it happen. After all, we are the G3 community. It's not like we're a bunch of (insert your favorite inferior language or technology here) hackers!

I'll see you at the next G3 Experience!

Tuesday, April 28, 2009

Linux Journal Readers Choice Awards

Well the votes are in and Groovy didn't get enough votes to get mentioned in the Linux Journal's Readers Choice awards.  The winner for favorite programming language was Python and favorite scripting language was bash (go figure :)  But I know that many Groovy users registered their votes in the "other" category so I wouldn't be surprised if next year we're at least on the list.  In fact as evidence that a write in one year can do well the following year, I am thrilled to announce that Contegix won the Readers Choice Award for Favorite Linux Friendly Web Hosting Company!  A quote from the article: "Talk about a meteoric rise, Contegix went from one write-in vote in 2008 to champion of the Favorite Linux-Friendly Web Hosting Company category in 2009."   

Since I have only been working for Contegix since last October, I don't feel like I can take any credit for this big win, but I am still thrilled because I can see how much they deserved it.  I have never worked with a more dedicated and sharp team of technologists.  It is an honor to be among them and I hope I can do my part to help win this award again next year.

But back to Groovy, the key point here is that last year Contegix was just a write in!  This year Groovy was just a write in...  Just wait till next year!   In the meantime, thank you to all you who voted for Groovy and for Contegix!

Thursday, March 19, 2009

Suggestions for Grails Refcard?

You may recall a recent poll on DZone where they were looking for input on what to cover next in their Refcardz project. Grails ended up at the top of that poll, by a very healthy margin (roughly 50% more votes than the #2 choice: Maven). The folks at DZone actually listen to their customers (unlike some other companies we know) and are now working on a Grails Refcard!

I have several of these cards and they are a great resource. I am very excited to see that their will soon be one on Grails! (Hopefully this May.) I'm also pretty excited that I get to write it. But these are a community resource so I am hoping to get some community involvement.

So, what would you most like to see in a Grails Refcard? What kind of things would you turn to a cheat sheet for when you're working on a Grails application? Are there features or syntax that you find yourself Googling for often? Now's your chance to get those covered on this handy reference card.

Post your wish list in a comment here or on the Grails mailing list.

Thanks for your help!
Dave

Sunday, March 1, 2009

Thoughts on Groovy, Grails, Griffon and JavaOne

You may have already heard that Groovy, Grails and Griffon are going to be under-represented at this year's JavaOne. While this is a bummer and hard to understand in the face of the enthusiasm that continues to grow in the community (see below for some examples), I don't think the right reaction is to say "who needs them" and skip JavaOne altogether. One idea Graeme Rocher mentioned on Twitter is a good one: a G3 mini conference would be great! The Monday night before JavaOne kicks off would be a perfect time for that.

Anyhow, it's important to note that last year there weren't all that many Groovy related talks either, but what I observed was that Groovy was represented as much by excited attendees as by presenters. I think it can be the same this year. Some of the brightest minds in the G3 community will be at JavaOne and they will have many opportunities outside of the session rooms, to talk about and demonstrate the power, efficiency and fun of Groovy, Grails and Griffon. The rest of us can do the same. So if you can make it to JavaOne go for it and feel the Groovy in the air!

Speaking of enthusiasm in the community, here are a few examples:

Here's a screenshot of the DZone popular link tab for 3/01/2008


This is one of my favorites, from a Sun blog.



This one is from the Stephen Colbourne's blog and shows the results of a whiteboard poll at Devoxx, a European conference that is very similar to JavaOne.

So don't be discouraged- the better mousetrap is doing all right!

Must See Lizard Brain Web Design

It's the morning of the last day of the first NFJS of 2009 and as I wait for things to get hopping, I had to mention that if you get a chance at a NoFluff event or elsewhere, you've got to see Scott Davis' talk titled Lizard Brain Web Design. If you are involved in web development this session will give you some great insight and ideas as to how to make your users happy that they went to your site. If you're not involved in web development, go see it anyway cause it's just plain fun!

Scott also gave a new talk called Dim Sum Grails. This was about as thorough a trip through Grails land as you could possibly fit into 90 minutes.

Brian Goetz, who I've heard has to bring an extra suitcase to carry his brains, gave a very helpful talk on Java Concurrency. He gave so many tips that it would be difficult to not pickup a few nuggets you can use right away. While Brian is not quite as dynamic a speaker as Scott, he is a good teacher and is able to get complex ideas across to the audience.

The day was capped off with the BOFs. I went to the JVM languages BOF and it was interesting but not quite as lively as they had been in the past. The discussion turned more towards functional languages and they just don't seem to get people quite as excited as dynamic languages. That or maybe we were all just to brain-full to get excited about anything.

Anyhow, it's been great so far and there's one more day to go. Today we'll hear more from Brian Goetz and Neal Ford, and Venkat Subramaniam, along with Stu Halloway. Good stuff in Milwaukee - stay up to date with the NoFluff news on Twitter. Search for #nfjs

Saturday, February 28, 2009

First NoFluffJustStuff of the year

It's finally here. The first NFJS of 2009! I'm sitting in Scott Davis' "Dim Sum Grails" session right now. Yesterday Scott had three brand new Groovy talks. They were very good. He's moving beyond the "what is Groovy" and into some really cool stuff. All, of course, in his award winning style!

There are also new sessions from Neal Ford, David Geary, Ken Sipe, Venkat Subramaniam, Mark Richards, Stuart Halloway and Brain Goetz. Since I haven't mastered the art of being in two places at once I will pretty much be in the Scott Davis track and then the Brian Goetz track.

I'll try to post more later. For now back to the dim sum!

Thursday, February 12, 2009

There's still time: Vote for Groovy by Feb. 14

The Linux Journal's Readers Choice Award website is still open. There's still time to cast your vote for Groovy as favorite scripting languge or favorite programming language (or, of course, BOTH).

You can cast your vote here: http://www.linuxjournal.com/content/readers-choice-awards/

Once on the site you'll notice that Groovy isn't even listed as an option. At first I was a bit miffed about that, but then I realized that they probably just did that to be fair. After all, as we've seen from polls recently at places like the Planetarium, MyEclipse and the Devoxx Whiteboards, when Groovy or Grails are listed they blow everything else away!

Since it's not on the list, Groovy probably won't lead the pack by double digits, but there's no reason it can't still win. Just choose other and write in Groovy. But you better hurry, there's only a couple days left! The polling closes after February 14th, 2009.

And while you're there, scroll down to the section on favorite Linux-friendly web hosting company and cast your vote for Contegix. Contegix is not only Linux-friendly, they are huge supporters of Groovy, Grails and open source in general. In fact Contegix is hosting the Groovy and Grails projects along with all of Codehaus.org!

Sunday, February 1, 2009

Pragmatic Grails Book in the Works!

I've always been impressed with the Pragmatic Programmers: as software artisans, as writers and as publishers. From a developer's perspective, you just can't beat the Pragmatic Programmers books. Not only do you have books written by developers for developers, you have books published by developers for developers, and often you have books edited by developers for developers.

When it comes to Groovy books, again, the Pragmatic Programmers shine. There are several good Groovy books out there. (Who can ever forget GinA?) But if I had to be stranded on a desert island with only one Groovy book (sounds kind of fun actually... can I bring my family?), it would have to be either Programming Groovy or Groovy Recipes, both Pragmatic titles.

All that to say that I am thrilled to announce that the Pragmatic Programmers will be coming out with their first Grails book! I don't know what it will be called or when it will ship, but it will be a "quick start guide," aimed at meeting the needs of all those new converts you are all out there making, as well as the untold millions of Spring users who are only a single Graeme Rocher demo away from becoming Grails users.

Another really cool thing for me about this new book is that I get to write it! I am almost as excited by this opportunity as I am overwhelmed by the responsibility. It is a big challenge, but I will do my best, and with God's help we'll soon have a book that can help rescue all those poor developers who are still suffering with Struts and JSF.

Another side benefit: with this task along with GroovyMag, I think I finally have a good excuse for my infrequent blog entries. :-)

I want to give a big Thank You to the folks at the Pragmatic Programmers for putting their trust in me and for their support behind the Groovy and Grails community.

Tuesday, January 13, 2009

Mea Culpa Groovy.mn

After posting on Twitter about two Groovy / Grails user group meetings this week, I was reminded that I had neglected to mention the gang in the Groovy capital of the mid-west, Minneapolis.  The Groovy Users  of Minnesota (GUM) have one of the oldest and most active groups in the G2 community.  The have meetings every 2nd Tuesday (including last night) and a very active and helpful mailing list.  This group is also home of some very prolific G2 bloggers, plugin developers and generally Groovy developers.  If you're anywhere near the Twin Cities, check them out.  If you're not in the area, you can still join the mailing list.   There's always something Groovy going on.