O'Reilly logo

Programming Groovy 2 by Venkat Subramaniam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using FactoryBuilderSupport

We’ll use FactoryBuilderSupport if we’re working with well-defined node names such as button, checkbox, label, and so on, in the SwingBuilder. The BuilderSupport we saw in Using BuilderSupport, is good for working with hierarchical structures. However, it’s not convenient for dealing with different types of nodes. Suppose we have to work with twenty different node types. Our implementation of createNode will get complicated. Based on the node name, we’ll create different nodes, which leads to a messy switch statement. Chances are we’ll quickly lean toward an abstract factory (see Design Patterns: Elements of Reusable Object-Oriented Software [GHJV95]) approach to create these nodes. That’s what FactoryBuilderSupport ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required