Programming Groovy 2: Dynamic Productivity for the Java Developer / Edition 1

Programming Groovy 2: Dynamic Productivity for the Java Developer / Edition 1

by Venkat Subramaniam
ISBN-10:
1937785300
ISBN-13:
9781937785307
Pub. Date:
07/22/2013
Publisher:
Pragmatic Bookshelf
ISBN-10:
1937785300
ISBN-13:
9781937785307
Pub. Date:
07/22/2013
Publisher:
Pragmatic Bookshelf
Programming Groovy 2: Dynamic Productivity for the Java Developer / Edition 1

Programming Groovy 2: Dynamic Productivity for the Java Developer / Edition 1

by Venkat Subramaniam

Paperback

$35.0
Current price is , Original price is $35.0. You
$35.00 
  • SHIP THIS ITEM
    In stock. Ships in 1-2 days.
  • PICK UP IN STORE

    Your local store may have stock of this item.

  • SHIP THIS ITEM

    Temporarily Out of Stock Online

    Please check back later for updated availability.


Overview

Groovy brings you the best of both worlds: a flexible, highly productive, agile, dynamic language that runs on the rich framework of the Java Platform. Groovy preserves the Java semantics and extends the JDK to give you true dynamic language capabilities. Programming Groovy 2 will help you, the experienced Java developer, learn and take advantage of the latest version of this rich dynamic language. You'll go from the basics of Groovy to the latest advances in the language, including options for type checking, tail-call and memoization optimizations, compile time metaprogramming, and fluent interfaces to create DSLs.

You don't have to leave the rich Java Platform to take advantage of Groovy. Groovy preserves Java's semantics and extends the JDK, so programming in Groovy feels like the Java language has been augmented; it's like working with a lighter, more elegant Java. If you're an experienced Java developer who wants to learn how Groovy works, you'll find exactly what you need in this book.

You'll start with the fundamentals of programming in Groovy and how it works with Java, and then you'll explore advanced concepts such as unit testing with mock objects, using Builders, working with databases and XML, and creating DSLs. You'll master Groovy's powerful yet complex run-time and compile-time metaprogramming features.

Much has evolved in the Groovy language since the publication of the first edition of Programming Groovy. Programming Groovy 2 will help you learn and apply Groovy's new features. Creating DSLs is easier now, and Groovy's already-powerful metaprogramming facilities have improved even more. You'll see how to work with closures, including tail call optimization and memoization. The book also covers Groovy's new static compilation feature.

Whether you're learning the basics of the language or interested in getting proficient with the new features, Programming Groovy 2 has you covered.

What You Need

To work on the examples in the book you need Groovy 2.0.5 and Java JDK 5 or higher.

Product Details

ISBN-13: 9781937785307
Publisher: Pragmatic Bookshelf
Publication date: 07/22/2013
Series: Pragmatic Programmers
Edition description: Second Edition
Pages: 370
Product dimensions: 7.40(w) x 9.10(h) x 0.80(d)

About the Author

*Dr. Venkat Subramaniam* is an award-winning author, founder of Agile Developer, Inc., and an adjunct faculty at the University of Houston. He has trained and mentored thousands of software developers in the US, Canada, Europe, and Asia, and is a regularly invited speaker at several international conferences. He's (co)author of multiple books, including the 2007 Jolt Productivity award winning book Practices of an Agile Developer.

Table of Contents


Foreword     xvii
Introduction     1
Why Dynamic Languages?     1
What's Groovy?     4
Why Groovy?     5
What's in This Book?     8
Who Is This Book For?     11
Acknowledgments     11
Beginning Groovy     15
Getting Started     17
Getting Groovy     17
Installing Groovy     18
Test-Drive Using groovysh     19
Using groovyConsole     20
Running Groovy on the Command Line     21
Using an IDE     22
Groovy for the Java Eyes     25
From Java to Groovy     25
JavaBeans     33
Optional Parameters     38
Implementing Interfaces     39
Groovy boolean Evaluation     43
Operator Overloading     44
Support of Java 5 Language Features     47
Gotchas     55
Dynamic Typing     63
Typing in Java     63
Dynamic Typing     66
Dynamic Typing != Weak Typing     67
Design by Capability     68
Optional Typing     74
Types in Groovy     74
Multimethods     75
Dynamic: To Be or Not to Be?     79
Using Closures     81
Closures     81
Use of Closures     85
Working with Closures     87
Closure and Resource Cleanup     87
Closures and Coroutines     90
Curried Closure     91
Dynamic Closures     94
Closure Delegation     96
Using Closures     99
Working with Strings     101
Literals and Expressions     101
GString Lazy Evaluation Problem     104
Multiline String     108
String Convenience Methods     110
Regular Expressions     111
Working with Collections     115
Using List     115
Iterating Over an ArrayList     117
Finder Methods     120
Collections' Convenience Methods     121
Using Map     124
Iterating Over Map     126
Map Convenience Methods     128
Using Groovy     131
Exploring the GDK     133
Object Extensions     133
Other Extensions     139
Working with XML      147
Parsing XML     147
Creating XML     152
Working with Databases     157
Connecting to a Database     158
Database Select     159
Transforming Data to XML     160
Using DataSet     161
Inserting and Updating     162
Accessing Microsoft Excel     162
Working with Scripts and Classes     165
The Melting Pot of Java and Groovy     165
Running Groovy     166
Using Groovy Classes from Groovy     167
Using Groovy Classes from Java     168
Using Java Classes from Groovy     169
Using Groovy Scripts from Groovy     171
Using Groovy Scripts from Java     173
Ease of Integration     175
MOPping Groovy     177
Exploring Meta-Object Protocol (MOP)     179
Groovy Object     180
Querying Methods and Properties     185
Dynamically Accessing Objects     187
Intercepting Methods Using MOP     189
Intercepting Methods Using GroovyInterceptable     189
Intercepting Methods Using MetaClass     192
MOP Method Injection and Synthesis     197
Injecting Methods Using Categories     198
Injecting Methods Using ExpandoMetaClass     203
Injecting Methods into Specific Instances     207
Method Synthesis Using methodMissing     209
Method Synthesis Using ExpandoMetaClass     214
Synthesizing Methods for Specific Instances     217
MOPping Up     219
Creating Dynamic Classes with Expando     219
Method Delegation: Putting It All Together     222
Review of MOP Techniques     226
Unit Testing and Mocking     229
Code in This Book and Automated Unit Tests     229
Unit Testing Java and Groovy Code     231
Testing for Exceptions     235
Mocking     236
Mocking by Overriding     239
Mocking Using Categories     243
Mocking Using ExpandoMetaClass     244
Mocking Using Expando     246
Mocking Using Map     248
Mocking Using the Groovy Mock Library     249
Groovy Builders     255
Building XML     255
Building Swing     259
Custom Builder Using Metaprogramming     260
Using BuilderSupport     263
Using FactoryBuilderSupport      267
Creating DSLs in Groovy     273
Context     273
Fluency     275
Types of DSLs     276
Designing Internal DSLs     277
Groovy and DSLs     277
Closures and DSLs     278
Method Interception and DSLs     279
The Parentheses Limitation and a Workaround     281
Categories and DSLs     282
ExpandoMetaClass and DSLs     285
Web Resources     287
Bibliography     293
Index     295
From the B&N Reads Blog

Customer Reviews