views:

467

answers:

3

Do you have any experience with T4 and T4 Editor? Can you compare it to CodeSmith or MyGeneration?

What code generators do you use? What do you recommend?

I want to use it for generatig of SPs. Is there anything else you find code generation useful?

A: 

Something that increases your productivity is by using the inbuilt snippets of Visual Studio.

tab tab

Like typing if and pressing tab twice will generate an if statement for you, and then basically you just fill in the blanks

try and two tabs will generate a try-catch block

etc...

There is a whole list of snippets which you can make use of.

Andreas Grech
Snippets are great but I am looking for a more powerful solution generating code based on specific data (eg., SPs based on database tables).
gius
Especially since you can create your own snippets, it may save a lot of time (and repeating actions).
gius
+1  A: 

What exactly you are trying to do? I guess it also depends on from where you are trying to generate the code (the model).

The advantage with Codesmith and MyGeneration is, they provide multiple options for you to generate your code - for eg, in MyGeneration, you can write your templates in various langs.

MyGeneration can provide a meta model of any DB and a lot of built in generator scripts - so that if you want to generate SPs, the easiest thing will be to use generators for MyGeneration - you can find generators for CRUD SPs right there. It also provides a reasonably good editor if you want to modify the generators.

If you are building a DSL or something (I mean, the model is coming from some where else), then you might consider using T4. How ever, T4 editing is not the easiest thing I've done, because there is no T4 editing support with in Visual Studio. You might consider purchasing Clarius T4 editor for good editing support.

amazedsaint
The main purpose is to generate CRUD SPs for existing DB tables. But I guess there should be another field where code generators are useful.
gius
For generating crud sps existing db tables, My Generation should be good as it can expose the entire DB as a model.
amazedsaint
A: 

As a code generation engine, T4 is as capable as CodeSmith or MyGeneration. It's main advantage is the tight integration in Visual Studio; the main drawback is the smaller number of ready-to-use templates.

I personally prefer the T4 editor from Tangible because it works with the T4 Toolbox.

Oleg

Oleg Sych