Course Ouline
This course can be customised to take into account the depth of Java experience of the audience. People who are heavily proficient with Java could either cover the base material in a shorter time, or go much further into the dynamic and meta-object protocol techniques that Groovy allows which are either very difficult or impossible to implement using Java alone.
Groovy Programming Overview
Groovy is a dynamic object-oriented programming language, with some similarities to Python, Perl, and Ruby.
Groovy is a dynamic programming language which is compiled to Java Virtual Machine bytecodes and works seamlessly with other Java code and libraries.
Groovy is also undergoing standardisation under JSR 241.
Course Content
Our Groovy training course provides an overview of Groovy architecture, and intensive hands-on experience in the development and implementation of Groovy applications.
This course has been developed for real-world, commercial scenarios by our expert instructors. See below for detailed syllabus. If you have a technical question, please email sales@jbinternational.co.uk
What you will learn
1. Learn the Groovy basics - language, syntax, potential uses.
2. Learn about the standard libraries, and the extras Groovy bring to them.
3. How Groovy integrates with other languages.
4. String and XML processing with Groovy.
5. Threading and synchronisation with Groovy.
6. Higher level abstractions for parallelism and concurrency using GPars: actors, dataflow, communication sequential processes (CSP), data parallelism.
7. GUI development with Groovy.
8. Idiomatic use of Groovy.
Groovy Programming Training Course Outline
Rationale
Why does Java need a partner?
Who are the major players?: Jython, JRuby, Groovy, Groovy, Grails, SpringSource, VMWare.
The Infrastructure
Groovy support in Eclipse, NetBeans and IntelliJ IDEA.
Groovy support in IntelliJ IDEA is currently the best, but Eclipse support is not far behind. Support for Groovy in NetBeans had been lagging behind quite badly but has recently had a large impetus.
Dynamic vs. Static Programming languages
Static typing, overloading.
Dynamic typing, polymorphic programming.
Duck typing.
EAFP: easier to ask forgiveness than permission.
The core issue here is the different way programmers have to think about type and typing in languages such as Groovy, Python, and Ruby compared to Java and Scala. The knock-on effect is the different way of handling polymorphic programming in static languages such as C++ and Java; polymorphism is usually handled by overloading.
Dynamic languages handle this very differently, duck typing.
Scripts vs Classes
Writing scripts instead of classes.
Writing classes as usual.
Java, indeed the JVM, requires all code to be contained within a class. Java has no facility for having code outside of a class. Groovy can be used to create classes, but it also has a script capability. Groovy scripts are still classes but the programmer sees a script and the Groovy system handles all the necessary infrastructure issues.
Meta-object Protocol Why?
The crucial difference between statically-typed and dynamically-typed languages is that the latter generally have a met-object protocol; a way of redefining features of the language at program runtime. This completely changes the way problems are solved. Python, Perl, Ruby and Groovy all share this approach that was first worked out in Lisp and then Smalltalk.
Builders: The Big Win
Builders and domain-specific languages.
Using the meta object protocol to define language at runtime.
SwingBuilder
Constructing Swing/AWT interfaces the easy way.
Relationship to JavaFX.
Scripts vs Classes
Writing scripts instead of classes.
Writing classes as usual.
Java, indeed the JVM, requires all code to be contained within a class. Java has no facility for having code outside of a class. Groovy can be used to create classes, but it also has a script capability. Groovy scripts are still classes but the programmer sees a script and the Groovy system handles all the necessary infrastructure issues.
Meta-object Protocol Why?
The crucial difference between statically-typed and dynamically-typed languages is that the latter generally have a met-object protocol; a way of redefining features of the language at program runtime. This
completely changes the way problems are solved. Python, Perl, Ruby and Groovy all share this approach that was first worked out in Lisp and then Smalltalk.
Builders: The Big Win
Builders and domain-specific languages.
Using the meta object protocol to define language at runtime.
SwingBuilder
Constructing Swing/AWT interfaces the easy way.
Relationship to JavaFX.
XML and other markup
Reading, writing and processing XML.
Showing how Java makes this hard, and Groovy makes this easy.
Relationship with SAX, W3C DOM, JDOM and Dom4J.
Dynamic methods and GPath: who needs XPath?
Dependency and Build
AntBuilder: Groovy's interface to the Ant tasks.
Gant: a lightweight Groovy Ant task scripting framework.
Gradle: a Groovy Ivy-based build framework.
Gmaven: making Maven Groovy.
Concurrency and Parallelism Threads and java.util.concurrent
Groovy doesn't have explicit syntax for handling concurrency and parallelism, although it does makes using the Java standard library very easy. On the other hand . . .
High-Level Concurrency and Parallelism using GPars
Groovy now comes with the GPars package as standard. GPars provides APIs for actors, dataflows, concurrency sequential processes (CSP), data parallelism, and software transactional memory (STM). These models for concurrency and parallelism are to be preferred to using shared-memory multi-threading.
Design strategies Java vs. Groovy
When to use Java, when to use Groovy.
How to make sure the integration is good and the problems few.