logo

Grails In Action 2.0 – The Great Spock Update

logo

Heaps of people have been tweeting me about the status of Grails In Action 2.0 – so it’s time to blog up a bit about how things are progressing.

How are things tracking?

We have about five chapters in bed so far (including a reworked Groovy introduction, a new chapter on Scaffolding, and the several of the original “intro” chapters from Part I and II of the book. Our current plan is to square off a few more chapters in Part II then set it free to the Manning MEAP programme.  We’re keen to get some good value in place before we unleash it on you all. Not being perfectionists, just making sure that when you get it it was worth the wait!

The good news is that Peter and I are presently sinking a good amount of time into writing and the pace of things is definitely picking up now! I would expect you’d see a MEAP sometime in August.

One of the things that has pleased me about the update process is that I”ve definitely improved as a Grails programmer in the last few years! There’s stuff in First Ed that was probably a bit hacky, and I’ll do my best to tidy that stuff up as I rework the chapters. I remember listening to a great keynote by David Heinemeier Hansson on “Legacy Code and Code Rot” – (can’t find the MP3 link, but it might be this one) and him saying that it’s not that your code rots, it’s that you’re a different person than when you wrote it! Great concept! I’m noticing it a lot in the update.

Some Spocktacular Updates

We’ve made the move to Spock for this version of the book – starting from Chapter 3 – and you’re gonna love it! Peter and I work in it exclusively now, and asking around twitter it seems a lot of working Grails devs have made the switch too. IMHO it makes our examples much clearer to the beginner too. Take our chapter 3 Listing 3.3 example explaining how to test property updates. Here’s the before and after (JUnit vs Spock):

void testSaveAndUpdate() {
    def user = new User(userId: 'joe', password: 'secret',
        homepage: 'http://www.grailsinaction.com')
    assertNotNull user.save()
    def foundUser = User.get(user.id)
    foundUser.password = 'sesame'                   
    foundUser.save()              
    def editedUser = User.get(user.id)
    assertEquals 'sesame', editedUser.password            
}

Which is replaced by:

    def "Updating a saved user changes its properties"() {

    	given: "An existing user"
    	def existingUser = new User(userId: 'joe', password: 'secret',
        	homepage: 'http://www.grailsinaction.com').save(failOnError: true)

        when: "A property is changed"
    	def foundUser = User.get(existingUser.id)    
    	foundUser.password = 'sesame'                   
    	foundUser.save()              

    	then: "The change is reflected in the database"
    	User.get(existingUser.id).password == 'sesame'

	}

Personally, I think Spock really does make the intention of the test much clearer to the new guy on the project.

But When, Glen, When??

We’ll keep you posted. I can’t imagine it would be much more than a month before we release a serious chunk of chapters to MEAP. We’re working hard to keep the same fun tone of the original book, but making sure we spend a lot more time focusing on “Best Practice” type issues to incorporate the stuff we’ve learned over the last few years in Grails consulting and commercial development.

Thanks everyone for your encouragement and support!

 

One Response to “Grails In Action 2.0 – The Great Spock Update”

  1. John Holme says:

    Looking forward to the 2.0 book, Glen! I hope you will provide more guidance on two related areas that have been challenging for me: maven integration (especially resolving dependency conflicts) and plugin-oriented architecture. They’re related because the more plugins I try to integrate, the more dependency conflicts pop up. The online documentation, while useful as a starting point, doesn’t even begin to cover the problems that emerge when using Grails to build the presentation tier of a complex enterprise app. thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

logo
logo
Powered by WordPress | Designed by Elegant Themes