<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>Things I Like</title>
  <id>http://127.0.0.1</id>
  <updated>2009-04-02</updated>
  <author>
    <name>Matt Van Horn</name>
  </author>
  <entry>
    <title>Today's Collected Wisdom</title>
    <link rel="alternate" href="http://127.0.0.1/2012/04/16/collected-wisdom/"/>
    <id>http://127.0.0.1/2012/04/16/collected-wisdom/</id>
    <published>2012-04-16</published>
    <updated>2012-04-16</updated>
    <author>
      <name>Matt Van Horn</name>
    </author>
    <summary type="html">&lt;p&gt;&lt;a href="http://avdi.org/talks/confident-code-railsconf-2011/"&gt;Confident Code&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://judykat.com/ken-judy/estimates-and-desire-to-be-lied-to/"&gt;Estimates and the desire to be lied to&lt;/a&gt;&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;&lt;a href="http://avdi.org/talks/confident-code-railsconf-2011/"&gt;Confident Code&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://judykat.com/ken-judy/estimates-and-desire-to-be-lied-to/"&gt;Estimates and the desire to be lied to&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.evanmiller.org/how-not-to-run-an-ab-test.html"&gt;How Not To Run An A/B Test&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.randsinrepose.com/archives/2011/07/12/bored_people_quit.html"&gt;Bored People Quit&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.commandlinefu.com/commands/browse/sort-by-votes"&gt;Command Line Fu&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;and a classic American cocktail to wash it down with:
&lt;a href="http://oldfashioned101.com/"&gt;Old Fashioned 101&lt;/a&gt;&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Testing as Idiot-Proofing</title>
    <link rel="alternate" href="http://127.0.0.1/2012/04/12/testing-as-idiot-proofing/"/>
    <id>http://127.0.0.1/2012/04/12/testing-as-idiot-proofing/</id>
    <published>2012-04-12</published>
    <updated>2012-04-12</updated>
    <author>
      <name>Matt Van Horn</name>
    </author>
    <summary type="html">&lt;p&gt;I was pairing on some code the other day with a coworker. It was a fairly simple thing, deep cloning an active record object and making sure the object&amp;rsquo;s collections were also cloned&amp;hellip;&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;I was pairing on some code the other day with a coworker. It was a fairly simple thing, deep cloning an active record object and making sure the object&amp;rsquo;s collections were also cloned.&lt;/p&gt;

&lt;p&gt;There was, along the way, a conversation that went something like:&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;My pair: &lt;em&gt;&amp;ldquo;We should write a spec that will break if any new collections are added that don&amp;rsquo;t get cloned&amp;rdquo;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Me: &amp;ldquo;Why?&amp;rdquo;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&amp;ldquo;Because, sometimes the admin tool breaks if we forget to clone a new collection. It&amp;rsquo;s happened before a few times.&amp;rdquo;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&amp;ldquo;Shouldn&amp;rsquo;t that be part of the specs that are written before adding a new collection?&amp;rdquo;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&amp;ldquo;Well, sometimes we forget to do that&amp;rdquo;&lt;/em&gt;&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;So&amp;hellip; we need to write a spec &lt;strong&gt;now&lt;/strong&gt;, to handle adding functionality &lt;strong&gt;later&lt;/strong&gt;, because we know that there&amp;rsquo;s a high probability that &lt;em&gt;&lt;strong&gt;we won&amp;rsquo;t spec the behavior before we add it&lt;/strong&gt;&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;How many general precepts of agile development does this violate?&lt;/p&gt;

&lt;p&gt;Well, first off it is violating &lt;a href="http://c2.com/cgi/wiki?YouArentGonnaNeedIt"&gt;YAGNI&lt;/a&gt;. We might never actually add another collection.&lt;/p&gt;

&lt;p&gt;It&amp;rsquo;s also aiding and abetting a violation of &lt;a href="http://butunclebob.com/ArticleS.UncleBob.TheThreeRulesOfTdd"&gt;TDD&lt;/a&gt;, which is that you would specify the future behavior before adding it.&lt;/p&gt;

&lt;p&gt;It is also introducing a spec which doesn&amp;rsquo;t actually specify how the object behaves &amp;ndash; it is specifying that certain implementation details don&amp;rsquo;t change.&lt;/p&gt;

&lt;p&gt;And lastly, it is violating the idea that &lt;a href="http://blog.stevensanderson.com/2009/08/24/writing-great-unit-tests-best-and-worst-practises/"&gt;there should only be one reason for a test to fail&lt;/a&gt;. In this case the test could fail because we added a collection that needed to be cloned and wasn&amp;rsquo;t, or because we added a collection that didn&amp;rsquo;t need to be cloned, in which case our spec is now wrong. Since we don&amp;rsquo;t know the nature of our future hypothetical collection, it is probably wrong to specify it&amp;rsquo;s behavior now.&lt;/p&gt;

&lt;p&gt;So given the situation as described, what is the right thing to test?&lt;/p&gt;

&lt;p&gt;We&amp;rsquo;re not going to specify that all collections should be cloned, since it is already known that not all collections need to be treated the same way.&lt;/p&gt;

