Code Generation has long been an interest of mine. No matter if it is PHP, C# or now VB.NET code generation can gets me up to speed with the basics fast. RAD is something that left a bad taste in my mouth. In fact most anyone who actually supports their work cringes when you say RAD or mention code generation. With the Framework craze these days though, there are many places where code isn’t generated, but the same problems are encountered with the convention over configuration crowd. So I approach code generation with caution. The sad fact is that there are things that we repeat over and over again.
How many times have you typed “SECT * FROM foo”? The key is keeping code generation extensible. Where technology in general falls apart is where it tries to think for you and have it’s own preference where preference is the only deciding factor. Frameworks that are good but require you to conform to their school of thought only find acceptance amongst those who already think that way or don’t have enough experience under their belt to have an opinion yet. The more generic and customizable the better.
Enter T4, the new code template system in Visual Studio 2008. This is a great technology. As I learn it I find myself weaving more repeditive code, but with better quality. It makes CRUD controllers a dream to deal with, and holds the potential for saving alot of time. As I come across usefull T4 resources I will post them here.
I am interested to see how this changes my perception of my own code generation. The T4 template usage is interesting. They really allow for alot of logic within the template makign complicated generation possible. Already I see this making it’s way into my own generator.