The post has been submitted for moderation and won't be listed publicly until it has been approved.

Review of "Programming Groovy"

Published by: The Pragmatic Bookshelf
ISBN: 1934356093

Reviewer Ratings

Relevance:
4

Readability:
3

Overall:
4

Buy it now

One Minute Bottom Line

If you're already fluent in Java, and you want to learn Groovy, this is a good book, well worth the money. It has a nice overview, without going into all the tedious details about language structure that you almost never need. It has a great section on closures and the functional programming capabilities of Groovy. It has a fabulous section on how to use the nifty groovy features to extend classes and inject methods dynamically. If you've ever wondered how Grails or Rails does all of its behind-the-scenes class changes, this book has some very illuminating examples.

The last section, on metaprogramming, DSLs and other advanced topics feels rushed - he's tried to jam an entire semester-long college course's worth of theory and practice into a 150 pages, and it doesn't really come across as well as I would like.

 

Review

Introduction

  • Standard introduction - this book is for people who know java, and want to learn Groovy 

 Getting Started

  • Examples of how to use groovy - command line, console and IDE 

Groovy for the Java Eyes

  • The first "meaty" chapter - lots of good advice on how to use Java from Groovy and vice-versa.

Dynamic Typing

  • A solid overview on the power and danger of Dynamic Typing.  A great primer if you're not already familiar with the concept.

Using Closures

  • Outstanding chapter, with lots of good examples and patient explanations of the power of closures.

Working With Strings

  • A good overview of the new things that Groovy offers to extend Java strings.  There's a small section at the end on regexp, but it's a bit too short.

Working with Collections

  • Another outstanding chapter of all the convenience methods provided by Groovy to work with lists, sets and maps.  Ruby practitioners will be right at home here.

Exploring the GDK

  • Some examples of how Groovy goes beyond Java in terms of convenience:  identity, indirect method invokation, and various other "syntactic sugar" to make programming easier

Working with XML

  • A typical XML overview chapter - practical advice for working with XML in Groovy

Working with Databases

  • Some nice examples of how to use the Groovy extensions to make connecting to and working with database data easier and simpler.

Working with Scripts and Classes

  • A hodgepodge of interesting examples of using Java from Groovy, Groovy from Java, Java from Groovy scripts, etc. 

Exploring Meta-Object Protocol

  • Some fascinating examples of how to manipulate your classes at runtime - adding properties and methods, handling missing methods and other missing data.  One of the best chapters in the book, and a must read if you'd like to understand more about how Rails or Grails works with database data. 

Intercepting Methods Using MOP

  • More interesting examples of using the "meta-power" of Groovy to build programatically dynamic systems.

MOP Method Injection and Synthesis

  • Another thought-provoking chapter, with information on Categories, ExpandoMetaClass and all sorts of other examples of extending your objects and classes at runtime.
 MOPping Up
  •  This is where things start to get confusing - some interesting examples of how to delegate work and create classes dynamically, but the examples are fairly abstract, and I don't think enough time is spent to really clarify what is going on here.

Unit Testing and Mocking

  • Some good examples of using Mocks and Stubs in your Groovy and Java unit tests.   At the same time, there are some fairly confusing examples of using ExpandoMetaClass and other techniques to mock objects, and they're not as clear.

Groovy Builders

  • Starts off with a nice, but simple example of building XML from object trees, but then the Swing and DSL-style examples are cryptic and hard to follow.  These are the kinds of topics that need an entire college course to cover, and this section does not do them justice.

Creating DSLs in Groovy

  • Again, while there is some interesting stuff here, there is a lot of theory crammed into a small space, and I don't think it comes across clearly.   Same comment as before about a college-course's worth of information to cover.
 

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)