<?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: Rails Worst Practices: 13 Coding Nightmares You Should Avoid</title>
	<atom:link href="http://pathfindersoftware.com/2008/12/rails-worst-practices-13-coding-nightmares-you-should-avoid/feed/" rel="self" type="application/rss+xml" />
	<link>http://pathfindersoftware.com/2008/12/rails-worst-practices-13-coding-nightmares-you-should-avoid/</link>
	<description>The Fastest Way to Launch Successful Software</description>
	<lastBuildDate>Thu, 19 Jan 2012 16:36:03 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Jason Roelofs</title>
		<link>http://pathfindersoftware.com/2008/12/rails-worst-practices-13-coding-nightmares-you-should-avoid/#comment-9105</link>
		<dc:creator>Jason Roelofs</dc:creator>
		<pubDate>Tue, 03 Feb 2009 05:00:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=1314#comment-9105</guid>
		<description>Great post, I agree with pretty much everything, but there&#039;s one part of #13 that no-one hear has touched on yet: testing.

I need to write a data change migration (splitting data from one table into another table, and removing redundant columns). Given that the product is in production now, I must have a test that proves my migration works. So, how do I test my migration? I need to pull the database up to the point prior to the migration, setup some data, run the migration, then see that the results are correct. This requires that all previous migrations run fine, which is currently not the case (some old pure-data migrations are of course failing hard).