&lt;p&gt;My preferred solution is to say we will write the specs for the new collection when we add it &amp;ndash; but that does not address my pair&amp;rsquo;s concern that the team doesn&amp;rsquo;t always test drive new code.&lt;/p&gt;

&lt;p&gt;My second favorite solution is that there should be an integration test on the admin tool that would catch any breakage.&lt;/p&gt;

&lt;p&gt;However, I&amp;rsquo;m genuinely curious about this issue and how other people are dealing with it. Do you use your tests to prop up coding practices that are undisciplined? Or do you accept that the more you try to idiot-proof, the stronger the idiocy you encounter?&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>True Stories of BDD</title>
    <link rel="alternate" href="http://127.0.0.1/2012/04/09/true-stories-of-bdd/"/>
    <id>http://127.0.0.1/2012/04/09/true-stories-of-bdd/</id>
    <published>2012-04-09</published>
    <updated>2012-04-09</updated>
    <author>
      <name>Matt Van Horn</name>
    </author>
    <summary type="html">&lt;p&gt;I&amp;rsquo;ve built up a healthy amount of cynicism working on the web for the last decade and a half, and it&amp;rsquo;s time to let some of it out. I just launched a little side project called &amp;ldquo;&lt;a href="http://truestoriesofbdd.com"&gt;True Stories of BDD&lt;/a&gt;.&amp;rdquo;&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;I&amp;rsquo;ve built up a healthy amount of cynicism working on the web for the last decade and a half, and it&amp;rsquo;s time to let some of it out. I just launched a little side project called &amp;ldquo;&lt;a href="http://truestoriesofbdd.com"&gt;True Stories of BDD&lt;/a&gt;.&amp;rdquo;&lt;/p&gt;

&lt;p&gt;It&amp;rsquo;s a place to collect and share the real story behind the &amp;ldquo;feature&amp;rdquo; you were asked to build.&lt;/p&gt;

&lt;p&gt;I&amp;rsquo;m not sure how many people feel the same way I do, but I see a lot of stupid, evil shit happening on the web every single day. But I&amp;rsquo;m sure I don&amp;rsquo;t see all of it &amp;ndash; so go over to &lt;a href="http://truestoriesofbdd.com"&gt;http://truestoriesofbdd.com&lt;/a&gt; and share the ones I don&amp;rsquo;t know about yet.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Carrots and Sticks</title>
    <link rel="alternate" href="http://127.0.0.1/2012/03/22/carrots-and-sticks/"/>
    <id>http://127.0.0.1/2012/03/22/carrots-and-sticks/</id>
    <published>2012-03-22</published>
    <updated>2012-03-22</updated>
    <author>
      <name>Matt Van Horn</name>
    </author>
    <summary type="html">&lt;h2&gt;&lt;em&gt;&amp;ldquo;I&amp;rsquo;m not sure if management wants to use these numbers as a carrot or a stick&amp;rdquo;&lt;/em&gt;&lt;/h2&gt;

&lt;p&gt;When our engineering director said that to me, in my head I heard the &lt;a href="http://www.youtube.com/watch?v=7J-y2rFfny8"&gt;red
alert sound&lt;/a&gt;
from the original Star Trek&amp;hellip;&lt;/p&gt;
</summary>
    <content type="html">&lt;h2&gt;&lt;em&gt;&amp;ldquo;I&amp;rsquo;m not sure if management wants to use these numbers as a carrot or a stick&amp;rdquo;&lt;/em&gt;&lt;/h2&gt;

&lt;p&gt;When our engineering director said that to me, in my head I heard the &lt;a href="http://www.youtube.com/watch?v=7J-y2rFfny8"&gt;red
alert sound&lt;/a&gt;
from the original Star Trek. It was my WTF detector going off, again.&lt;/p&gt;

&lt;p&gt;The numbers we were discussing were potential metrics for measuring the
engineering teams performance. That&amp;rsquo;s right, once again a small management
team came up with the brilliant idea of &lt;a href="http://alistair.cockburn.us/Programmer+productivity+discussion+on+the+APM+list+Oct+2008"&gt;trying&lt;/a&gt; to &lt;a href="http://www.joelonsoftware.com/news/20020715.html"&gt;measure&lt;/a&gt; programmer
&lt;a href="http://c2.com/cgi/wiki?LinesOfCode"&gt;productivity&lt;/a&gt;. Surely, this little startup team could do what no one in the
past 50 years had been able to manage. And once they had their measurements,
they were going to be able to &lt;a href="http://www.youtube.com/watch?v=KUqo5tPZjrM&amp;amp;feature=related"&gt;motivate their team&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Because that is what
&lt;a href="http://www.joelonsoftware.com/articles/fog0000000070.html"&gt;carrots&lt;/a&gt; and &lt;a href="http://en.wikipedia.org/wiki/Theory_X_and_theory_Y#Theory_X"&gt;sticks&lt;/a&gt; are for, right?&lt;/p&gt;

&lt;p&gt;For motivating &lt;del&gt;donkeys&lt;/del&gt; programmers.&lt;/p&gt;

