<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>has_many :thoughts: Tag TDD</title>
    <link>http://blog.kineticweb.com/articles/tag/tdd</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Musings from a Ruby on Rails development team</description>
    <item>
      <title>Skinny Controller, Fat Model</title>
      <description>&lt;p&gt;One of my favorite talks from RailsConf was by the team behind &lt;a href="http://www.therailsway.com"&gt;The Rails Way&lt;/a&gt;. Now back from the road trip and settled in, they have updated their site with some more details about one of the ideas they pushed: Controllers should be simple, basic, and generally have a lot less code then most of us use now. Most of your logic should end up in the model.&lt;/p&gt;


There&amp;#8217;s many reasons for this but the three I like the most:
	&lt;ol&gt;
	&lt;li&gt;It forces you to write code that more easily reused. Limits your temptation to copy/paste from one controller action to another.&lt;/li&gt;
		&lt;li&gt;Your templates can become more details. @order.total instead of @total (which would have to be mapped to something logic in the controller.)&lt;/li&gt;
		&lt;li&gt;The code is more easily tested. You can programmatically   access the results of the methods in your model without having to munge &lt;span class="caps"&gt;HTML&lt;/span&gt; output from a controller.&lt;/li&gt;
	&lt;/ol&gt;


	&lt;p&gt;&lt;a href="http://www.therailsway.com/2007/6/1/railsconf-recap-skinny-controllers"&gt;Their post&lt;/a&gt; has all the details and code samples.&lt;/p&gt;</description>
      <pubDate>Fri, 01 Jun 2007 21:07:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:f3c58e79-0490-4bc0-ab0a-7fbcd88131ff</guid>
      <author>Colin A. Bartlett</author>
      <link>http://blog.kineticweb.com/articles/2007/06/01/skinny-controller-fat-model</link>
      <category>Rails</category>
      <category>TDD</category>
      <category>RailsConf</category>
      <category>RailsConf07</category>
      <trackback:ping>http://blog.kineticweb.com/articles/trackback/36</trackback:ping>
    </item>
    <item>
      <title>Adding tests to legacy rails apps</title>
      <description>&lt;p&gt;This talk was excellent and provided some insight as to how we can start writing tests on the apps we haven&amp;#8217;t done jack with when it comes to testing. Since this is one of my main goals for our team in the coming months, I found this talk quite informative. Some tidbits:&lt;/p&gt;


	&lt;ol&gt;
	&lt;li&gt;Having no tests at all doesn&amp;#8217;t mean you can&amp;#8217;t start writing them.
	&lt;ul&gt;
	&lt;li&gt;It&amp;#8217;s really not that hard to get started writing tests. Rail scaffold will actually generate tests out of the box although the speaker implied they are not very good and might actually even break.&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
		&lt;li&gt;Write a test every time you refactor
	&lt;ul&gt;
	&lt;li&gt;If you are following the principal of putting that extra 10% of effort in to refactoring or improving some other portion of code at every single check-in, you have ample opportunity for writing beginning tests.&lt;/li&gt;
		&lt;li&gt;Simply create a test that passes under the current code, then refactor the test, and ensure the test still passes.&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
		&lt;li&gt;We should use RSpec to write tests
	&lt;ul&gt;
	&lt;li&gt;Since we&amp;#8217;re just getting started with &lt;span class="caps"&gt;TDD&lt;/span&gt; and writing tests at all, we should start with a tool that of people seem to think is superior to Test::Unit.&lt;/li&gt;
		&lt;li&gt;RSpec allows people to write tests in a domain specific language that makes the tests read better and make more sense.&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
		&lt;li&gt;There are some really handy tools available to help us test and help us test our tests.
	&lt;ol&gt;
	&lt;li&gt;rake stats
	&lt;ul&gt;
	&lt;li&gt;The rake stats output will show you a ratio of lines of code to lines of tests. You want to have a higher ratio because that means you&amp;#8217;re writing a lot of tests.&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
		&lt;li&gt;rcov
	&lt;ul&gt;
	&lt;li&gt;Rcov is a neat tool that will run your tests and show you lines of code that were not tested.&lt;/li&gt;
		&lt;li&gt;With an output similar to the cvsspam diff output that highlights lines of code that the whole body of your tests didn&amp;#8217;t run.&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
		&lt;li&gt;Heckle
	&lt;ul&gt;
	&lt;li&gt;Heckle is tool that sounds pretty damn cool. Basically, it fucks up your code and then tells you if your tests failed like should have.&lt;/li&gt;
		&lt;li&gt;Essentially, it changes variables, swaps if statements, and generally wreaks havoc on your code, one item at a time, running your tests each time.&lt;/li&gt;
		&lt;li&gt;At the end, it tells you what tests still passed after stuff was changed and shows you what it changed. By examining this, you can determine what stuff might be tested properly.&lt;/li&gt;
	&lt;/ol&gt;&lt;/li&gt;
	&lt;/ol&gt;&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;I&amp;#8217;m pretty anxious to start testing and I think I&amp;#8217;ll try out some of these techniques on Find Mini Golf tonight.&lt;/p&gt;</description>
      <pubDate>Fri, 18 May 2007 18:04:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:38bd5ae7-798d-4266-8114-7bc5698f44ce</guid>
      <author>Colin A. Bartlett</author>
      <link>http://blog.kineticweb.com/articles/2007/05/18/adding-tests-to-legacy-rails-apps</link>
      <category>TDD</category>
      <category>Rails</category>
      <category>RailsConf</category>
      <category>RailsConf07</category>
    </item>
    <item>
      <title>Clean Code</title>
      <description>&lt;p&gt;I just saw a talk by Robert Martin called &#8220;Clean Code&#8221; that was pretty eye opening. He walked through the process of coding a small app that parsed command line parameters. He demonstrated a rather common process of creating a small application with a specific function that, when requirements change, can quickly and easily morph into a mess of unmanageable code.&lt;/p&gt;


	&lt;p&gt;This is a problem we encounter often and was one of my main complaints the &lt;span class="caps"&gt;ASP&lt;/span&gt; applications that we were churning out. We can&amp;#8217;t do anything about clients changing requirements, but we can do something about how we keep up with them.&lt;/p&gt;


	&lt;p&gt;A few points to take a away:&lt;/p&gt;


	&lt;ol&gt;
	&lt;li&gt;Writing clean code is more important than you think.
	&lt;ul&gt;
	&lt;li&gt;It often seems like a better choice to just get the app done, and worry about the details later. But later almost always requires more work.&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
		&lt;li&gt;Test-first development is the way to go. 
	&lt;ul&gt;
	&lt;li&gt;The speaker is an agile development consultant and so he advocated test-first development, of course.&lt;/li&gt;
		&lt;li&gt;It was pretty clear to me that refactoring becomes a lot easier, because you can do it with confidence, when you have tests that can ensure that your code still works.&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
		&lt;li&gt;Improve code every time you check in.
	&lt;ul&gt;
	&lt;li&gt;When you add some functionality to an app, make it a habit of always improving something else at the same time.&lt;/li&gt;
		&lt;li&gt;A small investment of say, 10% additional work, every time you commit code, of improvement and refactoring of other code will go a long way to improving the app overall. Again, you can do this more confidently when you have tests.&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
		&lt;li&gt;Reading other people&amp;#8217;s code is a great way to learn.
	&lt;ul&gt;
	&lt;li&gt;It was pretty interesting to read someone else&amp;#8217;s code and learn how they would approach a problem. This is why things like Ruby Quiz are so helpful.&lt;/li&gt;
	&lt;/ol&gt;&lt;/li&gt;
	&lt;/ul&gt;</description>
      <pubDate>Fri, 18 May 2007 15:13:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:a2e2871b-d7bc-43f7-a660-6cf6d7577585</guid>
      <author>Colin A. Bartlett</author>
      <link>http://blog.kineticweb.com/articles/2007/05/18/clean-code</link>
      <category>Rails</category>
      <category>RailsConf</category>
      <category>RailsConf07</category>
      <category>TDD</category>
    </item>
    <item>
      <title>Airlines suck</title>
      <description>&lt;p&gt;It&amp;#8217;s difficult to blog about RailsConf when one is stuck in a city hundreds of miles away&amp;#8230;&lt;/p&gt;


	&lt;p&gt;Hopefully I&amp;#8217;ll get there for at least the second tutorial session tomorrow. It&amp;#8217;s a shame, because I was &lt;strong&gt;really&lt;/strong&gt; looking forward to the tutorial about test driven development.&lt;/p&gt;


	&lt;p&gt;Guess I will just have to spend my hours sitting at O&amp;#8217;Hare by reading about &lt;span class="caps"&gt;TDD&lt;/span&gt;.&lt;/p&gt;</description>
      <pubDate>Thu, 17 May 2007 01:45:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:c82f0e73-0e94-4081-b3e1-06a7d86898a4</guid>
      <author>Colin A. Bartlett</author>
      <link>http://blog.kineticweb.com/articles/2007/05/17/airlines-suck</link>
      <category>RailsConf</category>
      <category>RailsConf07</category>
      <category>TDD</category>
    </item>
  </channel>
</rss>
