Groovy Metakoans

You may have done Groovy Koans. But it’s not the end of the long way to enlightment. Groovy Metakoans will teach you how Meta Object Protocol works and how to change object behavior at runtime.

What is metaprogramming?

According to Wikipedia is

the writing of computer programs that write or manipulate other programs (or themselves) as their data, or that do part of the work at compile time that would otherwise be done at runtime

You will learn:

  • how dynamic method dispatch works with Groovy
  • how to obtain information about an object at runtime using MetaObjectProtocol interface
  • how to do AOP with Groovy
  • how to add new methods with categories and mixins
  • how to inject new methods and properties using MetaClass
  • how to synthetize behavior upon invocation (like Grails/GORM dynamic finders)

The Koans assume that you have some basic practical experience with Groovy. If not, I recommend you personally Programming Groovy by Venkat Subramaniam. Although it covers Groovy 1.5.4, you find on 300 pages everything about Groovy from first steps with the language to advanced metaprogramming.

Grab’em while they are hot!

Advertisements