&lt;p&gt;The numbers they plan to use are irrelevant. For the record, it looks like
we&amp;rsquo;re leaning towards Ron Jeffries &amp;lsquo;&lt;a href="http://xprogramming.com/xpmag/jatRtsMetric"&gt;running, tested features&lt;/a&gt;.&amp;rsquo; This is just as
likely to be &lt;a href="http://dilbert.com/strips/comic/1995-11-13/"&gt;gamed&lt;/a&gt; as any other KPI, and was originally intended as a window
providing transparency, not a carrot or a stick.&lt;/p&gt;

&lt;p&gt;The real problem is the idea that you are going to be able to move that number
through some kind of &lt;a href="http://jamesshore.com/Blog/The-Stunning-Truth.html"&gt;reward/punishment program&lt;/a&gt;. Software developers just don&amp;rsquo;t
work like that. Study after study has shown that programmers are intrinsically
motivated to a very high degree. This means they like working, for rewards
that are linked to the work itself.&lt;/p&gt;

&lt;p&gt;Another thing about programmers is that they are creative. In Daniel Pink&amp;rsquo;s
book &amp;ldquo;&lt;a href="http://www.danpink.com/drive"&gt;Drive&lt;/a&gt;&amp;rdquo; he talks about how external rewards actually lead to poorer
performance on creative tasks. &lt;a href="http://www.alfiekohn.org/managing/fbrftb.htm"&gt;Alfie Kohn&lt;/a&gt; wrote that &amp;ldquo;at least two dozen
studies over the last three decades have conclusively shown that people who
expect to receive a reward for completing a task or for doing that task
successfully simply do not perform as well as those who expect no reward at
all.&amp;rdquo;[1]&lt;/p&gt;

&lt;p&gt;So if this kind of approach to motivating a development team is all wrong &amp;ndash;
what is the right way to motivate them?&lt;/p&gt;

&lt;p&gt;Like any good developer, I&amp;rsquo;m going to start by unpacking the requirement a
little. Why would management want to motivate the development team? The simple
answer is that they want to get more done. This assumes on the face of it that
the team is not delivering at 100% capacity. A second less obvious assumption
is that whatever the delta between capacity and output, it is related to the
developer deciding not to work hard, and not the management style, working
conditions, or any other factor.&lt;/p&gt;

&lt;p&gt;The minute an intelligent team member sees you discussing carrots and sticks,
the clear message they'l take away is that you think &amp;ldquo;the team is an
underperforming bunch of slackers.&amp;rdquo; This is not likely to motivate them to
deliver incredible work.&lt;/p&gt;

&lt;p&gt;I think the biggest impediment to programmer motivation is the lack of an
interesting problem. Paul Graham, in &lt;a href="http://www.paulgraham.com/gh.html"&gt;an essay on great hackers&lt;/a&gt;, talked about nasty little problems being ones
where you don&amp;rsquo;t learn anything. When your day is filled with problems like
that, it is like the life force is being sucked out of you. A common problem
with managing developers is presenting them with a solution to implement,
rather than a problem to solve.&lt;/p&gt;

&lt;p&gt;The difference between interesting and nasty problems is often one of framing.
Suppose you&amp;rsquo;re looking to boost gross revenue to look good to investors.&lt;/p&gt;

&lt;p&gt;If you have a decent team, and you tell them &amp;ldquo;We need to increase top line
revenue&amp;rdquo; then you are likely to get back a lot of questions on how you are
measuring revenue, a bunch of suggestions on how to improve it, ways to
identify your big-spending customers, reports on your best selling products,
and potential tests for verifying whatever implementations are decided upon.&lt;/p&gt;

&lt;p&gt;If you tell them &amp;ldquo;give out some incentive credit to all our members, and get
it done by Wednesday&amp;rdquo; you&amp;rsquo;ve reduced it from a potentially interesting
problem, to several nasty little problems, involving your legacy accounting
and purchase systems.&lt;/p&gt;

&lt;p&gt;Once your team has an interesting problem, the next factor affecting
productivity is giving them the autonomy to solve it. Good teams need autonomy
over what they do, when and where they do it, who they do it with and how they
do it. Presume that your team wants to succeed, and that they want to get as
much done as soon as possible. Then get out of their way and let them do it.&lt;/p&gt;

&lt;p&gt;Of course, life is not perfect, and there will always be things that limit how
much much freedom the team has. I think of this as friction in the system.
When you have parts that rub together, you need to compensate by adding
lubrication. For developer teams this can take several forms. My favorite is
learning opportunities. Have a budget for conferences, big and small, near and
far. When a team member is getting down because of the friction, send them to
a conference that they want to go to. Great programmers get recharged by
learning. Other kinds of recognition are nice too &amp;ndash; take a developer to
dinner, and talk to him or her. You&amp;rsquo;ll likely get some insights into what
makes them tick, and the recognition of effort will not be missed by them.
Personal recognition of effort is worth much more than money to a good
developer (once a certain baseline compensation is met &amp;ndash; we don&amp;rsquo;t just work for praise).&lt;/p&gt;

&lt;p&gt;In short, treat your developers as the creative human beings that they are,
and not as beasts of burden that can be motivated by carrots and sticks.&lt;/p&gt;

&lt;p&gt;Because if they really were mules, they might wind up kicking you in the head.&lt;/p&gt;