I&#039;ve been searching, talking with co-workers, I just don&#039;t know what the solution to this is. I&#039;ve personally always had the mindset that all migrations should be up- and down-able for this reason. Any one have suggestions here?</description>
		<content:encoded><![CDATA[<p>Great post, I agree with pretty much everything, but there&#8217;s one part of #13 that no-one hear has touched on yet: testing.</p>
<p>I need to write a data change migration (splitting data from one table into another table, and removing redundant columns). Given that the product is in production now, I must have a test that proves my migration works. So, how do I test my migration? I need to pull the database up to the point prior to the migration, setup some data, run the migration, then see that the results are correct. This requires that all previous migrations run fine, which is currently not the case (some old pure-data migrations are of course failing hard).</p>
<p>I&#8217;ve been searching, talking with co-workers, I just don&#8217;t know what the solution to this is. I&#8217;ve personally always had the mindset that all migrations should be up- and down-able for this reason. Any one have suggestions here?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Digitalia &#8211; Links For Wednesday 7th January 2009</title>
		<link>http://pathfindersoftware.com/2008/12/rails-worst-practices-13-coding-nightmares-you-should-avoid/#comment-9104</link>
		<dc:creator>Digitalia &#8211; Links For Wednesday 7th January 2009</dc:creator>
		<pubDate>Wed, 07 Jan 2009 19:14:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=1314#comment-9104</guid>
		<description>[...] Rails Worst Practices: 13 Coding Nightmares You Should Avoid Ostensibly for Rails, but most of these apply to anyone using an MVC framework, and are worth a look. (tags: programming webdev tips) [...]</description>
		<content:encoded><![CDATA[<p>[...] Rails Worst Practices: 13 Coding Nightmares You Should Avoid Ostensibly for Rails, but most of these apply to anyone using an MVC framework, and are worth a look. (tags: programming webdev tips) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Timberlake</title>
		<link>http://pathfindersoftware.com/2008/12/rails-worst-practices-13-coding-nightmares-you-should-avoid/#comment-9103</link>
		<dc:creator>Andrew Timberlake</dc:creator>
		<pubDate>Wed, 07 Jan 2009 15:12:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=1314#comment-9103</guid>
		<description>I must agree with those people arguing against #13.

One thing I will NEVER do is re-run a migration. A migration is a run-once and once only script (per database) and therefore I have no problem with it updating any of my database state whether schema or data.

Sometimes changing a schema requires setting data to a value such as adding a column and setting a &#039;default&#039; value based on existing data. A migration allows that to be done inline so that migrations can run one after each other without having to stop to run a rake task.

To clarify my run-once statement, once a database is in production, there is no way I&#039;m dropping and re-creating with migrations. It&#039;s live and must stay live so backups become the order of the day there.</description>
		<content:encoded><![CDATA[<p>I must agree with those people arguing against #13.</p>
<p>One thing I will NEVER do is re-run a migration. A migration is a run-once and once only script (per database) and therefore I have no problem with it updating any of my database state whether schema or data.</p>
<p>Sometimes changing a schema requires setting data to a value such as adding a column and setting a &#8216;default&#8217; value based on existing data. A migration allows that to be done inline so that migrations can run one after each other without having to stop to run a rake task.</p>
<p>To clarify my run-once statement, once a database is in production, there is no way I&#8217;m dropping and re-creating with migrations. It&#8217;s live and must stay live so backups become the order of the day there.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Web Developer</title>
		<link>http://pathfindersoftware.com/2008/12/rails-worst-practices-13-coding-nightmares-you-should-avoid/#comment-9102</link>
		<dc:creator>Web Developer</dc:creator>
		<pubDate>Mon, 29 Dec 2008 19:06:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=1314#comment-9102</guid>
		<description>Nice post. But don&#039;t you think that you are are too dogmatic regarding some rules?</description>
		<content:encoded><![CDATA[<p>Nice post. But don&#8217;t you think that you are are too dogmatic regarding some rules?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Morgan</title>
		<link>http://pathfindersoftware.com/2008/12/rails-worst-practices-13-coding-nightmares-you-should-avoid/#comment-9101</link>
		<dc:creator>Morgan</dc:creator>
		<pubDate>Thu, 18 Dec 2008 11:07:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=1314#comment-9101</guid>
		<description>Greetings,
I know this is a week old (and I&#039;m loquacious, sorry), but I wanted to add a note about rule #13.  I have strong opinions about this one, having come off a project which did it a LOT, and having to be &#039;that guy&#039; who tried to encourage our new developers to avoid it.

I put migrations into three categories.  Structural changes (add/remove tables/columns, etc.), static data (a zip code to lat/long conversion table), and data (static or dynamic) changes (populate a new join table between users and topics).

Structural changes are what migrations are great at.  Use it and prosper.  (schema.rb is unfortunately usually shite in a big team in my experience, mainly due to conflicts, and its ever-changing nature.)

For static data, I have not yet found a good solution for bulk loading large amounts of static data into a newly created database, especially a test database (fixtures don&#039;t cut it for this stuff).  Rails just isn&#039;t built for that, and it&#039;s frustrating sometimes.  You end up in twisty little maze of implementations, all different.

Data changes are trouble, and I recommend against them as well.  You have two basic choices, either use the model (slow and harms refactorability) or direct SQL which bypasses your validations, so can lead to subtle data errors.

*I* feel #14 should be NEVER use models in your migrations.  If you find yourself tempted to use models in your migrations, you have clear evidence that you need a rake task.  A one-off rake task, perhaps, but a rake task.

I&#039;ve probably had a dozen models that I&#039;ve refactored away over the years that broke somebody&#039;s migration, and the only option was to go back and change their migration, which feels dirty for a reason.  :)

That said, I also believe that a fresh development database should always be creatable from the migrations and that you should set up CC.rb to do a migrate to create its databases.

A great back and forth related to this is on this very site at: http://www.pathf.com/blogs/2008/07/resolved-should-schemarb-be-included-in-your-source-control/

--  Morgan</description>
		<content:encoded><![CDATA[<p>Greetings,<br />
I know this is a week old (and I&#8217;m loquacious, sorry), but I wanted to add a note about rule #13.  I have strong opinions about this one, having come off a project which did it a LOT, and having to be &#8216;that guy&#8217; who tried to encourage our new developers to avoid it.</p>
<p>I put migrations into three categories.  Structural changes (add/remove tables/columns, etc.), static data (a zip code to lat/long conversion table), and data (static or dynamic) changes (populate a new join table between users and topics).</p>
<p>Structural changes are what migrations are great at.  Use it and prosper.  (schema.rb is unfortunately usually shite in a big team in my experience, mainly due to conflicts, and its ever-changing nature.)</p>
<p>For static data, I have not yet found a good solution for bulk loading large amounts of static data into a newly created database, especially a test database (fixtures don&#8217;t cut it for this stuff).  Rails just isn&#8217;t built for that, and it&#8217;s frustrating sometimes.  You end up in twisty little maze of implementations, all different.</p>
<p>Data changes are trouble, and I recommend against them as well.  You have two basic choices, either use the model (slow and harms refactorability) or direct SQL which bypasses your validations, so can lead to subtle data errors.</p>
<p>*I* feel #14 should be NEVER use models in your migrations.  If you find yourself tempted to use models in your migrations, you have clear evidence that you need a rake task.  A one-off rake task, perhaps, but a rake task.</p>
<p>I&#8217;ve probably had a dozen models that I&#8217;ve refactored away over the years that broke somebody&#8217;s migration, and the only option was to go back and change their migration, which feels dirty for a reason.  <img src='http://pathfindersoftware.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>That said, I also believe that a fresh development database should always be creatable from the migrations and that you should set up CC.rb to do a migrate to create its databases.</p>
<p>A great back and forth related to this is on this very site at: <a href="http://www.pathf.com/blogs/2008/07/resolved-should-schemarb-be-included-in-your-source-control/" rel="nofollow">http://www.pathf.com/blogs/2008/07/resolved-should-schemarb-be-included-in-your-source-control/</a></p>
<p>&#8211;  Morgan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gabriel C</title>
		<link>http://pathfindersoftware.com/2008/12/rails-worst-practices-13-coding-nightmares-you-should-avoid/#comment-9100</link>
		<dc:creator>Gabriel C</dc:creator>
		<pubDate>Tue, 16 Dec 2008 15:21:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=1314#comment-9100</guid>
		<description>You can reduce rule 7 and 8 into one:
NEVER USE COPY &amp; PASTE!!!!
It shows laziness and lack of abstraction. Is a maintenance nightmare waiting to happen...</description>
		<content:encoded><![CDATA[<p>You can reduce rule 7 and 8 into one:<br />
NEVER USE COPY &amp; PASTE!!!!<br />
It shows laziness and lack of abstraction. Is a maintenance nightmare waiting to happen&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Diego Scataglini</title>
		<link>http://pathfindersoftware.com/2008/12/rails-worst-practices-13-coding-nightmares-you-should-avoid/#comment-9099</link>
		<dc:creator>Diego Scataglini</dc:creator>
		<pubDate>Mon, 15 Dec 2008 18:05:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=1314#comment-9099</guid>
		<description>I posted my comments here http://jroller.com/dscataglini/entry/rails_worst_practices_blanket_statements</description>
		<content:encoded><![CDATA[<p>I posted my comments here <a href="http://jroller.com/dscataglini/entry/rails_worst_practices_blanket_statements" rel="nofollow">http://jroller.com/dscataglini/entry/rails_worst_practices_blanket_statements</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Webiest : Bookmarks for December 14th through December 15th</title>
		<link>http://pathfindersoftware.com/2008/12/rails-worst-practices-13-coding-nightmares-you-should-avoid/#comment-9098</link>
		<dc:creator>Webiest : Bookmarks for December 14th through December 15th</dc:creator>
		<pubDate>Mon, 15 Dec 2008 07:27:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=1314#comment-9098</guid>
		<description>[...] Pathfinder Development &#187; Rails Worst Practices: 13 Coding Nightmares You Should Avoid - [...]</description>
		<content:encoded><![CDATA[<p>[...] Pathfinder Development &raquo; Rails Worst Practices: 13 Coding Nightmares You Should Avoid &#8211; [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Phil</title>
		<link>http://pathfindersoftware.com/2008/12/rails-worst-practices-13-coding-nightmares-you-should-avoid/#comment-9097</link>
		<dc:creator>Phil</dc:creator>
		<pubDate>Sat, 13 Dec 2008 19:23:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=1314#comment-9097</guid>
		<description>A thousand-line controller? Are you kidding me? A 100 LOC controller is too long.</description>
		<content:encoded><![CDATA[<p>A thousand-line controller? Are you kidding me? A 100 LOC controller is too long.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bob Aman</title>
		<link>http://pathfindersoftware.com/2008/12/rails-worst-practices-13-coding-nightmares-you-should-avoid/#comment-9096</link>
		<dc:creator>Bob Aman</dc:creator>
		<pubDate>Fri, 12 Dec 2008 18:50:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=1314#comment-9096</guid>
		<description>As an addendum to my above comment, when you get into tricky stuff, it pays to build migrations that are liberal in what they accept and conservative in what they produce.  Whatever the expected post-migration state of the database is for the normal case, should also be the expected post-migration state of the database for the exceptional case.  And if and only if you cannot possibly produce that expected state should your migration fail.</description>
		<content:encoded><![CDATA[<p>As an addendum to my above comment, when you get into tricky stuff, it pays to build migrations that are liberal in what they accept and conservative in what they produce.  Whatever the expected post-migration state of the database is for the normal case, should also be the expected post-migration state of the database for the exceptional case.  And if and only if you cannot possibly produce that expected state should your migration fail.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic (User agent is rejected)
Page Caching using memcached (User agent is rejected)

Served from: pathfindersoftware.com @ 2012-02-10 02:57:32 -->
