<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Codeulate. &#187; coding</title>
	<atom:link href="http://codeulate.com/category/coding/feed/" rel="self" type="application/rss+xml" />
	<link>http://codeulate.com</link>
	<description></description>
	<lastBuildDate>Tue, 24 Apr 2012 23:40:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Don&#8217;t get blocked</title>
		<link>http://codeulate.com/2011/09/dont-get-blocked/</link>
		<comments>http://codeulate.com/2011/09/dont-get-blocked/#comments</comments>
		<pubDate>Tue, 27 Sep 2011 03:35:19 +0000</pubDate>
		<dc:creator>Ben Orenstein</dc:creator>
				<category><![CDATA[coding]]></category>

		<guid isPermaLink="false">http://codeulate.com/?p=390</guid>
		<description><![CDATA[Every day at our stand-up, each person shares what they did the day before, what they plan to do today, and, critically, whether or not they&#8217;re blocked. Blocked is a crappy place to be. It means you&#8217;re trying to get something done but can&#8217;t. Current velocity: zero. I&#8217;ve noticed something about programmers I admire: they&#8217;re [...]]]></description>
			<content:encoded><![CDATA[<p>Every day at our stand-up, each person shares what they did the day before, what they plan to do today, and, critically, whether or not they&#8217;re blocked.</p>
<p>Blocked is a crappy place to be. It means you&#8217;re trying to get something done but can&#8217;t. Current velocity: zero.</p>
<p>I&#8217;ve noticed something about programmers I admire: they&#8217;re extremely good at not getting blocked. </p>
<p>Some time ago I spent three days trying to get a feature working. I was blocked, and bad. Finally, I took a break and went to work on something else. The next day at standup, a colleague mentioned implementing that same feature, and then then going on to do two more tasks with the other half of his day. Incredulous, I asked him how he solved the problem I&#8217;d run into. He happily admitted he hadn&#8217;t. He&#8217;d run into that problem, spent a half hour on it, and then changed direction.</p>
<p>Me: got blocked, pounded on the barrier. Great programmer: got blocked, tried something else that worked and moved on.</p>
<p>Like most programmers, I have an strong desire to solve problems. Put some broken code in front of me and I&#8217;ll wrestle with it &#8217;til it works. There&#8217;s lots to do but I&#8217;ve got to start by fixing this problem.</p>
<p>The best programmers I know have a different mantra: don&#8217;t get blocked. They&#8217;re focused on moving things forward, not getting bogged down making everything perfect. They&#8217;ll duck and weave, leaping over obstacles or tunneling beneath them. They like problems too, but they like something else even more: shipping.</p>
<p>Don&#8217;t get blocked.</p>
]]></content:encoded>
			<wfw:commentRss>http://codeulate.com/2011/09/dont-get-blocked/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Programmer Resumes are Deprecated</title>
		<link>http://codeulate.com/2011/06/programmer-resumes-are-deprecated/</link>
		<comments>http://codeulate.com/2011/06/programmer-resumes-are-deprecated/#comments</comments>
		<pubDate>Tue, 14 Jun 2011 05:24:22 +0000</pubDate>
		<dc:creator>Ben Orenstein</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://codeulate.com/?p=377</guid>
		<description><![CDATA[First, some exciting news: after a thorough (but enjoyable!) interview process, I&#8217;ve accepted a position at thoughtbot in Boston and will begin in a few weeks. I can&#8217;t wait to get started. The interviews themselves will make great fodder for future posts, but I realized a startling fact the other day: I never once sent [...]]]></description>
			<content:encoded><![CDATA[<p>First, some exciting news: after a thorough (but enjoyable!) interview process, I&#8217;ve accepted a position at <a href="http://www.thoughtbot.com">thoughtbot</a> in Boston and will begin in a few weeks. I can&#8217;t wait to get started.</p>
<p>The interviews themselves will make great fodder for future posts, but I realized a startling fact the other day: I never once sent anyone at thoughtbot a resume.</p>
<p>Moreover, I was never asked about schools, degrees, nor much about my past experience. My &#8220;resume&#8221; took the form of links to this blog, some open source contributions, and access to a couple private github repos of Rails apps I&#8217;d built. </p>
<p>This experience confirms an idea that I&#8217;m glad to see gaining ground lately: resumes are deprecated. Code is king. Oh, and connections help a lot too.</p>
<p>A year ago I wrote that it was possible to <a href="http://codeulate.com/2010/06/land-a-rails-job-with-no-experience/">land a Rails job with no experience</a>, provided you had a portfolio application, some code on Github, and attended Ruby meetups to network. Some people were skeptical, but it was exactly those things that got me my first Rails job. Now, years later, the same set of things got me in the door at thoughtbot: code, more code, and the recommendation of thoughtbotter <a href="http://dancroak.com/">Dan Croak</a>, who I got to know during the &#8217;09 Rails Rumble (yet more coding!)</p>
<p>I&#8217;m starting to think this really is the secret sauce for professional programming success, regardless of experience level. Get some code out there for people to see, and get yourself out there to meet awesome programmers you might want to work with someday. Leave the bullshitty bullet points to the MBAs.</p>
]]></content:encoded>
			<wfw:commentRss>http://codeulate.com/2011/06/programmer-resumes-are-deprecated/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Don&#8217;t Use Rails&#8217; Scaffolded Controllers</title>
		<link>http://codeulate.com/2010/11/dont-use-rails-scaffolded-controllers/</link>
		<comments>http://codeulate.com/2010/11/dont-use-rails-scaffolded-controllers/#comments</comments>
		<pubDate>Sat, 13 Nov 2010 05:04:28 +0000</pubDate>
		<dc:creator>Ben Orenstein</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://codeulate.com/?p=199</guid>
		<description><![CDATA[Fellow Rails Developers, the state of the art has moved on, and you should no longer be using the controllers generated by Rails&#8217; scaffold command (or &#8216;rails g resource foo&#8217;). These controllers are all the same. Repetition like that can and should be eliminated. Instead, you should use something like Inherited Resources. Here&#8217;s what a [...]]]></description>
			<content:encoded><![CDATA[<p>Fellow Rails Developers, the state of the art has moved on, and you should no longer be using the controllers generated by Rails&#8217; scaffold command (or &#8216;rails g resource foo&#8217;).</p>
<p>These controllers are all the same. Repetition like that can and should be eliminated.</p>
<p>Instead, you should use something like <a href="https://github.com/josevalim/inherited_resources">Inherited Resources</a>. </p>
<p>Here&#8217;s what a controller generated by Rails looks like:</p>
<div class="codecolorer-container ruby vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;height:300px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#9966CC; font-weight:bold;">class</span> UsersController <span style="color:#006600; font-weight:bold;">&lt;</span> ApplicationController<br />
&nbsp; <span style="color:#008000; font-style:italic;"># GET /users</span><br />
&nbsp; <span style="color:#008000; font-style:italic;"># GET /users.xml</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> index<br />
&nbsp; &nbsp; <span style="color:#0066ff; font-weight:bold;">@users</span> = User.<span style="color:#9900CC;">all</span><br />
<br />
&nbsp; &nbsp; respond_to <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span><span style="color:#CC0066; font-weight:bold;">format</span><span style="color:#006600; font-weight:bold;">|</span><br />
&nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">format</span>.<span style="color:#9900CC;">html</span> <span style="color:#008000; font-style:italic;"># index.html.erb</span><br />
&nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">format</span>.<span style="color:#9900CC;">xml</span> &nbsp;<span style="color:#006600; font-weight:bold;">&#123;</span> render <span style="color:#ff3333; font-weight:bold;">:xml</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0066ff; font-weight:bold;">@users</span> <span style="color:#006600; font-weight:bold;">&#125;</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
&nbsp; <span style="color:#008000; font-style:italic;"># GET /users/1</span><br />
&nbsp; <span style="color:#008000; font-style:italic;"># GET /users/1.xml</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> show<br />
&nbsp; &nbsp; <span style="color:#0066ff; font-weight:bold;">@user</span> = User.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:id</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
<br />
&nbsp; &nbsp; respond_to <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span><span style="color:#CC0066; font-weight:bold;">format</span><span style="color:#006600; font-weight:bold;">|</span><br />
&nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">format</span>.<span style="color:#9900CC;">html</span> <span style="color:#008000; font-style:italic;"># show.html.erb</span><br />
&nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">format</span>.<span style="color:#9900CC;">xml</span> &nbsp;<span style="color:#006600; font-weight:bold;">&#123;</span> render <span style="color:#ff3333; font-weight:bold;">:xml</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0066ff; font-weight:bold;">@user</span> <span style="color:#006600; font-weight:bold;">&#125;</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
&nbsp; <span style="color:#008000; font-style:italic;"># GET /users/new</span><br />
&nbsp; <span style="color:#008000; font-style:italic;"># GET /users/new.xml</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> new<br />
&nbsp; &nbsp; <span style="color:#0066ff; font-weight:bold;">@user</span> = User.<span style="color:#9900CC;">new</span><br />
<br />
&nbsp; &nbsp; respond_to <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span><span style="color:#CC0066; font-weight:bold;">format</span><span style="color:#006600; font-weight:bold;">|</span><br />
&nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">format</span>.<span style="color:#9900CC;">html</span> <span style="color:#008000; font-style:italic;"># new.html.erb</span><br />
&nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">format</span>.<span style="color:#9900CC;">xml</span> &nbsp;<span style="color:#006600; font-weight:bold;">&#123;</span> render <span style="color:#ff3333; font-weight:bold;">:xml</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0066ff; font-weight:bold;">@user</span> <span style="color:#006600; font-weight:bold;">&#125;</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
&nbsp; <span style="color:#008000; font-style:italic;"># GET /users/1/edit</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> edit<br />
&nbsp; &nbsp; <span style="color:#0066ff; font-weight:bold;">@user</span> = User.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:id</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
&nbsp; <span style="color:#008000; font-style:italic;"># POST /users</span><br />
&nbsp; <span style="color:#008000; font-style:italic;"># POST /users.xml</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> create<br />
&nbsp; &nbsp; <span style="color:#0066ff; font-weight:bold;">@user</span> = User.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:user</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
<br />
&nbsp; &nbsp; respond_to <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span><span style="color:#CC0066; font-weight:bold;">format</span><span style="color:#006600; font-weight:bold;">|</span><br />
&nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#0066ff; font-weight:bold;">@user</span>.<span style="color:#9900CC;">save</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">format</span>.<span style="color:#9900CC;">html</span> <span style="color:#006600; font-weight:bold;">&#123;</span> redirect_to<span style="color:#006600; font-weight:bold;">&#40;</span>@user, <span style="color:#ff3333; font-weight:bold;">:notice</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'User was successfully created.'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">format</span>.<span style="color:#9900CC;">xml</span> &nbsp;<span style="color:#006600; font-weight:bold;">&#123;</span> render <span style="color:#ff3333; font-weight:bold;">:xml</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0066ff; font-weight:bold;">@user</span>, <span style="color:#ff3333; font-weight:bold;">:status</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:created</span>, <span style="color:#ff3333; font-weight:bold;">:location</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0066ff; font-weight:bold;">@user</span> <span style="color:#006600; font-weight:bold;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">format</span>.<span style="color:#9900CC;">html</span> <span style="color:#006600; font-weight:bold;">&#123;</span> render <span style="color:#ff3333; font-weight:bold;">:action</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;new&quot;</span> <span style="color:#006600; font-weight:bold;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">format</span>.<span style="color:#9900CC;">xml</span> &nbsp;<span style="color:#006600; font-weight:bold;">&#123;</span> render <span style="color:#ff3333; font-weight:bold;">:xml</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0066ff; font-weight:bold;">@user</span>.<span style="color:#9900CC;">errors</span>, <span style="color:#ff3333; font-weight:bold;">:status</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:unprocessable_entity</span> <span style="color:#006600; font-weight:bold;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
&nbsp; <span style="color:#008000; font-style:italic;"># PUT /users/1</span><br />
&nbsp; <span style="color:#008000; font-style:italic;"># PUT /users/1.xml</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> update<br />
&nbsp; &nbsp; <span style="color:#0066ff; font-weight:bold;">@user</span> = User.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:id</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
<br />
&nbsp; &nbsp; respond_to <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span><span style="color:#CC0066; font-weight:bold;">format</span><span style="color:#006600; font-weight:bold;">|</span><br />
&nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#0066ff; font-weight:bold;">@user</span>.<span style="color:#9900CC;">update_attributes</span><span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:user</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">format</span>.<span style="color:#9900CC;">html</span> <span style="color:#006600; font-weight:bold;">&#123;</span> redirect_to<span style="color:#006600; font-weight:bold;">&#40;</span>@user, <span style="color:#ff3333; font-weight:bold;">:notice</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'User was successfully updated.'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">format</span>.<span style="color:#9900CC;">xml</span> &nbsp;<span style="color:#006600; font-weight:bold;">&#123;</span> head <span style="color:#ff3333; font-weight:bold;">:ok</span> <span style="color:#006600; font-weight:bold;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">format</span>.<span style="color:#9900CC;">html</span> <span style="color:#006600; font-weight:bold;">&#123;</span> render <span style="color:#ff3333; font-weight:bold;">:action</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;edit&quot;</span> <span style="color:#006600; font-weight:bold;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">format</span>.<span style="color:#9900CC;">xml</span> &nbsp;<span style="color:#006600; font-weight:bold;">&#123;</span> render <span style="color:#ff3333; font-weight:bold;">:xml</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0066ff; font-weight:bold;">@user</span>.<span style="color:#9900CC;">errors</span>, <span style="color:#ff3333; font-weight:bold;">:status</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:unprocessable_entity</span> <span style="color:#006600; font-weight:bold;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
&nbsp; <span style="color:#008000; font-style:italic;"># DELETE /users/1</span><br />
&nbsp; <span style="color:#008000; font-style:italic;"># DELETE /users/1.xml</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> destroy<br />
&nbsp; &nbsp; <span style="color:#0066ff; font-weight:bold;">@user</span> = User.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:id</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; <span style="color:#0066ff; font-weight:bold;">@user</span>.<span style="color:#9900CC;">destroy</span><br />
<br />
&nbsp; &nbsp; respond_to <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span><span style="color:#CC0066; font-weight:bold;">format</span><span style="color:#006600; font-weight:bold;">|</span><br />
&nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">format</span>.<span style="color:#9900CC;">html</span> <span style="color:#006600; font-weight:bold;">&#123;</span> redirect_to<span style="color:#006600; font-weight:bold;">&#40;</span>users_url<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">format</span>.<span style="color:#9900CC;">xml</span> &nbsp;<span style="color:#006600; font-weight:bold;">&#123;</span> head <span style="color:#ff3333; font-weight:bold;">:ok</span> <span style="color:#006600; font-weight:bold;">&#125;</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></div>
<p>Here&#8217;s that SAME controller using Inherited Resources:</p>
<div class="codecolorer-container ruby vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#9966CC; font-weight:bold;">class</span> UsersController <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">InheritedResources::Base</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></div>
<p>That&#8217;s right, just by inheriting from InheritedResources::Base you all the standard REST actions for free. </p>
<p>If you need to, you can override any of the default actions:</p>
<div class="codecolorer-container ruby vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#9966CC; font-weight:bold;">class</span> UsersController <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">InheritedResources::Base</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> new<br />
&nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># do different stuff for new</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></div>
<p>It even has a nice DSL for customizations you&#8217;re likely to need. Here&#8217;s how to change just the redirect for the destroy action:</p>
<div class="codecolorer-container ruby vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#9966CC; font-weight:bold;">class</span> UsersController <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">InheritedResources::Base</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> destroy<br />
&nbsp; &nbsp; destroy!<span style="color:#006600; font-weight:bold;">&#123;</span> root_url <span style="color:#006600; font-weight:bold;">&#125;</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></div>
<p>The best thing is, once you&#8217;ve got that duplicated code out of there, you don&#8217;t need to test it! Inherited Resources already has its own tests for the standard actions, so you only need test the things you explicitly change.</p>
<p>A few months ago, I refactored an app to use Inherited Resources instead of the generated controllers. And by &#8216;refactored&#8217;, I mean &#8216;deleted pages and pages of controller and test code&#8217;. I &#8216;git rm&#8217;d almost all our functional tests and damn that felt <em>good</em>.</p>
<p>You gotta get in on this! The <a href="https://github.com/josevalim/inherited_resources/blob/master/README.rdoc">README</a> is solid, so you should have little trouble getting started.</p>
]]></content:encoded>
			<wfw:commentRss>http://codeulate.com/2010/11/dont-use-rails-scaffolded-controllers/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How Unit Testing Could Have Saved Lives</title>
		<link>http://codeulate.com/2009/01/how-unit-testing-could-have-saved-lives/</link>
		<comments>http://codeulate.com/2009/01/how-unit-testing-could-have-saved-lives/#comments</comments>
		<pubDate>Fri, 16 Jan 2009 19:35:07 +0000</pubDate>
		<dc:creator>Ben Orenstein</dc:creator>
				<category><![CDATA[coding]]></category>

		<guid isPermaLink="false">http://codeulate.com/?p=23</guid>
		<description><![CDATA[A recent article in The Independent describes a fascinating study.  Researchers found that forcing surgeons in a London hospital to implement a single new procedure caused the death rate after surgery to fall 47 percent.  Complications likewise fell by 36 percent. These are enormous numbers: Donald Berwick, the president of the US Institute for Healthcare [...]]]></description>
			<content:encoded><![CDATA[<p>A recent article in <a href="http://www.independent.co.uk/life-style/health-and-wellbeing/health-news/right-patient-right-limb-two-questions-that-have-almost-halved-death-rate-at-one-hospital-1366705.html">The Independent</a> describes a <a href="http://content.nejm.org/cgi/content/full/NEJMsa0810119">fascinating study</a>.  Researchers found that forcing surgeons in a London hospital to implement a single new procedure caused <strong>the death rate after surgery to fall 47 percent</strong>.  Complications likewise fell by 36 percent.</p>
<p>These are enormous numbers:</p>
<blockquote><p>Donald Berwick, the president of the US Institute for Healthcare Improvement, said of the innovation: &#8220;I cannot recall a clinical care innovation in the past 30 years that has shown results of [this] magnitude.&#8221;</p></blockquote>
<p>The change?  <strong>The surgeons were required to run through a simple checklist before and after every procedure.</strong></p>
<p>Now, <a href="http://www.who.int/patientsafety/safesurgery/tools_resources/SSSL_Checklist_finalJun08.pdf">this checklist</a> [pdf] is not lengthy.  In fact, it&#8217;s less than twenty questions.  Even more strikingly, <strong>the questions are not complicated</strong>: before administering anesthesia, has the patient confirmed his identity?  Does the patient have any known allergies?  Have we confirmed that this is the <em>right</em> foot?  I&#8217;d wager that the most common reaction of people seeing this checklist is &#8220;you mean these things weren&#8217;t being asked <em>already</em>?&#8221;</p>
<p>The thing is, these questions <em>were</em> already being asked.  The difference is that<strong> they weren&#8217;t being asked in systematic way</strong>.  Members of a surgical team assume that these obvious things have been checked <em>because</em> they&#8217;re so obvious.  &#8220;Of <em>course</em> this is the right patient.&#8221;  &#8220;Of <em>course </em>we asked if he&#8217;s allergic to the anesthetic.&#8221;  &#8220;Of <em>course</em> we marked the right limb for amputation.&#8221;</p>
<p>The problem is, these things are sometimes done incorrectly, or missed entirely.  Not often, not usually; just sometimes.  Forcing doctors and nurses to use the checklist caught these &#8220;sometimes&#8221; problems, and dramatically improved patient safety in the process.</p>
<p>From this study, we can draw the following conclusions:</p>
<ol>
<li>Even obvious errors are easy to commit, and once committed, can have terrible consequences.</li>
<li>Those who overlook these problems can be highly-trained and intelligent people.  It appears that you cannot out-train or out-brain our human tendency to err from time to time.</li>
<li>Instituting a rigorous system to check for errors lowers their occurrence dramatically, compared to existing processes that check for them informally.</li>
</ol>
<p>Laid out this way, these statements are probably starting to look familiar, because <strong>they are exactly like the arguments for using unit tests in programming</strong>.  As a software developer, I look at this list and think <em>we knew this stuff already</em>!  We knew it, and we came up with a way of mitigating the problems caused by our own flawed humanity.</p>
<p><strong>The errors that this checklist catches are the kind that kill people</strong>.  Thousands of people, every year.  If we, as an industry, had somehow conveyed the efficacy of systemic testing with the medical field, this checklist might have been implemented sooner, and lives could have been saved.</p>
<p>The fact that ideas like this don&#8217;t flow across fields is not surprising.  Industry-specific myopia reflects our human tendency to form into groups and <a href="http://query.nytimes.com/gst/fullpage.html?res=9C05E6D8113BF933A15757C0A9629C8B63&amp;sec=health&amp;spon=&amp;pagewanted=print">distrust outsiders</a>.  Despite this, I do believe it&#8217;s worth struggling against.  Perhaps the field of architecture could provide useful insights into the construction of software (<a href="http://www.codinghorror.com/blog/archives/001003.html">perhaps it already has</a>).  Maybe the next big idea in architecture will be inpsired <a href="http://blog.futurelab.net/2007/08/chemistry_as_architecture.html">by chemistry</a>, or <a href="http://zeta.math.utsa.edu/~yxk833/pinker.html">biology</a>.  Maybe the next time I open my editor I should think &#8220;<a href="http://en.wikipedia.org/wiki/Primum_non_nocere">first, do no harm</a>.&#8221;</p>
<p>It certainly couldn&#8217;t hurt.</p>
]]></content:encoded>
			<wfw:commentRss>http://codeulate.com/2009/01/how-unit-testing-could-have-saved-lives/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Damn Useful: When You Forget to type Sudo</title>
		<link>http://codeulate.com/2008/12/damn-useful-1-you-forgot-to-type-sudo/</link>
		<comments>http://codeulate.com/2008/12/damn-useful-1-you-forgot-to-type-sudo/#comments</comments>
		<pubDate>Tue, 09 Dec 2008 16:12:20 +0000</pubDate>
		<dc:creator>Ben Orenstein</dc:creator>
				<category><![CDATA[coding]]></category>

		<guid isPermaLink="false">http://codeulate.com/?p=22</guid>
		<description><![CDATA[(This post is part of a series.  To read more tips and to learn about the philosophy behind these posts, check out the parent post.) You know you&#8217;ve done this way too many times: ben@lispclub ~ $ apt-get install blahblahblah E: Could not open lock file /var/lib/dpkg/lock &#8211; open (13 Permission denied) E: Unable to [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://imgs.xkcd.com/comics/sandwich.png" width="360" align="middle" height="299" hspace="105" /></p>
<h2>(This post is part of a series.  To read more tips and to learn about the philosophy behind these posts, check out the <a href="http://codeulate.com/?p=21">parent post</a>.)</h2>
<p>You know you&#8217;ve done this way too many times:</p>
<p>ben@lispclub ~ $<strong> apt-get install blahblahblah<br />
</strong>E: Could not open lock file /var/lib/dpkg/lock &#8211; open (13 Permission denied)<br />
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?</p>
<p>Bah.</p>
<h2><strong>You forgot to type sudo first</strong>.</h2>
<p>So what do you do?  Hit up arrow, swing back to the beginning of the line, type sudo&#8211;ARGGH&#8230;THE WASTED SECONDS!</p>
<h2><strong>Do this instead: </strong><strong>sudo !!</strong></h2>
<p>In bash, !! means &#8220;repeat the last command I entered.&#8221;  Bash substitutes your apt-get command after the sudo, and you finally get to install blahblahblah 0.0.13.  Note that this isn&#8217;t specific to sudo.  If you do an ls, and then wish you&#8217;d grepped the results for foo, type !! | grep foo.</p>
<h2><strong>How to remember it: </strong></h2>
<p>Imagine an angry father yelling for his son.  &#8220;Sudo!!&#8221;  Sudo runs down from his room, sees the command  he was supposed to be in front of, and executes it immediately.</p>
]]></content:encoded>
			<wfw:commentRss>http://codeulate.com/2008/12/damn-useful-1-you-forgot-to-type-sudo/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Damn Useful Tips</title>
		<link>http://codeulate.com/2008/12/damn-useful-tips/</link>
		<comments>http://codeulate.com/2008/12/damn-useful-tips/#comments</comments>
		<pubDate>Tue, 09 Dec 2008 16:11:57 +0000</pubDate>
		<dc:creator>Ben Orenstein</dc:creator>
				<category><![CDATA[coding]]></category>

		<guid isPermaLink="false">http://codeulate.com/?p=21</guid>
		<description><![CDATA[This post is the first in a series called Damn Useful.  The posts will be a number of tips on the tools we use most frequently as programmers, particularly the shell and editor.  Because of my own preferences, I&#8217;ll focus on bash, vim, and unix tools like grep, screen, and others. Here are some guidelines [...]]]></description>
			<content:encoded><![CDATA[<p>   This post is the first in a series called Damn Useful.  The posts will be a number of tips on the tools we use most frequently as programmers, particularly the shell and editor.  Because of my own preferences, I&#8217;ll focus on bash, vim, and unix tools like grep, screen, and others.</p>
<p>Here are some guidelines on what to expect:</p>
<p>1. <strong>One tip per post.</strong></p>
<p>I&#8217;m a sucker for productivity tips.  I&#8217;ve read dozens of articles with titles like &#8220;25 _____ Tips for Fun and Profit!&#8221;  I usually take away at most one useful tidbit from these articles.  A lot of good stuff gets lost in the tidal wave of new information.  This posts in this series will be short: one tip each.  I&#8217;ll focus on just one idea and move on.</p>
<p>2. <strong>I&#8217;ll provide mnemonics or imagery to aid recall.</strong></p>
<p>Can you name the nine planets in our solar system?  How about the order of arithmetic operations?</p>
<p>If you can, I bet you access a mnemonic you&#8217;ve learned for this purpose.  I use My Video Eye May Just Show Us Nine Planets, and Please Excuse My Dear Aunt Sally for these two.<strong><br />
</strong><br />
I&#8217;m never, EVER going to forget the names of the planets.  That mnemonic is in my brain for good.  I want the things you learn through this series to be the same way.  As such, I&#8217;ll try hard to come up with memorable mnemonics for them.  Sometimes mnemonics don&#8217;t make sense, and I&#8217;ll instead provide an image to think about that will hopefully stick in your mind.</p>
<p>3. <strong>The tips will involve tools programmers tend to use daily.</strong><br />
<strong><br />
</strong>The value of a tip is proportional the number of times a day you can use it.  These tips will probably only be worth a few seconds each on their own, so I want to be sure there&#8217;s a big fat multiplier next to each one.  I&#8217;ll be focusing on the heavy hitters in the programming world.</p>
<p><strong>The Posts:</strong></p>
<p><a href="http://codeulate.com/?p=22&amp;"><strong>When You Forget to type Sudo</strong></a></p>
]]></content:encoded>
			<wfw:commentRss>http://codeulate.com/2008/12/damn-useful-tips/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>On the fundamentals of programming</title>
		<link>http://codeulate.com/2007/12/on-the-fundamentals-of-programming/</link>
		<comments>http://codeulate.com/2007/12/on-the-fundamentals-of-programming/#comments</comments>
		<pubDate>Fri, 14 Dec 2007 18:01:02 +0000</pubDate>
		<dc:creator>Ben Orenstein</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[music]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://codeulate.com/?p=4</guid>
		<description><![CDATA[Let&#8217;s start with a story. I am a volleyball fanatic. I enjoy the game in a way that borders on obsession. Lately I play three times a week for hours at a time. Now, my position is known as middle hitter. As you might have guessed, I&#8217;m the guy who stands in the middle of [...]]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s start with a <a href="http://www.joelonsoftware.com/articles/BestSoftwareWriting.html" title="Show, don't tell.">story</a>.</p>
<p>I am a volleyball fanatic.  I enjoy the game in a way that borders on obsession.  Lately I play three times a week for hours at a time.  Now, my position is known as middle hitter.  As you might have guessed, I&#8217;m the guy who stands in the middle of the court and tries to pound the ball through the other team&#8217;s floor.</p>
<p>A few months ago, I was going through an athletic crisis.  Despite many hours of play I still wasn&#8217;t that good at hitting.  In fact, I kinda sucked at it.  My other skills were decent, but when it came to spiking the heck out of the ball, something wasn&#8217;t right.  I just wasn&#8217;t getting the power other people were and I didn&#8217;t know why.  I experimented constantly: different arm swings, changing my hand shape, snapping my wrist.  Nothing worked.  Sad and ashamed, I enrolled in a clinic hoping to cure my hitting dysfunction.</p>
<p>On the first night, the coach ordered us into a hitting drill.  No problem.  I&#8217;m focused, I&#8217;m ready; I&#8217;m going to crush this ball.  I went up for my approach and, well&#8211;tapped&#8211;the ball over the net.  Not impressive.  I tried again but with similar results.  Discreetly, the coach pulled me aside:</p>
<p>&#8220;Did you know you&#8217;re taking an extra little hop before you jump?&#8221;</p>
<p>&#8220;I am?&#8221;</p>
<p>&#8220;You are.  It&#8217;s taking away all your momentum so your jump is all wrong.  Get rid of that and try again.&#8221;</p>
<p>On my next attempt, the set was perfect: high and tight, and I smacked it the same way you&#8217;d high-five your grandmother.  But that time, I <em>felt</em> the extra hop I was taking.  Suddenly it was so obviously there.</p>
<p>I lined up once more.  I took three strong steps, leapt in the air, and pounded down the best shot of my life.  WHAM!  I was elated.  The problem I had with hitting was simple: I was deficient in the fundamentals.  Everything I&#8217;d been tweaking was the minor stuff.  Fundamentals are the rock-solid road bed you build on.  I&#8217;d been rearranging the mile markers on a strip of sand.</p>
<p>The point here is important: mastery of any complex skill requires mastery of its fundamentals.  I think this idea just might tell us why there are so many bad programmers out there.  And I also think it tells us it&#8217;s our fault.</p>
<p><strong>How does one acquire the fundamentals of programming?</strong></p>
<p>I don&#8217;t think the answer lies in obtaining a computer science degree.  I once interviewed a recent <a href="http://www.mit.edu">MIT</a> graduate who&#8217;d majored in computer science.  She was articulate, had a strong GPA, and couldn&#8217;t write the pseudocode to sort an array.  Really.  This is actually a familiar phenomenon.  A CS degree tells you how, theoretically, you might spike a volleyball, but that doesn&#8217;t mean graduates have ever actually hit one.  Of course computer science isn&#8217;t really about programming, <a href="http://swiss.csail.mit.edu/classes/6.001/abelson-sussman-lectures/" title="Watch lecture 1a.">it&#8217;s not even about computers</a>.  Now, there are lots of strong coders with CS backgrounds, but that strength is almost always acquired through their own work&#8211;they are self-taught.</p>
<p>Academia isn&#8217;t much help, so we&#8217;re going to have to become deadly code-ninjas on our own.  Fortunately, there is a wizened master who can point us in the right direction: <a href="http://norvig.com/">Peter Norvig</a>, whose essay &#8220;<a href="http://norvig.com/21-days.html">Teach Yourself Programming in Ten Years</a>&#8221; wins my personal Nobel for Programming Literature.  It&#8217;s probably the best advice out there on the subject, and we&#8217;d all do well to follow his recommendations.  However, despite the fact that Peter is so smart his brain has its own gravitational pull, I think his essay glosses over an important point.</p>
<p>Let&#8217;s look at the main thrust of Norvig&#8217;s advice:</p>
<blockquote><p> Program. The best kind of learning is learning by doing. To put it more technically, &#8220;the maximal level of performance for individuals in a given domain is not attained automatically as a function of extended experience, but the level of performance can be increased even by highly experienced individuals as a result of deliberate efforts to improve.&#8221; (p. 366) and &#8220;the most effective learning requires a well-defined task with an appropriate difficulty level for the particular individual, informative feedback, and opportunities for repetition and corrections of errors.&#8221;</p></blockquote>
<p>This is clearly good advice.  Surely that MIT graduate could have written me that algorithm if she&#8217;d, you know, written code before.  But check out the quotation Norvig cites.  Where exactly does one find well-defined programming tasks of an appropriate difficulty level?  How about informative feedback and corrections of errors?</p>
<p>Well?</p>
<p>It turns out that there&#8217;s a shortage of things like this for programmers.  Especially new ones.  This is a serious problem, and it is this I blame for the huge numbers of coders who <a href="http://www.thedailywtf.com">lack the fundamental skills of our craft</a>.  Worse, this is our own fault: only people already skilled in an activity can devise effective training for newcomers.  Even <a href="http://www.thefreedictionary.com/worser">worser</a>: when you lack skills in the fundamentals you almost never know it.  I had <em>no idea</em> why I couldn&#8217;t spike a volleyball.</p>
<p>So how do we fix this?  We do what all great thinkers do: steal a great idea from somewhere else and reuse it.  So here&#8217;s my solution, shamelessly grabbed from a different, but related area of my life:</p>
<p><strong>To become a better programmer, one should practice like a musician.</strong></p>
<p>Bear with me&#8230;</p>
<p>A beautiful piano sonata is the product of thousands of perfectly executed notes.  If even one note is misplayed you have cacophony.  However, the consideration of individual notes never enters my mind while playing.  Instead, I&#8217;m thinking about making the phrases flow together, the winsome arc of the melody, or keeping the steady beat of the bass line.  It is these things that create music from mere notes.  I&#8217;m able to think of these things because my mind is free from worrying about playing individual keys, and my mind is free because of my mastery of the fundamentals.  The study of classical piano (and every other musical endeavor) devotes ample time to performing exercises.  There are perhaps <a href="http://www.amazon.com/s/ref=nb_ss_gw/104-0171174-3395900?url=search-alias%3Daps&amp;field-keywords=piano+exercises&amp;x=0&amp;y=0">hundreds of books</a> full of them.  Compared to a real piece of music they are simple and repetitive, but each exercise isolates and drills a vital skill.  This focused practice makes such skills automatic&#8211;I can play a very fast run of notes smoothly and accurately because I&#8217;ve quite literally practiced it thousands of times.  I no longer need to think about it.  Because of this, I am a better pianist.</p>
<p>The application of these ideas to programming should be clear.  When I&#8217;m focusing on the overall musicality of a piece, I&#8217;m operating at a <a href="http://www.paulgraham.com/power.html">higher level of abstraction</a>.  Individual details have faded away, and I&#8217;m able to focus on making something beautiful.  The same skill is required for creating beautiful programs.  If you must spend brain cycles struggling with minute implementation details you have no hope for making your solution elegant.</p>
<p>So let&#8217;s take this musical idea and alter it slightly.  After all, when it comes to programming exercises, coverage is more important than repetition. Not remembering how your language retrieves values from a hash is <em>far</em> less damaging than not knowing hashes exist in the first place.</p>
<p>Fortunately, I can already point to an excellent example of these sort of problems. I believe newcomers would learn more about programming per unit time by working through <a href="https://prof.ti.bfh.ch/hew1/informatik3/prolog/p-99/">Ninety-nine Prolog Problems</a> than almost anything else.  (Replace Prolog with your language of choice).  With the ability to check your answers and also post questions on a wiki, we&#8217;ve even covered the &#8220;correction of errors&#8221; and &#8220;informative feedback&#8221; requirements mentioned above.  Also excellent is <a href="http://www.pythonchallenge.com/">The Python Challenge</a>, a series of riddles with programmatic solutions that get progressively harder over time.  The site is massively popular <em>and</em> makes people better programmers.  Truly, this is a phenomenal start, but there&#8217;s much more to be done.</p>
<p>So how about it guys?  What are the first fifty programs someone should write to break out of that painful newcomer phase?  What topics would they <em>definitely</em> have to cover?  Later, what programs must one write to reach hacking virtuosity?  I also like to think about this a different way: what problems would you be embarrassed to tell your coworkers you can&#8217;t solve?</p>
<p>I think these questions are important, and they just might help improve the overall quality of programmers out there.  If you accept programming as an art, why don&#8217;t we treat it like one?  Let&#8217;s start practicing like musicians, and maybe we can create something beautiful.</p>
]]></content:encoded>
			<wfw:commentRss>http://codeulate.com/2007/12/on-the-fundamentals-of-programming/feed/</wfw:commentRss>
		<slash:comments>38</slash:comments>
		</item>
	</channel>
</rss>

