Book Review:Groovy Recipes: Greasing the Wheels of Java

One Minute Review

Positives
  • Examples are clear, complete
  • Good explanation on how to use Groovy effectively
  • Fun and readable style
Negatives
  • Several topics covered could be books in themselves
  • Not the perfect reference

Buy it now

Ratings and Stats

ISBN:0978739299 Relevance:
5
Publisher:The Pragmatic Bookshelf Readability:
5
Author(s):Scott Davis Overall:
5
Bottom Line:

The material in this book is very well organized for random access. Each and every chapter, and every section in each chapter is organized in such a way that it solves a specific problem or explains with excellent working examples some specific Groovy language feature.

For those who prefer a more text bookish approach, there is always the ultimate guide for Groovy, "Groovy in Action" book; but if you like to work out real world examples as you read, this is the book you need to buy.

Intent and Audience

If you're an experienced Java developer, or a new Groovy developer, who is interested in using Groovy in everyday Java development, this book is for you.

The author in this book says and shows that one way of thinking of Groovy is to say Groovy is Java. To quote the author" You write Groovy in the same IDE you use for Java development. You deploy it to the same application servers you already have in production. As a matter of fact, drop a single groovy.jar into your classpath, and you have just "Groovy-enabled" your entire application."

Groovy Recipes is one of the best books taking on the task of explaining this new language to potential users.

Chapter Highlights

Chapter 1, Introduction, as the name implied introduces you to Groovy, and also gives a road map of what you will be reading in this book.

Chapter 2, Getting Started, shows you how to install Groovy, running a Groovy Script, compiling Groovy code. This chapter also discusses two commonly used tools that come with the Groovy, which also provide the ability to execute Groovy commands interactively: the Groovy shell, and the Groovy console.

Finally, how to use Groovy with various IDE’s like Eclipse, IntelliJ IDEA and any other editor of your choice are explored.

Chapter 3, New to Groovy, discusses the most powerful features of Groovy like; duck typing, Groovy truth, closures, and many useful features with examples which you can work on as you read this chapter.

Chapter 4, Java and Groovy Integration explores how groovy can be integrated with an existing Java infrastructure. Calling Groovy from Java is explored, as well as calling Java from Groovy. This naturally leads to the discussion of the Groovy joint compiler, the ability to easily compile Java and Groovy code using a single command.

A brief discussion of compiling your project with Ant and Maven concludes this chapter.

Chapter 5, Groovy from the Command line. One of the easiest ways to learn Groovy language is to use the command line. And this is exactly where this chapter takes you.

Chapter 6, File Tricks discusses the different ways you can use Groovy to work with the file system; listing files in a directory, reading files, copying them. Using the AntBuilder to copy a file or a directory, moving and renaming files and also zipping and unzipping files are presented as well.

Chapter 7, Parsing XML, explores Groovy’s support to XML and also how easy it is to work with XML using Groovy. These include using Groovy's XMLParser and XMLSlurper classes, understanding the difference between them.

Chapter 8, Writing XML. The previous chapter explored different ways to consume XML, this chapter as the name indicates, discusses the different ways to write XML using MarkupBuilder and StreamMarkupBuilder.

Chapter 9, Web Services. The chapter begins with a brief discussion of how to find out your local IP address and name, as well of those on remote systems. Next few sections are focused on HTTP. The last few sections explore making SOAP calls, RESTful calls, XML-RPC calls, and much more.

Chapter 10, Metaprogramming. To quote from the bookMetaprogramming is writing code that has the ability to dynamically change its behavior at runtime”.

This chapter discusses the many ways to programmatically find what fields and methods a class has, add new fields and methods at runtime using the MetaClass class. The chapter also explores calling methods that don’t exist using the invokeMethod(). I assure you, this is the chapter which will show you how fun and powerful Groovy is.

Chapter 11, Working with Grails, presents Grails, a web application framework that is built around Groovy. The chapter discusses installing Grails, creating Grails application, and understanding the Grails environments. The chapter next explores how to customize your Grails application by showing how to change the database, the home page.

The last few sections explain what are Controllers and Views, what scaffolding is, validation your data. Finally, the chapter ends with discussion about managing table relationships and mapping classes to legacy databases.

Chapter 12, Grails and Web Services. If you want to know more about how to use your Grails framework with RESTful web services, JSON web services, Atom feeds, podcast feeds, this chapter gives you a brief overview for all the above.

Relevance of Material

It is surprising to see how wide a range of applications Groovy can handle and how successfully it can simplify and clarify code that in Java could easily become very complex.

This book is unquestionably on target when it comes to presenting what you need to know to get up and running with Groovy and Grails.

The reading style is very engaging; I felt like I was in one of Scott's NFJS sessions and listening to him. The author has given us a book with excellent Groovy code snippets that solve most everyday problems we face immediately.

Resources

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

Comments

Serge Bureau replied on Thu, 2008/04/03 - 11:30am

This is an excellent book.

 

The chapter on what Groovy adds to Java is the best summary I have seen.

This totally sold me to the Groovy concept.

 

Serge 

Meera Subbarao replied on Thu, 2008/04/03 - 8:28pm

Yes, Serge. I have talked to so many people who have read this book, and each and everyone has said that this is an awesome book. I wish I could give more than 5 stars.

Comment viewing options

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