Get in Touch
 Duration 21 hours

Course Outline

Introduction to Groovy

  • Familiarization with Apache Groovy
  • The background and progression of Groovy
  • The relationship between Groovy and the Java Virtual Machine
  • Groovy as both a scripting and programming tool
  • Typical scenarios for using Groovy
  • Integrating Groovy into Java-centric projects
  • Benefits of pairing Groovy with Java
  • Introduction to the sample project

Overview of Groovy Features

  • Dynamic typing and optional static typing mechanisms
  • Capabilities for scripting in Groovy
  • Concise syntax and language improvements
  • Closures and functional programming paradigms
  • Groovy collections and enhanced APIs
  • Operator overloading techniques
  • String interpolation methods
  • Safe navigation and the Elvis operator
  • Developing Domain-Specific Languages
  • Meta-programming capabilities
  • The Groovy Development Kit (GDK)

Setting up the Development Environment

  • Installation and configuration of Groovy
  • Working with various Groovy distributions
  • Utilizing Groovy via the command line
  • Execution of Groovy scripts
  • Configuring an Integrated Development Environment (IDE)
  • Initializing a Groovy project
  • Managing project dependencies
  • Integrating Groovy within Java projects
  • Setting up the development environment for containerized solutions

Writing Your First Groovy Application

  • Creating a fundamental Groovy script
  • Understanding the structure of Groovy scripts
  • Executing Groovy applications
  • Utilizing the println statement
  • Managing variables
  • Defining methods
  • Incorporating comments and documentation
  • Developing a basic sample application
  • Compiling Groovy code

Getting Familiar with Groovy's Syntax

  • Groovy statements and expressions
  • Semicolons and optional syntactic elements
  • Variables and constants
  • Dynamic versus explicit typing
  • String literals and interpolation
  • Single-line and multiline string handling
  • Operators and expressions
  • Groovy-specific operators and shortcuts
  • Null handling strategies
  • Safe navigation practices
  • Use of the Elvis operator
  • Multiple assignment techniques

Using Groovy's Data Types and Collections

  • Primitive and object types
  • Numbers and numeric operations
  • Strings and character handling
  • Boolean logic
  • Date and time-related values
  • Lists
  • Maps
  • Sets
  • Ranges
  • Iterating through collections
  • Transforming collections
  • Filtering and searching within collections
  • Sorting and grouping data
  • Groovy-specific collection methods

Using Groovy Closures

  • Concepts behind closures
  • Closure syntax structure
  • Defining closure parameters
  • Implicit closure parameters
  • Invoking closures
  • Closures as variables
  • Passing closures as method arguments
  • Returning closures from methods
  • Interactions between closures and collections
  • Using closures for filtering and transformation
  • Scope and variable capture
  • Closures in functional programming
  • Common closure patterns

Controlling Program Flow with Groovy Control Structures

  • Conditional statements
  • if and else constructs
  • Nested conditions
  • switch statements
  • Loops and iteration logic
  • for, while, and do-while loops
  • Using ranges within loops
  • Employing closures for iteration
  • break and continue statements
  • Exception handling
  • try, catch, and finally blocks
  • Raising custom exceptions
  • Groovy-specific control-flow features

Implementing Object Oriented Programming (OOP) in Your Application

  • Defining Groovy classes
  • Properties and fields
  • Constructors
  • Methods
  • Encapsulation
  • Inheritance
  • Interfaces
  • Abstract classes
  • Polymorphism
  • Method overriding
  • Method overloading
  • Groovy getters and setters
  • Traits
  • Enumerations (Enums)
  • Building domain models for the sample application

Runtime MetaProgramming and Compile Time MetaProgramming

  • Introduction to Groovy meta-programming
  • Dynamic method invocation
  • Expando objects
  • Manipulating methods and properties at runtime
  • Categories and extensions
  • The MetaClass
  • Dynamically adding methods
  • Intercepting method calls
  • Compile-time transformations
  • Common AST transformations
  • Responsible use of meta-programming
  • Practical meta-programming examples

Working with Builders

  • Introduction to the builder pattern
  • Purpose of Groovy builders
  • Creating hierarchical structures
  • XML builders
  • JSON builders
  • HTML and markup generation
  • Configuring builder output
  • Using closures with builders
  • Creating custom builders
  • Applying builders in Domain-Specific Languages

Accessing a Database with Groovy

  • Concepts of database connectivity
  • Connecting Groovy applications to databases
  • JDBC and Groovy database APIs
  • Configuring database connections
  • Executing SQL queries
  • Reading query results
  • Inserting, updating, and deleting data
  • Parameterized queries
  • Transactions
  • Handling database exceptions
  • Working with Groovy SQL
  • Building database functionality for the sample application

Calling Java from Groovy

  • Groovy and Java interoperability
  • Using Java classes from Groovy
  • Calling Java methods
  • Working with Java libraries
  • Using Java collections
  • Handling Java exceptions
  • Comparing Groovy and Java syntax
  • Calling Groovy code from Java
  • Mixing Groovy and Java source files
  • Integrating Groovy into existing Java applications
  • Best practices for interoperability

Connecting to REST Services and Applications

  • Introduction to REST APIs
  • HTTP concepts for Groovy applications
  • Sending HTTP requests
  • Handling GET, POST, PUT, and DELETE operations
  • Working with request parameters and headers
  • Processing JSON responses
  • Building JSON request bodies
  • Handling authentication
  • Managing HTTP errors
  • Consuming external REST services
  • Integrating REST functionality into the sample application

Working with the GDK

  • Introduction to the Groovy Development Kit
  • Enhanced Java APIs
  • Working with strings
  • Enhanced collections
  • File and directory operations
  • Reading and writing files
  • Working with streams
  • Processing XML
  • Processing JSON
  • Working with dates and times
  • Utility methods and convenience APIs
  • Selecting appropriate GDK functionality

Unit Testing a Groovy Application

  • Introduction to testing Groovy applications
  • Test-driven development concepts
  • Writing unit tests
  • Using testing frameworks
  • Structuring test classes
  • Assertions
  • Testing classes and methods
  • Testing closures
  • Testing exceptions
  • Mocking dependencies
  • Data-driven testing
  • Testing database-related functionality
  • Testing REST integrations
  • Running and analyzing test results

Troubleshooting

  • Diagnosing Groovy syntax errors
  • Debugging runtime errors
  • Handling compilation problems
  • Troubleshooting Java interoperability issues
  • Debugging closures and collection operations
  • Investigating database connectivity problems
  • Troubleshooting REST API integrations
  • Debugging meta-programming behavior
  • Using logging and diagnostic tools
  • Practical troubleshooting exercises

Summary and Conclusion

  • Review of Groovy language fundamentals
  • Review of syntax, types, and collections
  • Review of closures and functional programming
  • Review of object-oriented programming
  • Review of meta-programming and builders
  • Review of database and REST integration
  • Review of Groovy and Java interoperability
  • Review of GDK capabilities
  • Review of testing practices
  • Best practices for developing Groovy applications
  • Final hands-on exercise
  • Questions and discussion

Requirements

  • Programming experience in any programming language

Number of participants


Price per participant

Testimonials (1)

Upcoming Courses

Related Categories