<?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>gaskell.org &#187; ruby</title>
	<atom:link href="http://gaskell.org/category/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://gaskell.org</link>
	<description>picking up where teh rest leave off</description>
	<lastBuildDate>Sun, 15 Nov 2009 07:55:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Rails helper distance_of_time_in_words ported to C#</title>
		<link>http://gaskell.org/rails-helper-distance_of_time_in_words-ported-to-c/</link>
		<comments>http://gaskell.org/rails-helper-distance_of_time_in_words-ported-to-c/#comments</comments>
		<pubDate>Mon, 29 Sep 2008 06:31:10 +0000</pubDate>
		<dc:creator>andy gaskell</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[asp.net MVC]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://gaskell.org/?p=85</guid>
		<description><![CDATA[While learning rails I came across a very cool helper method called distance_of_time_in_words. You&#8217;ve probably seen this method in action if you&#8217;ve used Twitter &#8211; no guessing about time zones and as a user I think it&#8217;s a nice touch. So on to the port itself&#8230;
The Good
C# is automatically faster because everyone knows Ruby is [...]]]></description>
			<content:encoded><![CDATA[<p><img style="float:right;margin: 1em 2em;" src="/upload/kabouter-can-scale.jpg" alt="kabouter can scale." title="kabouter can scale." />While learning rails I came across a very cool helper method called <a href="http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#M001712">distance_of_time_in_words</a>. You&#8217;ve probably seen this method in action if you&#8217;ve used Twitter &#8211; no guessing about time zones and as a user I think it&#8217;s a nice touch. So on to the port itself&#8230;</p>
<p><strong>The Good</strong><br />
C# is automatically faster because everyone knows Ruby is slow and that <a href="http://canrailsscale.com">rails can&#8217;t scale</a>.<br />
Seriously though, the port to C# uses resource files so internationalization is handled by simply adding a translated resource file to your project. </p>
<p><strong>The Bad</strong><br />
C# doesn&#8217;t have the concept of static extension methods. To me DateTime.DistanceOfTimeInWords would be much nicer than DateHelper.DistanceOfTimeInWords.<br />
Range support in the language is hokey at best. No ranges in switch statements. bleh.</p>
<p><strong>The Ugly</strong><br />
The code! If you compare the C# version to the Ruby version it&#8217;s a little ahhhhhhhhhhh&#8230; inelegant? The Ruby version weighs in at 28 lines of <em>readable</em> code. The C# version is a b-e-a-s-t with 55 lines of code including 2 helper methods. I&#8217;m open to any suggestions in making the C# code shorter or more readable.</p>
<p><strong>The Rest</strong><br />
The method <a href="http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#M001713">time_ago_in_words</a> has also been ported. Altogether the helper code is 74 lines &#8211; also included is over 250 lines of test code. All examples listed on the Rails page were also included in the test.</p>
<p>You can grab the code <a href="http://gaskell.org/upload/Helpers.zip">here</a> or at the subversion repository <a href="http://svn.gaskell.org/helpers">http://svn.gaskell.org/helpers</a></p>
]]></content:encoded>
			<wfw:commentRss>http://gaskell.org/rails-helper-distance_of_time_in_words-ported-to-c/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.179 seconds -->
