×

Uh-oh, it looks like your Internet Explorer is out of date.

For a better shopping experience, please upgrade now.

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

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

by Venkat Subramaniam
 

ISBN-10: 1934356093

ISBN-13: 9781934356098

Pub. Date: 05/05/2008

Publisher: Pragmatic Programmers, LLC, The

The strength of Java is no longer in the language itself; it's in the Java Platform (the JVM, JDK, and rich frameworks and libraries). But recently, the industry has turned to dynamic languages for increased productivity and speed to market.

Groovy is one of a new breed of dynamic languages that run on the Java platform. You can use these new languages on the JVM

Overview

The strength of Java is no longer in the language itself; it's in the Java Platform (the JVM, JDK, and rich frameworks and libraries). But recently, the industry has turned to dynamic languages for increased productivity and speed to market.

Groovy is one of a new breed of dynamic languages that run on the Java platform. You can use these new languages on the JVM and intermix them with your existing Java code. You can leverage your Java investments while benefiting from advanced features including true Closures, Meta Programming, the ability to create internal DSLs, and a higher level of abstraction.

If you're an experienced Java developer, Programming Groovy will help you learn the necessary fundamentals of programming in Groovy. You'll see how to use Groovy to do advanced programming including using Meta Programming, Builders, Unit Testing with Mock objects, processing XML, working with Databases and creating your own Domain-Specific Languages (DSLs).

Product Details

ISBN-13:
9781934356098
Publisher:
Pragmatic Programmers, LLC, The
Publication date:
05/05/2008
Series:
Pragmatic Programmers Series
Pages:
300
Product dimensions:
7.54(w) x 9.11(h) x 0.95(d)

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

Customer Reviews

Average Review:

Post to your social network

     

Most Helpful Customer Reviews

See all customer reviews