Get in Touch
 Duration 21 hours

Course Outline

Introduction to Groovy

  • Overview of Apache Groovy
  • Historical context and evolution of the language
  • The relationship between Groovy and the Java Virtual Machine
  • Groovy as both a scripting and a general-purpose programming language
  • Typical use cases for Groovy
  • Integrating Groovy into Java-based projects
  • Benefits of using Groovy alongside Java
  • Introduction to the sample application

Groovy Features at a Glance

  • Dynamic typing with optional static typing
  • Enhanced scripting capabilities
  • Concise syntax and modern language enhancements
  • Closures and functional programming styles
  • Groovy collections and extended APIs
  • Operator overloading features
  • String interpolation techniques
  • Safe navigation and the Elvis operator
  • Developing Domain-Specific Languages (DSLs)
  • Meta-programming possibilities
  • The Groovy Development Kit (GDK)

Preparing the Development Environment

  • Installation and configuration of Groovy
  • Utilizing various Groovy distributions
  • Interacting with Groovy via the command line
  • Executing Groovy scripts
  • Setting up an Integrated Development Environment (IDE)
  • Initializing a new Groovy project
  • Managing project dependencies
  • Integrating Groovy components into Java projects
  • Configuring the environment for containerized deployments

Developing Your First Groovy Application

  • Creating a foundational Groovy script
  • Analyzing the structure of Groovy scripts
  • Executing Groovy applications
  • Utilizing the println statement
  • Manipulating variables
  • Defining methods
  • Incorporating comments and documentation
  • Assembling a simple sample application
  • Compiling Groovy source code

Navigating Groovy Syntax

  • Statements and expressions in Groovy
  • Semicolons and optional syntactic elements
  • Handling variables and constants
  • Dynamic versus explicit typing
  • String literals and interpolation
  • Working with single-line and multi-line strings
  • Operators and complex expressions
  • Groovy-specific operators and shortcuts
  • Null handling strategies
  • Implementing safe navigation
  • Using the Elvis operator
  • Multiple assignment operations

Groovy Data Types and Collections

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

Mastering Groovy Closures

  • Conceptual understanding of closures
  • Closure syntax and structure
  • Defining closure parameters
  • Handling implicit parameters
  • Invoking closures
  • Assigning closures to variables
  • Passing closures as method arguments
  • Returning closures from methods
  • Utilizing closures with collections
  • Applying closures for filtering and transformation
  • Scope rules and variable capture
  • Functional programming with closures
  • Common practical closure patterns

Program Flow Control in Groovy

  • Conditional logic
  • Using if and else blocks
  • Nested conditional statements
  • switch statement implementation
  • Loops and iteration mechanisms
  • for, while, and do-while loops
  • Using ranges within loops
  • Closures as iteration tools
  • Control flow with break and continue
  • Exception handling strategies
  • try, catch, and finally blocks
  • Raising custom exceptions
  • Unique Groovy control-flow features

Object-Oriented Programming (OOP) in Groovy

  • Declaring Groovy classes
  • Properties and fields
  • Constructors
  • Methods
  • Encapsulation principles
  • Inheritance mechanisms
  • Interfaces
  • Abstract classes
  • Polymorphism
  • Method overriding
  • Method overloading
  • Automated getters and setters
  • Traits
  • Enums
  • Designing domain models for the sample application

Runtime and Compile-Time Meta-Programming

  • Foundations of Groovy meta-programming
  • Dynamic method dispatch
  • Expando objects
  • Manipulating methods and properties at runtime
  • Categories and class extensions
  • The MetaClass mechanism
  • Dynamically injecting methods
  • Intercepting method invocations
  • Compile-time transformations
  • Standard Abstract Syntax Tree (AST) transformations
  • Responsible meta-programming practices
  • Practical meta-programming scenarios

Utilizing Builders

  • The builder pattern concept
  • Purpose and usage of Groovy builders
  • Constructing hierarchical structures
  • XML builders
  • JSON builders
  • Generating HTML and markup
  • Configuring builder outputs
  • Combining closures with builders
  • Developing custom builders
  • Leveraging builders in Domain-Specific Languages

Database Interaction with Groovy

  • Core database connectivity concepts
  • Establishing connections between Groovy apps and databases
  • JDBC and Groovy database APIs
  • Setting up database connections
  • Executing SQL queries
  • Retrieving and reading query results
  • Performing insert, update, and delete operations
  • Using parameterized queries
  • Managing transactions
  • Handling database-related exceptions
  • Working with Groovy SQL modules
  • Implementing database features in the sample application

Calling Java from Groovy

  • Groovy-Java interoperability
  • Utilizing Java classes within Groovy
  • Invoking Java methods
  • Integrating with Java libraries
  • Using Java collections in Groovy
  • Catching and handling Java exceptions
  • Comparing Groovy and Java syntax
  • Calling Groovy code from Java
  • Combining Groovy and Java source files
  • Integrating Groovy into existing Java applications
  • Best practices for interoperability

Connecting to REST Services

  • Introduction to REST APIs
  • HTTP concepts for Groovy applications
  • Sending HTTP requests
  • Handling GET, POST, PUT, and DELETE methods
  • Managing request parameters and headers
  • Parsing JSON responses
  • Constructing JSON request bodies
  • Implementing authentication
  • Managing HTTP error responses
  • Consuming external REST services
  • Integrating REST functionality into the sample application

Working with the GDK

  • Introduction to the Groovy Development Kit (GDK)
  • Enhanced Java API access
  • Advanced string manipulation
  • Extended collection features
  • File and directory management
  • File reading and writing
  • Stream processing
  • XML processing
  • JSON processing
  • Date and time utilities
  • Utility methods and convenience APIs
  • Selecting appropriate GDK tools

Unit Testing Groovy Applications

  • Foundations of testing Groovy applications
  • Test-driven development (TDD) concepts
  • Writing unit tests
  • Utilizing testing frameworks
  • Structuring test classes
  • Writing assertions
  • Testing classes and methods
  • Testing closures
  • Verifying exception handling
  • Mocking dependencies
  • Data-driven testing approaches
  • Testing database interactions
  • Testing REST integrations
  • Executing and interpreting test results

Troubleshooting

  • Identifying Groovy syntax errors
  • Debugging runtime errors
  • Resolving compilation issues
  • Addressing Java interoperability problems
  • Debugging closures and collection logic
  • Investigating database connection failures
  • Troubleshooting REST API integrations
  • Debugging meta-programming behavior
  • Using logging and diagnostic tools
  • Practical troubleshooting exercises

Summary and Conclusion

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

Requirements

  • General programming experience in any language

Custom Corporate Training

Training solutions designed exclusively for businesses.

  • Customized Content: We adapt the syllabus and practical exercises to the real goals and needs of your project.
  • Flexible Schedule: Dates and times adapted to your team's agenda.
  • Format: Online (live), In-company (at your offices), or Hybrid.
Investment

Price per private group, online live training, starting from 4800 € + VAT*

Contact us for an exact quote and to hear our latest promotions

Testimonials (1)

Provisional Upcoming Courses (Contact Us For More Information)

Related Categories