About this Book

Roadmap

Groovy in Action describes the Groovy language, presents the library classes and methods that Groovy adds to the standard Java Development Kit, and leads you through a number of topics that you are likely to encounter in your daily development work. The book is made up of these three parts:

An introductory chapter explains what Groovy is and then part 1 starts with a broad overview of Groovy’s language features, before going into more depth about scalar and collective datatypes. The language description includes an explanation of the closure concept that is ubiquitous in Groovy, describing how it relates to and distinguishes itself from control structures. Part 1 closes with Groovy’s model of object-orientation and its Meta-Object Protocol, which makes Groovy the dynamic language that it is.

Part 2 begins the library description with a presentation of Groovy’s builder concept, its various implementations, and their relation to template engines, along with their use in Groovlets for simple web applications. An explanation of the GDK follows, with Groovy’s enhancements to the Java standard library. This is the “beef” of the library description in part 2. The Groovy library shines with simple but powerful support for database programming and XML handling, and we include a detailed exposition of both topics. Another big advantage of Groovy is its all-out seamless integration with Java, and we explain the options provided by the Groovy library for setting this into action.

If part 1 was a tutorial and part 2 a reference, part 3 is a cookbook. It starts with tips and tricks, warnings of typical pitfalls and misconceptions, and snippets and solutions for common tasks, and then it leads you through the organizational aspects of your daily work with Groovy. A big part of day-to-day programming work is unit testing, and we describe in detail how Groovy helps with that. Since many programmers work on the Windows platform, we describe how to leverage your Groovy knowledge through integration with COM and ActiveX components.

A final bonus chapter gives a glimpse of how to use Grails, the Groovy web application framework. Grails is a perfect example for understanding and appreciating Groovy. It fully exploits Groovy’s dynamic capabilities for runtime injection of features while using the solid base of the Java enterprise platform and the performance and scalability of third-party libraries such as Spring and Hibernate to the fullest. Grails is worth studying on its own; we have included it in part 3 to demonstrate how mindful engineering can lead to new levels of productivity by standing on the shoulders of giants.

The book ends with a series of appendixes which are intended to serve as a quick reference.

Who should read this book?

This book is for everyone who wants to learn Groovy as a new agile programming language. Existing Groovy users can use it to deepen their knowledge; and both new and experienced programmers can use it as a black-and-white reference. We found ourselves going to our own book to look up details that we had forgotten. Newcomers to Groovy will need a basic understanding of Java since Groovy is completely dependent on it; Java basics are not covered in our book.

Topics have been included that will make reading and understanding easier, but are not mandatory prerequisites: patterns of object-oriented design, Ant, Maven, JUnit, HTML, XML, and Swing. It is beneficial—but not required—to have been exposed to some other scripting language. This enables you to connect what you read to what you already know. Where appropriate, we point out similarities and differences between Groovy and other scripting languages.

Code conventions

This book provides copious examples that show how you can make use of each of the topics covered. Source code in listings or in text appears in a fixed-width font like this to separate it from ordinary text. In addition, class and method names, object properties, and other code-related terms and content in text are presented using fixed-width font.

Occasionally, code is italicized, as in reference.dump(). In this case reference should not be entered literally but replaced with the content that is required, such as the appropriate reference.

Where the text contains the pronouns “I” and “we,” the “we” refers to all the authors. “I” refers to the lead author of the respective chapter: Guillaume Laforge for chapters 11 and 15, Andrew Glover for chapter 14, and Dierk König for the remaining chapters.

Most of the code examples contain Groovy code. This code is very compact so we present it “as is” without any omissions. Unless stated otherwise, you can copy and paste it into a new file and run it right away. In rare cases, when this wasn’t possible, we have used ... ellipsis.

Java, HTML, XML, and command-line input can be verbose. In many cases, the original source code (available online) has been reformatted; we’ve added line breaks and reworked indentation to accommodate the page space available in the book. In rare cases, when even this was not enough, line-continuation markers were added.

Code annotations accompany many of the listings, highlighting important concepts. In some cases, numbered cueballs link to additional explanations that follow the listing.

You can download the source code for all of the examples in the book from the publisher’s website at www.manning.com/koenig.

Keeping up to date

The world doesn’t stop turning when you finish writing a book, and getting the book through production also takes time. Therefore, some of the information in any technical book becomes quickly outdated, especially in the dynamic world of agile languages.

This book covers Groovy 1.0. Groovy will see numerous improvements, and by the time you read this, it’s possible that an updated version will have become available. New Groovy versions always come with a detailed list of changes. It is unlikely that any of the core Groovy concepts as laid out in this book will change significantly before Groovy 2.0; and even then the emphasis is likely to be on additional concepts and features. This outlook makes the book a wise investment, even in a rapidly changing world.

We will do our best to keep the online resources for this book reasonably up to date and provide information about language and library changes as the project moves on. Please check for updates on the book’s web page at www.manning.com/koenig.

Author Online

Purchase of Groovy in Action includes free access to a private web forum run by Manning Publications where you can make comments about the book, ask technical questions, and receive help from the authors and from other users. To access the forum and subscribe to it, point your web browser to www.manning.com/koenig. This page provides information on how to get on the forum once you are registered, what kind of help is available, and the rules of conduct on the forum. It also provides links to the source code for the examples in the book, errata, and other downloads.

Manning’s commitment to our readers is to provide a venue where a meaningful dialog between individual readers and between readers and the authors can take place. It is not a commitment to any specific amount of participation on the part of the authors, whose contribution to the AO remains voluntary (and unpaid). We suggest you try asking the authors some challenging questions lest their interest stray!

The Author Online forum and the archives of previous discussions will be accessible from the publisher’s website as long as the book is in print.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.48.204