Get in Touch

Course Outline

Introduction to Groovy

  • Overview of Apache Groovy
  • Background and evolution of the language
  • The relationship between Groovy and the Java Virtual Machine
  • Using Groovy for scripting and application development
  • Typical use cases for Groovy
  • Integrating Groovy into Java-centric projects
  • Benefits of using Groovy in conjunction with Java
  • Introduction to the sample project

Overview of Groovy Features

  • Dynamic typing and optional static typing
  • Scripting capabilities
  • Concise syntax and language extensions
  • Closures and functional programming paradigms
  • Enhanced collections and APIs
  • Operator overloading
  • String interpolation
  • Safe navigation and the Elvis operator
  • Building Domain-Specific Languages
  • Meta-programming features
  • The Groovy Development Kit (GDK)

Setting up the Development Environment

  • Installation and configuration of Groovy
  • Understanding different Groovy distributions
  • Using the Groovy command-line interface
  • Executing Groovy scripts
  • Configuring an Integrated Development Environment (IDE)
  • Initialising a new Groovy project
  • Managing project dependencies
  • Integrating Groovy with existing Java projects
  • Configuring the environment for containerised development

Writing Your First Groovy Application

  • Creating a basic script
  • Understanding script structure
  • Running Groovy applications
  • Utilising the println statement
  • Working with variables
  • Defining methods
  • Adding comments and documentation
  • Developing a simple sample application
  • Compiling Groovy code

Getting Familiar with Groovy's Syntax

  • Statements and expressions in Groovy
  • Semicolons and optional syntax rules
  • Variables and constants
  • Dynamic versus explicit typing
  • String literals and interpolation
  • Single-line and multi-line strings
  • Operators and expression evaluation
  • Groovy-specific operators and shortcuts
  • Null value handling
  • Safe navigation operators
  • The Elvis operator
  • Multiple assignment

Using Groovy's Data Types and Collections

  • Primitive and object types
  • Numeric types and operations
  • Strings and character handling
  • Boolean values
  • Date and time management
  • Lists
  • Maps
  • Sets
  • Ranges
  • Iterating through collections
  • Transforming collections
  • Filtering and searching data
  • Sorting and grouping information
  • Groovy collection methods

Using Groovy Closures

  • Concepts behind closures
  • Closure syntax
  • Defining parameters
  • Implicit parameters
  • Invoking closures
  • Storing closures in variables
  • Passing closures as arguments
  • Returning closures from methods
  • Working with collections and closures
  • Filtering and transforming data using closures
  • Scope and variable capture
  • Functional programming with closures
  • Practical closure patterns

Controlling Program Flow with Groovy Control Structures

  • Conditional logic
  • if and else statements
  • Nested conditional statements
  • switch statements
  • Loops and iteration
  • for, while, and do-while loops
  • Using ranges in loops
  • Iterating with closures
  • 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 classes in Groovy
  • Properties and fields
  • Constructors
  • Methods
  • Encapsulation principles
  • Inheritance
  • Interfaces
  • Abstract classes
  • Polymorphism
  • Method overriding
  • Method overloading
  • Getters and setters
  • Traits
  • Enums
  • Building domain models for the sample application

Runtime MetaProgramming and Compile Time MetaProgramming

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

Working with Builders

  • The builder pattern
  • Purpose of Groovy builders
  • Creating hierarchical structures
  • XML builders
  • JSON builders
  • Generating HTML and markup
  • Configuring builder output
  • Using closures within 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 connections
  • Executing SQL queries
  • Reading results
  • Insert, update, and delete operations
  • Parameterized queries
  • Transactions
  • Handling database exceptions
  • Using the Groovy SQL module
  • Implementing database features in the sample application

Calling Java from Groovy

  • Interoperability between Groovy and Java
  • Accessing Java classes
  • Invoking Java methods
  • Utilising Java libraries
  • Handling Java collections
  • Catching Java exceptions
  • Comparing Groovy and Java syntax
  • Calling Groovy from Java
  • Combining 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
  • Managing GET, POST, PUT, and DELETE operations
  • Handling parameters and headers
  • Parsing JSON responses
  • Constructing JSON request bodies
  • Authentication mechanisms
  • Handling HTTP errors
  • Consuming external services
  • Integrating REST functionality into the sample application

Working with the GDK

  • Introduction to the Groovy Development Kit
  • Enhanced Java APIs
  • String manipulation
  • Enhanced collection utilities
  • File and directory operations
  • Reading and writing files
  • Stream processing
  • XML processing
  • JSON processing
  • Date and time utilities
  • Convenience methods and APIs
  • Selecting appropriate GDK features

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 exception handling
  • Mocking dependencies
  • Data-driven testing
  • Testing database interactions
  • Testing REST integrations
  • Executing and analysing test results

Troubleshooting

  • Diagnosing syntax errors
  • Debugging runtime errors
  • Resolving compilation issues
  • Addressing interoperability problems
  • Debugging closures and collections
  • Investigating database connectivity issues
  • Troubleshooting REST API integrations
  • Debugging meta-programming behaviour
  • Using logging and diagnostic tools
  • Practical troubleshooting exercises

Summary and Conclusion

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

Requirements

  • Prior programming experience in any general-purpose language
 21 Hours

Number of participants


Price per participant

Testimonials (1)

Provisional Upcoming Courses (Require 5+ participants)

Related Categories