title: Code Generators or T4 Templates, are they really evil?
body: <p>I have heard people state that Code Generators and T4 templates should not be used. The logic behind that is that if you are generating code with a generator then there is a better more efficient way to build the code through generics and templating. </p>
  
  <p>While I slightly agree with this statement above, I have not really found effective ways to build templates that can say for instance instantiate themselves. In otherwords I can never do :</p>
  
  <pre><code>return new T();
  </code></pre>
  
  <p>Additionally, if I want to generate code based on database values I have found that using <code>Microsoft.SqlServer.Management.SMO</code> in conjunction with T4 templates have been wonderful at generating mass amounts of code without having to copy / paste or use resharper.</p>
  
  <p>Many of the problems I have found with Generics too is that to my shock there are a lot of developers who do not understand them. When I do examine generics for a solution, there are times where it gets complicated because C# states that you cannot do something that may seem logical in my mind.</p>
  
  <p>What are your thoughts? Do you prefer to build a generator, or do you prefer to use generics? Also, how far can generics go? I know a decent amount about generics, but there are traps and pitfalls that I always run into that cause me to resort to a T4 template.</p>
  
  <p>What is the more proper way to handle scenarios where you need a large amount of flexibility? Oh and as a bonus to this question, what are good resources on C# and Generics?</p>