Groovy Programming for Java Developers
Published by O'Reilly Media, Inc.
Build better applications with Groovy scripts, Plain Old Groovy Objects, and the Groovy JDK
Learn the advantages of using the Groovy programming language by itself and with existing Java projects. This two-day online course takes you to the heart of this JVM language and shows you how Groovy can help increase your productivity through dynamic language features similar to those found in Python and Ruby. Presenter and Java consultant Ken Kousen demonstrates how writing anything from a simple build script to a full scale application is much easier with Groovy than with Java. You’ll quickly understand how to add Groovy to your projects, and then explore the language through a host of examples and hands-on exercises.
What you’ll learn and how you can apply it
By the end of this live, hands-on, online course, you’ll understand:
- How to write Groovy scripts and classes
- How to work with Groovy's native data structures and closures
- The advantages of Plain Old Groovy Objects
- How to use the Groovy JDK to simplify your code
- How to parse and generate XML and JSON data quickly and easily
- How to add Groovy to existing Java systems
- How to build Groovy applications
- The range of available tools and technologies that Groovy brings
And you’ll be able to:
- Access relational data with Groovy SQL
- Access RESTful web services
- Work with functional concepts, like closures, filters, and map/reduce
- Create and execute unit and integration tests
This live event is for you because...
- You are a Java developer at any level of proficiency and you want to dramatically simplify your code
- You are a member of a software team that has adopted a tool from the Groovy ecosystem, like Gradle, Grails, or Spock
Prerequisites
- Some knowledge of Java or another object-oriented programming language
- Some familiarity with web applications and/or RESTful web services
Note: Courseware will be accessible online, and all code samples will be made available in a public GitHub repository.
Setup information will be provided before the course, but the preferred setup will use Java 8 Standard Edition, the Gradle Build Tool (a wrapper will be included in the courseware), and an IDE that understands Java and Groovy (preferably IntelliJ IDEA, though other options are supported).
Recommended Preparation:
Schedule
The time frames are only estimates and may vary according to how the class is progressing.
DAY 1
Installing and Configuring Groovy (15 min)
- Download options
- Using the sdkman tool
- Environment variables and options
Running Groovy (30 min)
- Using the command line tools
- Working with the Groovy Shell and the Groovy Console
- Build tool support
Exercise: Creating Groovy Scripts and Classes (15 min)
Groovy Types (20 min)
- Wrapper classes
- Strings and Groovy Strings
- Static, dynamic, and optional typing
Exercise: Working with Groovy Strings (10 min)
Break: 15 min
Operator Overloading (30 min)
- Operators and associated methods
- Overloading in the Groovy JDK
- Using assert and equals methods
- POJOs vs POGOs
Exercise: Plain Old Groovy Objects (20 min)
Native Collections (30 min)
- Lists and Sets
- Maps
- Basics of closures and the "each" and "collect" methods
Exercise: Building a Query String for a RESTful web service (15 min)
DAY 2
Review of Day 1 material and Q/A (15 min)
Working with Relational Data (30 min)
- The Groovy SQL class
- Building a DAO layer
- Spring and Hibernate support
Exercise: Using groovy.sql.SQL to access relational data (30 min)
Abstract Syntax Tree transformations (15 min)
- @ToString, @EqualsAndHashCode, @TupleConstructor
- @Canonical
- @Immutable and @Delegate
- @Sortable and sorting
Exercise: Using AST transformations (15 min)
Break (15 min)
Parsing and Generation (15 min)
- Working with XML
- Parsing and generating JSON data
Exercise: Accessing a RESTful web service (15 min)
Miscellaneous Operators (15 min)
- Safe navigation
- The Groovy Truth and the Elvis operator
- The Spaceship operator
Summary and References (10 min)
- Adding Groovy to Java
- Social media and references
- The Groovy Community
Your Instructor
Ken Kousen
Ken Kousen is the author of the Kotlin Cookbook (O'Reilly), Modern Java Recipes (O'Reilly), Gradle Recipes for Android (O’Reilly), and Making Java Groovy (Manning), as well as O’Reilly video courses in Android, Groovy, Gradle, advanced Java, and Spring. A JavaOne Rock Star, he’s a regular speaker on the No Fluff Just Stuff conference tour and has spoken at conferences all over the world. Through his company, Kousen I.T., Inc., he’s taught software development training courses to thousands of students.