<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>Continuous Thinking - Home</title>
  <id>tag:www.continuousthinking.com,2008:mephisto/</id>
  <generator version="0.7.3" uri="http://mephistoblog.com">Mephisto Noh-Varr</generator>
  <link href="http://www.continuousthinking.com/feed/atom.xml" rel="self" type="application/atom+xml"/>
  <link href="http://www.continuousthinking.com/" rel="alternate" type="text/html"/>
  <updated>2008-05-05T13:59:20Z</updated>
  <entry xml:base="http://www.continuousthinking.com/">
    <author>
      <name>zdennis</name>
    </author>
    <id>tag:www.continuousthinking.com,2008-05-05:530</id>
    <published>2008-05-05T09:58:00Z</published>
    <updated>2008-05-05T13:59:20Z</updated>
    <link href="http://www.continuousthinking.com/2008/5/5/h-r-5353-i-called-have-you" rel="alternate" type="text/html"/>
    <title>H.R. 5353 - I called, have you?</title>
<content type="html">
            &lt;p&gt;I just got off the phone with my state representative Peter Hoekstra&#8217;s office to urge him to support the Internet Freedom Preservation Act os 2008&#8212;&lt;a href='http://www.opencongress.org/bill/110-h5353/show'&gt;H.R. 5353&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;For more information on the issue or to determine who to call and what to say, please see &lt;a href='http://www.savetheinternet.com'&gt;www.savetheinternet.com&lt;/a&gt;&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://www.continuousthinking.com/">
    <author>
      <name>zdennis</name>
    </author>
    <id>tag:www.continuousthinking.com,2008-05-03:529</id>
    <published>2008-05-03T12:50:00Z</published>
    <updated>2008-05-03T16:51:00Z</updated>
    <link href="http://www.continuousthinking.com/2008/5/3/book-review-ruby-on-rails-enterprise-application-development" rel="alternate" type="text/html"/>
    <title>Book Review - Ruby on Rails: Enterprise Application Development</title>
<content type="html">
            &lt;p&gt;I know Slashdot is a busy place, but come on, four months and a book review is still pending, and they don&#8217;t respond to any emails? Anyways here is my review of &#8220;Ruby on Rails: Enterprise Application Development&#8221;.&lt;/p&gt;


&lt;p&gt;Ruby on Rails &#8211; Enterprise Application Development by Elliot Smith and Rob Nichols targets a new niche in the Rails world of published books. Its goal is to connect all of the dots that make up typical Rails development for developers who have been through the tutorials, but wonder &#8216;what do I do next?&#8217;&lt;/p&gt;

    &lt;p&gt;The focus of this book is breadth and not depth. The authors do a good job of balancing the explanation of essential Rails concepts while letting the reader know when they are approaching a more advanced topic that won&#8217;t be covered in depth.&lt;/p&gt;

    &lt;p&gt;Throughout the book the authors follow a fictional, yet realistic scenario in which Rory the IT guy implements a simple web-based contacts management application. Each chapter builds on the previous walking the reader through the whole process of development to production deployment.&lt;/p&gt;

    &lt;p&gt;There is no Rails development until Chapter 4, pg 91. The emphasis of the first 90 pages is understanding what Rails is and why you would use it, as well as introducing the problem scenario that will be used throughout the book. This would be a bigger turn off then it was, but the authors made up for this a little walking the reader through installing everything required for Rails development on multiple operating systems.&lt;/p&gt;

    &lt;p&gt;Rather then focus on a single platform for development or production the authors use a mixed environment of Ubuntu Linux, &lt;span class='caps'&gt;&lt;span class='caps'&gt;OSX&lt;/span&gt;&lt;/span&gt; and Windows and a cross platform Eclipse &lt;span class='caps'&gt;&lt;span class='caps'&gt;IDE&lt;/span&gt;&lt;/span&gt;. They also take the time to walk the reader through installation and setup of each platform as it pertains to Rails development.&lt;/p&gt;

    &lt;p&gt;The majority of the development in this book sticks to the functionality included in Rails itself. When it comes to core components of Rails the authors do a great job of covering them: migrations, models, validations, associations, controllers, filters, views and view helpers.&lt;/p&gt;

    &lt;p&gt;Plugins are not covered except for acts_as_attachment, which is now deprecated in favor of attachment_fu.&lt;/p&gt;

    &lt;p&gt;The only issue I had with the book was with the sections on testing. The authors cover unit and functional testing with the built-in Rails testing framework. Unfortunately, the example tests are horrible and should not appear in production quality code. The sections on testing should only be used to understand how the built-in testing framework works in Rails and not as an example for writing tests. It is too bad that the authors didn&#8217;t cover integration testing either.&lt;/p&gt;

    &lt;p&gt;A good thing that did come out of the testing sections in this book is the encouragement for developers to write tests which expose bugs before fixing them. It&#8217;s the only way to ensure you really fixed it.&lt;/p&gt;

    &lt;p&gt;Rails 1.2.3 is used throughout the book so any changes, improvements or deprecations in Rails 2.0 aren&#8217;t covered. If the reader follows the book with Rails 1.2.3 they should have no issues walking through and developing the code themselves. If the reader follows the book with Rails 2.0 they should be aware of some of the changes, those can be found at &lt;a href='http://weblog.rubyonrails.org/2007/12/7/rails-2-0-it-s-done'&gt;http://weblog.rubyonrails.org/2007/12/7/rails-2-0-it-s-done&lt;/a&gt;&lt;/p&gt;

    &lt;p&gt;The things that stuck out to me were:&lt;/p&gt;

    &lt;ul&gt;
    &lt;li&gt;view template file naming conventions&lt;/li&gt;
        &lt;li&gt;the verbosity of not having named routes&lt;/li&gt;
        &lt;li&gt;the lack of the db:rollback rake task&lt;/li&gt;
    &lt;/ul&gt;

    &lt;p&gt;The authors take the time to walk the reader through setting up and using Subversion as an integral part of Rails software development. It also includes setting up and using Apache and Mongrel to serve Rails. As the book moves from development to production deployment the user is shown how to deploy automatically from Subversion to their production server using Capistrano.&lt;/p&gt;

    &lt;p&gt;There were a few minor typos and one redundant sentence on page 52. This is considerably lower then other technical books that I&#8217;ve read.&lt;/p&gt;

    &lt;p&gt;The only giant red sections marked in my copy are the ones on testing. Take those examples with a grain of salt.&lt;/p&gt;

    &lt;p&gt;Overall, the majority of the book is filled with good advice for novice Rails developers like, &#8220;do not wait until your application is built before you create and test the production environment&#8221; and &#8220;involve the end users throughout the process&#8221;.&lt;/p&gt;

    &lt;p&gt;If you are a novice Rails developer who understand bits and pieces of Rails this book does a good job of connecting the other dots because the authors take the time to go through the full process of development to production. On the other hand if you have a good grasp on the whole Rails development process you can skip this book.&lt;/p&gt;

    &lt;p&gt;A good chapter outline of this book can be found at &lt;span class='caps'&gt;PACKT&lt;/span&gt;&#8217;s &lt;a href='http://www.packtpub.com/Ruby-on-Rails-Enterprise-Application-Open-Source/book'&gt;web site&lt;/a&gt;&lt;/p&gt;.
          </content>  </entry>
  <entry xml:base="http://www.continuousthinking.com/">
    <author>
      <name>zdennis</name>
    </author>
    <id>tag:www.continuousthinking.com,2008-05-03:528</id>
    <published>2008-05-03T00:44:00Z</published>
    <updated>2008-05-03T04:44:47Z</updated>
    <link href="http://www.continuousthinking.com/2008/5/3/net-neutrality-save-the-internet" rel="alternate" type="text/html"/>
    <title>Net Neutrality - Save The Internet</title>
