Programming Groovy - Dynamic Productivity for the Java Developer

Published by: Pragmatic Bookshelf
ISBN: 1934356093

Reviewer Ratings

Relevance:
5

Readability:
5

Overall:
5

Buy it now

One Minute Bottom Line

Programming Groovy is currently the best book out there for a Java developer to learn Groovy. It may not be as good of a reference as Groovy in Action and it may not have the fast answer examples of Groovy Recipes but then we have those books for that. The strength of this book is in the clear explanations, illustrative examples and excellent teaching style with which Venkat presents this material. If you are a Java developer and want to really learn Groovy or if you are already using Groovy and want to fill those gaps in your knowledge then you need this book. I have been working with Groovy for a year and I still had many “aha” moments while reading Programming Groovy. At the risk of over-hyping, Venkat’s thorough yet approachable coverage of meta-programming alone is well worth the price of the book.

Review

1. In the intro Venkat makes a good case for the value of dynamic languages in general and Groovy in particular.

2. Getting Started – Along with the usual downloading and installing instructions this chapter provides an overview of the different ways to work with Groovy: groovysh, groovyConsole, Groovy on the command line and a look at support in some IDEs.

3. Groovy for Java Eyes is an important transitional chapter for Java programmers. It starts out with some Java code that is also Groovy code and then gradually removes the stuff that Groovy doesn’t need. Then it goes on to discuss several of the easy to grasp, yet incredibly powerful features of Groovy. It concludes with a discussion of some common gotchas to watch out for.

4. Dynamic Typing actually covers typing in general in very thorough manner. Venkat clearly describes the difference between dynamic and static typing as well as the difference between strong and weak typing. He clears up the misconception that dynamic typing always means weak typing and then lays out how those terms apply to Groovy, Java and several other popular languages.

5. Using Closures will have you not only using, but understanding closures. This is no small feat and a credit to Venkat’s teaching ability. Closures are often one of the more difficult concepts for Java programmers to grasp but this chapter will make it much easier.

6. Working with Strings will seem like light reading after making it through closures. This chapter covers the Groovy way to work with strings. There are sections on GStrings, multi-line strings, regular expressions and more.

7. Working with Collections highlights some of the awesome new features added to Java Lists and Maps. It doesn’t cover every one of them but it hits the best ones and give good examples to show their usefulness.

8. Exploring the GDK is all about the ways that Groovy’s GDK extends and enhances old familiar classes in the JDK. Starting with Object and moving on to several popular classes in the java.lang, .io, .util packages.

9. Working with XML shows us how to read XML with XMLParser, XMLSlurper and DOMCategory and how to write XML with GString, MarkupBuilder and StreamingMarkupBuilder. The strengths and weaknesses of the different approaches are also discussed.

10. Working with Databases will forever change the way you think about JDBC. This chapter shows how ridiculously easy it is to work with SQL databases using Groovy’s Sql and DataSet classes.

11. Working with Scripts and Classes describes the various ways that Groovy code can be executed and integrated with Java. While this chapter is not as exciting as the rest it is very practical and necessary if we want to take our Groovy code beyond groovysh or groovyConsole.

12. Exploring Meta-Object Protocol lays the foundation for the thorough explanation of meta-programming that follows in chapters 13 – 15 with a good explanation of the GroovyObject and GroovyInterceptable interfaces.

13. Intercepting Methods Using MOP shows how to intercept method calls using either GroovyInterceptable.invokeMethod() or metaClass for those classes that do not implement GroovyInterceptable.

14. MOP Method Injection and Synthesis really gets into the meat of MOP. With examples using categories, methodMissing() and, my favorite, ExpandoMetaClass

15. MOPping Up continues and concludes the discussion of meta-programming with some more examples and a discussion of the Expando class.

16. Unit Testing and Mocking – It is often said that with dynamic languages unit testing becomes even more necessary. Perhaps that is why Groovy makes it so much easier to do. This chapter will get you started writing unit tests the Groovy way.

17. Groovy Builders takes a closer look at MarkupBuilder as well as SwingBuilder and then discusses Builders in general and the different ways that Groovy provides for creating your own custom Builders.

18. Creating DSLs in Groovy explains what a DSL is, when and how to use a DSL and how to create them in Groovy. Many of the features discussed in earlier chapters come into play here which makes this chapter a fitting ‘bringing it all together’ chapter. Even if you don’t have a need for a DSL the exercise of creating one would be a great way to become more fluent in Groovy.

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

Comments

Jing Ge replied on Wed, 2008/04/16 - 1:56am

Nice work! Which groovy version is covered in this book?

regards 

Dave Klein replied on Wed, 2008/04/16 - 7:48am in response to: polygoncell

Thanks!  The book and all examples are based on version 1.5.4

Amit Saha replied on Mon, 2009/02/02 - 12:49pm

Here is my detailed review: http://amitksaha.blogspot.com/2009/02/book-review-programming-groovy.html

Amit Saha replied on Mon, 2009/02/02 - 12:49pm

Here is my detailed review: http://amitksaha.blogspot.com/2009/02/book-review-programming-groovy.html

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.