<?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; MVC</title>
	<atom:link href="http://gaskell.org/category/mvc/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>
		<item>
		<title>Bulletproof Ajax with ASP.NET MVC (this time with jQuery)</title>
		<link>http://gaskell.org/bulletproof-ajax-with-aspnet-mvc-this-time-with-jquery/</link>
		<comments>http://gaskell.org/bulletproof-ajax-with-aspnet-mvc-this-time-with-jquery/#comments</comments>
		<pubDate>Sun, 10 Aug 2008 22:11:11 +0000</pubDate>
		<dc:creator>andy gaskell</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://gaskell.org/?p=81</guid>
		<description><![CDATA[As a follow up a recent post about using unobtrusive javascript and Ajax in your ASP.NET MVC applications, I ported the Bulletproof Ajax bookstore application to use jQuery instead of Hijax. This led to more terse code &#8211; lines of javascript were reduced from 178 to 41. If you&#8217;ve spent at least few hours jQuery [...]]]></description>
			<content:encoded><![CDATA[<p>As a follow up a <a href="/bulletproof-ajax-with-aspnet-mvc/">recent post</a> about using <a href="http://en.wikipedia.org/wiki/Unobtrusive_JavaScript" target="_blank">unobtrusive javascript</a> and Ajax in your ASP.NET MVC applications, I ported the <a href="http://www.amazon.com/Bulletproof-Ajax-Jeremy-Keith/dp/0321472667&amp;tag=9182-20">Bulletproof Ajax</a> bookstore application to use jQuery instead of <a href="http://bulletproofajax.com/shop/javascript/hijax.js">Hijax</a>. This led to more terse code &#8211; lines of javascript were reduced from 178 to 41. If you&#8217;ve spent at least few hours jQuery then you should find that the new code is also more readable. No server side code changes were necessary.
<p>jQuery is also really easy to extend &#8211; I wrote a couple of extensions that would be usable throughout an application. Here&#8217;s the extension I wrote to produce the ubiquitous <a href="http://www.37signals.com/svn/archives/000558.php">yellow fade effect</a>: </p>
<pre class="code">(<span style="color: blue">function</span>($) {
   $.fn.yellowFade = <span style="color: blue">function</span>() {
    <span style="color: blue">return this</span>.css({backgroundColor: <span style="color: #a31515">&quot;#ffffcc&quot;</span>})
    .animate({backgroundColor: <span style="color: #a31515">&quot;#ffffff&quot;</span>}, 1500, <span style="color: #a31515">&quot;linear&quot;</span>);
   }
 })(jQuery);</pre>
<p>Calling this method flows with the rest of jQuery style chaining of methods:</p>
<pre class="code"><span style="color: blue">function</span>(data) { $(<span style="color: #a31515">&quot;div#basket&quot;</span>).html(data).yellowFade(); });</pre>
<p>This one liner is a callback from our http post to the /Cart/AddProduct. The data parameter contains the response from the server. $(<span style="color: #a31515">&quot;div#basket&quot;</span>) is getting the container div from our shopping cart. Then we replace the html within the shopping cart div with the response from the server and follow it up with a yellow fade to provide user feedback.</p>
<p>Code is downloadable <a href="http://gaskell.org/upload/jShop.zip" target="_blank">here</a>. The <a href="http://jshop.gaskell.org" target="_blank">demo</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://gaskell.org/bulletproof-ajax-with-aspnet-mvc-this-time-with-jquery/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

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