Groovy Programming
Revision: TE6701_20130401
(6.08 KB) View, Download, or Print Course as a PDF.

- Course Length:
- 3 Days
- Course Description:
- Groovy is a dynamic scripting and programming language for the Java platform. It combines the dynamic features of modern scripting languages such as Ruby and Python with familiar Java syntax. To quote one of the Groovy developers: “Groovy is what Java would have been if it had been created in the 21st century.” This course introduces the Java developer to the Groovy language. The course focuses on understanding the internals of how Groovy works in addition to understanding the Groovy language syntax. After taking this course developers will understand the Groovy syntax and be able to leverage existing Java classes within Groovy. This class combines lecture with a unifying, hands-on experience, and open discussion that will help the developer quickly understand the benefits of Groovy and how to use the language.
- Who Should Attend:
- This course is intended for experienced Java developers.
- Benefits of Attendance:
-
Upon completion of this course, students will be able to:
- Write applications using Groovy.
- Understand how Groovy operates within the Java Virtual Machine.
- Incorporate existing Java classes and libraries within Groovy applications.
- Add new methods and member variables to existing Java or Groovy classes dynamically.
- Understand the role of Closures within Groovy.
- Take advantage of Groovy’s simplified object configuration syntax.
- Override operators for Groovy or Java classes.
- Understand the concept of Metaprogramming and how to leverage it to simplify application development.
- Explore Groovy’s Regular Expression syntax for easily managing String processing.
- Prerequisites:
- Participants should have taken the Software Development for Non-Programmers course or have a solid understanding of Java programming.
- Course Outline:
-
- Language Overview
- What is Groovy?
- What Groovy can do
- Installing
- Running Groovy scripts
- Basic Syntax and Scalar Variables
- Syntax rules
- Numbers - Integers, Floats, and BigDecimal
- Strings - Double quoted, Single quoted, Here documents, Slash quoted, GStrings
- Operators
- Collections
- Lists
- Coding a closure - The it parameter, Passing multiple parameters, Naming parameters (the -> operator)
- Maps
- Ranges
- Flow Control
- If statements - The truth in Groovy
- Switch statements
- While loops
- For loops
- Exceptions
- Classes
- Defining classes - File-to-class relationships
- Member variables - Automatic getter/setter generation, Default visibility, Safe dereferencing with ? operator
- Methods - Optional parameters and default parameters
- Operator overloading
- Automatic constructor generation - Initializing property values in the constructor
- The Closure Groovy class
- Coding a method that expects a closure - Calling into the closure, Passing parameters
- Advanced Classes and Closures
- Closures - Using methods as closures, Polymorphic closures
- Operator overloading
- Metaprogramming - Discovering a class, Discovering fields, Discovering methods, Method resolution
- Pointers - Method, Field
- Calling methods that do not exist - ExpandoMetaClass, Categories
- Regular Expressions
- Regular Expression syntax
- The =~ operator
- The ==~ operator
- Common methods that use Regular Expressions
- Builders and Slurpers
- What are Builders and Slurpers?
- NodeBuilder
- MarkupBuilder
- AntBuilder
- Using the ConfigSlurper
- Language Overview

















