Groovy Programming

Book description

Groovy Programming is an introduction to the Java-based scripting language Groovy. Groovy has much in common with popular scripting languages such as Perl, Python, and Ruby, but is written in a Java-like syntax. And, unlike these other languages, Groovy is sanctioned by the Java community for use on the Java platform. Since it is based on Java, applications written in Groovy can make full use of the Java Application Programmer Interfaces (APIs). This means Groovy can integrate seamlessly with applications written in Java, while avoiding the complexities of the full Java language. This bare-bones structure also means Groovy can be used as an introduction to Java and to programming in general. Its simpler constructions and modern origins make it ideal as a first language and for introducing principles such as object-oriented programming.This book introduces all the major aspects of Groovy development and emphasizes Groovy's potential as a learning tool. Case studies and exercises are included, along with numerous programming examples. The book begins assuming only a general familiarity with Java programming, and progresses to discuss advanced topics such as GUI builders, Groovlets, Unit Testing, and Groovy SQL.
  • The first comprehensive book on Groovy programming that shows how writing applications and scripts for the Java platform is fast and easy
  • Written by leading software engineers and acclaimed computing instructors
  • Offers numerous programming examples, code samples, detailed case studies, exercises for self-study, and a companion website with a Windows-based Groovy editor

Table of contents

  1. Cover
  2. Title Page
  3. Dedication
  4. Copyright
  5. Foreword
  6. Preface
  7. About the authors
  8. Table of Contents
  9. Chapter 1: Groovy
    1. 1.1 Why Scripting?
    2. 1.2 Why Groovy?
  10. Chapter 2: Numbers and Expressions
    1. 2.1 Numbers
    2. 2.2 Expressions
    3. 2.3 Operator Precedence
    4. 2.4 Assignment
    5. 2.5 Increment and Decrement Operators
    6. 2.6 Object References
    7. 2.7 Relational and Equality Operators
    8. 2.8 Exercises
  11. Chapter 3: Strings and Regular Expressions
    1. 3.1 String Literals
    2. 3.2 String Indexing and Slicing
    3. 3.3 Basic Operations
    4. 3.4 String Methods
    5. 3.5 String Comparison
    6. 3.6 Regular Expressions
    7. 3.7 Exercises
  12. Chapter 4: Lists, Maps, and Ranges
    1. 4.1 Lists
    2. 4.2 List Methods
    3. 4.3 Maps
    4. 4.4 Map Methods
    5. 4.5 Ranges
    6. 4.6 Exercises
  13. Chapter 5: Simple Input and Output
    1. 5.1 Simple Output
    2. 5.2 Formatted Output
    3. 5.3 Simple Input
    4. 5.4 Exercises
  14. Chapter 6: Case study
    1. 6.1 Iteration I: Specification and List Implementation
    2. 6.2 Iteration 2: Map Implementation
    3. 6.3 Exercises
  15. Chapter 7: Methods
    1. 7.1 Methods
    2. 7.2 Method Parameters
    3. 7.3 Default Parameters
    4. 7.4 Method Return Values
    5. 7.5 Parameter Passing
    6. 7.6 Scope
    7. 7.7 Collections as Method Parameters and Return Values
    8. 7.8 Exercises
  16. Chapter 8: Flow of Control
    1. 8.1 While Statement
    2. 8.2 For Statement
    3. 8.3 If Statement
    4. 8.4 Switch Statement
    5. 8.5 Break Statement
    6. 8.6 Continue Statement
    7. 8.7 Exercises
  17. Chapter 9: Closures
    1. 9.1 Closures
    2. 9.2 Closures, Collections, and Strings
    3. 9.3 Other Closure Features
    4. 9.4 Exercises
  18. Chapter 10: Files
    1. 10.1 Command Line Arguments
    2. 10.2 File Class
    3. 10.3 Exercises
  19. Chapter 11: Case study
    1. 11.1 Iteration I: Specification and Map Implementation
    2. 11.2 Iteration 2: Implementation of a Text-Based User Interface
    3. 11.3 Iteration 3: Implementation with Closures
    4. 11.4 Exercises
  20. Chapter 12: Classes
    1. 12.1 Classes
    2. 12.2 Composition
    3. 12.3 Exercises
  21. Chapter 13: Case study
    1. 13.1 Specification
    2. 13.2 Iteration 1: An Initial Model
    3. 13.3 Iteration 2: Augment the Model
    4. 13.4 Iteration 3: Reinstate the User Interface
    5. 13.5 Exercises
  22. Chapter 14: Inheritance
    1. 14.1 Inheritance
    2. 14.2 Inherited Methods
    3. 14.3 Redefined Methods
    4. 14.4 Polymorphism
    5. 14.5 The Abstract Class
    6. 14.6 The Interface Class
    7. 14.7 Exercises
  23. Chapter 15: Unit testing (junit)
    1. 15.1 Unit Testing
    2. 15.2 The Groovytestcase and Junit Testcase Classes
    3. 15.3 The Groovytestsuite and Junit Testsuite Classes
    4. 15.4 The Role of Unit Testing
    5. 15.5 Exercises
  24. Chapter 16: Case study
    1. 16.1 Specification
    2. 16.2 Iteration 1: Confirm the Polymorphic Effect
    3. 16.3 Iteration 2: Demonstrate the Required Functionality
    4. 16.4 Iteration 3: Provide User Feedback
    5. 16.5 Iteration 4: Enforce Constraints
    6. 16.6 Exercises
  25. Chapter 17: Persistence
    1. 17.1 Simple Queries
    2. 17.2 Relations
    3. 17.3 Database Updates
    4. 17.4 Objects From Tables
    5. 17.5 Inheritance
    6. 17.6 The Spring Framework
    7. 17.7 Exercises
  26. Chapter 18: Case study
    1. 18.1 Iteration 1: Persist the Domain Model
    2. 18.2 Iteration 2: The Impact of Persistence
    3. 18.3 Exercises
  27. Chapter 19: XML Builders and Parsers
    1. 19.1 Groovy Markup
    2. 19.2 Markupbuilder
    3. 19.3 Xml Parsing
    4. 19.4 Exercises
  28. Chapter 20: GUI Builders
    1. 20.1 Swingbuilder
    2. 20.2 Lists and Tables
    3. 20.3 Box and Boxlayout Classes
    4. 20.4 Exercises
  29. Chapter 21: Template Engines
    1. 21.1 Strings
    2. 21.2 Templates
    3. 21.3 Exercises
  30. Chapter 22: Case study
    1. 22.1 Iteration I: Prototype the Gui
    2. 22.2 Iteration 2: Implement the Handlers
    3. 22.3 Exercises
  31. Chapter 23: Server-side Programming
    1. 23.1 Servlets
    2. 23.2 Groovlets
    3. 23.3 Gsp Pages
    4. 23.4 Exercises
  32. Chapter 24: Case study
    1. 24.1 Iteration I: Web Implementation
    2. 24.2 Exercise
  33. Chapter 25: Epilogue
  34. Software Distribution
    1. A.1 The Java Development Kit
    2. A.2 The Groovy Development Kit
    3. A.3 Ant
    4. A.4 The Derby/Cloudscape Database
    5. A.5 The Spring Framework
    6. A.6 The Tomcat Server
    7. A.7 Eclipse Ide
    8. A.8 The Textbook Sources
  35. Groovy
    1. B.1 Simple and Elegant
    2. B.2 Methods
    3. B.3 Lists
    4. B.4 Classes
    5. B.5 Polymorphism
    6. B.6 Closures
    7. B.7 Exceptions
  36. More on Numbers and Expressions
    1. C.1 Classes
    2. C.2 Expressions
    3. C.3 Operator Associativity
    4. C.4 Variable Definitions
    5. C.5 Compound Assignment Operators
    6. C.6 Logical Operators
    7. C.7 Conditional Operator
    8. C.8 Qualified Numeric Literals
    9. C.9 Conversions
    10. C.10 Static Typing
    11. C.11 Testing
  37. More on Strings and Regular Expressions
    1. D.1 Regular Expressions
    2. D.2 Single Character Match
    3. D.3 Match at the Beginning
    4. D.4 Match at the End
    5. D.5 Match Zero or More
    6. D.6 Match One or More
    7. D.7 Match None or One
    8. D.8 Match Number
    9. D.9 Character Classes
    10. D.10 Alternation
    11. D.11 Miscellaneous Notations
    12. D.12 Grouping
  38. More on Lists, Maps, and Ranges
    1. E.1 Classes
    2. E.2 Lists
    3. E.3 Ranges
    4. E.4 The Spread Operator
    5. E.5 Testing
  39. More on Simple Input and Output
    1. F.1 Formatted Output
    2. F.2 Console Class
  40. More on Methods
    1. G.1 Recursive Methods
    2. G.2 Static Typing
    3. G.3 Actual Parameter Agreement
    4. G.4 Method Overloading
    5. G.5 Default Parameter Ambiguity
    6. G.6 Collections as Method Parameters and Return Values
  41. More on Closures
    1. H.1 Closures and Ambiguity
    2. H.2 Closures and Methods
    3. H.3 Default Parameters
    4. H.4 Closures and Scope
    5. H.5 Recursive Closures
    6. H.6 Static Typing
    7. H.7 Actual Parameter Agreement
    8. H.8 Closures, Collections, and Ranges
    9. H.9 Return Statement
    10. H.10 Testing
  42. More on Classes
    1. I.1 Properties and Visibility
    2. I.2 Object Navigation
    3. I.3 Static Members
    4. I.4 Operator Overloading
    5. I.5 The Invokemethod
    6. I.6 Exercises
  43. Advanced Closures
    1. J.1 Simple Closures
    2. J.2 Partial Application
    3. J.3 Composition
    4. J.4 Patterns of Computation
    5. J.5 Business Rules
    6. J.6 Packaging
    7. J.7 List Reduction
    8. J.8 Exercises
  44. More on Builders
    1. K.1 Antbuilder
    2. K.2 Specialized Builders
  45. More on GUI Builders
    1. L.1 Menus and Toolbars
    2. L.2 Dialogs
  46. Bibliography
  47. Index
  48. Instructions for online access

Product information

  • Title: Groovy Programming
  • Author(s): Kenneth Barclay, John Savage
  • Release date: July 2010
  • Publisher(s): Morgan Kaufmann
  • ISBN: 9780080471594