&lt;p&gt;[1] Harvard Business Review Sept/Oct, 1993&lt;/p&gt;

&lt;h3&gt;Update:&lt;/h3&gt;

&lt;p&gt;This post on &lt;a href="http://regenerate.posterous.com/weaponized-metrics"&gt;Weaponized Metrics&lt;/a&gt; is another good take on the subject.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Gimme Cookie!</title>
    <link rel="alternate" href="http://127.0.0.1/2012/02/13/gimme-cookie/"/>
    <id>http://127.0.0.1/2012/02/13/gimme-cookie/</id>
    <published>2012-02-13</published>
    <updated>2012-02-13</updated>
    <author>
      <name>Matt Van Horn</name>
    </author>
    <summary type="html">&lt;p&gt;I&amp;rsquo;m using signed permanent cookies to track users in my app, and sometimes it&amp;rsquo;s
nice to be able to be able to set them in the browser manually. I&amp;rsquo;m using &amp;ldquo;Edit This Cookie&amp;rdquo;&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;I&amp;rsquo;m using signed permanent cookies to track users in my app, and sometimes it&amp;rsquo;s
nice to be able to be able to set them in the browser manually. I&amp;rsquo;m using &amp;ldquo;Edit This Cookie&amp;rdquo;
in Chrome to handle this, but it was a bit tricky to figure out how to get the
encrypted value of the cookie to manually set it. Well, for future reference, I&amp;rsquo;ll put it here.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;cookie_jar = ActionDispatch::Cookies::CookieJar.new(Rails.configuration.secret_token)
cookie_jar.permanent.signed[:foo] = 'bar'
cookie_jar[:foo] # =&amp;gt; "BAhpBg==--8e5eb732858427af92a0c1eeb4f81b276a775fb8"
&lt;/code&gt;&lt;/pre&gt;
</content>
  </entry>
  <entry>
    <title>Using Webmock with Cucumber for Robust Integration Tests</title>
    <link rel="alternate" href="http://127.0.0.1/2012/02/09/cucumber-webmock/"/>
    <id>http://127.0.0.1/2012/02/09/cucumber-webmock/</id>
    <published>2012-02-09</published>
    <updated>2012-02-09</updated>
    <author>
      <name>Matt Van Horn</name>
    </author>
    <summary type="html">&lt;p&gt;I decided that it would be a good idea to make my integration tests reflect as
much of the real-world setup of my app as possible. This includes hitting 3rd
party APIs over the internet&amp;hellip;&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;I decided that it would be a good idea to make my integration tests reflect as
much of the real-world setup of my app as possible. This includes hitting 3rd
party APIs over the internet.
While this can be slow, it is nice to check
assertions against actual responses, in case an API change breaks something.&lt;/p&gt;

&lt;p&gt;The drawback to this was that I could no longer rely on all my cucumber
features passing while I was coding on the train, or in a park, for example.&lt;/p&gt;

&lt;p&gt;Mocking the responses would work, but I didn&amp;rsquo;t want to have 2 sets of
scenarios, just for offline and online testing. I also wanted to run the same
assertions regardless of where I was.&lt;/p&gt;

&lt;p&gt;So I came up with the following pattern, which tries to use a real connection,
and falls back to a stub when a connection can&amp;rsquo;t be made.&lt;/p&gt;

&lt;p&gt;First, I use curl to record an actual response for Webmock to send.
The -i option is necessary to include the headers.
(The API I was using in this example accepts posts of json, and returns json responses.)&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;curl -iX POST -d @request.json http://www.api.example.com/do_something &amp;gt; do_something_response.json
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Next, I set up my API stubs, in support/fake_api.rb. Note the instance variable in the After block &amp;ndash; that a key part that we will return to.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;module FakeApi
  def stub_api
    canned_response  = File.read(File.join(Rails.root, 'features', 'support', 'fixtures', 'api', 'do_something_response.json'))

    stub_request(:post, "http://www.api.example.com/do_something").to_return( canned_response )
  end
end

World(FakeApi)

After do
  @api_stubbed = false
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Lastly, I write my cucumber step that deals with the API&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;When /^I do something at an external API endpoint$/ do
  api = MyApi.new
  begin
    result = api.do_something
    result.should be_something

  rescue SocketError =&amp;gt; e
    unless @api_stubbed
      stub_api
      @api_stubbed = true
      retry
    end
    fail "Can't connect to API (real OR fake)"
  end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;So what we do here is try the real API, and if we cannot connect, we retry the
begin-rescue block using the stubbed version. We use the instance variable as
a flag to prevent an infinite loop, and we use the After block to ensure that
the next scenario starts with a real attempt again.&lt;/p&gt;

&lt;p&gt;You might want to adjust this, perhaps omitting the After block cleanup to assume that
if the network isn&amp;rsquo;t there for one test, it won&amp;rsquo;t be there for the duration of the run.&lt;/p&gt;