<content type="html">
            &lt;p&gt;If you haven&#8217;t heard of &lt;a href='http://en.wikipedia.org/wiki/Network_neutrality'&gt;Net Neutrality&lt;/a&gt; before, wikipedia describes it as:&lt;/p&gt;


	&lt;p&gt;&#8221;... a principle that is applied to residential broadband networks, and potentially to all networks. A neutral broadband network is one that is free of restrictions on the kinds of equipment that may be attached, on the modes of communication allowed, which does not restrict content, sites or platforms, and where communication is not unreasonably degraded by other communication streams.&#8221;&lt;/p&gt;


	&lt;p&gt;Unfortunately there are corporations out there which want to control access, speeds and content available to those connecting to the Internet through their services. Below is an informative 10 minute video (I found it at  &lt;a href='http://www.matthewgood.org/2008/05/net-neutrality/'&gt;http://www.matthewgood.org/2008/05/net-neutrality/&lt;/a&gt;). If you have the time please hit play.&lt;/p&gt;


&lt;div&gt;
&amp;lt;object height='355' width='425'&gt;
&amp;lt;param name='movie' value='http://www.youtube.com/v/JP_3WnJ42kw&#38;hl=en' /&gt;
&amp;lt;param name='wmode' value='transparent' /&gt;
&amp;lt;embed src='http://www.youtube.com/v/JP_3WnJ42kw&#38;hl=en' type='application/x-shockwave-flash' height='355' wmode='transparent' width='425' /&gt;
&amp;lt;/object&gt;
&lt;/div&gt;

	&lt;p&gt;If this issue concerns checkout &lt;a href='http://www.savetheinternet.com'&gt;www.savetheinternet.com&lt;/a&gt; . I urge you to spread awareness of the issue and contact your congressman.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://www.continuousthinking.com/">
    <author>
      <name>zdennis</name>
    </author>
    <id>tag:www.continuousthinking.com,2008-04-02:518</id>
    <published>2008-04-02T17:28:00Z</published>
    <updated>2008-04-02T21:29:46Z</updated>
    <link href="http://www.continuousthinking.com/2008/4/2/form_test_helper-select_form-update" rel="alternate" type="text/html"/>
    <title>form_test_helper, select_form update</title>
<content type="html">
            &lt;p&gt;Revision 71 of form_test_helper includes a bug fix for the select_form method. Previously calling select_form with a block would submit the form. The fix forces you to call submit on the form. So&#8230;&lt;/p&gt;


&lt;table class='CodeRay'&gt;&lt;tr&gt;
  &lt;td title='click to toggle' class='line_numbers'&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class='code'&gt;&lt;pre&gt;&lt;span class='c'&gt;# THIS which used to submit the form&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;form = select_form &lt;span class='s'&gt;&lt;span class='dl'&gt;'&lt;/span&gt;&lt;span class='k'&gt;trip&lt;/span&gt;&lt;span class='dl'&gt;'&lt;/span&gt;&lt;/span&gt; &lt;span class='r'&gt;do&lt;/span&gt; |form|&lt;tt&gt;
&lt;/tt&gt;  form.trip.destination = &lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;bahamas&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class='r'&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class='c'&gt;# WILL NOW LOOK LIKE THIS&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;form = select_form &lt;span class='s'&gt;&lt;span class='dl'&gt;'&lt;/span&gt;&lt;span class='k'&gt;trip&lt;/span&gt;&lt;span class='dl'&gt;'&lt;/span&gt;&lt;/span&gt; &lt;span class='r'&gt;do&lt;/span&gt; |form|&lt;tt&gt;
&lt;/tt&gt;  form.trip.destination = &lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;bahamas&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class='r'&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;form.submit&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;This doesn&#8217;t affect the usage of submit_form which still acts as expected.&lt;/p&gt;


	&lt;p&gt;This will be included in the next release of form_test_helper. Currently trunk for form_test_helper works with Rails 2.0.0 and higher (including today&#8217;s most recent trunk commit).&lt;/p&gt;


	&lt;p&gt;The form_test_helper edge docs have been updated as well and can be found &lt;a href='http://continuous.rubyforge.org/form_test_helper/rdoc/'&gt;here&lt;/a&gt;&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://www.continuousthinking.com/">
    <author>
      <name>zdennis</name>
    </author>
    <id>tag:www.continuousthinking.com,2008-04-01:517</id>
    <published>2008-04-01T00:46:00Z</published>
    <updated>2008-04-01T00:46:36Z</updated>
    <link href="http://www.continuousthinking.com/2008/4/1/rails-ticket-11491" rel="alternate" type="text/html"/>
    <title>Rails Ticket #11491</title>
<content type="html">
            &lt;p&gt;If you have a few minutes, please review and comment on Rails ticket #11491.&lt;/p&gt;


	&lt;pre&gt;&lt;code&gt;&lt;a href='http://dev.rubyonrails.org/ticket/11491'&gt;http://dev.rubyonrails.org/ticket/11491&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;


	&lt;p&gt;In short, it adds the ability for &#8220;render :partial =&amp;gt; some_collection&#8221; to render the correct partial based on each element in some_collection. Currently Rails uses the first element to determine what to render for every element in the collection.&lt;/p&gt;


	&lt;p&gt;Thanks in advance,&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://www.continuousthinking.com/">
    <author>
      <name>zdennis</name>
    </author>
    <id>tag:www.continuousthinking.com,2008-03-25:510</id>
    <published>2008-03-25T03:38:00Z</published>
    <updated>2008-03-25T03:41:05Z</updated>
    <link href="http://www.continuousthinking.com/2008/3/25/more-people-more-progress" rel="alternate" type="text/html"/>
    <title>More People != More Progress</title>
<content type="html">
            &lt;p&gt;There is a common misconception that the best way to add capacity to a project and reduce its completion date is simple&#8212;just throw more people at it. Although there is some truth in this, it is usually applied at the wrong times and it ends up having a very negative impact on the project.&lt;/p&gt;


	&lt;p&gt;This mindset that project development is a series of tasks and that somehow you can just throw people at them and everything will work out is foreign to me, because it won&#8217;t work out&#8212;at least not when it&#8217;s applied in haste.&lt;/p&gt;


	&lt;p&gt;Adding value to a project is more than completing tasks. Tasks are not isolated during project development. They are features which build on top of one another. Making good responsible decisions and understanding the code base both technically and conceptually goes a long way to help exploit easier and better ways of implementing features. This also helps keep the code base well factored, which in turn helps teams progress consistently and avoid creating a giant roadblock of technical debt which may have lurked just ahead.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://www.continuousthinking.com/">
    <author>
      <name>zdennis</name>
    </author>
    <id>tag:www.continuousthinking.com,2008-03-22:505</id>
    <published>2008-03-22T00:58:00Z</published>
    <updated>2008-03-22T05:01:41Z</updated>
    <category term="factory_loader"/>
    <link href="http://www.continuousthinking.com/2008/3/22/why_factory_loader" rel="alternate" type="text/html"/>
    <title>What is a factory and why FactoryLoader?</title>
<content type="html">
            &lt;p&gt;This statement and question were posted to the &lt;a href='http://www.gr-ruby.org'&gt;http://www.gr-ruby.org&lt;/a&gt; mailing list as it pertained to the release of FactoryLoader. This post should answer the question &#8220;what is a factory?&#8221; and also provide more insight into what FactoryLoader&#8217;s role is.&lt;/p&gt;


&lt;table class='CodeRay'&gt;&lt;tr&gt;
  &lt;td title='click to toggle' class='line_numbers'&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class='code'&gt;&lt;pre&gt;&amp;gt; I've read over your website, but I still have a lagging question which&lt;tt&gt;
&lt;/tt&gt;&amp;gt; completely blinds my ability to see the usefulness of it: What is a factory?&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;A factory is &#8220;a mechanism for encapsulating complex creation logic&#8221; [0].&lt;/p&gt;


	&lt;p&gt;Here&#8217;s an example. Let&#8217;s say that you start writing an application that is a project management tool for a business. To start with they need the ability to create Projects. This is no big deal, you have a ProjectsController#create action and it makes your Project by doing something similar to the below:&lt;/p&gt;


&lt;table class='CodeRay'&gt;&lt;tr&gt;
  &lt;td title='click to toggle' class='line_numbers'&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class='code'&gt;&lt;pre&gt;  &lt;span class='r'&gt;def&lt;/span&gt; &lt;span class='fu'&gt;create&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    project = &lt;span class='co'&gt;Project&lt;/span&gt;.new params[&lt;span class='sy'&gt;:project&lt;/span&gt;]&lt;tt&gt;
&lt;/tt&gt;    &lt;span class='r'&gt;if&lt;/span&gt; project.save&lt;tt&gt;
&lt;/tt&gt;      flash[&lt;span class='sy'&gt;:notice&lt;/span&gt;] = &lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;successfully created the project&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      render &lt;span class='sy'&gt;:action&lt;/span&gt; =&amp;gt; &lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;create&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class='r'&gt;else&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      flash[&lt;span class='sy'&gt;:error&lt;/span&gt;] = &lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;failed to create the project&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      render &lt;span class='sy'&gt;:action&lt;/span&gt; =&amp;gt; &lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;new&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class='r'&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class='r'&gt;end&lt;/span&gt;  &lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;Now a few weeks later the customer says that in order to create a project it needs to be assigned a project manager off the bat (the currently logged in user). This is not a very big deal since you have a &#8220;current_user&#8221; already, you just update your controller to look like:&lt;/p&gt;


&lt;table class='CodeRay'&gt;&lt;tr&gt;
  &lt;td title='click to toggle' class='line_numbers'&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class='code'&gt;&lt;pre&gt;  &lt;span class='r'&gt;def&lt;/span&gt; &lt;span class='fu'&gt;create&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    project = &lt;span class='co'&gt;Project&lt;/span&gt;.new params[&lt;span class='sy'&gt;:project&lt;/span&gt;]&lt;tt&gt;
&lt;/tt&gt;    project.manager = current_user&lt;tt&gt;
&lt;/tt&gt;    &lt;span class='r'&gt;if&lt;/span&gt; project.save&lt;tt&gt;
&lt;/tt&gt;      flash[&lt;span class='sy'&gt;:notice&lt;/span&gt;] = &lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;successfully created the project&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      render &lt;span class='sy'&gt;:action&lt;/span&gt; =&amp;gt; &lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;create&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class='r'&gt;else&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      flash[&lt;span class='sy'&gt;:error&lt;/span&gt;] = &lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;failed to create the project&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      render &lt;span class='sy'&gt;:action&lt;/span&gt; =&amp;gt; &lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;new&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class='r'&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class='r'&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;A few more weeks go by and your customer says that projects are tied to company budgets and when they are created they need to be automatically assigned to the correct budget based on the type of project. So we update to ProjectsController#create looks like the below:&lt;/p&gt;


&lt;table class='CodeRay'&gt;&lt;tr&gt;
  &lt;td title='click to toggle' class='line_numbers'&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class='code'&gt;&lt;pre&gt;  &lt;span class='r'&gt;def&lt;/span&gt; &lt;span class='fu'&gt;create&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    project = &lt;span class='co'&gt;Project&lt;/span&gt;.new params[&lt;span class='sy'&gt;:project&lt;/span&gt;]&lt;tt&gt;
&lt;/tt&gt;    project.manager = current_user&lt;tt&gt;
&lt;/tt&gt;    project.budget = &lt;span class='co'&gt;Budget&lt;/span&gt;.find_by_project_type(project.type)&lt;tt&gt;
&lt;/tt&gt;    &lt;span class='r'&gt;if&lt;/span&gt; project.save&lt;tt&gt;
&lt;/tt&gt;      flash[&lt;span class='sy'&gt;:notice&lt;/span&gt;] = &lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;successfully created the project&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class='r'&gt;else&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      flash[&lt;span class='sy'&gt;:error&lt;/span&gt;] = &lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;failed to create the project&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      render &lt;span class='sy'&gt;:action&lt;/span&gt; =&amp;gt; &lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;new&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class='r'&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class='r'&gt;end&lt;/span&gt;  &lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;Uh oh. There are important business rules being applied in the controller. The controller&#8217;s responsibility is to map an incoming request with an outgoing response and to know high level what the application needs to be doing. It should not know the intimate details of Project creation. Since we&#8217;re implementing the business rules on the controller we can&#8217;t re-use them for anything, unless we make a &lt;span class='caps'&gt;POST&lt;/span&gt; request to ProjectsController#create. This is quite limiting.&lt;/p&gt;


	&lt;p&gt;Another option to make them more reusable would be to tuck this away in the Project model itself. Perhaps we add a before_save callback which finds the appropriate budget. Even then we&#8217;ve only moved the budget logic out of the controller and there is still requirement for a Project to have a manager. If we go this route we&#8217;ll be separating two important pieces of how a Project gets constructed from each other. We would have the ProjectsController#create action setting the manager and then a before_save callback on the Project model finding a budget, both of which are required for a Project to be constructed.&lt;/p&gt;


	&lt;p&gt;One thought to remedy this would be put everything in the Project model, maybe in a before_save callback or overriding the constructor. But we quickly hit a roadblock because our Project model doesn&#8217;t know about the current user, that is application state and only the model knows about that. We could do something stupid and make the current_user global to the application, but that is a bad decision with pretty bad repercussions.&lt;/p&gt;


	&lt;p&gt;It&#8217;d be nice if we had a single object responsible for constructing a Project with these business rules. This is where a ProjectFactory comes into play. The ProjectFactory looks like:&lt;/p&gt;


&lt;table class='CodeRay'&gt;&lt;tr&gt;
  &lt;td title='click to toggle' class='line_numbers'&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class='code'&gt;&lt;pre&gt;  &lt;span class='r'&gt;class&lt;/span&gt; &lt;span class='cl'&gt;ProjectFactory&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class='r'&gt;def&lt;/span&gt; &lt;span class='fu'&gt;create&lt;/span&gt;(project_attrs, manager)&lt;tt&gt;
&lt;/tt&gt;      project = &lt;span class='co'&gt;Project&lt;/span&gt;.new project_attrs&lt;tt&gt;
&lt;/tt&gt;      project.budget = &lt;span class='co'&gt;Budget&lt;/span&gt;.find_by_project_type(project.type)&lt;tt&gt;
&lt;/tt&gt;      project.save!&lt;tt&gt;
&lt;/tt&gt;      project&lt;tt&gt;
&lt;/tt&gt;    &lt;span class='r'&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class='r'&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;And the ProjectsController#create action looks like:&lt;/p&gt;


&lt;table class='CodeRay'&gt;&lt;tr&gt;
  &lt;td title='click to toggle' class='line_numbers'&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class='code'&gt;&lt;pre&gt;  &lt;span class='r'&gt;def&lt;/span&gt; &lt;span class='fu'&gt;create&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    project = &lt;span class='co'&gt;ProjectFactory&lt;/span&gt;.create params[&lt;span class='sy'&gt;:project&lt;/span&gt;], current_user&lt;tt&gt;
&lt;/tt&gt;    flash[&lt;span class='sy'&gt;:notice&lt;/span&gt;] = &lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;successfully created the project&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class='r'&gt;rescue&lt;/span&gt; &lt;tt&gt;
&lt;/tt&gt;    flash[&lt;span class='sy'&gt;:error&lt;/span&gt;] = &lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;failed to create the project&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    render &lt;span class='sy'&gt;:action&lt;/span&gt; =&amp;gt; &lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;new&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;    &lt;tt&gt;
&lt;/tt&gt;  &lt;span class='r'&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;This is pretty straightforward. I just moved some of the lines from the action into the factory. More importantly then just moving line of code is that the act of constructing a valid project (given the customer&#8217;s requirements) isn&#8217;t the responsibility of the Project. The act of constructing a valid project is a process by itself which is important to the customer, so we isolate it in a ProjectFactory.&lt;/p&gt;


	&lt;p&gt;This is valuable because:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;the business logic used to construct a project is in one spot. Should the customer change, add or remove requirements you only have to go to one spot to implement them. Granted if the method signature to this changes you have to go update the spots calling the create method, but you the actual logic for constructing the project isn&#8217;t spread throughout multiple files or classes.&lt;/li&gt;
		&lt;li&gt;it promotes reusability (the whole &lt;span class='caps'&gt;DRY&lt;/span&gt; thing), since my ProjectFactory is much more reusable then my ProjectsController.&lt;/li&gt;
		&lt;li&gt;it promotes single responsibility&lt;/li&gt;
		&lt;li&gt;it provides clearer meaning to the code base because we aren&#8217;t muddying up the controller or the Project model with creation logic&lt;/li&gt;
		&lt;li&gt;it makes for easier testing and easier to understand tests&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;The technical implementation of this pattern is mentioned in the GoF book [1]. The value of the pattern as it applies to Domain Driven Design is mentioned in the &lt;span class='caps'&gt;DDD&lt;/span&gt; book by Eric Evans.&lt;/p&gt;


	&lt;p&gt;Hopefully that helps clarify what a factory is, by seeing how it is used and some of the value it provides. This relates to the FactoryLoader because sometimes the progression of creation logic is over time.&lt;/p&gt;


	&lt;p&gt;For the first few weeks or months of a project you are hardcoding things like &#8220;Project.create&#8221; in multiple spots. When the customer starts introducing requirements for constructing (or updating) a Project you have to go update all of those spots with the same code (violating &lt;span class='caps'&gt;DRY&lt;/span&gt;) or go find all of those spots and refactor them to use a ProjectFactory, and then make a ProjectFactory. It doesn&#8217;t happen all the time, but when it does happen it can be time consuming, frustrating and painful to do.&lt;/p&gt;


	&lt;p&gt;What FactoryLoader would do in our example is it give us a ProjectFactory upfront w/o having to write any code. If we used FactoryLoader in the above example our ProjectsController#create action would look like:&lt;/p&gt;


&lt;table class='CodeRay'&gt;&lt;tr&gt;
  &lt;td title='click to toggle' class='line_numbers'&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class='code'&gt;&lt;pre&gt;  &lt;span class='r'&gt;def&lt;/span&gt; &lt;span class='fu'&gt;create&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    project = &lt;span class='co'&gt;ProjectFactory&lt;/span&gt;.create params[&lt;span class='sy'&gt;:project&lt;/span&gt;]&lt;tt&gt;
&lt;/tt&gt;    &lt;span class='r'&gt;if&lt;/span&gt; project.save&lt;tt&gt;
&lt;/tt&gt;      flash[&lt;span class='sy'&gt;:notice&lt;/span&gt;] = &lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;successfully created the project&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      render &lt;span class='sy'&gt;:action&lt;/span&gt; =&amp;gt; &lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;create&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class='r'&gt;else&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      flash[&lt;span class='sy'&gt;:error&lt;/span&gt;] = &lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;failed to create the project&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      render &lt;span class='sy'&gt;:action&lt;/span&gt; =&amp;gt; &lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;new&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class='r'&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class='r'&gt;end&lt;/span&gt;  &lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;Where the ProjectFactory is created for you by FactoryLoader (you didn&#8217;t create the class, FactoryLoader did dynamically). There&#8217;s only one line that differs between the example that uses the FactoryLoader and the one that doesn&#8217;t.&lt;/p&gt;


	&lt;p&gt;Now when the customer starts adding business rules for creating a Project you can create your own ProjectFactory class and implement the customer&#8217;s business rules.   FactoryLoader will see that you have provided your own ProjectFactory so it won&#8217;t dynamically create one. Since all of the spots where you create a Project are already using a ProjectFactory they get the changes for free. Overall you get to touch less code for the changes and you get to spend less time refactoring if any refactoring is needed.&lt;/p&gt;


	&lt;p&gt;The goal of FactoryLoader is to allow developers the ability to scale to these customer requirements with less pain. The above examples have been quite trivial, hopefully they are clear enough and meaningful enough to express why I wrote FactoryLoader,&lt;/p&gt;


	&lt;p&gt;&#8212;
Zach Dennis
http://www.continuousthinking.com&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;0 &#8211; Domain Driven Design by Eric Evans&lt;/li&gt;
		&lt;li&gt;1 &#8211; Design Patterns: Elements of Reusable Object-Oriented Software by Gamma, Helm, Johnson and Vlissides&lt;/li&gt;
	&lt;/ul&gt;
          </content>  </entry>
  <entry xml:base="http://www.continuousthinking.com/">
    <author>
      <name>zdennis</name>
    </author>
    <id>tag:www.continuousthinking.com,2008-03-18:504</id>
    <published>2008-03-18T06:10:00Z</published>
    <updated>2008-03-21T22:08:31Z</updated>
    <category term="factory_loader"/>
    <link href="http://www.continuousthinking.com/2008/3/18/factory-loader" rel="alternate" type="text/html"/>
    <title>Factory Loader</title>
<content type="html">
            &lt;p&gt;FactoryLoader is intended to help scale object creation with less pain and less refactoring by creating factory classes for basic object construction.&lt;/p&gt;


	&lt;p&gt;In the early stages of a project object creation is simple and dependencies are kept to a minimum. As the project grows so does the complexity of object creation and its dependencies. It doesn‘t make sense to create custom factory classes upfront to deal with complex object construction that may not exist yet. But when those custom factories are needed it is usually painful and time consuming to update the code base to use them. It‘s also easy for developers to give-in due to time constraints and start making bad decisions.&lt;/p&gt;


	&lt;p&gt;This is where FactoryLoader comes into play. It automatically creates a Factory class for your objects and provides a &lt;em&gt;create&lt;/em&gt; method which passes any arguments along to your object‘s constructor.&lt;/p&gt;


	&lt;p&gt;When you need to have custom factory behavior you can implement the factory without having to update other code references (assuming you‘ve used the factory in the rest of your application rather then direct class references).&lt;/p&gt;


&lt;pre&gt;
  project/
    init.rb
    lib/
     |--things/
            |-- foo.rb
            |-- bar.rb
     |--factories/
            |-- bar_factory.rb
&lt;/pre&gt;

	&lt;p&gt;Given the above project directory structure you could have the following code in init.rb:&lt;/p&gt;


&lt;table class='CodeRay'&gt;&lt;tr&gt;
  &lt;td title='click to toggle' class='line_numbers'&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class='code'&gt;&lt;pre&gt; factory_loader = &lt;span class='co'&gt;FactoryLoader&lt;/span&gt;.new(&lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;lib/factories&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt; factory_loader.load(&lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;lib/things&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;The first call constructs a factory loader telling it which directory is used to store developer-written custom factories.&lt;/p&gt;


	&lt;p&gt;The second call will create an in-memory factory class for each *.rb file in the lib/things/ directory. A FooFactory class will be created to correspond with the foo.rb file. The generated factory will provide a &lt;em&gt;create&lt;/em&gt; method which will pass along all arguments to the constructor of the object it wraps. So&#8230;&lt;/p&gt;


&lt;table class='CodeRay'&gt;&lt;tr&gt;
  &lt;td title='click to toggle' class='line_numbers'&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class='code'&gt;&lt;pre&gt; &lt;span class='co'&gt;FooFactory&lt;/span&gt;.new.create &lt;span class='sy'&gt;:a&lt;/span&gt; =&amp;gt; &lt;span class='sy'&gt;:b&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;is the same as:&lt;/p&gt;


&lt;table class='CodeRay'&gt;&lt;tr&gt;
  &lt;td title='click to toggle' class='line_numbers'&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class='code'&gt;&lt;pre&gt; &lt;span class='co'&gt;Foo&lt;/span&gt;.new &lt;span class='sy'&gt;:a&lt;/span&gt; =&amp;gt; &lt;span class='sy'&gt;:b&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;Even though a bar.rb file exists a BarFactory will &lt;span class='caps'&gt;NOT&lt;/span&gt; be created. This is because we told the FactoryLoader that custom factories are storied in lib/factories/ and a bar_factory.rb file exists there, so FactoryLoader assumes you want to use a custom factory. It also assumes that the class inside of bar_factory.rb is BarFactory.&lt;/p&gt;


	&lt;p&gt;FactoryLoader dynamically creates the factory classes — they are not written to disk. FactoryLoader also uses file naming conventions to determine what to do. For example:&lt;/p&gt;


&lt;table class='CodeRay'&gt;&lt;tr&gt;
  &lt;td title='click to toggle' class='line_numbers'&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class='code'&gt;&lt;pre&gt;   foo.rb =&amp;gt; &lt;span class='co'&gt;FooFactory&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;   crazy_dolphins.rb =&amp;gt; &lt;span class='co'&gt;CrazyDolphinsFactory&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;h3&gt;Factory.new&lt;/h3&gt;


	&lt;p&gt;The dynamically created factories are classes and &lt;em&gt;create&lt;/em&gt; is an instance method on them. You have to construct a factory in order to use it. This is so the factories themselves can be easily used in dependency injection frameworks.&lt;/p&gt;


	&lt;h3&gt;Making a custom factory&lt;/h3&gt;


	&lt;p&gt;So you&#8217;re using FactoryLoader to do the work of creating factories for you. Let&#8217;s say our Foo object now has some creation logic that we do not want in Foo&#8217;s constructor. To put it in the FooFactory just create the file in lib/factories/foo_factory.rb. The contents of foo_factory.rb might look like:&lt;/p&gt;


&lt;table class='CodeRay'&gt;&lt;tr&gt;
  &lt;td title='click to toggle' class='line_numbers'&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class='code'&gt;&lt;pre&gt;&lt;span class='r'&gt;class&lt;/span&gt; &lt;span class='cl'&gt;FooFactory&lt;/span&gt;  &lt;tt&gt;
&lt;/tt&gt;  &lt;span class='r'&gt;def&lt;/span&gt; &lt;span class='fu'&gt;create&lt;/span&gt; options={}&lt;tt&gt;
&lt;/tt&gt;    &lt;span class='r'&gt;if&lt;/span&gt; business_logic_passes?&lt;tt&gt;
&lt;/tt&gt;      &lt;span class='co'&gt;Foo&lt;/span&gt;.new options&lt;tt&gt;
&lt;/tt&gt;    &lt;span class='r'&gt;else&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      raise &lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;business logic failed&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class='r'&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class='r'&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class='r'&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;h3&gt;Install it!&lt;/h3&gt;


	&lt;p&gt;gem install -r factory_loader&lt;/p&gt;


	&lt;h3&gt;More Info&lt;/h3&gt;


	&lt;ul&gt;
	&lt;li&gt;&lt;span class='caps'&gt;RDOC&lt;/span&gt;: &lt;a href='http://mhs.rubyforge.org/factory_loader/rdoc/'&gt;http://mhs.rubyforge.org/factory_loader/rdoc/&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;Public git repository: &lt;a&gt;git://github.com/zdennis/factory_loader.git&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;Homepage: &lt;a href='www.continuousthinking.com/factory_loader'&gt;www.continuousthinking.com/factory_loader&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;


	&lt;h3&gt;Author&lt;/h3&gt;


	&lt;p&gt;Me, Zach Dennis&lt;/p&gt;


	&lt;h3&gt;Special Thanks&lt;/h3&gt;


	&lt;ul&gt;
	&lt;li&gt;Dave Crosby at Atomic Object&lt;/li&gt;
		&lt;li&gt;Ryan Fogle at Atomic Object&lt;/li&gt;
	&lt;/ul&gt;
          </content>  </entry>
  <entry xml:base="http://www.continuousthinking.com/">
    <author>
      <name>zdennis</name>
    </author>
    <id>tag:www.continuousthinking.com,2008-03-05:503</id>
    <published>2008-03-05T00:35:00Z</published>
    <updated>2008-03-05T05:37:36Z</updated>
    <link href="http://www.continuousthinking.com/2008/3/5/trying-rspec-s-rubyesque-stories" rel="alternate" type="text/html"/>
    <title>Trying RSpec's Rubyesque Stories</title>
<content type="html">
            &lt;p&gt;Today my pair and I wrote some stories using the rubyesque RSpec story style along with a corresponding step file. It went better then expected.  We ended up a story like:&lt;/p&gt;


&lt;table class='CodeRay'&gt;&lt;tr&gt;
  &lt;td title='click to toggle' class='line_numbers'&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;15&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;18&lt;tt&gt;
&lt;/tt&gt;19&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;20&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;21&lt;tt&gt;
&lt;/tt&gt;22&lt;tt&gt;
&lt;/tt&gt;23&lt;tt&gt;
&lt;/tt&gt;24&lt;tt&gt;
&lt;/tt&gt;25&lt;tt&gt;
&lt;/tt&gt;26&lt;tt&gt;
&lt;/tt&gt;27&lt;tt&gt;
&lt;/tt&gt;28&lt;tt&gt;
&lt;/tt&gt;29&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class='code'&gt;&lt;pre&gt;&lt;span class='c'&gt;# in stories/expenses/a_user_creating_a_misc_expense_story.rb&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class='co'&gt;Story&lt;/span&gt; &lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;User creating misc. expense&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class='s'&gt;&lt;span class='dl'&gt;%|&lt;/span&gt;&lt;span class='k'&gt;&lt;tt&gt;
&lt;/tt&gt;  As a user &lt;tt&gt;
&lt;/tt&gt;  I want be able to submit an expense reimbursement request for a misc. expense&lt;tt&gt;
&lt;/tt&gt;  so that I can be reimbursed for business expenditures&lt;/span&gt;&lt;span class='dl'&gt;|&lt;/span&gt;&lt;/span&gt;,&lt;tt&gt;
&lt;/tt&gt;  &lt;span class='sy'&gt;:steps_for&lt;/span&gt; =&amp;gt; &lt;span class='sy'&gt;:expense&lt;/span&gt;,&lt;tt&gt;
&lt;/tt&gt;  &lt;span class='sy'&gt;:type&lt;/span&gt; =&amp;gt; &lt;span class='co'&gt;RailsStory&lt;/span&gt; &lt;span class='r'&gt;do&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt; &lt;tt&gt;
&lt;/tt&gt;  &lt;span class='co'&gt;Scenario&lt;/span&gt; &lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;creating a misc. expense unsuccessfully&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class='r'&gt;do&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class='co'&gt;Given&lt;/span&gt; &lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;a user at a new expense reimbursement page&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class='c'&gt;# ....&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class='r'&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;tt&gt;
&lt;/tt&gt;  &lt;span class='co'&gt;Scenario&lt;/span&gt; &lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;creating a misc. expense successfully&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class='r'&gt;do&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class='co'&gt;Given&lt;/span&gt; &lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;a user at a new expense reimbursement page&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class='c'&gt;# ...&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class='r'&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class='r'&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class='c'&gt;# in stories/steps/expense.rb&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;steps_for &lt;span class='sy'&gt;:expense&lt;/span&gt; &lt;span class='r'&gt;do&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class='co'&gt;Given&lt;/span&gt; &lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;a user at a new expense reimbursement page&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class='r'&gt;do&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    go_to_root&lt;tt&gt;
&lt;/tt&gt;    click_new_expense_reimbursement_link&lt;tt&gt;
&lt;/tt&gt;  &lt;span class='r'&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class='c'&gt;# ...&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class='r'&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


&lt;div&gt;
&lt;div class='article_sidebar'&gt;
One nice thing that came out of this was a small patch to RSpec which David committed tonight involving the options you pass along to Story. Now when declaring a story you can consistently use the &lt;strong&gt;steps_for&lt;/strong&gt; option rather then using &lt;strong&gt;steps_for&lt;/strong&gt; and/or &lt;strong&gt;steps&lt;/strong&gt;. &lt;br /&gt;&lt;br /&gt;

Previously you could use the &lt;strong&gt;steps&lt;/strong&gt; option to pass in a custom StepGroup but that is no longer supported in trunk. Now you use &lt;strong&gt;steps_for&lt;/strong&gt; when supplying a custom StepGroup, a symbol or an array of StepGroups and symbols. This helps avoid confusion of passing in &lt;strong&gt;steps&lt;/strong&gt; or &lt;strong&gt;steps_for&lt;/strong&gt; and not getting what you expect.
&lt;/div&gt;

	&lt;p&gt;Overall there are four story styles (that I&#8217;m aware of) in RSpec: plain text stories, rubyesque stories with separate step files, rubyesque stories with inlined steps and rubyesque stories with inlined blocks.&lt;/p&gt;


	&lt;p&gt;We did try using plain text stories at first, but one drawback of plain text stories is being able to run them individually from within your editor or easily from the command line. We didn&#8217;t have the need for plain text stories so we opted to not use it.&lt;/p&gt;


	&lt;p&gt;We started using the rubyesque stories with inlined steps secondly until we got a feel for the stories and then we moved those steps into their own file so we could achieve higher reuse and better step organization.&lt;/p&gt;


	&lt;p&gt;We knew coming in that we were not going to use the inlined block style since we have used that on another project and it gets clunky really fast.&lt;/p&gt;


	&lt;p&gt;If you&#8217;re considering using RSpec stories try the rubyesque stories with step matchers (inlined or in separate files). If you&#8217;re going to take the plunge into trying plain text stories look to RSpec itself for examples. The actual stories in the stories/ directory helped us get up and running earlier today.&lt;/p&gt;


&lt;/div&gt;
          </content>  </entry>
  <entry xml:base="http://www.continuousthinking.com/">
    <author>
      <name>zdennis</name>
    </author>
    <id>tag:www.continuousthinking.com,2008-02-26:501</id>
    <published>2008-02-26T20:04:00Z</published>
    <updated>2008-02-26T20:04:54Z</updated>
    <link href="http://www.continuousthinking.com/2008/2/26/mocha-s-error-messages-suck" rel="alternate" type="text/html"/>
    <title>Mocha's error messages suck</title>
<content type="html">
            &lt;p&gt;Mocha&#8217;s parameter matching error messages suck.&lt;/p&gt;


	&lt;p&gt;When writing a failing test similar to the below snippet I am given the error message &#8220;undefined method `keys&#8217; for :no_args:Symbol&#8221;&lt;/p&gt;


&lt;table class='CodeRay'&gt;&lt;tr&gt;
  &lt;td title='click to toggle' class='line_numbers'&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class='code'&gt;&lt;pre&gt;&lt;span class='iv'&gt;@user&lt;/span&gt;.should_not_receive(&lt;span class='sy'&gt;:update_attributes&lt;/span&gt;).with(has_key(&lt;span class='s'&gt;&lt;span class='dl'&gt;'&lt;/span&gt;&lt;span class='k'&gt;name&lt;/span&gt;&lt;span class='dl'&gt;'&lt;/span&gt;&lt;/span&gt;))&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;I love Mocha&#8217;s parameter matching, but what kind of error message is that?&lt;/p&gt;


	&lt;p&gt;This is not the first time I&#8217;ve gawked at Mocha&#8217;s error messages, but this time just did it for me. My pair didn&#8217;t know if we should ping or if we had broken our app.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://www.continuousthinking.com/">
    <author>
      <name>zdennis</name>
    </author>
    <id>tag:www.continuousthinking.com,2008-01-29:499</id>
    <published>2008-01-29T02:01:00Z</published>
    <updated>2008-01-30T04:02:42Z</updated>
    <link href="http://www.continuousthinking.com/2008/1/29/pair-programming-in-1-sentence" rel="alternate" type="text/html"/>
    <title>Pair Programming in 1 sentence</title>
<content type="html">
            &lt;p&gt;Pair programming is a catalyst to writing better software.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://www.continuousthinking.com/">
    <author>
      <name>zdennis</name>
    </author>
    <id>tag:www.continuousthinking.com,2008-01-26:495</id>
    <published>2008-01-26T21:09:00Z</published>
    <updated>2008-01-27T02:12:24Z</updated>
    <link href="http://www.continuousthinking.com/2008/1/26/using-vlad" rel="alternate" type="text/html"/>
    <title>Trying out Vlad the Deployer</title>
<content type="html">
            &lt;p&gt;This blog wasn&#8217;t using any form of automated deployment until late last night. For the longest time rsync and ssh seemed to be adequate enough even though I&#8217;m familiar with &lt;a href='http://www.capify.org'&gt;Capistrano&lt;/a&gt; and had been well aware of &lt;a href='http://rubyhitsquad.com/Vlad_the_Deployer.html'&gt;Vlad the Deployer&#8217;s&lt;/a&gt; release. Since I know about Capistrano I decided to invest some time getting to know Vlad.&lt;/p&gt;


	&lt;p&gt;This site is currently running on a 0.7.3 &lt;a href='http://mephistoblog.com/'&gt;Mephisto&lt;/a&gt; installation with a custom theme by yours truly and it&#8217;s hosted on &lt;a href='http://www.dreamhost.com/'&gt;Dreamhost&lt;/a&gt; servers. Out of the box Vlad works with mongrel+apache+svn. Unfortunately Dreamhost uses apache+fastcgi, but thankfully tweaking Vlad was a piece of cake.&lt;/p&gt;


	&lt;p&gt;I followed the instructions on the &lt;a href='http://rubyhitsquad.com/Examples.html'&gt;examples&lt;/a&gt; page for Vlad, but ultimately found I needed to do a little tweaking for my environment. Based on those basic examples I ended up making the following changes to my Rakefile and deploy.rb recipe file.&lt;/p&gt;


	&lt;p&gt;Here&#8217;s what I appended to my Rakefile:&lt;/p&gt;


&lt;table class='CodeRay'&gt;&lt;tr&gt;
  &lt;td title='click to toggle' class='line_numbers'&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class='code'&gt;&lt;pre&gt;&lt;span class='c'&gt;# appended to my Rakefile&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;require &lt;span class='s'&gt;&lt;span class='dl'&gt;'&lt;/span&gt;&lt;span class='k'&gt;vlad&lt;/span&gt;&lt;span class='dl'&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class='co'&gt;Vlad&lt;/span&gt;.load(&lt;span class='sy'&gt;:app&lt;/span&gt; =&amp;gt; &lt;span class='sy'&gt;:apache&lt;/span&gt;)&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;Here&#8217;s my config/deploy.rb file:&lt;/p&gt;


&lt;table class='CodeRay'&gt;&lt;tr&gt;
  &lt;td title='click to toggle' class='line_numbers'&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;15&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;18&lt;tt&gt;
&lt;/tt&gt;19&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;20&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;21&lt;tt&gt;
&lt;/tt&gt;22&lt;tt&gt;
&lt;/tt&gt;23&lt;tt&gt;
&lt;/tt&gt;24&lt;tt&gt;
&lt;/tt&gt;25&lt;tt&gt;
&lt;/tt&gt;26&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class='code'&gt;&lt;pre&gt;set &lt;span class='sy'&gt;:domain&lt;/span&gt;,      &lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;continuousthinking.com&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;set &lt;span class='sy'&gt;:deploy_to&lt;/span&gt;,   &lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;/my/path/to/continuousthinking.com/&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;set &lt;span class='sy'&gt;:repository&lt;/span&gt;,  &lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;http://myserver/svn/continuousthinking.com/trunk&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;set &lt;span class='sy'&gt;:web_command&lt;/span&gt;, &lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;echo skipping web &lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;namespace &lt;span class='sy'&gt;:vlad&lt;/span&gt; &lt;span class='r'&gt;do&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  remote_task &lt;span class='sy'&gt;:start_app&lt;/span&gt; &lt;span class='r'&gt;do&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    run &lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;pkill -f dispatch.fcgi&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    fork &lt;span class='r'&gt;do&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      puts &lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;sending a request to the domain so dispatchers restart&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      &lt;span class='sh'&gt;&lt;span class='dl'&gt;`&lt;/span&gt;&lt;span class='k'&gt;wget http://&lt;/span&gt;&lt;span class='il'&gt;&lt;span class='dl'&gt;#{&lt;/span&gt;domain&lt;span class='dl'&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class='k'&gt; -O /dev/null&lt;/span&gt;&lt;span class='dl'&gt;`&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class='r'&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class='r'&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  remote_task &lt;span class='sy'&gt;:update&lt;/span&gt; &lt;span class='r'&gt;do&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class='co'&gt;Rake&lt;/span&gt;::&lt;span class='co'&gt;Task&lt;/span&gt;[&lt;span class='s'&gt;&lt;span class='dl'&gt;'&lt;/span&gt;&lt;span class='k'&gt;vlad:after_update&lt;/span&gt;&lt;span class='dl'&gt;'&lt;/span&gt;&lt;/span&gt;].invoke&lt;tt&gt;
&lt;/tt&gt;  &lt;span class='r'&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;tt&gt;
&lt;/tt&gt;  remote_task &lt;span class='sy'&gt;:after_update&lt;/span&gt; &lt;span class='r'&gt;do&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    run &lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;ln -s &lt;/span&gt;&lt;span class='il'&gt;&lt;span class='dl'&gt;#{&lt;/span&gt;deploy_to&lt;span class='dl'&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class='k'&gt;/shared/system/database.yml &lt;/span&gt;&lt;span class='il'&gt;&lt;span class='dl'&gt;#{&lt;/span&gt;deploy_to&lt;span class='dl'&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class='k'&gt;/current/config/database.yml&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    run &lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;rm -f /home/zdennis/continuousthinking.com &amp;amp;&amp;amp;&lt;tt&gt;
&lt;/tt&gt;         ln -s &lt;/span&gt;&lt;span class='il'&gt;&lt;span class='dl'&gt;#{&lt;/span&gt;deploy_to&lt;span class='dl'&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class='k'&gt;/current /home/zdennis/continuousthinking.com&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;      &lt;tt&gt;
&lt;/tt&gt;  &lt;span class='r'&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;tt&gt;
&lt;/tt&gt;  remote_task &lt;span class='sy'&gt;:deploy&lt;/span&gt; =&amp;gt; [&lt;span class='sy'&gt;:update&lt;/span&gt;, &lt;span class='sy'&gt;:start_app&lt;/span&gt;]&lt;tt&gt;
&lt;/tt&gt;&lt;span class='r'&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;I overrode the :web_command setting so Vlad didn&#8217;t try to restart apache. The other tasks were added to customize specific needs for the deployment of the blog:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;:start_app &#8211; kill all of dispatchers on Dreamhost and then send a request to have Dreamhost launch new ones&lt;/li&gt;
		&lt;li&gt;:update &#8211; adds this task to the :update task call chain. This simulates an after_update.&lt;/li&gt;
		&lt;li&gt;:after_update &#8211; create symlinks, etc to be performed after code has been updated. &lt;/li&gt;
		&lt;li&gt;:deploy &#8211; update code and restart the app&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Overall, it was a pleasant process. I give Vlad a +1.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://www.continuousthinking.com/">
    <author>
      <name>zdennis</name>
    </author>
    <id>tag:www.continuousthinking.com,2008-01-20:471</id>
    <published>2008-01-20T21:52:00Z</published>
    <updated>2008-01-20T21:53:23Z</updated>
    <link href="http://www.continuousthinking.com/2008/1/20/ar-extensions-get-a-little-praise" rel="alternate" type="text/html"/>
    <title>ar-extensions get a little praise</title>
<content type="html">
            &lt;p&gt;Alan Miles found the import functionality of my ar-extensions gem/plugin helpful and he posted about it &lt;a href='http://www.jobwd.com/article/show/31'&gt;here&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;I&#8217;m so glad to hear that ar-extensions is helping Alan and it&#8217;s nice to see that he&#8217;s sharing this usefulness with others via his &lt;a href='http://www.jobwd.com/'&gt;blog&lt;/a&gt;&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://www.continuousthinking.com/">
    <author>
      <name>zdennis</name>
    </author>
    <id>tag:www.continuousthinking.com,2007-12-29:460</id>
    <published>2007-12-29T14:50:00Z</published>
    <updated>2007-12-29T19:51:52Z</updated>
    <link href="http://www.continuousthinking.com/2007/12/29/hotkeys-in-bash" rel="alternate" type="text/html"/>
    <title>&#8984;-k Hotkey in bash, on linux</title>
<content type="html">
            &lt;p&gt;I never thought I would say &#8220;I wish my console acted more like the &lt;span class='caps'&gt;OSX&lt;/span&gt;&#8217;s Terminal.app&#8221;, but the truth is that I said that two days ago. That day my MacBook Pro (MBP) went out of commission due to an accidental overdose of Raspberry Iced Tea. Ever since then I&#8217;ve been plugging away on my Kubuntu box using Yakuake and Emacs23 to develop.&lt;/p&gt;


	&lt;p&gt;I have this obsessive need to clear the terminal all the time during development, primarily when I&#8217;m going to run tests. On my &lt;span class='caps'&gt;MBP I&lt;/span&gt; would just hit &#8984;-k to clear the terminal, but I don&#8217;t have that luxury in Yakuake or any other terminal that I know of. So why not roll my own?&lt;/p&gt;


	&lt;p&gt;After googling around for a while I found this &lt;a href='http://linuxgazette.net/issue55/henderson.html'&gt;article&lt;/a&gt; by Bryan Henderson from the &lt;a href='http://linuxgazette.net'&gt;Linux Gazette&lt;/a&gt; . Even though the article is seven years old it still applies. In addition to this article I also read the man page for readline which has a lot of cool information in it. Since bash relies on readline to do the input processing new doors have opened for what I want to tinker with on my system.&lt;/p&gt;


	&lt;h2&gt;Writing Your &#8984;-k Hotkey&lt;/h2&gt;


	&lt;p&gt;Create a ~/.inputrc file. In that file put the following contents. Now log out and log back in (or fire up a new terminal session):&lt;/p&gt;


&lt;table class='CodeRay'&gt;&lt;tr&gt;
  &lt;td title='click to toggle' class='line_numbers'&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class='code'&gt;&lt;pre&gt;&amp;quot;\ek&amp;quot;:&amp;quot;\C-a\C-kclear\n\C-y&amp;quot;&lt;tt&gt;
&lt;/tt&gt;&amp;quot;\C-x\C-r&amp;quot;: re-read-init-file&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;The first line expresses that I want Meta-k to map to the following set of keystrokes:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;C-a which brings me to the beginning of the line&lt;/li&gt;
		&lt;li&gt;C-k which cuts the line&lt;/li&gt;
		&lt;li&gt;clear which is used to clear the terminal&lt;/li&gt;
		&lt;li&gt;a newline which executes the clear command just as if I typed it and hit enter&lt;/li&gt;
		&lt;li&gt;C-y which pastes what I cut with C-k back onto the terminal&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;And now you have a Terminal.app &#8984;-k hotkey on any system that uses bash. The only difference is that its mapped to Meta-k.&lt;/p&gt;


	&lt;p&gt;The second line is a simple nicety so you can reload your ~/.inputrc file without having to log out and log back in. Just type C-x C-r to reload any changes.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://www.continuousthinking.com/">
    <author>
      <name>zdennis</name>
    </author>
    <id>tag:www.continuousthinking.com,2007-12-22:453</id>
    <published>2007-12-22T22:21:00Z</published>
    <updated>2007-12-23T03:22:45Z</updated>
    <link href="http://www.continuousthinking.com/2007/12/22/make-yourself-write-good-software" rel="alternate" type="text/html"/>
    <title>On Writing Good Software</title>
<content type="html">
            &lt;p&gt;The craft of writing is so similar to that of software development. I recently found this out by reading On Writing Well by William Zinsser. Below are some quotes from the book with commentary on how they apply to the software developer.&lt;/p&gt;


	&lt;h3&gt;You will write only as well as you make yourself write.&lt;/h3&gt;


	&lt;p&gt;Substitute &lt;em&gt;write&lt;/em&gt; with &lt;em&gt;write software&lt;/em&gt; and it remains a truism.&lt;/p&gt;


	&lt;p&gt;Writing software is easy. Writing good software is hard. It takes discipline to become a good software developer. The only way to get there is to write better software today then you wrote yesterday. And the only way to do that is to learn from what you and others have written.&lt;/p&gt;


	&lt;h3&gt;Clutter is the disease of American writing.&lt;/h3&gt;


	&lt;p&gt;The same can be said for writing good software. It&#8217;s very painful to create or find a bloated method or class doing something it shouldn&#8217;t be doing. It&#8217;s even more painful to maintain. Small and simple works wonders within the design of a program.&lt;/p&gt;


	&lt;h3&gt;Strip every sentence to its cleanest components.&lt;/h3&gt;


	&lt;p&gt;Strip every method and class to include only the functionality it needs to do its job. Methods which might be used at some point&#8212;get rid of them. 
Comments which try to explain away complexity or ambiguity&#8212;simplify the code so it&#8217;s readable and remove the them.
Classes which try to do everything&#8212;refactor and pull out things it doesn&#8217;t need to do into their own class or module. 
Clever code&#8212;turn it into simple code. Simplify, simplify, simplify.&lt;/p&gt;


	&lt;h3&gt;You must know what the essential tools are and what job they were designed to do.&lt;/h3&gt;


	&lt;p&gt;A carpenter must know how-to hammer nails and saw wood before he can build a house. Likewise, a developer must know how-to write good code, perform object decomposition and refactor before he can build an application. Other basic tools and skills that a developer should know are: writing testable code, testing and test automation.&lt;/p&gt;


	&lt;h3&gt;Take your stand with conviction.&lt;/h3&gt;


	&lt;p&gt;Care about the software you develop. Stand up for customer involvement. Stand up for short iterations. Stand up for testing. Stand up for quality, even when the deadline is fast approaching, it&#8217;s the best chance you&#8217;ve got for hitting it with working software.&lt;/p&gt;


	&lt;h3&gt;Never hesitate to imitate another writer.&lt;/h3&gt;


	&lt;p&gt;Never hesitate to imitate another developer, especially one that writes better software than you. It will make you better in the process. Find open source projects that exceptional developers have worked on and read that code. How are they attacking a problem? How did they solve it?&lt;/p&gt;


	&lt;p&gt;A while back a coworker asked me if I had read through Mephisto&#8217;s source and I said I had scanned it, but that I didn&#8217;t think it was anything special besides the routing. A few weeks later I started reading the source. Rick Olson, the author of Mephisto, has some great techniques and code tucked away in Mephisto, things that I would be missing out on if my coworker would have never challenged me to read the source. Thanks Drew.&lt;/p&gt;


	&lt;h3&gt;...it&#8217;s hard not to be intimidated by the expertise of the expert.&lt;/h3&gt;


	&lt;p&gt;Ask questions. If you don&#8217;t understand something, ask. If you think it&#8217;s a dumb question, ask. Let the resident expert enlighten you. When they explain something and you still don&#8217;t get it, ask clarifying questions. They didn&#8217;t wake up one day an expert. And neither will you.&lt;/p&gt;


	&lt;h3&gt;Writing is related to character. If your values are sound your writing will be sound.&lt;/h3&gt;


	&lt;p&gt;Developers who have character are exceptional people to work with. They not only write better software, they  inspire those around them to write better software.&lt;/p&gt;


	&lt;h3&gt;Decide what you want to do. Then decide to do it. Then do it.&lt;/h3&gt;


	&lt;p&gt;For all of those &#8220;I want to learn language X&#8221;, &#8220;I want to start learning &lt;span class='caps'&gt;TDD&lt;/span&gt;&#8221;, etc. statements&#8212;start learning language X, start doing &lt;span class='caps'&gt;TDD&lt;/span&gt;.&lt;/p&gt;


	&lt;h3&gt;Think small.&lt;/h3&gt;


	&lt;p&gt;Two immediate thoughts come to mind. First, good object decomposition. Work with simple objects that work with a single responsibility and let the overall system evolve of those simple objects. Second, short iterations over long ones and short stories over full blown specification documents. Thinking small in these regards will help you produce cleaner and simpler code as well as produce the right working features&#8212;sooner.&lt;/p&gt;
          </content>  </entry>
</feed>
