[stringtemplate-interest] Why an == operator is sometimes necessary, and how to implement it (ST3/C#)

Harald Mueller harald_m_mueller at gmx.de
Tue Mar 23 15:49:37 PDT 2010


Hi Terence -

The problem, in that case, is that the model cannot decide what replacement to do because the loop over the things that define waht to replace happens in ST. 
With a "standard two layered design" with a model and templates accessing the model, you don't "get back" this information, unless using a trick like the one I described.

Now, we both know that there are alternatives to that design: One can do a four-layer design (an inner model [layer 1] is used by local templates [layer 2] to create code snippets into a "parts model" [3], which is then assembled by assembly templates [4]). Or a three-layered version, where a coded [3] loop tells the model about the replacements and then uses templates [2] to get information out of the updated model [1].

However, when I did the latter, it got awfully ugly - pieces of SQL code at various levels. As long as the decision about the replacement could be made in a loop that was "very external" to the generated code (in our case, when we simply created trigger code per SQL table), we could "fix up" the model "in time" to return different information through properties (the 3-layered design). Still, this introduced mutable models, where one had to *know* at which time the model was in which state to deliver the correct replacements.

When, however, those loops had to be multiplied at a more than one place with boilerplate SQL in between, we'd have needed a 4-layered design ... and that would have been a large rewrite (and redesign) for a seemingly small piece of information.

But I stop here with general arguments ... just show me how, with a standard two-layered design, you can get the output of my example :-) [warning: I might make it more complex if your solution is too easily done, but my example was too much simplified ;-) ... did anyone say I'd have to be fair?]. If we can agree on the result, I'll happily rewrite our code (well, it's a real project, so I might not have the time and money to do it ...).

Regards

Harald

-- 
GMX DSL: Internet, Telefon und Entertainment für nur 19,99 EUR/mtl.!
http://portal.gmx.net/de/go/dsl02


More information about the stringtemplate-interest mailing list