&lt;p&gt;You could also move the flag setting into the method that does the stubbing.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>My Development Setup</title>
    <link rel="alternate" href="http://127.0.0.1/2012/01/30/my-development-setup/"/>
    <id>http://127.0.0.1/2012/01/30/my-development-setup/</id>
    <published>2012-01-30</published>
    <updated>2012-01-30</updated>
    <author>
      <name>Matt Van Horn</name>
    </author>
    <summary type="html">&lt;p&gt;I was working on the CSS for this blog, and reading an older post, when I realized how much my daily development setup has changed. Almost everything has changed from a couple of years ago, and I thought it might be nice to share how I get things done, since IMHO it is a pretty nice way to work&amp;hellip;&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;I was working on the CSS for this blog, and reading an older post, when I realized how much my daily development setup has changed. Almost everything has changed from a couple of years ago, and I thought it might be nice to share how I get things done, since IMHO it is a pretty nice way to work.&lt;/p&gt;

&lt;h2&gt;Hardware&lt;/h2&gt;

&lt;p&gt;This has changed the least. I&amp;rsquo;m still tooling away on my 2008 MacBook Pro, although I did drop in a 500GB drive. I will say this about Apple products &amp;ndash; they stay useful far longer than their counterparts from Acer and Dell.&lt;/p&gt;

&lt;h2&gt;Editor&lt;/h2&gt;

&lt;p&gt;Still using Textmate, although I am now starting to explore alternatives. Rubymine (which I use at work) is a total pain to work with, so right now I&amp;rsquo;m leaning towards biting the bullet and learning Vim, unless another decent editor pops up.&lt;/p&gt;

&lt;h2&gt;VCS&lt;/h2&gt;

&lt;p&gt;Github. Is there really anything that needs to be said about that?&lt;/p&gt;

&lt;h2&gt;Ruby &amp;amp; Rails&lt;/h2&gt;

&lt;p&gt;I&amp;rsquo;m currently using Ruby 1.9.2-p290, with RVM. My most recent project is Rails 3.1.2, but I will probably upgrade to 3.2 within the month.&lt;/p&gt;

&lt;h2&gt;Development App Server&lt;/h2&gt;

&lt;p&gt;I&amp;rsquo;m using Pow, from 37 signals, which although it has some drawbacks with regard to SSL, is still pretty nice to use locally. I got sick of tweaking Apache and Passenger config files all the time.&lt;/p&gt;

&lt;h2&gt;Testing Tools&lt;/h2&gt;

&lt;p&gt;Cucumber, RSpec 2.8 &amp;amp; Capybara for the basics.
Fabrication as a factory for test data
NullDb to ensure that my unit tests are actually unit tests.
Shoulda Matchers, Email Spec, and Timecop for some miscellaneous conveniences.&lt;/p&gt;

&lt;h2&gt;Extras&lt;/h2&gt;

&lt;p&gt;I use Guard, with guard-spork, guard-rspec, guard-cucumber, guard-bundler, and  guard-pow. This keeps my tests running quickly and continuously.&lt;/p&gt;

&lt;p&gt;I&amp;rsquo;m also using TDDium to offload my CI work.  There&amp;rsquo;s a post-receive hook set at Github, and they push to Heroku for me when the build is green. Pain-free continuous deployment, yay!&lt;/p&gt;

&lt;p&gt;I&amp;rsquo;m also using Pivotal Tracker and pickler to coordinate my development priorities. With the Pivotal iPhone app, I can write stories on the train, and then pickler-pull them into my test suite to do BDD.&lt;/p&gt;

&lt;p&gt;That&amp;rsquo;s about it &amp;ndash; some nice tools to keep me focused on writing code instead of struggling to configure a bunch of stuff on my machine. After all, who likes shaving yaks?&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Set Up A Rails 3.1 App On Heroku Cedar, Ruby 1.9, with Assets Precompiled on the Server</title>
    <link rel="alternate" href="http://127.0.0.1/2012/01/07/heroku-cedar-assets-ruby-1-9/"/>
    <id>http://127.0.0.1/2012/01/07/heroku-cedar-assets-ruby-1-9/</id>
    <published>2012-01-07</published>
    <updated>2012-01-07</updated>
    <author>
      <name>Matt Van Horn</name>
    </author>
    <summary type="html">&lt;p&gt;Someone told me the other day that they had some trouble with this, so here is a quick guide to getting set up on Heroku.
This approach is going to compile assets during slug compilation, which I think is the best of the available options&amp;hellip;&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;Someone told me the other day that they had some trouble with this, so here is a quick guide to getting set up on Heroku.
This approach is going to compile assets during slug compilation, which I think is the best of the available options.&lt;/p&gt;

&lt;h2&gt;Step 1&lt;/h2&gt;

&lt;p&gt;set up a new Rails app&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ rails new placepanda --database=postgresql --skip-test-unit&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;Step 2&lt;/h2&gt;

&lt;p&gt;put the app into a Git repo&lt;/p&gt;

&lt;p&gt;First, I like to add the following two lines to .gitignore:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;config/database.yml
.DS_Store
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Heroku makes it own database connection, and I hate those .DS_Store files cluttering up my repository.
Now we can get on with the commit.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ git init
$ git add .
$ git commit -m "my brand new Rails app"
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Step 3&lt;/h2&gt;

&lt;p&gt;Deploy to Heroku as soon as possible. This way we can deal with issues as they arise, not after they accumulate and become hard to track down.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ heroku create --stack cedar
$ git push heroku master
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now we can look at the app&amp;rsquo;s status&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ heroku ps

