<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Beware The Evils Of Code Generation</title>
	<atom:link href="http://davybrion.com/blog/2008/09/beware-the-evils-of-code-generation/feed/" rel="self" type="application/rss+xml" />
	<link>http://davybrion.com/blog/2008/09/beware-the-evils-of-code-generation/</link>
	<description>Trying to walk that thin line between intelligence and ignorance</description>
	<lastBuildDate>Sat, 13 Mar 2010 21:19:34 +0100</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Darius Damalakas</title>
		<link>http://davybrion.com/blog/2008/09/beware-the-evils-of-code-generation/comment-page-1/#comment-18334</link>
		<dc:creator>Darius Damalakas</dc:creator>
		<pubDate>Wed, 03 Jun 2009 13:02:01 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=467#comment-18334</guid>
		<description>Oh yes, code generation is a real flame war :)

Personally, i am also for not using code-generation if possible. We have a framework which has lots of functionality, and we are keep adding it. 

With code generation i would not image how would i be able to change something.

Technically looking at the problem, code generation solves a problem of a loop. That is, based on a standard set, create lots of similar code. So why not just abstract that similar code into some class, and then just make a simple for loop and iterate?  That would be the result of code generation.

Of course, one thing i use code generation is to generate an initial draft of my WinForm application window. After i have initial design, i still wire up all code manually, all events, and add custom controls dynamically either at startup time or at run-time.</description>
		<content:encoded><![CDATA[<p>Oh yes, code generation is a real flame war <img src='http://davybrion.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Personally, i am also for not using code-generation if possible. We have a framework which has lots of functionality, and we are keep adding it. </p>
<p>With code generation i would not image how would i be able to change something.</p>
<p>Technically looking at the problem, code generation solves a problem of a loop. That is, based on a standard set, create lots of similar code. So why not just abstract that similar code into some class, and then just make a simple for loop and iterate?  That would be the result of code generation.</p>
<p>Of course, one thing i use code generation is to generate an initial draft of my WinForm application window. After i have initial design, i still wire up all code manually, all events, and add custom controls dynamically either at startup time or at run-time.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Davy Brion</title>
		<link>http://davybrion.com/blog/2008/09/beware-the-evils-of-code-generation/comment-page-1/#comment-2602</link>
		<dc:creator>Davy Brion</dc:creator>
		<pubDate>Wed, 24 Sep 2008 15:13:09 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=467#comment-2602</guid>
		<description>not really, i can&#039;t post code from work here, and it&#039;d be way too much work to come up with a similar (but not real) example :)

But hey, if code generation works for you, knock yourself out ;)</description>
		<content:encoded><![CDATA[<p>not really, i can&#8217;t post code from work here, and it&#8217;d be way too much work to come up with a similar (but not real) example <img src='http://davybrion.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>But hey, if code generation works for you, knock yourself out <img src='http://davybrion.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Trevor</title>
		<link>http://davybrion.com/blog/2008/09/beware-the-evils-of-code-generation/comment-page-1/#comment-2600</link>
		<dc:creator>Trevor</dc:creator>
		<pubDate>Wed, 24 Sep 2008 14:41:01 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=467#comment-2600</guid>
		<description>I still don&#039;t see it.
Could you maybe cherry pick a particularly bad code example (some from each tier) to better illustrate your point?</description>
		<content:encoded><![CDATA[<p>I still don&#8217;t see it.<br />
Could you maybe cherry pick a particularly bad code example (some from each tier) to better illustrate your point?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Davy Brion</title>
		<link>http://davybrion.com/blog/2008/09/beware-the-evils-of-code-generation/comment-page-1/#comment-2599</link>
		<dc:creator>Davy Brion</dc:creator>
		<pubDate>Wed, 24 Sep 2008 14:33:30 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=467#comment-2599</guid>
		<description>&quot;Ooh, and one thing I truly don’t understand is generating tests. If they can be generated why not define a higher level tests that contains the logic (and/or architecture) you now put in the test generator.&quot;

taking that idea one step further leads me to this:

why not create higher-level reusable classes that contain the code that otherwise would be generated?

which is pretty much what i meant with:

&quot;Always keep in mind that code generation is usually a solution to a problem that wasn’t solved properly in the first place.&quot;</description>
		<content:encoded><![CDATA[<p>&#8220;Ooh, and one thing I truly don’t understand is generating tests. If they can be generated why not define a higher level tests that contains the logic (and/or architecture) you now put in the test generator.&#8221;</p>
<p>taking that idea one step further leads me to this:</p>
<p>why not create higher-level reusable classes that contain the code that otherwise would be generated?</p>
<p>which is pretty much what i meant with:</p>
<p>&#8220;Always keep in mind that code generation is usually a solution to a problem that wasn’t solved properly in the first place.&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: I've just written a codegenerator</title>
		<link>http://davybrion.com/blog/2008/09/beware-the-evils-of-code-generation/comment-page-1/#comment-2598</link>
		<dc:creator>I've just written a codegenerator</dc:creator>
		<pubDate>Wed, 24 Sep 2008 13:59:48 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=467#comment-2598</guid>
		<description>Lots of comments on this article. And fierce debate.
Developers seem to love generating code. I know I do. I think it&#039;s because of emotional reasons rather than rational ones though. Producing lines of code without actually having to work certainly is an appealing idea to any programmer ;-). The second reason I think is that code generators are fun to write and they make the developer feel smart, sort of like a meta-programmer. After all you understand the language so well that you can program the program.
In almost all cases, and for me this includes &lt;i&gt; generating the O/R layer, generating skeleton classes from established interfaces, generating stubs at various levels, generating CRUD sprocs in the db, generating full tests or stubbed tests, etc... &lt;i&gt;, code generation is at best a hack to get around language limitations (f.i. the webservice proxy ugly thingies), and should be avoided when possible. I think I should be regarded as a CodeSmell.

In above comment :

&lt;i&gt;Replace “code generation” in your piece with “hammer” or “guns”, such as “Beware The Evils Of Hammers”. &lt;/i&gt;

Try the other one : “Beware The Evils Of Guns” ... Sounds like pretty solid advice to me ;-).

Ooh, and one thing I truly don&#039;t understand is generating tests. If they can be generated why not define a higher level tests that contains the logic (and/or architecture) you now put in the test generator.</description>
		<content:encoded><![CDATA[<p>Lots of comments on this article. And fierce debate.<br />
Developers seem to love generating code. I know I do. I think it&#8217;s because of emotional reasons rather than rational ones though. Producing lines of code without actually having to work certainly is an appealing idea to any programmer <img src='http://davybrion.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> . The second reason I think is that code generators are fun to write and they make the developer feel smart, sort of like a meta-programmer. After all you understand the language so well that you can program the program.<br />
In almost all cases, and for me this includes <i> generating the O/R layer, generating skeleton classes from established interfaces, generating stubs at various levels, generating CRUD sprocs in the db, generating full tests or stubbed tests, etc&#8230; </i><i>, code generation is at best a hack to get around language limitations (f.i. the webservice proxy ugly thingies), and should be avoided when possible. I think I should be regarded as a CodeSmell.</p>
<p>In above comment :</p>
<p></i><i>Replace “code generation” in your piece with “hammer” or “guns”, such as “Beware The Evils Of Hammers”. </i></p>
<p>Try the other one : “Beware The Evils Of Guns” &#8230; Sounds like pretty solid advice to me <img src='http://davybrion.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> .</p>
<p>Ooh, and one thing I truly don&#8217;t understand is generating tests. If they can be generated why not define a higher level tests that contains the logic (and/or architecture) you now put in the test generator.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Richard Gardiner</title>
		<link>http://davybrion.com/blog/2008/09/beware-the-evils-of-code-generation/comment-page-1/#comment-2582</link>
		<dc:creator>Richard Gardiner</dc:creator>
		<pubDate>Wed, 24 Sep 2008 04:16:11 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=467#comment-2582</guid>
		<description>I have to agree with you.  I see code generation as too often used as a productivity boost at the beginning of a project.  It works fine at first but then as the project/product grows and evolves the template get more complex, more workarounds (hacks) are added, the original designers move on, etc.

For an example of how code generation can get complex very quickly, see this article from Visual Studio Magazine &lt;a href=&quot;http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2762&quot; title=&quot;Customize Code Generation in EF&quot; / rel=&quot;nofollow&quot;&gt;.  The question was &quot;I&#039;m working with Entity Framework (EF), and I&#039;ve run into a problem. All of the generated properties are marked with the DataMember attribute ... Can I remove these attributes?&quot;. The answer runs to almost &lt;b&gt;four&lt;/b&gt; pages in the printed magazine!</description>
		<content:encoded><![CDATA[<p>I have to agree with you.  I see code generation as too often used as a productivity boost at the beginning of a project.  It works fine at first but then as the project/product grows and evolves the template get more complex, more workarounds (hacks) are added, the original designers move on, etc.</p>
<p>For an example of how code generation can get complex very quickly, see this article from Visual Studio Magazine <a href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2762" title="Customize Code Generation in EF" / rel="nofollow">.  The question was &#8220;I&#8217;m working with Entity Framework (EF), and I&#8217;ve run into a problem. All of the generated properties are marked with the DataMember attribute &#8230; Can I remove these attributes?&#8221;. The answer runs to almost <b>four</b> pages in the printed magazine!</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: levi_h</title>
		<link>http://davybrion.com/blog/2008/09/beware-the-evils-of-code-generation/comment-page-1/#comment-2570</link>
		<dc:creator>levi_h</dc:creator>
		<pubDate>Tue, 23 Sep 2008 21:44:23 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=467#comment-2570</guid>
		<description>I think you still have two options:

- drop the code generation: check in the generated files and remove the generation from your build files;
- for making a tiny change in one particular source file, introduce a conditional in the appropriate template.

The second option is the worst one, of course, but could be justifiable when you&#039;re gradually moving away from your current solution.

A mix of both options would be to have your template skip certain files, which might be least hacky.</description>
		<content:encoded><![CDATA[<p>I think you still have two options:</p>
<p>- drop the code generation: check in the generated files and remove the generation from your build files;<br />
- for making a tiny change in one particular source file, introduce a conditional in the appropriate template.</p>
<p>The second option is the worst one, of course, but could be justifiable when you&#8217;re gradually moving away from your current solution.</p>
<p>A mix of both options would be to have your template skip certain files, which might be least hacky.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Davy Brion</title>
		<link>http://davybrion.com/blog/2008/09/beware-the-evils-of-code-generation/comment-page-1/#comment-2568</link>
		<dc:creator>Davy Brion</dc:creator>
		<pubDate>Tue, 23 Sep 2008 19:54:29 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=467#comment-2568</guid>
		<description>except for generating the O/R layer and tests, i pretty much agree with that

but i didn&#039;t really state that Code Generation _in general_ is evil. But when you&#039;re generating too much code, and depending on it in too many places, i think it definitely is.

and seriously, the O/R layer never changes? Please tell me i misread that...</description>
		<content:encoded><![CDATA[<p>except for generating the O/R layer and tests, i pretty much agree with that</p>
<p>but i didn&#8217;t really state that Code Generation _in general_ is evil. But when you&#8217;re generating too much code, and depending on it in too many places, i think it definitely is.</p>
<p>and seriously, the O/R layer never changes? Please tell me i misread that&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: alphadogg</title>
		<link>http://davybrion.com/blog/2008/09/beware-the-evils-of-code-generation/comment-page-1/#comment-2567</link>
		<dc:creator>alphadogg</dc:creator>
		<pubDate>Tue, 23 Sep 2008 19:47:46 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=467#comment-2567</guid>
		<description>Not to rag on you more, but your project is likely using code generation incorrectly. Code generation is for boilerplate, bog-standard, lowish-level code that never changes. Examples: generating the O/R layer, generating skeleton classes from established interfaces, generating stubs at various levels, generating CRUD sprocs in the db, generating full tests or stubbed tests, etc.

Used well, it does the 80% in no time flat, and the 20% tricky stuff has more time to be developed by hand. Note, code generation will never help you generate the whole nut! It also helps setup a lot of code that adheres to internal standards. 

It&#039;s not for:

- generating code in areas where the design is still in flux
- generating incorrect code
- generating incorrect architecture

Replace &quot;code generation&quot; in your piece with &quot;hammer&quot; or &quot;guns&quot;, such as &quot;Beware The Evils Of Hammers&quot;. It&#039;s just a tool. Inherent in generators is the potential, like any other tool, for ignorance and/or malice. Most common issue is no easy way to control the output, and no versioning/backwards compatibility with template changes.

Saying a code generator is evil is like saying compilers are evil, because a code generator is basically a simple &quot;compiler&quot; for a DSL.</description>
		<content:encoded><![CDATA[<p>Not to rag on you more, but your project is likely using code generation incorrectly. Code generation is for boilerplate, bog-standard, lowish-level code that never changes. Examples: generating the O/R layer, generating skeleton classes from established interfaces, generating stubs at various levels, generating CRUD sprocs in the db, generating full tests or stubbed tests, etc.</p>
<p>Used well, it does the 80% in no time flat, and the 20% tricky stuff has more time to be developed by hand. Note, code generation will never help you generate the whole nut! It also helps setup a lot of code that adheres to internal standards. </p>
<p>It&#8217;s not for:</p>
<p>- generating code in areas where the design is still in flux<br />
- generating incorrect code<br />
- generating incorrect architecture</p>
<p>Replace &#8220;code generation&#8221; in your piece with &#8220;hammer&#8221; or &#8220;guns&#8221;, such as &#8220;Beware The Evils Of Hammers&#8221;. It&#8217;s just a tool. Inherent in generators is the potential, like any other tool, for ignorance and/or malice. Most common issue is no easy way to control the output, and no versioning/backwards compatibility with template changes.</p>
<p>Saying a code generator is evil is like saying compilers are evil, because a code generator is basically a simple &#8220;compiler&#8221; for a DSL.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Davy Brion</title>
		<link>http://davybrion.com/blog/2008/09/beware-the-evils-of-code-generation/comment-page-1/#comment-2565</link>
		<dc:creator>Davy Brion</dc:creator>
		<pubDate>Tue, 23 Sep 2008 19:39:43 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=467#comment-2565</guid>
		<description>if the generated code had been hand written, we&#039;d at least be able to make changes in places where it&#039;s actually causing problems. Because it&#039;s generated, we either change the whole thing, or we don&#039;t.  If we change it, everything breaks and we need to fix _a lot_ of stuff at once.

For those who think merely improving the generated code through the templates is the solution to the problem, i wonder on what kind of projects you guys use code generation on. For small to medium projects, it&#039;s probably not that big of an issue. For a large project, it&#039;s really not that simple.</description>
		<content:encoded><![CDATA[<p>if the generated code had been hand written, we&#8217;d at least be able to make changes in places where it&#8217;s actually causing problems. Because it&#8217;s generated, we either change the whole thing, or we don&#8217;t.  If we change it, everything breaks and we need to fix _a lot_ of stuff at once.</p>
<p>For those who think merely improving the generated code through the templates is the solution to the problem, i wonder on what kind of projects you guys use code generation on. For small to medium projects, it&#8217;s probably not that big of an issue. For a large project, it&#8217;s really not that simple.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Samus</title>
		<link>http://davybrion.com/blog/2008/09/beware-the-evils-of-code-generation/comment-page-1/#comment-2563</link>
		<dc:creator>Samus</dc:creator>
		<pubDate>Tue, 23 Sep 2008 19:11:32 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=467#comment-2563</guid>
		<description>Seems like the problem is caused by tightly coupling the hand written code to the implementation details of the generated code. I don&#039;t see how the problem is related to code generation at all. I.e. how would this issue be any different if the generated code was hand written? If anything, the generator can help you to get out of this mess with a lot less effort than refactoring by hand.</description>
		<content:encoded><![CDATA[<p>Seems like the problem is caused by tightly coupling the hand written code to the implementation details of the generated code. I don&#8217;t see how the problem is related to code generation at all. I.e. how would this issue be any different if the generated code was hand written? If anything, the generator can help you to get out of this mess with a lot less effort than refactoring by hand.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Davy Brion</title>
		<link>http://davybrion.com/blog/2008/09/beware-the-evils-of-code-generation/comment-page-1/#comment-2558</link>
		<dc:creator>Davy Brion</dc:creator>
		<pubDate>Tue, 23 Sep 2008 17:21:24 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=467#comment-2558</guid>
		<description>@Corey

Yes, the design of the of the generated code is indeed pretty bad. However, due to the fact that a whole lot of that code is generated (and used), it becomes much harder (if not impossible in some cases) to try to improve that design. 

i&#039;ve seen good code generation as well, and if the generated code enables loosely-coupled systems, then that at least increases your options. But i do think that as the project increases in size, any kind of code generation eventually becomes more of a problem than the solution it was originally ment to be. 

As for the duplication... maybe you&#039;ve seen some really great code generators, but in most cases that i&#039;ve seen, the generated code often has a lot of duplicated code in it. Or perhaps you ment duplicated efforts instead of duplicate code. Either way, writing reusable code could solve both issues and i think it offers you more flexibility in the long run.</description>
		<content:encoded><![CDATA[<p>@Corey</p>
<p>Yes, the design of the of the generated code is indeed pretty bad. However, due to the fact that a whole lot of that code is generated (and used), it becomes much harder (if not impossible in some cases) to try to improve that design. </p>
<p>i&#8217;ve seen good code generation as well, and if the generated code enables loosely-coupled systems, then that at least increases your options. But i do think that as the project increases in size, any kind of code generation eventually becomes more of a problem than the solution it was originally ment to be. </p>
<p>As for the duplication&#8230; maybe you&#8217;ve seen some really great code generators, but in most cases that i&#8217;ve seen, the generated code often has a lot of duplicated code in it. Or perhaps you ment duplicated efforts instead of duplicate code. Either way, writing reusable code could solve both issues and i think it offers you more flexibility in the long run.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: showens</title>
		<link>http://davybrion.com/blog/2008/09/beware-the-evils-of-code-generation/comment-page-1/#comment-2556</link>
		<dc:creator>showens</dc:creator>
		<pubDate>Tue, 23 Sep 2008 17:19:58 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=467#comment-2556</guid>
		<description>I too am not convinced that Code Generation, per se, is the problem.  There is bad code and there is good code - you can create either one by hand or by generation.

I have successfully used the Open Source tool MyGeneration to generate a DAL.  My experience is that once you understand and buy into the model of the tool or framework, you don&#039;t have a problem.  If you misuse the tool/framework, you can cause problems for yourself.

It sounds more like the generated code was not flexible enough to handle changing requirements.  This, to my mind, does not make CG evil.  I suspect your team may have the same amount of work to refactor computer-generated code as with hand-generated.  Thus, the technical debt is not in the method (CG) but in the design used to build the CG templates.</description>
		<content:encoded><![CDATA[<p>I too am not convinced that Code Generation, per se, is the problem.  There is bad code and there is good code &#8211; you can create either one by hand or by generation.</p>
<p>I have successfully used the Open Source tool MyGeneration to generate a DAL.  My experience is that once you understand and buy into the model of the tool or framework, you don&#8217;t have a problem.  If you misuse the tool/framework, you can cause problems for yourself.</p>
<p>It sounds more like the generated code was not flexible enough to handle changing requirements.  This, to my mind, does not make CG evil.  I suspect your team may have the same amount of work to refactor computer-generated code as with hand-generated.  Thus, the technical debt is not in the method (CG) but in the design used to build the CG templates.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Davy Brion</title>
		<link>http://davybrion.com/blog/2008/09/beware-the-evils-of-code-generation/comment-page-1/#comment-2555</link>
		<dc:creator>Davy Brion</dc:creator>
		<pubDate>Tue, 23 Sep 2008 17:15:03 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=467#comment-2555</guid>
		<description>if the generated code was good and completely up to our standards, then it would have been less of a problem but it still would&#039;ve had a lot of potential for creating future problems. 

In this case, one of the biggest problems was that the manually written code was very tightly coupled to the generated code... trying to reduce coupling by using interfaces proved to be impossible because every possible way of creating one of the generated components turned out to be used at least somewhere in the system.  We couldn&#039;t even make that change without introducing hundreds of compiler errors in manually written code. Now, as i mentioned in my post, if it was merely a case of fixing some syntax errors or reference types, it woulnd&#039;t have been that big of an issue.

Now, again as i mentioned in the post, if you need to change the behavior of the generated code, and the manually written code expects certain things to happen and certain things not to happen, then you&#039;re in a pretty bad situation because you simply can&#039;t change it, unless you want a couple of developers to fix hundreds of compiler errors for a few days.  Once that&#039;s done, you&#039;ll probably need to modify a lot of manually written code where assumptions were made on the behavior of the generated code.

The point is, because it is generated, you can&#039;t easily change it. The larger the project is, the harder it becomes to make changes to the code generation.  And we can&#039;t simply turn off the code generation either, because then we&#039;d have to manually maintain all of that shitty code whenever database changes occur. All in all, it&#039;s probably about a 1000 classes at this point, and a lot of them contain very similar code. Which probably would&#039;ve been written in a more reusable manner had it been written manually from the start. And then we&#039;d at least have more options on making changes when needed or wanted.</description>
		<content:encoded><![CDATA[<p>if the generated code was good and completely up to our standards, then it would have been less of a problem but it still would&#8217;ve had a lot of potential for creating future problems. </p>
<p>In this case, one of the biggest problems was that the manually written code was very tightly coupled to the generated code&#8230; trying to reduce coupling by using interfaces proved to be impossible because every possible way of creating one of the generated components turned out to be used at least somewhere in the system.  We couldn&#8217;t even make that change without introducing hundreds of compiler errors in manually written code. Now, as i mentioned in my post, if it was merely a case of fixing some syntax errors or reference types, it woulnd&#8217;t have been that big of an issue.</p>
<p>Now, again as i mentioned in the post, if you need to change the behavior of the generated code, and the manually written code expects certain things to happen and certain things not to happen, then you&#8217;re in a pretty bad situation because you simply can&#8217;t change it, unless you want a couple of developers to fix hundreds of compiler errors for a few days.  Once that&#8217;s done, you&#8217;ll probably need to modify a lot of manually written code where assumptions were made on the behavior of the generated code.</p>
<p>The point is, because it is generated, you can&#8217;t easily change it. The larger the project is, the harder it becomes to make changes to the code generation.  And we can&#8217;t simply turn off the code generation either, because then we&#8217;d have to manually maintain all of that shitty code whenever database changes occur. All in all, it&#8217;s probably about a 1000 classes at this point, and a lot of them contain very similar code. Which probably would&#8217;ve been written in a more reusable manner had it been written manually from the start. And then we&#8217;d at least have more options on making changes when needed or wanted.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Corey Haines</title>
		<link>http://davybrion.com/blog/2008/09/beware-the-evils-of-code-generation/comment-page-1/#comment-2554</link>
		<dc:creator>Corey Haines</dc:creator>
		<pubDate>Tue, 23 Sep 2008 17:12:35 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=467#comment-2554</guid>
		<description>Like a couple people have said, it doesn&#039;t really sound like &#039;code generation&#039; is the culprit here, as much as &#039;bad design generation&#039;

I&#039;ve seen lots of good code generation that create loosely-coupled systems that preserve the ability to change the template when needed.

Now, in my view, code generation shouldn&#039;t be rushed to, instead relying on it as a method of eliminating a type of duplication.</description>
		<content:encoded><![CDATA[<p>Like a couple people have said, it doesn&#8217;t really sound like &#8216;code generation&#8217; is the culprit here, as much as &#8216;bad design generation&#8217;</p>
<p>I&#8217;ve seen lots of good code generation that create loosely-coupled systems that preserve the ability to change the template when needed.</p>
<p>Now, in my view, code generation shouldn&#8217;t be rushed to, instead relying on it as a method of eliminating a type of duplication.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Trevor</title>
		<link>http://davybrion.com/blog/2008/09/beware-the-evils-of-code-generation/comment-page-1/#comment-2553</link>
		<dc:creator>Trevor</dc:creator>
		<pubDate>Tue, 23 Sep 2008 16:47:45 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=467#comment-2553</guid>
		<description>&quot;the problem was that a lot of the bad code was generated, and then used all over the place which makes it pretty much impossible to make changes to the generated code, which limits refactoring possibilities in general&quot;

Again, I just don&#039;t see your point.  O/R entities and persistence code (which presumably this was) will be used everywhere, whether it was generated or not.  I just don&#039;t see how the fact that the code was generated in your example is relevant.  By the sounds of it, you have bad code that is used extensively throughout the system.  The code happened to be generated.  If the code generated was good code, would it still be a problem?</description>
		<content:encoded><![CDATA[<p>&#8220;the problem was that a lot of the bad code was generated, and then used all over the place which makes it pretty much impossible to make changes to the generated code, which limits refactoring possibilities in general&#8221;</p>
<p>Again, I just don&#8217;t see your point.  O/R entities and persistence code (which presumably this was) will be used everywhere, whether it was generated or not.  I just don&#8217;t see how the fact that the code was generated in your example is relevant.  By the sounds of it, you have bad code that is used extensively throughout the system.  The code happened to be generated.  If the code generated was good code, would it still be a problem?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Davy Brion</title>
		<link>http://davybrion.com/blog/2008/09/beware-the-evils-of-code-generation/comment-page-1/#comment-2552</link>
		<dc:creator>Davy Brion</dc:creator>
		<pubDate>Tue, 23 Sep 2008 16:36:48 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=467#comment-2552</guid>
		<description>the generated code was not altered... manually written code relied on implementation details and was very tightly coupled to the generated code. In small projects, that&#039;s easy to rectify. In a large project where the generated code is pretty much used all over the place, you can&#039;t just start cleaning it up one bit at a time.  If you need to make a change in the generated code, you need to modify the templates.  If you can&#039;t change the templates in a way that it doesn&#039;t break anything in the existing manually written code, then you&#039;re in a pretty bad situation.

The compiler comparison doesn&#039;t really hold up... the generated machine language will (in most cases) not be used by something else that needs to be maintained manually.</description>
		<content:encoded><![CDATA[<p>the generated code was not altered&#8230; manually written code relied on implementation details and was very tightly coupled to the generated code. In small projects, that&#8217;s easy to rectify. In a large project where the generated code is pretty much used all over the place, you can&#8217;t just start cleaning it up one bit at a time.  If you need to make a change in the generated code, you need to modify the templates.  If you can&#8217;t change the templates in a way that it doesn&#8217;t break anything in the existing manually written code, then you&#8217;re in a pretty bad situation.</p>
<p>The compiler comparison doesn&#8217;t really hold up&#8230; the generated machine language will (in most cases) not be used by something else that needs to be maintained manually.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: codexrox</title>
		<link>http://davybrion.com/blog/2008/09/beware-the-evils-of-code-generation/comment-page-1/#comment-2549</link>
		<dc:creator>codexrox</dc:creator>
		<pubDate>Tue, 23 Sep 2008 16:07:03 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=467#comment-2549</guid>
		<description>&lt;blockquote&gt;In our case, most of the things you could do with the generated code could be done in more than one way. Every possible usage scenario was being used at least somewhere in the application’s code base. And not just in a few places, but pretty much all over the code base. This made it pretty much impossible to make changes in the templates that would be used to generate the code&lt;/blockquote&gt;

I find this a bit vague too. Was the generated code altered? Or did new code rely on implementation details of the generated code? Generally speaking I can&#039;t really see a fundamental difference between generating code from a high level description on the one hand and a compiling a program in written in a high level language to machine code on the other. (I can see practical differences though. For example, a programming language and its compiler are usually a lot more polished than ones own definition schema.) The major benefit of code generation isn&#039;t necessarily the productivity boost you get when writing the code but of the benefit of keeping your definitions in one place when each definition may lead to multiple classes and interactions.</description>
		<content:encoded><![CDATA[<blockquote><p>In our case, most of the things you could do with the generated code could be done in more than one way. Every possible usage scenario was being used at least somewhere in the application’s code base. And not just in a few places, but pretty much all over the code base. This made it pretty much impossible to make changes in the templates that would be used to generate the code</p></blockquote>
<p>I find this a bit vague too. Was the generated code altered? Or did new code rely on implementation details of the generated code? Generally speaking I can&#8217;t really see a fundamental difference between generating code from a high level description on the one hand and a compiling a program in written in a high level language to machine code on the other. (I can see practical differences though. For example, a programming language and its compiler are usually a lot more polished than ones own definition schema.) The major benefit of code generation isn&#8217;t necessarily the productivity boost you get when writing the code but of the benefit of keeping your definitions in one place when each definition may lead to multiple classes and interactions.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Davy Brion</title>
		<link>http://davybrion.com/blog/2008/09/beware-the-evils-of-code-generation/comment-page-1/#comment-2548</link>
		<dc:creator>Davy Brion</dc:creator>
		<pubDate>Tue, 23 Sep 2008 15:24:44 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=467#comment-2548</guid>
		<description>the problem was that a lot of the bad code was generated, and then used all over the place which makes it pretty much impossible to make changes to the generated code, which limits refactoring possibilities in general

Did you actually read the article before you commented, or did you just skim over it? :p</description>
		<content:encoded><![CDATA[<p>the problem was that a lot of the bad code was generated, and then used all over the place which makes it pretty much impossible to make changes to the generated code, which limits refactoring possibilities in general</p>
<p>Did you actually read the article before you commented, or did you just skim over it? :p</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Trevor</title>
		<link>http://davybrion.com/blog/2008/09/beware-the-evils-of-code-generation/comment-page-1/#comment-2547</link>
		<dc:creator>Trevor</dc:creator>
		<pubDate>Tue, 23 Sep 2008 15:20:45 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=467#comment-2547</guid>
		<description>Interesting.  I really see nothing in the article that to me indicates the problem was with code generation, it seems you inherited a project with bad code.  How is this the fault of code generation?  So if the original developers had not used code generation, they would have written good code, but when they went to code generation, the decided to write templates that would generate sh*tty code?

Did you think about this article before you wrote it?</description>
		<content:encoded><![CDATA[<p>Interesting.  I really see nothing in the article that to me indicates the problem was with code generation, it seems you inherited a project with bad code.  How is this the fault of code generation?  So if the original developers had not used code generation, they would have written good code, but when they went to code generation, the decided to write templates that would generate sh*tty code?</p>
<p>Did you think about this article before you wrote it?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
