Summary
In Chapter 7, Power Groovy DSL Features, we discussed how builders worked via the Groovy MOP. In this chapter, we have taken a deeper look at how features of the MOP are used to implement the builder pattern. We've looked at the language features used to create a builder, and seen how they involve implementing pretended methods and influence how methods calls are resolved. Implementing a builder directly by using the MOP in this way focuses on the nuts and bolts of the semantics of the builder, rather than the construction process.
In this chapter, we have seen how Groovy provides two useful support classes that make it much simpler to implement our own builders than if we use the MOP. We've seen how to use BuilderSupport
and FactoryBuilderSupport
to create our own builder classes.
Using these support classes greatly simplifies the implementation of builders. Hopefully, this will inspire you to see opportunities to develop your own Groovy-based builders for you own applications. You...