Process  State       Command
-------  ----------  ---------------------------------
web.1    up for 10s  bundle exec rails server -p $PORT

$ heroku logs

2012-01-07T18:35:28+00:00 heroku[api]: Add-on add logging:basic by user@example.com
2012-01-07T18:35:28+00:00 heroku[api]: Release v2 created by user@example.com
2012-01-07T18:36:18+00:00 heroku[slugc]: Slug compilation started
2012-01-07T18:37:08+00:00 heroku[api]: Add-on add shared-database:5mb by user@example.com
2012-01-07T18:37:08+00:00 heroku[api]: Release v3 created by user@example.com
2012-01-07T18:37:08+00:00 heroku[api]: Config add RAILS_ENV, LANG, PATH, RACK_ENV, GEM_PATH by user@example.com
2012-01-07T18:37:08+00:00 heroku[api]: Release v4 created by user@example.com
2012-01-07T18:37:11+00:00 heroku[api]: Deploy cc64c78 by user@example.com
2012-01-07T18:37:11+00:00 heroku[api]: Release v5 created by user@example.com
2012-01-07T18:37:11+00:00 heroku[web.1]: State changed from created to starting
2012-01-07T18:37:15+00:00 heroku[web.1]: Starting process with command `bundle exec rails server -p 40738`
2012-01-07T18:37:18+00:00 heroku[slugc]: Slug compilation finished
2012-01-07T18:37:20+00:00 app[web.1]: [2012-01-07 18:37:20] INFO  WEBrick 1.3.1
2012-01-07T18:37:20+00:00 app[web.1]: [2012-01-07 18:37:20] INFO  ruby 1.9.2 (2011-07-09) [x86_64-linux]
2012-01-07T18:37:20+00:00 app[web.1]: [2012-01-07 18:37:20] INFO  WEBrick::HTTPServer#start: pid=1 port=40738
2012-01-07T18:37:21+00:00 heroku[web.1]: State changed from starting to up
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Step 4&lt;/h2&gt;

&lt;p&gt;I use HAML, so I am installing the haml-rails gem, and so we can check if the assets precompilation on deploy works,
I am also building out a minimal app with a HAML view, an image, and a SASS stylesheet. I&amp;rsquo;ve also installed RSpec, and Thin
as the webserver at this point, because that&amp;rsquo;s just how I roll.
&lt;a href="http://github.com/mattvanhorn/placepanda/commits"&gt;You can see the actual commits here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now I deploy to Heroku again.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ git push heroku master
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And it all seems to be working.&lt;/p&gt;

&lt;p&gt;I will update this post a little later, as I add more real-world features to the app, and see if we can&amp;rsquo;t keep everything working and happy.&lt;/p&gt;

&lt;h2&gt;Step 5&lt;/h2&gt;

&lt;p&gt;O.K. &amp;ndash; I&amp;rsquo;m back now, and installing the Compass gem and framework.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ compass init rails . --syntax sass
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;edit your Gemfile to include&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;gem "compass", "&amp;gt;= 0.12.alpha.3"
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;in the :assets group.&lt;/p&gt;

&lt;p&gt;Now, we&amp;rsquo;ve got to move the sass files to where Rails expects them to be, and
also to rename them (to include the &amp;lsquo;.css&amp;rsquo;) for the assets pipeline.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ mv app/stylesheets/screen.sass app/assets/stylesheets/screen.css.sass
$ mv app/stylesheets/print.sass app/assets/stylesheets/print.css.sass
$ mv app/stylesheets/ie.sass app/assets/stylesheets/ie.css.sass
$ rm -rf app/stylesheets
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Also, we need to update the app/config/application.rb to include:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;config.assets.precompile &amp;lt;&amp;lt; /^((.*?)\/)?(?!_)[^\/]*$/
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;(The idea is that this regex prevents the pre-compilation of partials, because if that is attempted, it
will fail with errors like &amp;ldquo;Undefined mixin &amp;lsquo;blueprint-form&amp;rsquo;&amp;rdquo;)&lt;/p&gt;

&lt;p&gt;I usually put the above line with the regex after the line:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;config.assets.enabled = true
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Also, in order to use Compass properly, we need to rearrange our stylesheet folder a bit. I make a folder called&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;app/assets/stylesheets/application
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;and I put all my custom stylesheets in there.&lt;/p&gt;

&lt;p&gt;Then I edit app/assets/stylesheets/application.css, and change from:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;*= require_tree .
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;to:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;*= require_tree ./application
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This allows the compass stylesheets to render and be included separately, which I prefer.
I wind up with one stylesheet for the framework, and one for the rest of my app. My layout head section looks like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;%head
  %title Placepanda
  = stylesheet_link_tag 'screen.css', :media =&amp;gt; 'screen, projection'
  = stylesheet_link_tag 'print.css', :media =&amp;gt; 'print'
  /[if IE]
    = stylesheet_link_tag 'ie.css', :media =&amp;gt; 'screen, projection'
  = stylesheet_link_tag    "application"
  = javascript_include_tag "application"
  = csrf_meta_tags
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Naturally, you might want to do this all in one big file, in which case, I suggest not using the folder structure above, and instead
you can just edit the application css to require the files in the right order, as the default alphabetical order is usually non-optimal.
It would probably end up like:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;*= require_self
* THE COMPASS STYLES
*= require screen
*
* YOUR STYLES THAT NEED TO BE ORDERED
*= require my_stylesheet
*= require my_other_stylesheet
*
* EVERYTHING ELSE IN THE STYLESHEETS FOLDER
*= require_tree .
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now we can deploy to Heroku again&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ git push heroku master
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;and everything should still be peachy.&lt;/p&gt;

