Programming Groovy: Dynamic Productivity for the Java Developer (Pragmatic Programmers)
معرفی کتاب «Programming Groovy: Dynamic Productivity for the Java Developer (Pragmatic Programmers)» نوشتهٔ Venkat Subramaniam; Daniel Howard Steinberg، منتشرشده توسط نشر The Pragmatic Bookshelf در سال 2008. این کتاب در فرمت pdf، زبان انگلیسی ارائه شده است. «Programming Groovy: Dynamic Productivity for the Java Developer (Pragmatic Programmers)» در دستهٔ بدون دستهبندی قرار دارد.
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). Contents......Page 9 Foreword......Page 14 Why Dynamic Languages?......Page 16 What's Groovy?......Page 19 Why Groovy?......Page 20 What's in This Book?......Page 23 Acknowledgments......Page 26 Beginning Groovy......Page 29 Getting Groovy......Page 30 Installing Groovy......Page 31 Test-Drive Using groovysh......Page 32 Using groovyConsole......Page 33 Running Groovy on the Command Line......Page 34 Using an IDE......Page 35 From Java to Groovy......Page 37 JavaBeans......Page 45 Optional Parameters......Page 50 Implementing Interfaces......Page 51 Groovy boolean Evaluation......Page 55 Operator Overloading......Page 56 Support of Java 5 Language Features......Page 59 Gotchas......Page 67 Typing in Java......Page 75 Dynamic Typing......Page 78 Dynamic Typing != Weak Typing......Page 79 Design by Capability......Page 80 Types in Groovy......Page 86 Multimethods......Page 87 Dynamic: To Be or Not to Be?......Page 91 Closures......Page 92 Use of Closures......Page 96 Closure and Resource Cleanup......Page 98 Closures and Coroutines......Page 101 Curried Closure......Page 102 Dynamic Closures......Page 105 Closure Delegation......Page 107 Using Closures......Page 110 Literals and Expressions......Page 111 GString Lazy Evaluation Problem......Page 114 Multiline String......Page 118 String Convenience Methods......Page 120 Regular Expressions......Page 121 Using List......Page 124 Iterating Over an ArrayList......Page 126 Finder Methods......Page 129 Collections' Convenience Methods......Page 130 Using Map......Page 133 Iterating Over Map......Page 135 Map Convenience Methods......Page 137 Using Groovy......Page 140 Object Extensions......Page 141 Other Extensions......Page 147 Parsing XML......Page 155 Creating XML......Page 160 Working with Databases......Page 164 Connecting to a Database......Page 165 Database Select......Page 166 Transforming Data to XML......Page 167 Using DataSet......Page 168 Accessing Microsoft Excel......Page 169 The Melting Pot of Java and Groovy......Page 172 Running Groovy......Page 173 Using Groovy Classes from Groovy......Page 174 Using Groovy Classes from Java......Page 175 Using Java Classes from Groovy......Page 176 Using Groovy Scripts from Groovy......Page 178 Using Groovy Scripts from Java......Page 180 Ease of Integration......Page 182 MOPping Groovy......Page 183 Exploring Meta-Object Protocol (MOP)......Page 184 Groovy Object......Page 185 Querying Methods and Properties......Page 190 Dynamically Accessing Objects......Page 192 Intercepting Methods Using GroovyInterceptable......Page 194 Intercepting Methods Using MetaClass......Page 197 MOP Method Injection and Synthesis......Page 202 Injecting Methods Using Categories......Page 203 Injecting Methods Using ExpandoMetaClass......Page 208 Injecting Methods into Specific Instances......Page 212 Method Synthesis Using methodMissing......Page 214 Method Synthesis Using ExpandoMetaClass......Page 219 Synthesizing Methods for Specific Instances......Page 222 Creating Dynamic Classes with Expando......Page 224 Method Delegation: Putting It All Together......Page 227 Review of MOP Techniques......Page 231 Code in This Book and Automated Unit Tests......Page 234 Unit Testing Java and Groovy Code......Page 236 Testing for Exceptions......Page 240 Mocking......Page 241 Mocking by Overriding......Page 244 Mocking Using Categories......Page 248 Mocking Using ExpandoMetaClass......Page 249 Mocking Using Expando......Page 251 Mocking Using Map......Page 253 Mocking Using the Groovy Mock Library......Page 254 Building XML......Page 260 Building Swing......Page 264 Custom Builder Using Metaprogramming......Page 265 Using BuilderSupport......Page 268 Using FactoryBuilderSupport......Page 272 Context......Page 277 Fluency......Page 279 Types of DSLs......Page 280 Groovy and DSLs......Page 281 Closures and DSLs......Page 282 Method Interception and DSLs......Page 283 The Parentheses Limitation and a Workaround......Page 285 Categories and DSLs......Page 286 ExpandoMetaClass and DSLs......Page 289 Web Resources......Page 291 Bibliography......Page 296 C......Page 298 F......Page 299 J......Page 300 M......Page 301 S......Page 302 X......Page 303 Contents 9 Foreword 14 Introduction 16 Why Dynamic Languages? 16 What's Groovy? 19 Why Groovy? 20 What's in This Book? 23 Who Is This Book For? 26 Acknowledgments 26 Beginning Groovy 29 Getting Started 30 Getting Groovy 30 Installing Groovy 31 Test-Drive Using groovysh 32 Using groovyConsole 33 Running Groovy on the Command Line 34 Using an IDE 35 Groovy for the Java Eyes 37 From Java to Groovy 37 JavaBeans 45 Optional Parameters 50 Implementing Interfaces 51 Groovy boolean Evaluation 55 Operator Overloading 56 Support of Java 5 Language Features 59 Gotchas 67 Dynamic Typing 75 Typing in Java 75 Dynamic Typing 78 Dynamic Typing != Weak Typing 79 Design by Capability 80 Optional Typing 86 Types in Groovy 86 Multimethods 87 Dynamic: To Be or Not to Be? 91 Using Closures 92 Closures 92 Use of Closures 96 Working with Closures 98 Closure and Resource Cleanup 98 Closures and Coroutines 101 Curried Closure 102 Dynamic Closures 105 Closure Delegation 107 Using Closures 110 Working with Strings 111 Literals and Expressions 111 GString Lazy Evaluation Problem 114 Multiline String 118 String Convenience Methods 120 Regular Expressions 121 Working with Collections 124 Using List 124 Iterating Over an ArrayList 126 Finder Methods 129 Collections' Convenience Methods 130 Using Map 133 Iterating Over Map 135 Map Convenience Methods 137 Using Groovy 140 Exploring the GDK 141 Object Extensions 141 Other Extensions 147 Working with XML 155 Parsing XML 155 Creating XML 160 Working with Databases 164 Connecting to a Database 165 Database Select 166 Transforming Data to XML 167 Using DataSet 168 Inserting and Updating 169 Accessing Microsoft Excel 169 Working with Scripts and Classes 172 The Melting Pot of Java and Groovy 172 Running Groovy 173 Using Groovy Classes from Groovy 174 Using Groovy Classes from Java 175 Using Java Classes from Groovy 176 Using Groovy Scripts from Groovy 178 Using Groovy Scripts from Java 180 Ease of Integration 182 MOPping Groovy 183 Exploring Meta-Object Protocol (MOP) 184 Groovy Object 185 Querying Methods and Properties 190 Dynamically Accessing Objects 192 Intercepting Methods Using MOP 194 Intercepting Methods Using GroovyInterceptable 194 Intercepting Methods Using MetaClass 197 MOP Method Injection and Synthesis 202 Injecting Methods Using Categories 203 Injecting Methods Using ExpandoMetaClass 208 Injecting Methods into Specific Instances 212 Method Synthesis Using methodMissing 214 Method Synthesis Using ExpandoMetaClass 219 Synthesizing Methods for Specific Instances 222 MOPping Up 224 Creating Dynamic Classes with Expando 224 Method Delegation: Putting It All Together 227 Review of MOP Techniques 231 Unit Testing and Mocking 234 Code in This Book and Automated Unit Tests 234 Unit Testing Java and Groovy Code 236 Testing for Exceptions 240 Mocking 241 Mocking by Overriding 244 Mocking Using Categories 248 Mocking Using ExpandoMetaClass 249 Mocking Using Expando 251 Mocking Using Map 253 Mocking Using the Groovy Mock Library 254 Groovy Builders 260 Building XML 260 Building Swing 264 Custom Builder Using Metaprogramming 265 Using BuilderSupport 268 Using FactoryBuilderSupport 272 Creating DSLs in Groovy 277 Context 277 Fluency 279 Types of DSLs 280 Designing Internal DSLs 281 Groovy and DSLs 281 Closures and DSLs 282 Method Interception and DSLs 283 The Parentheses Limitation and a Workaround 285 Categories and DSLs 286 ExpandoMetaClass and DSLs 289 Web Resources 291 Bibliography 296 Index 298 Symbols 298 A 298 B 298 C 298 D 299 E 299 F 299 G 300 H 300 I 300 J 300 K 301 L 301 M 301 N 302 O 302 P 302 Q 302 R 302 S 302 T 303 U 303 V 303 W 303 X 303 Foreword Introduction Why Dynamic Languages? What's Groovy? Why Groovy? What's in This Book? Who Is This Book For? Acknowledgements Beginning Groovy Getting Started getting Groovy Installing Groovy Test-Drive Using groovysh Using groovyConsolr Running Groovy on the Command Line Using an IDE Groovy for the Java Eyes From Java to Groovy Optional Parameters Optional Parameters Implementing Interfaces 39 Groovy boolean Evaluation Operator Overloading Support of Java 5 Language Features Gotchas Dynamic Typing Typing in Java Dynamic Typing Dynamic Typing != Weak Typing Design by Capability Optional Typing Types in Groovy Multimethods Dynamic: To Be or Not to Be? Using Closures Closures Use of Closures Working with Closures Closure and Resource Cleanup Closures and Coroutines Curried Closure Dynamic Closures Closure Delegation Using Closures Working with Strings Literals and Expressions GString Lazy Evaluation Problem Multiline String String Convenience Methods Regular Expressions Working with Collections Using List Iterating Over an ArrayList Finder Methods collections' Convenience Methods Using Map Iterating Over Map Map Convenience Methods Using Groovy Exploring the GDK Object Extensions Other Extensions Working with XML Parsing XML Creating XML Working with Databases Connecting to a Database Database Select Transforming Data to XML Using DataSet Inserting and Updating Accessing Microsoft Excel Working with Scripts and Classes The Melting Pot of Java and Groovy Running Groovy Using Groovy Classes from Groovy Using Groovy Classes from Java Using Java Classes from Groovy Using Groovy Scripts from Groovy Using Groovy Scripts from Java Ease of Integration MOPping Groovy Exploring Meta-Object Protocol (MOP) Groovy Object Querying Methods and Properties Dynamically Accessing Objects Intercepting Methods Using MOP Intercepting Methods Using GroovyInterceptable Intercepting Methods Using MetaClass MOP Method Injection and Synthesis Injecting Methods Using Categories Injecting Methods Using ExpandoMetaClass Injecting Methods into Specific Instances Method Synthesis Using methodMissing Method Synthesis Using ExpandoMetaClass Synthesizing Methods for Specific Instances MOPping Up Creating Dynamic Classes with Expando Method Delegation: Putting It All Together Review of MOP Techniques Unit Testing and Mocking Code in This Book and Automated Unit Tests Unit testing Java and Groovy Code Testing for Exceptions Mocking Mocking by Overriding Mocking Using Categories Mocking Using expandoMetaClass Mocking Using Expando Mocking Using Map Mocking Using the Groovy Mock Library Groovy Builders Building XML Building Swing Custom Builder Suing Metaprogramming Using BuilderSupport Using FactoryBuilderSupport Creating DSLs in Groovy Context Fluency Types of DSLs Designing Internal DSLs Groovy and DSLs Closures and DSLs Method Interception and DSLs The Parentheses Limitation and a Workaround Categories and DSLs ExpandoMetaClass and DSLs Web Resources Bibliography Index Demonstrates how developers working with small- to mid-sized companies can take advantage of Amazon Web Services (AWS) such as the Simple Storage Service (S3), Elastic Compute Cloud (EC2), Simple Queue Service (SQS), Flexible Payments Service (FPS), and SimpleDB to build web-scale business applications.
دانلود کتاب Programming Groovy: Dynamic Productivity for the Java Developer (Pragmatic Programmers)