<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>CyberFOX Software Inc. &#187; Ruby</title>
	<atom:link href="http://cyberfox.com/blog/category/ruby/feed" rel="self" type="application/rss+xml" />
	<link>http://cyberfox.com/blog</link>
	<description>Coding, Connections, and Other Bloggy Bits of Goodness</description>
	<lastBuildDate>Sat, 25 Jul 2009 21:27:37 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>The three kinds of Rails migrations</title>
		<link>http://cyberfox.com/blog/2009/05/22/54/the-three-kinds-of-rails-migrations</link>
		<comments>http://cyberfox.com/blog/2009/05/22/54/the-three-kinds-of-rails-migrations#comments</comments>
		<pubDate>Sat, 23 May 2009 01:21:56 +0000</pubDate>
		<dc:creator>Cyberfox</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[migrations]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.cyberfox.com/blog/?p=54</guid>
		<description><![CDATA[Greetings,
What alternative do you suggest for using models in migrations? I was in several situations where I had to not only change the underlying db structure but change the contained data, too.
Data changes, especially moving data around, are almost always rake task-worthy in my experience.
The other side of that, populating large amounts of seed data [...]]]></description>
			<content:encoded><![CDATA[<p>Greetings,</p>
<p style="padding-left: 30px;"><em>What alternative do you suggest for using models in migrations? I was in several situations where I had to not only change the underlying db structure but change the contained data, too.</em></p>
<p>Data changes, especially moving data around, are almost always rake task-worthy in my experience.</p>
<p>The other side of that, populating large amounts of seed data into new databases, is a difficult task no matter the method; seed_fu attempted to deal with it, but it’s not an optimal solution and pretty old. I’m not even sure if it works anymore. It’s worse if you need the seed data to be from a legacy database in tests (e.g. a nutritional database). Reloading lots of data each time a clone_structure_to_test is done makes your tests very slow.</p>
<p>I break down migrations into three kinds; structural (tables, columns, indices, etc.), data (pre-populating tables, etc.) and procedural (moving data around, recalculating counts, etc.). The first is what I strive to limit migrations to. I feel like there should be a good answer for the second and Rails 3.0 has a &#8216;Simplest Thing That Can Work&#8217; feature in <span class="status-body"><span class="entry-content"> Rails <a title="This is also known as the &quot;Stop Putting Gawd Damn Seed Data In Your Migrations&quot; feature [DHH]" href="http://github.com/rails/rails/commit/4932f7b38f72104819022abca0c952ba6f9888cb">commit #4932f7b</a></span></span>. The third, I try to relegate to rake tasks that are usually run once, on deployment of the branch.</p>
<p>The procedural tasks don’t need to be run when building a fresh database, because there isn’t legacy data to correct. That’s why you can usually define the model in the migration to force it to work even if the real model is gone or renamed; there’s no data, so the operations often don’t matter. If they don’t NEED to be run when building a fresh database, I try not to put them in the migrations.</p>
<p>It’s not ‘hard and fast’, because I usually work in startups to small companies, where dogma doesn’t work so well. Imagine, though, a large and thin piece of foam. It’s flexible, and you can make it into all sorts of shapes, and yet it’s simple. Each time you add code that makes reasonable changes in the future painful, it’s like putting a thin glass rod into the foam. It’s still flexible, but there’s some bends you can’t do without breaking. Add too many and you’ve got an inflexible and brittle object, no matter how dynamic the base material is.</p>
<p>The fear of breaking things by changing the code is deeply demotivating for everyone.</p>
<p>I know I waterboarded that analogy, but hopefully it makes sense…</p>
<p>—  Morgan Schweers, Cyber<strong>FOX</strong>!</p>
]]></content:encoded>
			<wfw:commentRss>http://cyberfox.com/blog/2009/05/22/54/the-three-kinds-of-rails-migrations/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Approaching an inherited Rails codebase</title>
		<link>http://cyberfox.com/blog/2009/05/21/56/approaching-an-inherited-rails-codebase</link>
		<comments>http://cyberfox.com/blog/2009/05/21/56/approaching-an-inherited-rails-codebase#comments</comments>
		<pubDate>Fri, 22 May 2009 06:20:29 +0000</pubDate>
		<dc:creator>Cyberfox</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[startup]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[work]]></category>
		<category><![CDATA[maintenance]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.cyberfox.com/blog/?p=56</guid>
		<description><![CDATA[Greetings,
[Edit: Since writing this article up back in early March, I've moved on from this job. The folks who are now maintaining it at least know where the pain points are, can run migrations safely, deploy it locally, and to dev servers, and to the main deployment area.  It's a working app, although I never [...]]]></description>
			<content:encoded><![CDATA[<p>Greetings,</p>
<p><small><em>[Edit: Since writing this article up back in early March, I've moved on from this job. The folks who are now maintaining it at least know where the pain points are, can run migrations safely, deploy it locally, and to dev servers, and to the main deployment area.  It's a working app, although I never got code coverage above about 45% at least the coverage was decent in the core app areas by the time I left.]</em></small></p>
<p><a title="A Fresh Cup" href="http://afreshcup.com/">Mike Gunderloy</a> had an interesting article entitled &#8216;<a href="http://afreshcup.com/2009/03/23/batting-clean-up/">Batting Clean-up</a>&#8216;, which was very timely for me.  I’ve just started maintaining and trying to improve a Rails app developed by an ‘outsourced’ group. The only tests were the ones generated automatically by ‘restful authentication’, and they were never maintained, so they didn’t come close to passing. Swaths of the program are written in terribly complex (and sometimes computed) SQL, migrations didn’t bring up a fresh database (poor use of acts_as_enumerated causes great hurt), and vendor/plugins should have just had one named ‘kitchen_sink’.</p>
<p>It hurts to see Rails abused like that; you want to take the poor application under your arm and say, ‘It’ll be okay…we’ll add some tests and get you right as rain in no time!’, but you know you’d be lying…</p>
<p>I did much of what Mike <a title="Batting Clean-Up" href="http://afreshcup.com/2009/03/23/batting-clean-up/">described</a> (half the gems it used were config.gem’ed, the other half weren’t), vendor’ed rails (it breaks on newer than 2.1.0), and brought the development database kicking and screaming into life. There was no schema.rb, it had been .gitignore’d, and the migrations added data, used models, and everything else you can imagine doing wrong. (Including using a field on a model after adding that column in the previous line…I don’t know what version of Rails that ever worked on…) I didn’t want a production database; who knows what’s been done to that by hand. I want to know what the database is _supposed_ to look like; I can figure out the difference with production later.</p>
<p>Once the clean (only data inserted by migrations) dev database was up, I brought the site up to see if it worked. Surprisingly enough, it did; apparently they used manual QA as their only testing methodology. I appreciate their QA a lot; it means it’s a working application, even if it’s not going to help me refactor it.</p>
<p>I ran <a title="Flog (grotesque art, great tool)" href="http://ruby.sadi.st/Flog.html">flog</a> and <a href="http://ruby.sadi.st/Flay.html">flay</a> and looked at the pain points they found to get an idea how bad things might be. I picked an innocuous join table (with some extra data and functionality) to build the first set of tests for, which gave me insight into both sides of the join without having to REALLY dig into the ball of fur on either side. I viciously stripped all the ‘test_truth’ tests. I looked for large files that flog and flay hadn’t picked up to pore over. Check out custom rake tasks, because those often are clear stories and easy to quickly understand in a small context.</p>
<p>Checking out the deployment process tells you a lot also, although it turns out this was stock engine yard capistrano.</p>
<p>Skimming views (sort by size!) will tell you a lot also, especially when you find SQL queries being run in them…</p>
<p>Use the site for a little while, and watch the log in another window. Just let it skim by; if you’ve looked at log files much, things that seem wrong will jump out even if it’s going faster than you can really read.</p>
<p>In my case, the code’s mine now, so it’s my responsibility to make it better before anybody else has to touch it. I’ve got about a week of ‘free fix-it-up time’ before I need to start actually implementing new features and (thankfully) stripping out old ones… At my previous company, I was the guy pushing folks to test, now I’ve inherited a codebase with zero tests. Poetic justice, I suppose&#8230; <img src='http://cyberfox.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Good luck!</p>
<p>—  Morgan Schweers, Cyber<strong>FOX</strong>!</p>
]]></content:encoded>
			<wfw:commentRss>http://cyberfox.com/blog/2009/05/21/56/approaching-an-inherited-rails-codebase/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hackety Hack!</title>
		<link>http://cyberfox.com/blog/2007/04/27/27/hackety-hack</link>
		<comments>http://cyberfox.com/blog/2007/04/27/27/hackety-hack#comments</comments>
		<pubDate>Fri, 27 Apr 2007 19:31:56 +0000</pubDate>
		<dc:creator>Cyberfox</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[learning]]></category>
		<category><![CDATA[passion]]></category>

		<guid isPermaLink="false">http://www.vixen.com/blog/2007/04/27/27</guid>
		<description><![CDATA[Greetings,
Programming should be fun, it&#8217;s what gets us programmers into it in the first place, and it&#8217;s what keeps us going at it.
Too many layers have been heaped on programming these days; most IDEs are oppressive, process-oriented beasts.
I, and many other programmers, have been concerned about how the next generation of programmers are going to [...]]]></description>
			<content:encoded><![CDATA[<p>Greetings,</p>
<p>Programming should be <strong><em>fun</em></strong>, it&#8217;s what gets us programmers into it in the first place, and it&#8217;s what keeps us going at it.</p>
<p>Too many layers have been heaped on programming these days; most IDEs are oppressive, process-oriented beasts.</p>
<p>I, and many other programmers, have been <a title="Why little Susie can&#039;t code..." target="_blank" href="http://www.whytheluckystiff.net/articles/theLittleCodersPredicament.html">concerned</a> about how the next generation of programmers are going to be introduced to the joy of programming when all the tools out there seem to suck the fun out of it.</p>
<p>Enter <a title="A really fun coding blog." target="_blank" href="http://redhanded.hobix.com/"><em>why the lucky stiff</em></a>, and <a title="Hackety Hack --  A programming environment for learning" target="_blank" href="http://hacketyhack.net/">Hackety Hack!</a>.  Taking one back to the days when programming was as easy as typing something in, and hitting enter.  <img src='http://cyberfox.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Hackety Hack! is about <a target="_blank" title="Included programming lessons..." href="http://code.whytheluckystiff.net/hacketyhack/wiki/HacketyLessons">learning to program</a>, and being able to do <a title="A blog in six lines of code!" target="_blank" href="http://hacketyhack.net/">really cool things</a> in a very few short lines.</p>
<p>I&#8217;ve been a fan of <a title="why the luck stiff" target="_blank" href="http://whytheluckystiff.net/"><em>_why</em></a> for a while, with a <a title="The best damn Ruby tutorial out there." target="_blank" href="http://poignantguide.net/ruby/">really wild approach to teaching Ruby</a>, and a lot of <a title="_why&#039;s coding archive" target="_blank" href="http://code.whytheluckystiff.net/">really interesting code</a>, and this is even cooler.</p>
<p>If you&#8217;re new to programming, or have kids, or just want to play with one of the simplest ways to write programs, <a title="easy introduction to programming" target="_blank" href="http://hacketyhack.net/get/">get Hackety Hack!</a></p>
<p>&#8211;  Morgan Schweers, CyberFOX!</p>
]]></content:encoded>
			<wfw:commentRss>http://cyberfox.com/blog/2007/04/27/27/hackety-hack/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