&lt;h2&gt;Step 6&lt;/h2&gt;

&lt;p&gt;Installing blueprint.&lt;/p&gt;

&lt;p&gt;If you&amp;rsquo;re following along with the commits on github, at this point, I&amp;rsquo;ve added my basic app functions, and
I just want to style my static pages using blueprint. (The procedure will be similar for other frameworks)&lt;/p&gt;

&lt;p&gt;First in my app directory:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ compass install blueprint
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And once again we have to move the files that get created into our assets folder and rename them to &amp;lsquo;some-name.css.sass&amp;rsquo;&lt;/p&gt;

&lt;p&gt;After that, we can just deploy again, and everything is still working.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ git push heroku master
&lt;/code&gt;&lt;/pre&gt;
</content>
  </entry>
  <entry>
    <title>Cleaning Up After Paperclip Cucumber Tests</title>
    <link rel="alternate" href="http://127.0.0.1/2011/11/24/cucumber-paperclip-cleanup/"/>
    <id>http://127.0.0.1/2011/11/24/cucumber-paperclip-cleanup/</id>
    <published>2011-11-24</published>
    <updated>2011-11-24</updated>
    <author>
      <name>Matt Van Horn</name>
    </author>
    <summary type="html">&lt;p&gt;I love using cucumber for acceptance testing, but recently on a personal project
I noticed that I was accumulating files in my public/system directory every time&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;I love using cucumber for acceptance testing, but recently on a personal project
I noticed that I was accumulating files in my public/system directory every time
a paperclip step was executed. A little googling got me to
&lt;a href="http://blog.ardes.com/2009/8/4/that-cuking-paperclip"&gt;a solution&lt;/a&gt;, which I&amp;rsquo;ve
adapted below for Rails 3.1&lt;/p&gt;

&lt;p&gt;In features/support/env.rb:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;require 'paperclip'

module Paperclip::Interpolations 
  alias_method :orig_attachment, :attachment 
  def attachment(att, style) 
    "cucumber/" + orig_attachment(att, style) 
  end 
end

After do 
  `rm -rf #{"#{Rails.root}/public/system/cucumber"}`  #remove paperclip files
end
&lt;/code&gt;&lt;/pre&gt;
</content>
  </entry>
  <entry>
    <title>Story Anti-Patterns 1</title>
    <link rel="alternate" href="http://127.0.0.1/2011/11/06/story-anti-patterns-one/"/>
    <id>http://127.0.0.1/2011/11/06/story-anti-patterns-one/</id>
    <published>2011-11-06</published>
    <updated>2011-11-06</updated>
    <author>
      <name>Matt Van Horn</name>
    </author>
    <summary type="html">&lt;p&gt;This is the first in a series, where I describe some common mistakes made when trying to run an agile team&amp;hellip;&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;This is the first in a series, where I describe some common mistakes made when trying to run an agile team.&lt;/p&gt;

&lt;h1&gt;Anti-Pattern 1 &amp;ndash; Visual design isn&amp;rsquo;t the whole story.&lt;/h1&gt;

&lt;h2&gt;Example 1 &amp;ndash; &lt;em&gt;the team is using Pivotal Tracker as a to-do list&lt;/em&gt; &lt;/h2&gt;

&lt;blockquote&gt;&lt;h3&gt;Typical Story&lt;/h3&gt;

&lt;blockquote&gt;&lt;p&gt;Add styling to product page.&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;In teams that have stories like this, there are probably a few others that look like:&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;Clicking on product title directs user to to product page&lt;/p&gt;

&lt;p&gt;Product page shows detailed description and product specs&lt;/p&gt;

&lt;p&gt;User clicks buy now button on product page
    &lt;/p&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;

&lt;h2&gt;Example 2 &amp;ndash; &lt;em&gt;all the business value attached to the wrong thing for the wrong role&lt;/em&gt;&lt;/h2&gt;

&lt;blockquote&gt;&lt;h3&gt;Typical Story&lt;/h3&gt;

&lt;blockquote&gt;&lt;p&gt;As the designer&lt;br/&gt;
I want a well-designed product page&lt;br/&gt;
In order to encourage purchases&lt;/p&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;

&lt;p&gt;Here, the team is trying to find the value, but they are looking in the wrong place for it.
This is an example of thinking about &amp;ldquo;what do I want the user to do?&amp;rdquo; instead of &amp;ldquo;what does the user want to do?&amp;rdquo;&lt;/p&gt;

