on 15 January 2010
It's worth picking up this book if you want to be a Grails expert and discover some interesting corner cases not covered in other books.
The main failing of this book is the sheer number of gaffs in terms of errors I spotted. Apress could have done with having a few proof readers look over the text before it went to print.
This book is split into two parts:
1) An introduction to Groovy : Chapters 1-9 : 2 star rating.
Ch 1: Getting Started with Groovy : Installation, Groovy Shell, Console, Eclipse, IntelliJ (fails to mention chgmod for bin folder for UNIX flavours P9)
Ch 2: From Java to Groovy
Ch 3: Groovy data types and Control Structures
Ch 4: Object Orientated Groovy : Incorrectly mentions Groovy doesn't support multiple inheritance on P76: Luke Daley wrote the Injecto library used in GLDAPO to facilitate this. This appears to have gone walkabout on Luke's site. Otherwise I'd include a link. It's on the internet archive though (Wayback Machine). Since Groovy 1.6 there has been the @mixin annotation. Mixin got a mention in GroovyMag Apr 2009 (What's new in Groovy 1.6) and Dec 2009 (Groovy MetaObject Programming) issues.
Ch 5: Closures
Ch 6: Builders
Ch 7: Working with databases : - Best Groovy chapter. USP* for buying book
Ch 8: Testing with Groovy : - This chapter is a howler. The main reason for loss of a star.
Section 8-2 P158. Bubblesort routine. If you do a for loop in Groovy with a range of the format for (n in m..<n), if m contains 1 and n contains 0, then the loop will execute once. So the test case would not work for an empty list or a list with one entry. This is not the same as a conventional Java for loop. for (int i=1; i<0;i++) which will never execute.
Ch 9: Miscellaneous Recipes :
There are far better Groovy guides out there. I often felt the author failed to use the best syntax or omitted things that you can do in Groovy. That combined with the number of typos and errors combined accounts or the low rating for the Groovy half of the book.
Scott Davis Groovy Recipes is far superior as a Getting started guide to Groovy.
Groovy in Action if you prefer a reference to a recipe book. GinA is more complete. (The second edition will be out later this year).
I think the Scott's Recipe book is one you'd refer to more often.
2) An introduction to Grails : Chapters 10-16 : 4 star rating.
Ch 10: Installing Grails : Eclipse / IntelliJ integration (both now a bit dated what with Spring Tool Suite and IntelliJ 8 & 9 now being out)
Ch 11: Web layer. Nice architectural diagram. The Grails section of the book is presented in a rather peculiar sequence. The author decided to showcase the view first (GSP's and Controllers).
In order to get a prototype of a Forum app up and running the author saves all the data off to the session first.
This is like swimming against the tide with Grails, since Grails facilitates automation of this stuff with scaffolding that you can later adapt by converting the scaffolding from dynamic (generated on the fly in memory) to static (generates a source you can modify).
Ch12: Covers the data layer and all things GORM. This is a good chapter, with the exception of Section 12-7. A mistake on P276. The like statements needed percent signs to make them work as a contains. Minor issue. Should have emphasised the need for Serialized on Composite keys in text - it's in example...
Ch13: Scaffolding. A really nice chapter. Would have thought it better to put ch 11 after 13.
This is one of the books USP's. Covers how to change templates and add property editors to render a rating property in a Domain class. Like the Amazon five star review using a Rich UI plugin tag. It's a bit rough round the edges, but an excellent intro.
Ch14: Security The usual stuff on XSS & protecting against SQL injection & restricting Request Methods on actions (so you can't delete a domain instance with a hacked URL), Codecs and Filters. Rounds out with best part (a USP*) on Acegi (Spring) Security (a brief overview is provided to get you started) and a discussion on OpenId.
Ch15: On Testing Grails apps. Really nice chapter. Unit testing Controllers - mocking operations. Integration Testing. Testing Taglibs (could have done with identifying folder these go into), Domain Classes and Functional Testing with Canoo Web Test. Mentions the Firefox plug-in to record these.
Ch16: Miscellaneous Recipes. Highlights for me were Using Grails with Maven 2 and Apache CXF, the successor to XFire is showcased for doing SOAP web services. It's handy to use Maven here for dependency resolution. A huge number of jars are required for this.
Services, REST, logging and tweaking web.xml and spring bean configuration (via XML & GroovyBuilders) round out the chapter. Log4j pattern matching could have done with a table of what the codes meant. Lucky I have a copy of APress's Pro Apache Log4J!
Overall this part of the book isn't one I'd recommend over Jon Dickinson's newer Grails 1.1 book by PACKT for Depth of coverage - although this is easier to follow.
It goes into slightly more detail than Dave Klein's Quick Start book.
The author doesn't always show just the best way of doing things. So this is sometimes handy if you want a quick and dirty fix and broadening your Groovy & Grails skills which it undoubtably will do.
As I said at the start, it's worth picking up this book if you want to be a Grails expert and discover some interesting corner cases not covered in other books.
* USP = Unique Selling Point