Code Generation Talk

I gave a talk at the local users group on code generation in .NET. I talked about the benefits and things to be aware of when generating code, some of the things in the framework that help when generating code, examples of where code-gen is used in the framework, and then a look at some tools (both in the framework and 3rd party) for generating useful things. Unfortunately I spoke for 1 hr (I was only supposed to go for 45 minutes), and didn’t get to finish my last (and best) demo which I had written the night before. It was an “end to end” demonstration of how you could use code-generation techniques to generate a “search” style T-SQL stored procedure, data access tier, middle tier and winforms GUI, (with a couple of helper classes thrown in where it didn’t make sense to generate things). I think it would have been a cool demo, but I was only able to demonstrate the generation of a “search” style stored procedure. It was the first presentation I’ve ever given that had a substantial “code” component. Hopefully I can do better the next time.

Perparing the demo did give me a good chance to road-test my XML-metadata-based ASP.NET style templating code generator (tentatively called M3RLIN). By using XML as my metadata source I can do XPath expressions in my templates, which are really powerful. Debugging is much better than XSLT, and I can leverage parts of the .NET framework like string manipulation etc that are hard to do (for me at least) in XSLT. Maybe the EXSLT GotDotNet workspace, and the XSLT debugger in Whidbey will tip the balance back to XSLT.  I still don’t have syntax hilighting working properly in my generator (I’ve been using VS.NET to edit the templates), but apart from that it is probably ready to go up on GotDotNet. I am tempted to forget about syntax hilighting anyway after hearing about the cool things (like intellisense in the code-in-front) in VS.NET Whidbey that would make template editing so much better than anything I could do.

In general I’m finding templates to be a very productive way of generating code - make a changes to templates and then seeing the output almost immediately is great, and being able to easily add sections of literal text is also very useful. Unless I REALLY needed to generate things in multiple .NET languages (where I would use the CodeDom) or generate XML as my output (where I would use XSLT) I think I will stick with templates……for now.

Comments

Jack Herrington
I’m very interested in publishing the contents of your talk on the Code Generation Network. Please contact me at [email protected] .

Thanks.
30/10/2003 12:45:00 AM
Jason Kolb
I would really love to see any code/slides/content you have from this talk. If you’re feeling especially kind, would you please email whatever you have to [email protected]? Thanks :)

Jason
2/11/2003 11:04:00 PM