Get in Touch

Course Outline

Introduction to Groovy

  • Overview of Apache Groovy
  • Historical background and evolution
  • Relationship with the Java Virtual Machine
  • Groovy as a language for both scripting and application development
  • Typical use cases for Groovy
  • Integration within Java-based projects
  • Benefits of pairing Groovy with Java
  • Introduction to the sample project

Overview of Groovy Features

  • Dynamic typing and the option for static typing
  • Scripting capabilities
  • Concise syntax and language enhancements
  • Closures and functional programming concepts
  • Enhanced collection APIs
  • Operator overloading
  • String interpolation
  • Safe navigation and the Elvis operator
  • Creating Domain-Specific Languages
  • Meta-programming capabilities
  • The Groovy Development Kit (GDK)

Setting up the Development Environment

  • Installation and configuration steps
  • Working with different Groovy distributions
  • Executing Groovy from the command line
  • Running scripts
  • Configuring an IDE
  • Creating a new Groovy project
  • Managing dependencies
  • Integrating Groovy with existing Java projects
  • Configuring the environment for containerized deployments

Writing Your First Groovy Application

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

Getting Familiar with Groovy's Syntax

  • Statements and expressions
  • Optional semicolons and syntax elements
  • Variables and constants
  • Dynamic versus explicit typing
  • String literals and interpolation
  • Single-line and multi-line strings
  • Operators and expressions
  • Unique Groovy operators and shortcuts
  • Null handling
  • Safe navigation
  • The Elvis operator
  • Multiple assignment

Using Groovy's Data Types and Collections

  • Primitive and object types
  • Numeric operations
  • Strings and characters
  • Booleans
  • Date and time values
  • Lists
  • Maps
  • Sets
  • Ranges
  • Iterating over collections
  • Transforming collections
  • Filtering and searching
  • Sorting and grouping data
  • Collection methods

Using Groovy Closures

  • Concept of closures
  • Syntax
  • Parameters
  • Implicit parameters
  • Invoking closures
  • Using closures as variables
  • Passing closures to methods
  • Returning closures
  • Closures and collections
  • Filtering and transformation
  • Scope and variable capture
  • Functional programming patterns
  • Practical usage patterns

Controlling Program Flow with Groovy Control Structures

  • Conditional statements
  • if and else blocks
  • Nested conditions
  • switch statements
  • Loops and iteration
  • for, while, and do-while loops
  • Using ranges in loops
  • Iterating with closures
  • break and continue
  • Exception handling
  • try, catch, and finally blocks
  • Throwing custom exceptions
  • Groovy-specific flow control

Implementing Object Oriented Programming (OOP) in Your Application

  • Defining classes
  • Properties and fields
  • Constructors
  • Methods
  • Encapsulation
  • Inheritance
  • Interfaces
  • Abstract classes
  • Polymorphism
  • Method overriding
  • Method overloading
  • Getters and setters
  • Traits
  • Enums
  • Creating domain models for the sample app

Runtime MetaProgramming and Compile Time MetaProgramming

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

Working with Builders

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

Accessing a Database with Groovy

  • Connectivity concepts
  • Connecting applications to databases
  • JDBC and Groovy database APIs
  • Configuration of connections
  • Executing SQL queries
  • Reading results
  • Insert, update, and delete operations
  • Parameterized queries
  • Transactions
  • Handling exceptions
  • Groovy SQL
  • Building database features for the sample app

Calling Java from Groovy

  • Interoperability concepts
  • Using Java classes
  • Invoking Java methods
  • Working with Java libraries
  • Using Java collections
  • Handling Java exceptions
  • Syntax comparison
  • Calling Groovy from Java
  • Mixing source files
  • Integrating into Java applications
  • Best practices

Connecting to REST Services and Applications

  • REST API overview
  • HTTP concepts
  • Sending requests
  • GET, POST, PUT, and DELETE operations
  • Parameters and headers
  • Processing JSON responses
  • Building JSON bodies
  • Authentication
  • Error management
  • Consuming external services
  • Integrating REST into the sample app

Working with the GDK

  • Introduction to the Groovy Development Kit
  • Enhanced Java APIs
  • String manipulation
  • Enhanced collections
  • File and directory operations
  • File I/O
  • Stream processing
  • XML processing
  • JSON processing
  • Date and time handling
  • Utility methods
  • Selecting appropriate tools

Unit Testing a Groovy Application

  • Testing overview
  • Test-driven development
  • Writing unit tests
  • Using frameworks
  • Structuring test classes
  • Assertions
  • Testing classes and methods
  • Testing closures
  • Testing exceptions
  • Mocking
  • Data-driven tests
  • Testing database functionality
  • Testing REST integrations
  • Running and analyzing results

Troubleshooting

  • Diagnosing syntax errors
  • Debugging runtime issues
  • Compilation problems
  • Java interoperability issues
  • Debugging closures and collections
  • Database connectivity problems
  • REST API issues
  • Meta-programming behavior
  • Logging and diagnostics
  • Practical exercises

Summary and Conclusion

  • Review of fundamentals
  • Review of syntax and types
  • Review of closures
  • Review of OOP
  • Review of meta-programming and builders
  • Review of database and REST integration
  • Review of Java interoperability
  • Review of GDK
  • Review of testing
  • Best practices
  • Final hands-on exercise
  • Questions and discussion

Requirements

  • Programming experience in any language
 21 Hours

Number of participants


Price per participant

Testimonials (1)

Upcoming Courses

Related Categories