Work in Progress
This section I will discuss how builders work and how you can create your own builder. Builders are based on the builder pattern from the GOF design pattern book. It provides a way to build your own DSL and represents a powerful concept in Groovy. Let me start by saying I am not an expert on the subject of Groovy and this is a good thing for the following reasons. I will take you through a step ny step example from anovice point of view. Much of the Groovy documentation is very useful but you have to know a lot to get the most out of the pages. I an starting smae pages to learn more about the power of Groovy and share that undestanding to other novices like me. It is also my hope that this will encourage other novices to take up the challange and write their own pages.
Things you need to know
- Hierarchic structures - XML data in groovy
- Closures
- Method Handlers
- Properties
- Meta ProgrammingLet:
// create a builder, (note: this is not in one of the packages that are automatically imported
def builder = new groovy.xml.MarkupBuilder()
// create a simple xml markup
builder.stocks {
stock(symbol: 'JAVA')
stock(symbol: 'MSFT')
stock(symbol: 'IBM' )
}
WORK IN PROGRESS