Chapter 15MOPping Up

We’ve seen how to synthesize methods, and in this chapter we’ll see how to synthesize an entire class. Rather than creating explicit classes ahead of time, we can create classes on the fly, which gives us more flexibility. Delegation is better than inheritance, yet it has been hard to implement in Java. We’ll see how Groovy’s metaobject protocol (MOP) allows method delegation with only one line of code. We’ll wrap up this chapter by reviewing the MOP techniques we’ve seen in the preceding chapters.

Get Programming Groovy 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.