<?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>Richard Hart &#124; Hates_ &#187; programming</title>
	<atom:link href="http://www.ur-ban.com/blog/tag/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ur-ban.com/blog</link>
	<description>Programming &#38; Life - ur-ban.com</description>
	<lastBuildDate>Wed, 30 Jun 2010 12:20:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Broken Window Policy of Programming</title>
		<link>http://www.ur-ban.com/blog/2010/01/14/broken-window-policy-of-programming/</link>
		<comments>http://www.ur-ban.com/blog/2010/01/14/broken-window-policy-of-programming/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 14:54:43 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[bestpractice]]></category>

		<guid isPermaLink="false">http://www.ur-ban.com/blog/?p=1335</guid>
		<description><![CDATA[There comes a point in every software projects life where everything just feels wrong. No one wants to touch the code as it stinks and everyone working on the project just feels demotivated and would rather just go home then have to do anything more on it. On projects like this, when it comes to [...]]]></description>
			<content:encoded><![CDATA[<p>There comes a point in every software projects life where everything just feels wrong. No one wants to touch the code as it stinks and everyone working on the project just feels demotivated and would rather just go home then have to do anything more on it. On projects like this, when it comes to adding new features or bits of code, because everything else is such a mess, the changes are just hacked in rather than being properly thought out and coded up well.</p>
<p>We&#8217;ve all been there and the frustrating thing is that our opinion of the project, from good to bad, seems to happens over night. If you sit down and think back, you can probably pick out all the things that were just shoved in that eventually led to the project becoming a mess, but at the time we never chose to do anything about. It&#8217;s almost always a case of deferring better solutions or a round of refactoring to some point in the future. &#8220;I&#8217;ll knock this up now and come back to it later.&#8221;. The problem is that later never comes. This is the essence of technical debt. You may only go into debt by a fraction, but do it a few times and eventually all those fractions add up. Until one day when you go to check your balance, you find yourself swimming in the middle of the ocean with no land in sight.</p>
<p>Implementing a broken window policy can go a huge way towards keeping a project healthy. If there is a broken window (bad code) fix it as-soon-as-possible. It doesn&#8217;t have to be that instant (although if you can, you should), but fix it. Part of the policy also means trying not to break windows yourself. Write the best code you can, as often as you can. Set the benchmark of quality for the rest of the team, even if they don&#8217;t follow suit. The danger is that many people are very &#8220;me too&#8221; about things. &#8220;Well if such-and-such can do it like this, then so can I *hack* *hack* *hack*&#8221;. </p>
<p>Of course we all write crap from time to time. TBH most of the stuff I write is crap. But I honestly feel more motivated to work on code that&#8217;s been loved and looked after, rather than something that&#8217;s hanging together by a thread.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ur-ban.com/blog/2010/01/14/broken-window-policy-of-programming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Essential reading for developers</title>
		<link>http://www.ur-ban.com/blog/2009/11/08/essential-reading/</link>
		<comments>http://www.ur-ban.com/blog/2009/11/08/essential-reading/#comments</comments>
		<pubDate>Sun, 08 Nov 2009 15:26:01 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[computing]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[books]]></category>

		<guid isPermaLink="false">http://www.ur-ban.com/blog/?p=1229</guid>
		<description><![CDATA[I&#8217;ve been meaning to write up a list of what books I think every developer, aspiring or seasoned should read. So let&#8217;s cut to the chase, and in no particular order: Code Complete If there was ever a bible for coding, this is it. It&#8217;s even Bible sized. A nice size to chuck at those [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been meaning to write up a list of what books I think every developer, aspiring or seasoned should read. So let&#8217;s cut to the chase, and in no particular order:</p>
<p style="text-align: center;"><img class="aligncenter" src="http://images.ur-ban.com/galleryv2/d/16120-1/code_complete.png" alt="" width="150" height="183" /></p>
<p><strong>Code Complete</strong><br />
If there was ever a bible for coding, this is it. It&#8217;s even Bible sized. A nice size to chuck at those annoying developers who just have no clue.</p>
<p style="text-align: center;"><img class="aligncenter" src="http://images.ur-ban.com/galleryv2/d/16118-1/clean_code.png" alt="" width="150" height="199" /></p>
<p><strong>Clean Code</strong><br />
I would consider this book the &#8220;Ten Commandments&#8221; of coding and compliments Code Complete very very very well. If Code Complete teaches you how to be a Christian, then Clean Code teaches you how to be Jesus.</p>
<p style="text-align: center;"><img class="aligncenter" src="http://images.ur-ban.com/galleryv2/d/16122-1/refactoring_to_patterns.png" alt="" width="150" height="202" /></p>
<p><strong>Refactoring to Patterns</strong><br />
What I love about this book is that it you learn the fundamentals of refactoring at the same time as design patterns. The GoF Design Patterns book is quite heavy going. The examples aren&#8217;t well laid out and can be confusing especially if you&#8217;re not familiar with SmallTalk The examples in refactoring to patterns all take pretty familiar real world bits of code and walk you through the process of refactoring them into sensible patterns.</p>
<p>Three books? Is that it? Yup. In my mind those are the only three books that are essential reading, no matter what form of development you do. If you even remotely care about coding, then go to Amazon now and buy these books. Read them and take a good long hard look at your own code. If on the other hand you feel &#8220;You can&#8217;t be bothered&#8221; to read, learn and improve, then why are you doing something you don&#8217;t love or care about? You&#8217;re in the wrong industry if you&#8217;re not prepared to take time, all the time, to learn new things. Once you&#8217;ve read those, then you&#8217;re ready to move onto more specialised books. Here are some of my other favourite development books from over the years:</p>
<p>The Productive Programmer<br />
The Art of Agile Development<br />
Practices of an Agile Developer<br />
Joel on Software<br />
Unix Power Tools<br />
Programming Perl<br />
Essential Java<br />
Well Grounded Rubyist<br />
Design Patterns in Ruby<br />
CSS Mastery<br />
Prioritizing Web Usability</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ur-ban.com/blog/2009/11/08/essential-reading/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Don&#8217;t use PHPMyAdmin. SSH tunnel instead.</title>
		<link>http://www.ur-ban.com/blog/2009/10/26/why-use-phpmyadmin-when-you-can-ssh/</link>
		<comments>http://www.ur-ban.com/blog/2009/10/26/why-use-phpmyadmin-when-you-can-ssh/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 21:10:36 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[computing]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.ur-ban.com/blog/?p=1202</guid>
		<description><![CDATA[If you&#8217;re still using phpMyAdmin to admin your remote database, then you&#8217;re doing it wrong. Don&#8217;t expose your database to the outside world like this, instead use a SSH tunnel. In your terminal simply create the tunnel: ssh -fNg -L 8888:127.0.0.1:3306 {your_username}@{yourdomain.com} Then in your MySQL interface of choice just connect to 127.0.0.1 port 8888 [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re still using phpMyAdmin to admin your remote database, then you&#8217;re doing it wrong. Don&#8217;t expose your database to the outside world like this, instead use a SSH tunnel. In your terminal simply create the tunnel:</p>
<pre class="textmate-source"><span class="source source_shell">  ssh -fNg -L 8888:127.0.0.1:3306 {your_username}@{yourdomain.com}</span></pre>
<p>Then in your MySQL interface of choice just connect to 127.0.0.1 port 8888 and voila, you&#8217;ll be connected to your remote database.</p>
<p style="text-align: center;"><img class="aligncenter" src="http://images.ur-ban.com/galleryv2/d/16112-1/ssh-tunnel-1.png" alt="" width="395" height="320" /></p>
<p>Apps like Querious even let you setup the connection internally without having to tunnel through in Terminal.</p>
<p style="text-align: center;"><img class="aligncenter" src="http://images.ur-ban.com/galleryv2/d/16116-1/ssh-tunnel-2.png" alt="" width="410" height="491" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ur-ban.com/blog/2009/10/26/why-use-phpmyadmin-when-you-can-ssh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Law of Demeter and the delegate method</title>
		<link>http://www.ur-ban.com/blog/2009/10/25/law-of-demeter-and-the-delegate-method/</link>
		<comments>http://www.ur-ban.com/blog/2009/10/25/law-of-demeter-and-the-delegate-method/#comments</comments>
		<pubDate>Sun, 25 Oct 2009 13:02:52 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[computing]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[bestpractice]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.ur-ban.com/blog/?p=1193</guid>
		<description><![CDATA[The Law of Demeter, or Principle of Least Knowledge is a fairly simple design pattern, which, simply put means that an object should only talk to it&#8217;s immediate &#8220;friends&#8221; The law states that a method M of and object O may only invoke the methods of the following kind: 1. a method on O itself [...]]]></description>
			<content:encoded><![CDATA[<p>The Law of Demeter, or Principle of Least Knowledge is a fairly simple design pattern, which, simply put means that an object should only talk to it&#8217;s immediate &#8220;friends&#8221;</p>
<p>The law states that a method M of and object O may only invoke the methods of the following kind:</p>
<p>1. a method on O itself<br />
2. any parameters passed to M<br />
3. any objects instantiated within M<br />
4. any direct components of O</p>
<p>The classic example coined by David Bock used a Paperboy (one object) delivering a paper, then extracting money from a Customer&#8217;s (another object) Wallet (and another):</p>
<pre class="textmate-source"><span class="source source_ruby"><span class="meta meta_class meta_class_ruby">  <span class="keyword keyword_control keyword_control_class keyword_control_class_ruby">class</span> <span class="entity entity_name entity_name_type entity_name_type_class entity_name_type_class_ruby">Paperboy</span></span>
    <span class="meta meta_function meta_function_method meta_function_method_with-arguments meta_function_method_with-arguments_ruby"><span class="keyword keyword_control keyword_control_def keyword_control_def_ruby">def</span> <span class="entity entity_name entity_name_function entity_name_function_ruby">get_payment</span><span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby">(</span><span class="variable variable_parameter variable_parameter_function variable_parameter_function_ruby">customer</span><span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby">)</span></span>
      <span class="variable variable_language variable_language_ruby">self</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>money <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_augmented keyword_operator_assignment_augmented_ruby">+=</span> customer<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>wallet<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>take_out<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="constant constant_numeric constant_numeric_ruby">10</span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>
    <span class="keyword keyword_control keyword_control_ruby">end</span>
  <span class="keyword keyword_control keyword_control_ruby">end</span></span></pre>
<p>In the &#8220;real world&#8221; the Paperboy would ask the customer for the money who would then take it out for them, rather then the Paperboy reaching into the customer&#8217;s back pocket and getting it for themself.</p>
<p>Really we want something as follows:</p>
<pre class="textmate-source"><span class="source source_ruby"><span class="meta meta_class meta_class_ruby">  <span class="keyword keyword_control keyword_control_class keyword_control_class_ruby">class</span> <span class="entity entity_name entity_name_type entity_name_type_class entity_name_type_class_ruby">Paperboy</span></span>
    <span class="meta meta_function meta_function_method meta_function_method_with-arguments meta_function_method_with-arguments_ruby"><span class="keyword keyword_control keyword_control_def keyword_control_def_ruby">def</span> <span class="entity entity_name entity_name_function entity_name_function_ruby">get_payment</span><span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby">(</span><span class="variable variable_parameter variable_parameter_function variable_parameter_function_ruby">customer</span><span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby">)</span></span>
      <span class="variable variable_language variable_language_ruby">self</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>money <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_augmented keyword_operator_assignment_augmented_ruby">+=</span> customer<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>get_payment<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="constant constant_numeric constant_numeric_ruby">10</span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>
    <span class="keyword keyword_control keyword_control_ruby">end</span>
  <span class="keyword keyword_control keyword_control_ruby">end</span>

<span class="meta meta_class meta_class_ruby">  <span class="keyword keyword_control keyword_control_class keyword_control_class_ruby">class</span> <span class="entity entity_name entity_name_type entity_name_type_class entity_name_type_class_ruby">Customer</span></span>
    <span class="meta meta_function meta_function_method meta_function_method_with-arguments meta_function_method_with-arguments_ruby"><span class="keyword keyword_control keyword_control_def keyword_control_def_ruby">def</span> <span class="entity entity_name entity_name_function entity_name_function_ruby">get_payment</span><span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby">(</span><span class="variable variable_parameter variable_parameter_function variable_parameter_function_ruby">amount</span><span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby">)</span></span>
      wallet<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>take_out<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="constant constant_numeric constant_numeric_ruby">10</span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>
    <span class="keyword keyword_control keyword_control_ruby">end</span>
  <span class="keyword keyword_control keyword_control_ruby">end</span></span></pre>
<p>This may all seem trivial and a waste of time, but what happens if some Customers want to pay by cheque? Those decisions should have an impact on the Paperboy, otherwise we end up with:</p>
<pre class="textmate-source"><span class="source source_ruby"><span class="meta meta_class meta_class_ruby">  <span class="keyword keyword_control keyword_control_class keyword_control_class_ruby">class</span> <span class="entity entity_name entity_name_type entity_name_type_class entity_name_type_class_ruby">Paperboy</span></span>
    <span class="meta meta_function meta_function_method meta_function_method_with-arguments meta_function_method_with-arguments_ruby"><span class="keyword keyword_control keyword_control_def keyword_control_def_ruby">def</span> <span class="entity entity_name entity_name_function entity_name_function_ruby">get_payment</span><span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby">(</span><span class="variable variable_parameter variable_parameter_function variable_parameter_function_ruby">customer</span><span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby">)</span></span>
      <span class="keyword keyword_control keyword_control_ruby">if</span> customer<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>pay_by_cash?
        <span class="variable variable_language variable_language_ruby">self</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>money <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_augmented keyword_operator_assignment_augmented_ruby">+=</span> customer<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>wallet<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>take_out<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="constant constant_numeric constant_numeric_ruby">10</span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>
      <span class="keyword keyword_control keyword_control_ruby">elsif</span> customer<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>pay_by_cheque?
        <span class="variable variable_language variable_language_ruby">self</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>money <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_augmented keyword_operator_assignment_augmented_ruby">+=</span> customer<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>cheque_book<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>write_cheque<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="constant constant_numeric constant_numeric_ruby">10</span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>
      <span class="keyword keyword_control keyword_control_ruby">end</span>
    <span class="keyword keyword_control keyword_control_ruby">end</span>
  <span class="keyword keyword_control keyword_control_ruby">end</span></span></pre>
<p>Where as it makes more sense for the change to be contained within the Customer:</p>
<pre class="textmate-source"><span class="source source_ruby"><span class="meta meta_class meta_class_ruby">  <span class="keyword keyword_control keyword_control_class keyword_control_class_ruby">class</span> <span class="entity entity_name entity_name_type entity_name_type_class entity_name_type_class_ruby">Paperboy</span></span>
    <span class="meta meta_function meta_function_method meta_function_method_with-arguments meta_function_method_with-arguments_ruby"><span class="keyword keyword_control keyword_control_def keyword_control_def_ruby">def</span> <span class="entity entity_name entity_name_function entity_name_function_ruby">get_payment</span><span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby">(</span><span class="variable variable_parameter variable_parameter_function variable_parameter_function_ruby">customer</span><span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby">)</span></span>
      <span class="variable variable_language variable_language_ruby">self</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>money <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_augmented keyword_operator_assignment_augmented_ruby">+=</span> customer<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>get_payment<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="constant constant_numeric constant_numeric_ruby">10</span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>
    <span class="keyword keyword_control keyword_control_ruby">end</span>
  <span class="keyword keyword_control keyword_control_ruby">end</span>

<span class="meta meta_class meta_class_ruby">  <span class="keyword keyword_control keyword_control_class keyword_control_class_ruby">class</span> <span class="entity entity_name entity_name_type entity_name_type_class entity_name_type_class_ruby">Customer</span></span>
    <span class="meta meta_function meta_function_method meta_function_method_with-arguments meta_function_method_with-arguments_ruby"><span class="keyword keyword_control keyword_control_def keyword_control_def_ruby">def</span> <span class="entity entity_name entity_name_function entity_name_function_ruby">get_payment</span><span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby">(</span><span class="variable variable_parameter variable_parameter_function variable_parameter_function_ruby">amount</span><span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby">)</span></span>
      <span class="keyword keyword_control keyword_control_ruby">if</span> pay_by_cash?
        wallet<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>take_out<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="constant constant_numeric constant_numeric_ruby">10</span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>
      <span class="keyword keyword_control keyword_control_ruby">elsif</span> pay_by_cheque?
        cheque_book<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>write_cheque<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="constant constant_numeric constant_numeric_ruby">10</span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>
      <span class="keyword keyword_control keyword_control_ruby">end</span>
    <span class="keyword keyword_control keyword_control_ruby">end</span>
  <span class="keyword keyword_control keyword_control_ruby">end</span></span></pre>
<p>So what does this have to do with Rails and the delegate method? The delegate method adds a quick and simple way of following the Law of Demeter without having to do very much at all.</p>
<pre class="textmate-source"><span class="source source_ruby"><span class="meta meta_class meta_class_ruby">  <span class="keyword keyword_control keyword_control_class keyword_control_class_ruby">class</span> <span class="entity entity_name entity_name_type entity_name_type_class entity_name_type_class_ruby">Order</span></span>
    belongs_to <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>customer</span>
  <span class="keyword keyword_control keyword_control_ruby">end</span>

<span class="meta meta_class meta_class_ruby">  <span class="keyword keyword_control keyword_control_class keyword_control_class_ruby">class</span> <span class="entity entity_name entity_name_type entity_name_type_class entity_name_type_class_ruby">Customer</span></span>
    has_many <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>orders</span>
    has_one <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>credit_card</span>
    has_one <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>bank_account</span>

    <span class="meta meta_function meta_function_method meta_function_method_without-arguments meta_function_method_without-arguments_ruby"><span class="keyword keyword_control keyword_control_def keyword_control_def_ruby">def</span> <span class="entity entity_name entity_name_function entity_name_function_ruby">payment_method</span></span>
      <span class="keyword keyword_control keyword_control_ruby">if</span> pay_by_card?
        credit_card
      <span class="keyword keyword_control keyword_control_ruby">elsif</span> pay_by_account?
        bank_account
      <span class="keyword keyword_control keyword_control_ruby">end</span>
    <span class="keyword keyword_control keyword_control_ruby">end</span>
  <span class="keyword keyword_control keyword_control_ruby">end</span>

<span class="meta meta_class meta_class_ruby">  <span class="keyword keyword_control keyword_control_class keyword_control_class_ruby">class</span> <span class="entity entity_name entity_name_type entity_name_type_class entity_name_type_class_ruby">CreditCard</span></span>
    belongs_to <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>customer</span>
  <span class="keyword keyword_control keyword_control_ruby">end</span>

<span class="meta meta_class meta_class_ruby">  <span class="keyword keyword_control keyword_control_class keyword_control_class_ruby">class</span> <span class="entity entity_name entity_name_type entity_name_type_class entity_name_type_class_ruby">BankAccount</span></span>
    belongs_to <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>customer</span>
  <span class="keyword keyword_control keyword_control_ruby">end</span></span></pre>
<p>This setup means to get an Order&#8217;s payment we would have to say:</p>
<pre class="textmate-source"><span class="source source_ruby">  <span class="variable variable_other variable_other_readwrite variable_other_readwrite_instance variable_other_readwrite_instance_ruby"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_ruby">@</span>order</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>customer<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>payment_method<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>withdraw<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span>amount<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span></span></pre>
<p>But if we simply change our objects as such:</p>
<pre class="textmate-source"><span class="source source_ruby"><span class="meta meta_class meta_class_ruby">  <span class="keyword keyword_control keyword_control_class keyword_control_class_ruby">class</span> <span class="entity entity_name entity_name_type entity_name_type_class entity_name_type_class_ruby">Order</span></span>
    belongs_to <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>customer</span>
    delegate <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>withdraw_payment</span><span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span> <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>to</span> <span class="punctuation punctuation_separator punctuation_separator_key-value">=&gt;</span> <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>customer</span>
  <span class="keyword keyword_control keyword_control_ruby">end</span>

<span class="meta meta_class meta_class_ruby">  <span class="keyword keyword_control keyword_control_class keyword_control_class_ruby">class</span> <span class="entity entity_name entity_name_type entity_name_type_class entity_name_type_class_ruby">Customer</span></span>
    has_many <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>orders</span>
    has_one <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>credit_card</span>
    has_one <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>bank_account</span>

    <span class="meta meta_function meta_function_method meta_function_method_with-arguments meta_function_method_with-arguments_ruby"><span class="keyword keyword_control keyword_control_def keyword_control_def_ruby">def</span> <span class="entity entity_name entity_name_function entity_name_function_ruby">withdraw_payment</span><span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby">(</span><span class="variable variable_parameter variable_parameter_function variable_parameter_function_ruby">amount</span><span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby">)</span></span>
      <span class="keyword keyword_control keyword_control_ruby">if</span> pay_by_card?
        credit_card<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>withdraw<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span>amount<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>
      <span class="keyword keyword_control keyword_control_ruby">elsif</span> pay_by_account?
        bank_account<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>withdraw<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span>amount<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>
      <span class="keyword keyword_control keyword_control_ruby">end</span>
    <span class="keyword keyword_control keyword_control_ruby">end</span>
  <span class="keyword keyword_control keyword_control_ruby">end</span></span></pre>
<p>Now all we have to say is:</p>
<pre class="textmate-source"><span class="source source_ruby">  <span class="variable variable_other variable_other_readwrite variable_other_readwrite_instance variable_other_readwrite_instance_ruby"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_ruby">@</span>order</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>withdraw_payment<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span>amount<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span></span></pre>
<p>So at any time, the details of how a payment  is to be decided can be contained with the Customer. This is of course a simplistic example, but hopefully explains how you chould be using this handy feature.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ur-ban.com/blog/2009/10/25/law-of-demeter-and-the-delegate-method/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>From TextMate to Vim</title>
		<link>http://www.ur-ban.com/blog/2009/10/24/from-textmate-to-vim/</link>
		<comments>http://www.ur-ban.com/blog/2009/10/24/from-textmate-to-vim/#comments</comments>
		<pubDate>Sat, 24 Oct 2009 16:00:43 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[computing]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[textmate]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://www.ur-ban.com/blog/?p=1179</guid>
		<description><![CDATA[I&#8217;ve finally done it. After months and months of on-off usage of Vim, I&#8217;m now finally using it 100% of the time. It&#8217;s been a long and hard road getting here, but let me tell you, it&#8217;s been well worth it. I now feel like I absolutely fly through my code. I&#8217;ve read many a [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="aligncenter" src="http://images.ur-ban.com/galleryv2/d/16110-1/vim.png" alt="" width="550" height="352" /></p>
<p>I&#8217;ve finally done it. After months and months of on-off usage of Vim, I&#8217;m now finally using it 100% of the time. It&#8217;s been a long and hard road getting here, but let me tell you, it&#8217;s been well worth it. I now feel like I absolutely fly through my code. I&#8217;ve read many a time, people saying that watching someone using Vim is like watching something mystical, and I can see why. Looking at how I edit code in Vim now, makes me feel clumsy when I think back to using other editors like TextMate. Don&#8217;t get me wrong, TextMate is a wonderful editor, but there is just something about the speed and finesse of editing in Vim which I have just fallen in love with.</p>
<p>I wrote about trying MacVim before and how I just felt it lacked the spit and polish that TextMate does. But now, I can&#8217;t remember why I originally felt that way. There&#8217;s a simple elegance to the Vim, yet with this awesome power available to you. Switching wasn&#8217;t easy in the slightest. I would load Vim up for an hour, tinker around, get frustrated and go back to Textmate. Then a month later I&#8217;d try again, learn a new command, last two hours and go back to TextMate. A few more months and hours turned into a full day, then the full day turned into a couple of days, and then I never looked back.</p>
<p>One of the keys to hitting the ground running is having a good config. I originally used <a href="http://github.com/jferris/config_files">jferris</a>&#8216;s vimfiles but moved to <a href="http://github.com/scrooloose/vimfiles">scrooloose&#8217;s</a> files not long ago. It practically has every plugin you could ever need to make life in Vim sublime.</p>
<p>Some other handy references I&#8217;ve used along the way have been vimtutor, the Vim Recipies Cookbook, the Vim Tips Wiki. To aid my own memory of useful commands I&#8217;ve even started my own <a href="http://vimstuff.tumblr.com/">Vim tumblr</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ur-ban.com/blog/2009/10/24/from-textmate-to-vim/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Vlad 2.0 Not Finding Tasks in deploy.rb</title>
		<link>http://www.ur-ban.com/blog/2009/09/15/vlad-2-0-not-finding-tasks-in-deploy-rb/</link>
		<comments>http://www.ur-ban.com/blog/2009/09/15/vlad-2-0-not-finding-tasks-in-deploy-rb/#comments</comments>
		<pubDate>Tue, 15 Sep 2009 17:50:55 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[computing]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.ur-ban.com/blog/?p=1142</guid>
		<description><![CDATA[When I restalled all my gems on Snow Leopard, vlad refused to find any of the tasks I had defined in my deploy.rb. I thought this was a SL issue but turned out a week before it&#8217;s release Vlad had been updated to version 2 which used a new plugin system. Looking for vlad rake [...]]]></description>
			<content:encoded><![CDATA[<p>When I restalled all my gems on Snow Leopard, vlad refused to find any of the tasks I had defined in my deploy.rb. I thought this was a SL issue but turned out a week before it&#8217;s release Vlad had been updated to version 2 which used a new plugin system. Looking for vlad rake tasks returned an error:</p>
<pre class="textmate-source"><span class="text text_plain"><span class="meta meta_paragraph meta_paragraph_text">  >> rake -T vlad
  Could not load vlad: no such file to load -- vlad/git</span></span></pre>
<p>To solve the problem just required an install of the new vlad-git gem.</p>
<pre class="textmate-source"><span class="text text_plain"><span class="meta meta_paragraph meta_paragraph_text">  >> sudo gem install vlad-git</span></span></pre>
<p>Now all my tasks were appearing properly. Vlad 2 always brought around a few changes in it&#8217;s deploy.rb and use. Here is my deploy.rb for reference:</p>
<pre class="textmate-source"><span class="source source_ruby source_ruby_rails">  set <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>application</span><span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span> <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>yourdomain<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
  set <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>domain</span><span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span> <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>yourdomain@yourdomain.com<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>

  set <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>user</span><span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span> <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>yourdomain<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
  set <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>repository</span><span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span> <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>git@github.com:youraccount/yourdomain.git<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>

  task <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>staging</span> <span class="keyword keyword_control keyword_control_start-block keyword_control_start-block_ruby">do
</span>    set <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>revision</span><span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span> <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>origin/staging<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
    set <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>deploy_to</span><span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span> <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>/opt/yourdomain.staging/<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
  <span class="keyword keyword_control keyword_control_ruby">end</span>   

  task <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>production</span> <span class="keyword keyword_control keyword_control_start-block keyword_control_start-block_ruby">do
</span>    set <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>revision</span><span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span> <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>origin/master<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
    set <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>deploy_to</span><span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span> <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>/opt/yourdomain/<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
  <span class="keyword keyword_control keyword_control_ruby">end</span>

  namespace <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>vlad</span> <span class="keyword keyword_control keyword_control_start-block keyword_control_start-block_ruby">do
</span>
    desc <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>Pull from git, run migrations, then (re)start the app server<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
    task <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>migrate_deploy</span> <span class="punctuation punctuation_separator punctuation_separator_key-value">=&gt;</span> <span class="punctuation punctuation_section punctuation_section_array punctuation_section_array_ruby">[</span><span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>update</span><span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span> <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>migrate</span><span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span> <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>start_app</span><span class="punctuation punctuation_section punctuation_section_array punctuation_section_array_ruby">]</span>

    desc <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>Pull from git then (re)start the app server<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
    task <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>deploy</span> <span class="punctuation punctuation_separator punctuation_separator_key-value">=&gt;</span> <span class="punctuation punctuation_section punctuation_section_array punctuation_section_array_ruby">[</span><span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>update</span><span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span> <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>start_app</span><span class="punctuation punctuation_section punctuation_section_array punctuation_section_array_ruby">]</span>

    desc <span class="string string_quoted string_quoted_single string_quoted_single_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">'</span>Restart Passenger<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">'</span></span>
    remote_task <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>restart</span> <span class="keyword keyword_control keyword_control_start-block keyword_control_start-block_ruby">do
</span>      puts <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>Touching: <span class="source source_ruby source_ruby_embedded source_ruby_embedded_source"><span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">#{</span>deploy_to<span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">}</span></span>current/tmp/restart.txt<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
      run <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>touch <span class="source source_ruby source_ruby_embedded source_ruby_embedded_source"><span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">#{</span>deploy_to<span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">}</span></span>/current/tmp/restart.txt<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
    <span class="keyword keyword_control keyword_control_ruby">end</span>

  <span class="keyword keyword_control keyword_control_ruby">end</span>
</span></pre>
<p>Now invoking Vlad for my staging environment works as such:</p>
<pre class="textmate-source"><span class="text text_plain"><span class="meta meta_paragraph meta_paragraph_text">  >> rake staging vlad:deploy</span></span></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ur-ban.com/blog/2009/09/15/vlad-2-0-not-finding-tasks-in-deploy-rb/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The Code Shall Set You Free</title>
		<link>http://www.ur-ban.com/blog/2009/09/06/the-code-shall-set-you-free/</link>
		<comments>http://www.ur-ban.com/blog/2009/09/06/the-code-shall-set-you-free/#comments</comments>
		<pubDate>Sun, 06 Sep 2009 01:38:26 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[computing]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[bestpractice]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.ur-ban.com/blog/?p=1130</guid>
		<description><![CDATA[I was recently asked why I don&#8217;t comment my code. It&#8217;s a fair enough question. There was a time when commenting your code was the done thing. I was once a great believer in commenting code as much as possible and would bash those that didn&#8217;t, but now I vary rarely comment my code at [...]]]></description>
			<content:encoded><![CDATA[<div style="text-align: center;"><img class="alignnone" src="http://images.ur-ban.com/galleryv2/d/16100-1/commenting_code.png" alt="" width="461" height="276" /></div>
<p>I was recently asked why I don&#8217;t comment my code. It&#8217;s a fair enough question. There was a time when commenting your code was the done thing. I was once a great believer in commenting code as much as possible and would bash those that didn&#8217;t, but now I vary rarely comment my code at all. In my current project of over 1,500 LOC, there are only a handful of comments. Many people will argue this is irresponsible. Well how is anyone supposed to pick up and understand my code, if it&#8217;s not commented?</p>
<p>The code should comment itself.</p>
<p>That just sounds silly. It&#8217;s like saying a car should drive itself. But it can be done. A lot of this change of heart about comments has come from my commitment to becoming a better developer and spending countless hours reading about the practice of great development, which is something I&#8217;ve written about in the <a href="http://www.ur-ban.com/blog/2008/12/01/its-an-improvement-adventure/">past</a>. I&#8217;m a big believer that most of the time if you need to comment a piece of code, then it&#8217;s either bad code or too complicated. Of course that&#8217;s not true 100% of the time, but for the other 99% it really is. There are cases where things need to be explained and especially warned of, but a lot of the time, commenting is just an easy escape from having to do &#8220;proper&#8221; coding. It took me years and years to get a basic understanding of proper OO and I&#8217;ve still got a long way to go to reaching Journeyman levels of understanding, but I would always create large objects with huge and complex methods, when really what I needed were more concise classes with more responsibility for what they should be able to do. It&#8217;s not object orientated when you&#8217;re focus is on the method and not the class.</p>
<p>A simple example of commented code:</p>
<pre class="textmate-source"><span class="source source_ruby"><span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby">  <span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> Feed the fish.
</span>  <span class="meta meta_function meta_function_method meta_function_method_with-arguments meta_function_method_with-arguments_ruby"><span class="keyword keyword_control keyword_control_def keyword_control_def_ruby">def</span> <span class="entity entity_name entity_name_function entity_name_function_ruby">check_food</span><span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby">(</span><span class="variable variable_parameter variable_parameter_function variable_parameter_function_ruby">food</span><span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby">)</span></span>
<span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby">     <span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> Check if Fish has eaten more then 5 hours ago.
</span>     <span class="keyword keyword_control keyword_control_ruby">if</span> <span class="variable variable_language variable_language_ruby">self</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>last_meal_time <span class="keyword keyword_operator keyword_operator_comparison keyword_operator_comparison_ruby">&lt;</span> <span class="constant constant_numeric constant_numeric_ruby">5</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>hours<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>ago
       <span class="keyword keyword_control keyword_control_pseudo-method keyword_control_pseudo-method_ruby">return</span> <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>Not hungry<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
<span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby">     <span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> Check if the Fish eats this food.
</span>     <span class="keyword keyword_control keyword_control_ruby">elsif</span> <span class="keyword keyword_operator keyword_operator_logical keyword_operator_logical_ruby">!</span><span class="variable variable_language variable_language_ruby">self</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>edible_foods<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>contains?<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span>food<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>
       <span class="keyword keyword_control keyword_control_pseudo-method keyword_control_pseudo-method_ruby">return</span> <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>Can't eat that!<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
<span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby">     <span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> Make sure the fish isn't being underfed.
</span>     <span class="keyword keyword_control keyword_control_ruby">elsif</span> food<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>amount <span class="keyword keyword_operator keyword_operator_comparison keyword_operator_comparison_ruby">&lt;</span>  fish_feeding_amount<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="variable variable_language variable_language_ruby">self</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>type<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>
       <span class="keyword keyword_control keyword_control_pseudo-method keyword_control_pseudo-method_ruby">return</span> <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>Not enough food.<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
<span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby">     <span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> Make sure the fish isn't being over fed.
</span>     <span class="keyword keyword_control keyword_control_ruby">elsif</span> food<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>amount <span class="keyword keyword_operator keyword_operator_comparison keyword_operator_comparison_ruby">&gt;</span> fish_feeding_amount<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="variable variable_language variable_language_ruby">self</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>type<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>
       <span class="keyword keyword_control keyword_control_pseudo-method keyword_control_pseudo-method_ruby">return</span> <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>Too much food.<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
     <span class="keyword keyword_control keyword_control_ruby">end</span>
<span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby">     <span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> Eat food.
</span>     <span class="variable variable_language variable_language_ruby">self</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>eat<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span>food<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>
  <span class="keyword keyword_control keyword_control_ruby">end</span></span></pre>
<p>Most comments can be done away with. If we split out functionality into more concise bits, then just reading the code should explain what&#8217;s happening better:</p>
<pre class="textmate-source"><span class="source source_ruby">  <span class="meta meta_function meta_function_method meta_function_method_with-arguments meta_function_method_with-arguments_ruby"><span class="keyword keyword_control keyword_control_def keyword_control_def_ruby">def</span> <span class="entity entity_name entity_name_function entity_name_function_ruby">feed</span><span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby">(</span><span class="variable variable_parameter variable_parameter_function variable_parameter_function_ruby">food</span><span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby">)</span></span>
    <span class="keyword keyword_control keyword_control_pseudo-method keyword_control_pseudo-method_ruby">return</span> <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>Not Hungry<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span> <span class="keyword keyword_control keyword_control_ruby">if</span> <span class="variable variable_language variable_language_ruby">self</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>recently_eaten?
    <span class="keyword keyword_control keyword_control_pseudo-method keyword_control_pseudo-method_ruby">return</span> <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>Can't eat that!<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span> <span class="keyword keyword_control keyword_control_ruby">if</span> <span class="variable variable_language variable_language_ruby">self</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>does_not_eat?<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span>food<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>
    <span class="keyword keyword_control keyword_control_pseudo-method keyword_control_pseudo-method_ruby">return</span> <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>Not Enough food<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span> <span class="keyword keyword_control keyword_control_ruby">if</span> <span class="variable variable_language variable_language_ruby">self</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>not_enough_food?<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span>food<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>
    <span class="keyword keyword_control keyword_control_pseudo-method keyword_control_pseudo-method_ruby">return</span> <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>Too much food<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span> <span class="keyword keyword_control keyword_control_ruby">if</span> <span class="keyword keyword_operator keyword_operator_logical keyword_operator_logical_ruby">!</span><span class="variable variable_language variable_language_ruby">self</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>too_much_food?<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span>food<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>
    <span class="variable variable_language variable_language_ruby">self</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>eat<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span>food<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>
  <span class="keyword keyword_control keyword_control_ruby">end</span></span></pre>
<p>This isn&#8217;t a great example as once again the validation of whether the food can/will be eaten should move into it&#8217;s own method or class ever. If we&#8217;re follow Uncle Bob&#8217;s SOLID principles, the above examples breaks the OCP (Open Closed Principle) where entities should be open to extension and closed to modification. If more validation rules were needed, then that would require the code to be modified.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ur-ban.com/blog/2009/09/06/the-code-shall-set-you-free/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Gist</title>
		<link>http://www.ur-ban.com/blog/2009/08/21/gist/</link>
		<comments>http://www.ur-ban.com/blog/2009/08/21/gist/#comments</comments>
		<pubDate>Fri, 21 Aug 2009 16:42:37 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[computing]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.ur-ban.com/blog/?p=1114</guid>
		<description><![CDATA[Great find by andhapp.]]></description>
			<content:encoded><![CDATA[<script src="http://gist.github.com/172116.js"></script>
<p>Great find by <a href="http://www.andhapp.com/blog/2009/08/20/gist-in-your-blog/">andhapp</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ur-ban.com/blog/2009/08/21/gist/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>rake spec fixtures failing</title>
		<link>http://www.ur-ban.com/blog/2009/08/06/rake-specdbfixturesload-failing-2/</link>
		<comments>http://www.ur-ban.com/blog/2009/08/06/rake-specdbfixturesload-failing-2/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 12:02:38 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.ur-ban.com/blog/?p=1088</guid>
		<description><![CDATA[For some reason my rspec fixtures were not loading into my development database when doing spec:db:fixtures:load. An extra parameter to db:fixtures:load is all that’s needed. &#62;: rake spec:db:fixtures:load rake aborted! uninitialized constant Fixtures Fixed by: &#62;: rake db:fixtures:load FIXTURES_PATH=spec/fixtures]]></description>
			<content:encoded><![CDATA[<p>For some reason my rspec fixtures were not loading into my development database when doing spec:db:fixtures:load. An extra parameter to db:fixtures:load is all that’s needed.</p>
<pre class="textmate-source">
     &gt;: rake spec:db:fixtures:load
     rake aborted!
     uninitialized constant Fixtures
</pre>
<p>Fixed by:</p>
<pre class="textmate-source">
     &gt;: rake db:fixtures:load FIXTURES_PATH=spec/fixtures
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ur-ban.com/blog/2009/08/06/rake-specdbfixturesload-failing-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>So you want to be a developer?</title>
		<link>http://www.ur-ban.com/blog/2009/03/08/so-you-want-to-be-a-developer/</link>
		<comments>http://www.ur-ban.com/blog/2009/03/08/so-you-want-to-be-a-developer/#comments</comments>
		<pubDate>Sun, 08 Mar 2009 01:54:01 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[computing]]></category>
		<category><![CDATA[work]]></category>
		<category><![CDATA[bestpractice]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.ur-ban.com/?p=1066</guid>
		<description><![CDATA[I&#8217;m so glad that I&#8217;m not just getting started as a web developer these days. Facebook is the main example I give to people when talking to about this. It has set the standard for what and how people think a web app should behave. Move forward or backwards through photos and they are dynamically [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="aligncenter" src="/galleryv2/d/15990-1/lol.jpg" alt="" width="400" height="276" /></p>
<p>I&#8217;m so glad that I&#8217;m not just getting started as a web developer these days. Facebook is the main example I give to people when talking to about this. It has set the standard for what and how people think a web app should behave. Move forward or backwards through photos and they are dynamically loaded without refreshing the page. Send someone a message and a modal box appears with autocomplete on the textboxes. You can browse the site, chat to friends and do all sorts of stuff without ever having to experience a page refresh. I even remember when they added AJAX to their photo albums. I mentally flipped as it made the site so much more usable. I showed it to someone going &#8220;Look! Look! There&#8217;s no page refresh.&#8221; while they just shrugged and went &#8220;I don&#8217;t see what you mean.&#8221;, D&#8217;oh&#8230; exactly! The sort of stuff no one even realises is happening. But I&#8217;m sure they&#8217;ll feel the difference if they use functionality on your site that&#8217;s similar to something Facebook does, but which requires a refresh where as Facebook doesn&#8217;t. Even I feel the pain of moving forward and backwards through photos on Flickr. After the third or fourth page refresh, I just give up.</p>
<p>When I got started, web stuff was so new and so simple that in hindsight it was amazing what you could get away with. You could just fly by the seat of your pants. I know I did. The first piece of web development I ever did was back in the mid nineties two days before my first interview. I wrote a Java servlet that simply took a single text parameter and queried a MySQL database using JDBC. I showed it at the interview and got a job as a web developer using Perl. I didn&#8217;t even know the Perl but still got the job. All I had to do, day-in, day-out was write HTML and scripts that responded to clicked links or submitted forms. Submit, refresh and display the result, job done, I can go home now. Creating a site wasn&#8217;t hard, almost anyone could do it and almost everyone was at the time. Life was simple and it was pretty much a level playing field. Now though, it is a totally different ball game. You&#8217;ll need good knowledge of at least a couple of languages, HTML, CSS (Yes we need it to work across all the major browsers), SQL, Javascript + a framework like jQuery + how to use AJAX.</p>
<p>There is just so much that you need to know that if you&#8217;re not doing this in your spare time, how are you supposed to ever compete with the kids nearly half your age who can already do this stuff with their eyes closed. Even me, who does this stuff every day as a job has to learn more and more if I even want a chance of staying relevant and employable. I love learning, so it doesn&#8217;t bother me. Programming still turns me on and it has to if you ever want to make a go of doing this for a living. Sometimes you can be in the fortunate position of working for a company that really loves this stuff, so you can learn and grow, but I suspect the majority of IT related jobs are done in companies where IT is a second thought to their overall business goal. Where managers prefer to say &#8220;no&#8221; to your ideas rather then say &#8220;ZOMG we could totally awesomely AJAX dis bitch up!!!11!&#8221;. And the learning doesn&#8217;t just stop at work related subjects. There&#8217;s a lot to be said about learning new languages and techniques totally unrelated to your work. Not only for the mental stimulus but also how they can teach you to approach a subject in a new way. I admit this is perhaps one area where I don&#8217;t spend enough time, but I&#8217;m trying. So go forth and learn. Be totally fucking awesome.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ur-ban.com/blog/2009/03/08/so-you-want-to-be-a-developer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
