| [Xtend2] Builder Pattern: Cross References [message #757885] |
Fri, 18 November 2011 07:26  |
Hauke Fuhrmann Messages: 319 Registered: July 2009 |
Senior Member |
|
|
Hi there,
I love the new Xtend2 Builder Pattern that you can use since the new
Closure syntax in Xtend as presented by Sven
http://blog.efftinge.de/2011/10/xtend-21-type-safe-groovy-style-builder.html
This allows to create containment trees of elements very elegantly like
Sven shows in the HTML example.
Is there a good solution how to integrate cross references between the
elements also beautifully? I only came up with something like this:
graph[
node[name="a"]
node[name="b"]
node[name="c"]
edge[connect("a","b")]
edge[connect("b","c")]
]
where the connect function uses eContainer to search the containment
hierarchy for nodes with the corresponding names. This seems to be
rather brittle as it will notice only at runtime that a corresponding
element is not there.
As crossreferences may be a very common case, maybe there is a generic
solution to that? Maybe like giving results of the closures a name or
something such that you can address closure elements from other
elements? Hmm... dunno, seems to not match the idea of a closure. Any ideas?
Cheers,
Hauke
|
|
|
|
Powered by
FUDForum. Page generated in 0.07394 seconds