jastrachan | 17 May 11:00 2004

Re: [groovy-dev] builder support

On 17 May 2004, at 09:39, robert kuzelj wrote:
> hi james,
> this would certainly work and would be an improvement of course.
> the only thing that bothers me why have the node doing this stuff?
> ioc is certainly a buzzword these days but it feels unnatural.
> i would rather go for something like this:
> ant = new AntBuilder(node)
> ant.build();

It could be done either way around. Here's why I chose to add the 
method to Node...

(i) there could be lots of different models to store the XML in. 
(dom4j, W3C DOM, XMLBeans, SAX). Node is but one model

(ii) adding a helper method on Node means it'll work with any builder - 
rather than every builder having to add a new constructor. i.e. its 1 
new method rather than 6.

i.e. its much less work on the builder writers.

e.g. should we add a W3C DOM and Node constructor to all builders? What 
about dom4j? And XMLBeans? Before long we'd end up in constructor hell. 
I think its a little cleaner all-round for a model to allow itself to 
be streamed into any builder.