Programming Groovy 2, 2nd Edition
- Length: 350 pages
- Edition: 2
- Language: English
- Publisher: Pragmatic Bookshelf
- Publication Date: 2013-07-22
- ISBN-10: 1937785300
- ISBN-13: 9781937785307
- Sales Rank: #937755 (See Top 100 Books)
Programming Groovy 2: Dynamic Productivity for the Java Developer (Pragmatic Programmers)
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.
Table of Contents
Part I: Beginning Groovy
Chapter 1. Getting Started
Chapter 2. Groovy for Java Eyes
Chapter 3. Dynamic Typing
Chapter 4. Using Closures
Chapter 5. Working with Strings
Chapter 6. Working with Collections
Part II: Using Groovy
Chapter 7. Exploring the GDK
Chapter 8. Working with XML
Chapter 9. Working with Databases
Chapter 10. Working with Scripts and Classes
Part III: MOPping Groovy
Chapter 11. Exploring Metaobject Protocol (MOP)
Chapter 12. Intercepting Methods Using MOP
Chapter 13. MOP Method Injection
Chapter 14. MOP Method Synthesis
Chapter 15. MOPping Up
Chapter 16. Applying Compile-Time Metaprogramming
Part IV: Using Metaprogramming
Chapter 17. Groovy Builders
Chapter 18. Unit Testing and Mocking
Chapter 19. Creating DSLs in Groovy
Appendix A1. Web Resources
Appendix A2. Bibliography
Programming Groovy 2 Table of Contents What readers are saying about Programming Groovy 2 Foreword to the Second Edition Introduction What’s Groovy? Why Dynamic Languages? Why Groovy? What’s in This Book? Changes Since This Book’s First Edition Who Is This Book For? Online Resources Acknowledgments Part 1: Beginning Groovy Chapter 1: Getting Started 1.1 Installing Groovy 1.2 Installing and Managing Groovy Versions 1.3 Test-Drive Using groovysh 1.4 Using groovyConsole 1.5 Running Groovy on the Command Line 1.6 Using an IDE Chapter 2: Groovy for Java Eyes 2.1 From Java to Groovy 2.2 JavaBeans 2.3 Flexible Initialization and Named Arguments 2.4 Optional Parameters 2.5 Using Multiple Assignments 2.6 Implementing Interfaces 2.7 Groovy Boolean Evaluation 2.8 Operator Overloading 2.9 Support of Java 5 Language Features 2.10 Using Groovy Code-Generation Transformations 2.11 Gotchas Chapter 3: Dynamic Typing 3.1 Typing in Java 3.2 Dynamic Typing 3.3 Dynamic Typing != Weak Typing 3.4 Design by Capability 3.5 Optional Typing 3.6 Multimethods 3.7 Dynamic: To Be or Not to Be? 3.8 Switching Off Dynamic Typing Chapter 4: Using Closures 4.1 The Convenience of Closures 4.2 Programming with Closures 4.3 Ways to Use Closures 4.4 Passing Parameters to Closures 4.5 Using Closures for Resource Cleanup 4.6 Closures and Coroutines 4.7 Curried Closure 4.8 Dynamic Closures 4.9 Closure Delegation 4.10 Programming with Tail Recursion 4.11 Improving Performance Using Memoization Chapter 5: Working with Strings 5.1 Literals and Expressions 5.2 GString Lazy-Evaluation Problem 5.3 Multiline Strings 5.4 String Convenience Methods 5.5 Regular Expressions Chapter 6: Working with Collections 6.1 Using List 6.2 Iterating Over an ArrayList 6.3 Using Finder Methods 6.4 Other Convenience Methods on List s 6.5 Using the Map Class 6.6 Iterating Over Map 6.7 Other Convenience Methods on Map s Part 2: Using Groovy Chapter 7: Exploring the GDK 7.1 Using Object Extensions 7.2 Other Extensions 7.3 Custom Methods Using the Extension Modules Chapter 8: Working with XML 8.1 Parsing XML 8.2 Creating XML Chapter 9: Working with Databases 9.1 Setting Up the Database 9.2 Connecting to a Database 9.3 Database Select 9.4 Transforming Data to XML 9.5 Using DataSet 9.6 Inserting and Updating 9.7 Accessing Microsoft Excel Chapter 10: Working with Scripts and Classes 10.1 The Melting Pot of Java and Groovy 10.2 Running Groovy 10.3 Using Groovy Classes from Groovy 10.4 Intermixing Groovy and Java with Joint Compilation 10.5 Creating and Passing Groovy Closures from Java 10.6 Calling Groovy Dynamic Methods from Java 10.7 Using Java Classes from Groovy 10.8 Using Groovy Scripts from Groovy 10.9 Using Groovy Scripts from Java Part 3: MOPping Groovy Chapter 11: Exploring Metaobject Protocol (MOP) 11.1 Groovy Object 11.2 Querying Methods and Properties 11.3 Dynamically Accessing Objects Chapter 12: Intercepting Methods Using MOP 12.1 Intercepting Methods Using GroovyInterceptable 12.2 Intercepting Methods Using MetaClass Chapter 13: MOP Method Injection 13.1 Injecting Methods Using Categories 13.2 Injecting Methods Using ExpandoMetaClass 13.3 Injecting Methods into Specific Instances 13.4 Injecting Methods Using Mixins 13.5 Decorating Classes with Multiple Mixins Chapter 14: MOP Method Synthesis 14.1 Method Synthesis Using methodMissing 14.2 Method Synthesis Using ExpandoMetaClass 14.3 Synthesizing Methods for Specific Instances Chapter 15: MOPping Up 15.1 Creating Dynamic Classes with Expando 15.2 Method Delegation: Putting It All Together 15.3 Review of MOP Techniques Chapter 16: Applying Compile-Time Metaprogramming 16.1 Analyzing Code at Compile Time 16.2 Intercepting Method Calls Using AST Transformations 16.3 Injecting Methods Using AST Transformations Part 4: Using Metaprogramming Chapter 17: Groovy Builders 17.1 Building XML 17.2 Building JSON 17.3 Building Swing 17.4 Custom Builder Using Metaprogramming 17.5 Using BuilderSupport 17.6 Using FactoryBuilderSupport Chapter 18: Unit Testing and Mocking 18.1 Code in This Book and Automated Unit Tests 18.2 Unit Testing Java and Groovy Code 18.3 Testing for Exceptions 18.4 Mocking 18.5 Mocking by Overriding 18.6 Mocking Using Categories 18.7 Mocking Using ExpandoMetaClass 18.8 Mocking Using Expando 18.9 Mocking Using Map 18.10 Mocking Using the Groovy Mock Library Chapter 19: Creating DSLs in Groovy 19.1 Context 19.2 Fluency 19.3 Types of DSLs 19.4 Designing Internal DSLs 19.5 Groovy and DSLs 19.6 Using Command-Chain Fluency 19.7 Closures and DSLs 19.8 Method Interception and DSLs 19.9 The Parentheses Limitation and a Workaround 19.10 Categories and DSLs 19.11 ExpandoMetaClass and DSLs Appendix 1: Web Resources Appendix 2: Bibliography You May Be Interested In…
Donate to keep this site alive
1. Disable the AdBlock plugin. Otherwise, you may not get any links.
2. Solve the CAPTCHA.
3. Click download link.
4. Lead to download server to download.