Groovy is a leading dynamic language for the Java platform. It offers a flexible, Java-like syntax that is easily learned and simplifies many common programming tasks, such as working with collections, while also adding many new exciting capabilities like dynamic method invocation, closures and metaprogramming. Since it compiles to Java bytecodes, it’s fully compatible with existing Java frameworks such as Spring and Hibernate, which Grails utilizes extensively, while at the same time enhances them via its simplified programming model.

Although Groovy is syntactically simpler than Java, it is not “Java-Lite,” and this course will emphasize that, especially in the Grails portion, which leverages closures and metaprogramming extensively.

Grails is an advanced and innovative web application framework that delivers new levels of developer productivity by applying proven architectural principles such as MVC, ORM, and SOA to modern application development techniques such as Convention over Configuration. Grails helps development teams embrace agile methodologies, deliver quality applications in less time, and focus on what really matters: creating high-quality, easy-to-use applications that delight users. Grails naturally complements Java application development since it is based on Groovy.

In this five-day training, students will cover the core fundamentals of application development with Groovy and Grails. After an introduction to the technology, participants are taken through the intermediate and more advanced aspects of the Groovy programming language and Grails framework. This training is designed to help developers quickly master the basics and move on to the most powerful aspects of Groovy and Grails.

Course Duration: 5 days
Course Outline:
  • Getting Started with Groovy
    • Lab – HelloWorld Groovy

 

  • Language Basics and Data Types
    • Lab Using an IDE (eclipse) Creating Number and Other Datatypes
    • String and GString
    • Lab – Strings
    • Methods and Method Signatures
    • Lab – Calling Methods
    • Groovy Truth
    • Lab – What is True and What is False?
    • Regular Expressions
    • Lab – Expressions

 

  • Collections
    • Lists, Sets and Ranges
    • Lab – Working with Collections
    • Using Sort, Reverse, Join and the Spread Dot Operator
    • Lab – Collection Operations
    • Using any, every find and findAll
    • Lab – Using Groovy Truth
    • Map Elements
    • Lab – Map Operations

 

  • Closures
    • Basics
    • Parameters
    • Iteration
    • Lab – Iterating Using Closures
    • Maps and Closures
    • Sort collect find and findAll
    • Lab – Map Operations

 

  • Conditionals and Loops
    • If else, switch, Elvis and Safe De-Reference Operators
    • Lab – Conditional Operators
    • For Loops and Iterations

 

  • Classes
    • Class Definition
    • Packages, Variables and Groovy Beans
    • Lab – Creating Classes
    • Methods and Constructors
    • Lab – Constructors and Methods
    • Exceptions
    • Duck Typing
    • Lab – Polymorphism
    • AST Transformations
    • Lab – AST

 

  • Builders and Parsers
    • MarkUpBuilder and JsonBuilder
    • Lab – Using Builders
    • XmlSlurper
    • Lab – Using Parsers

 

  • Database Access
    • Queries and Updates
    • SQL
    • Lab – Query and Inserts

 

  • Grails Overview and Supporting Frameworks
    • MVC – Overview of Domain Classes, Controllers, GSPs, Services
    • Hibernate
    • Spring
    • Convention Over Configuration
    • Grails Toolset – The Grails Commands
    • Grails Application Structure
    • Dynamic Scaffolding
    • Lab – Your First Grails Application

 

  • Domain Classes
    • Configuring a DataSource, dev/test/prod Environments
    • Lab – Configure a Data Source
    • Properties, id, version, dateCreated, lastUpdated
    • Lab – Creating Domain Classes
    • Constraints and Validation, Unit Testing of Validation Constraints
    • Custom Validators
    • Using JUnit and Mocks
    • Lab – Validation
    • Inserting and Retrieving Domain Objects
    • Lab – Domain Object Persistence
    • Updating Domain Objects
    • Integration Testing versus Unit Testing
    • Lab – Integration Testing

 

  • Domain Class Relationships
    • One-to-Many
    • Unidirectional versus Bidirectional Relationships
    • Lab – Modeling Relationships
    • Transitive Persistence
    • Many-to-Many
    • Sorting
    • Lazy and Eager Fetching of Relationships, Batch Fetching
    • Lab – Fetching Strategies

 

  • Queries
    • Dynamic Finders
    • Lab – Using Dynamic Finders
    • HQL, Aggregate Functions, Tuple Queries, Explicit and Implicit Joins
    • Lab – HQL
    • Query Parameters for Sorting, Fetching, etc.

 

  • Legacy Schemas
    • Mapping Domain Classes onto Existing Tables
    • Lab – Legacy Schema Mappings
    • Mapping Relationships
    • Lab – Mapping Relationships
    • Dynamic Scaffolding (revisited), Static Scaffolding
    • Lab – Scaffolding

 

  • Controllers
    • URL Mappings
    • Writing Actions
    • Role of SpringMVC DispatcherServlet
    • Alternative Output Formats
      • Returning Data in XML and JSON Format
    • Lab – Request Parameters
    • Sharing Data Between Components: scopes – request, flash, session, application
    • Lab – Using Scopes
    • Forward vs. Redirect
    • Request Processing
    • Lab – A True MVC approach

 

  • Groovy Server Pages
    • Basics, MVC (revisited), Sharing Data between Components (revisited)
    • Rendering Data and Links
    • Lab – Rendering Data
    • Lab – Controllers and Actions
    • Rendering Errors
    • Externalized Messages and Internationalization (I18N)
    • Lab – Rendering Errors
    • Static Scaffolding

 

  • Services
    • Role of Services
    • Writing Services
    • Lab – Define a Service
    • Service Scope and Lifecycle
    • Injection into Controllers and Unit/Integration Tests
    • Lab – Dependency Injection of Services into Integration Tests and Controllers

 

  • Deployment
    • Java EE Deployment Overview
    • Exporting Grails Application into WAR File, Customizing/Deploying the WAR
    • Using Server-Configured DataSources
    • Exporting Generated Schema (in Domain-Driven Development)
    • Lab – Create and Customize a WAR