&lt;h3&gt;Forces leading to the use of this anti-pattern:&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The team is using Pivotal Tracker (or their equivalent tool) to track to-do items, instead of tracking the stakeholder conversations it was meant for.&lt;/li&gt;
&lt;li&gt;The visual designers are not working on the same team as the software developers (stovepiping).&lt;/li&gt;
&lt;li&gt;UI design and graphic asset production is being done in a big-design-up-front fashion.&lt;/li&gt;
&lt;li&gt;The user is lacking representation in the agile process&lt;/li&gt;
&lt;li&gt;The development team feels pressured to put points on the board.&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;Problems caused by this anti-pattern:&lt;/h3&gt;

&lt;p&gt;When this pattern becomes common, you wind up with an application that spends most of its time not ready for deployment.
If the demo gets rescheduled two weeks earlier, there&amp;rsquo;s a good chance you won&amp;rsquo;t be able to show many features in a complete state.
Punchlists that need to be completed in order to deploy is the opposite of agile practice.&lt;/p&gt;

&lt;p&gt;Another issue this pattern leads to is programmers waiting on designers, or vice versa. Again &amp;ndash; not very agile. This fosters
an us-vs-them mentality that is inimical to getting things done.&lt;/p&gt;

&lt;p&gt;Lastly, when software development is iterating, but UI design and/or production is handled as a page-at-a-time waterfall,
the mismatch leads to gross inefficiencies in how the look &amp;amp; feel gets implemented &amp;ndash; bloated CSS, endless tweaking of styles, etc.&lt;/p&gt;

&lt;h2&gt;Solutions:&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Use story templates that enforce business value consideration&lt;/li&gt;
&lt;li&gt;Use iterative development in ui design as well as programming&lt;/li&gt;
&lt;li&gt;Designers and developers work together on the same stories until they are done.&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;Using better story templates&lt;/h3&gt;

&lt;p&gt;Story templates need to show three important things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Business &lt;strong&gt;value&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;role&lt;/strong&gt; that benefits from the value&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;feature&lt;/strong&gt; necessary to provide the value&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;The above story could become:&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;In order to &lt;em&gt;&lt;strong&gt;more easily make a purchase decision&lt;/strong&gt;&lt;/em&gt;&lt;br/&gt;
&lt;em&gt;&lt;strong&gt;the customer&lt;/strong&gt;&lt;/em&gt;&lt;br/&gt;
wants to see &lt;em&gt;&lt;strong&gt;a well-designed product details page&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Given an existing product named &amp;ldquo;Foo"&lt;br/&gt;
When the customer visits the product page for "Foo"&lt;br/&gt;
Then the customer should see the product details for "Foo"&lt;br/&gt;
And the page should be styled according to the current design specifications for the product page&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;Notice that there are no implementation details exposed in the story or scenario. This prevents brittle tests.
The feature is written from a user&amp;rsquo;s point of view, and doesn&amp;rsquo;t concern itself with what the developers consider details,
or what the designers mean by well-designed.&lt;/p&gt;

&lt;p&gt;If what is meant by &amp;ldquo;product details&amp;rdquo; changes, this is a change in requirements that will correctly force a change in
the implementation of the step. However, the feature itself does not need to change, since it is value-driven and focused on the
user&amp;rsquo;s needs. Ideally, what is meant by product details should be centralized, and changed only in one place to update all
the features that rely on it.&lt;/p&gt;

&lt;p&gt;The last step could be implemented using matchers for such ui requirements as:
All headlines should be blue, and all body copy should be 16px high. This then becomes a reusable step that can
help catch look &amp;amp; feel flaws on other pages, as well.&lt;/p&gt;

&lt;p&gt;It can be argued that tests for this sort of thing are excessive, since look and feel changes so often, and maintaining these
tests creates a lot of overhead. I think that perhaps the overhead would encourage more consideration of changes, since the actual
cost of doing them correctly becomes exposed. The alternative is to not care whether the look and feel is correct &amp;ndash; if you do care,
there is work to be done to ensure correctness, whether it is automated or (like most teams) manually reviewed by designers working
over the shoulders of developers, nearly doubling the overhead costs.&lt;/p&gt;

&lt;h3&gt;Iterative UI design&lt;/h3&gt;

&lt;p&gt;There&amp;rsquo;s not enough space or time to go into a full discussion of agile UI development here. I wish there were more resources
online, but unfortunately there is not a lot written on the topic. Briefly, though, UI development should follow many of
the same principles as software development. The UI design can and should be developed in an organic, iterative fashion.
Stories should be deployed as they are completed &amp;ndash; in this system you&amp;rsquo;ll never hear &amp;ldquo;the story is done, but we can&amp;rsquo;t deploy it until
the UI is finished.&amp;rdquo;&lt;/p&gt;

&lt;h3&gt;No More Us-And-Them&lt;/h3&gt;

&lt;p&gt;The UI design team should be an integral part of the development team, and should pair with software engineers to deliver stories. The
pairs can work on establishing what UI elements are needed for a given story, and can add chores to create the actual assets, while using
placeholders in development. Programmer-Designer pairs can go from paper wireframes to HTML prototype to working application code, together.
The agile principle of YAGNI will be critical to making this system work. Design development can also benefit from DRY thinking.&lt;/p&gt;
</content>
  </entry>
</f
