<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>The McDev Blog</title> <link>http://www.mcdev.za.net</link> <description>Kevin McKelvin's general banter on software development</description> <lastBuildDate>Mon, 23 Jan 2012 12:23:44 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.2.1</generator> <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/mcdev" /><feedburner:info uri="mcdev" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item><title>Rails 3.2 Released – The upgrade story</title><link>http://feedproxy.google.com/~r/mcdev/~3/V1dh5RZBVwY/</link> <comments>http://www.mcdev.za.net/2012/01/rails-3-2-released-the-upgrade-story/#comments</comments> <pubDate>Mon, 23 Jan 2012 11:31:55 +0000</pubDate> <dc:creator>Kevin McKelvin</dc:creator> <category><![CDATA[Ruby]]></category><guid isPermaLink="false">http://www.mcdev.za.net/?p=296</guid> <description><![CDATA[Rails 3.2 was released on Friday 20 January. &#160;So as any good developer would, I started playing around with it on an app I&#8217;m building. It was a breeze getting the bundle updated, just add these lines to the Gemfile and run bundle update Once the updated gems had installed, firing up the rails server ...]]></description> <content:encoded><![CDATA[<p>Rails 3.2 was released on Friday 20 January. &nbsp;So as any good developer would, I started playing around with it on an app I&#8217;m building.</p><p>It was a breeze getting the bundle updated, just add these lines to the Gemfile and run <code>bundle update</code></p><pre class="brush: ruby; title: ; notranslate">
gem 'rails', '3.2.0'
gem 'sass-rails',   '3.2.3'
gem 'coffee-rails', '~&gt; 3.2.1'
gem 'uglifier', '&gt;= 1.0.3'
</pre><p>Once the updated gems had installed, firing up the rails server spat a few errors out.  It turns out ActiveAdmin v0.3.4 doesn&#8217;t work with Rails 3.2.  Within a few hours of the Rails release there was already a fix for this which has been pulled into the activeadmin Github repo.</p><p>Bundling against the edge release is risky, but it works and all my tests were still passing:</p><pre class="brush: ruby; title: ; notranslate">gem 'activeadmin', git: 'git://github.com/gregbell/active_admin.git'</pre><p>The last issue I had was related to using Ruby 1.9.3.  WEBrick has a few issues, so I switched over to using Thin in development instead.</p><pre class="brush: ruby; title: ; notranslate">gem 'thin'</pre><p>Overall I&#8217;ve noticed a significant improvement in speed in Rails 3.2&#8242;s development environment using Ruby 1.9.2.  It feels even faster when I ramp it up to Ruby 1.9.3.</p><p>Check out the Rails 3.2 <a
href="http://weblog.rubyonrails.org/2012/1/20/rails-3-2-0-faster-dev-mode-routing-explain-queries-tagged-logger-store">release announcement</a> and the <a
href="http://guides.rubyonrails.org/3_2_release_notes.html">upgrade instructions</a> doc.</p> <img src="http://feeds.feedburner.com/~r/mcdev/~4/V1dh5RZBVwY" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://www.mcdev.za.net/2012/01/rails-3-2-released-the-upgrade-story/feed/</wfw:commentRss> <slash:comments>0</slash:comments> <feedburner:origLink>http://www.mcdev.za.net/2012/01/rails-3-2-released-the-upgrade-story/</feedburner:origLink></item> <item><title>OSX Lion Reverse Scrolling</title><link>http://feedproxy.google.com/~r/mcdev/~3/LbL0Ap0f__8/</link> <comments>http://www.mcdev.za.net/2011/09/osx-lion-reverse-scrolling/#comments</comments> <pubDate>Wed, 21 Sep 2011 12:44:29 +0000</pubDate> <dc:creator>Kevin McKelvin</dc:creator> <category><![CDATA[Mac]]></category><guid isPermaLink="false">http://www.mcdev.za.net/?p=291</guid> <description><![CDATA[The subject of mouse movement in OS X has been debated for years now. Personally I despise the default movement settings in OS X and have a whole array of tweaks in place. But that&#8217;s a debate for another day. Today I&#8217;m looking at the new &#8220;natural&#8221; reversed scrolling feature in Lion. Having used it ...]]></description> <content:encoded><![CDATA[<p>The subject of mouse movement in OS X has been debated for years now.  Personally I despise the default movement settings in OS X and have a whole array of tweaks in place.  But that&#8217;s a debate for another day.</p><p>Today I&#8217;m looking at the new &#8220;natural&#8221; reversed scrolling feature in Lion.  Having used it for a couple of days now I found that I like having the reverse scrolling on the trackpad, but whenever I reach for my mouse I prefer the classic scrolling method that we&#8217;ve been using for years.</p><p>I dug around and couldn&#8217;t find any way inside OS X of decoupling them, but I came across a cool app called <a
href="http://pilotmoon.com/scrollreverser/" target="_blank">Scroll Reverser</a>.  It allows you to customize the reverse scrolling of the track pad and not of the mouse.</p><p>The settings might seem a bit confusing though.  I have OSX set up to reverse scrolling so that it works across all applications.  I then use Scroll Reverser to reverse the scrolling on the mouse from OSX&#8217;s behaviour back to the classic behaviour.</p><p><img
src="http://mcdev.za.net/images/110921_scrollreverser_settings.png" alt="Scroll Reverser Settings" /></p><p><img
src="http://mcdev.za.net/images/110921_mouse_pref.png" alt="" /></p> <img src="http://feeds.feedburner.com/~r/mcdev/~4/LbL0Ap0f__8" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://www.mcdev.za.net/2011/09/osx-lion-reverse-scrolling/feed/</wfw:commentRss> <slash:comments>0</slash:comments> <feedburner:origLink>http://www.mcdev.za.net/2011/09/osx-lion-reverse-scrolling/</feedburner:origLink></item> <item><title>FakeWeb</title><link>http://feedproxy.google.com/~r/mcdev/~3/c4g6LO9OvVs/</link> <comments>http://www.mcdev.za.net/2011/09/fakeweb/#comments</comments> <pubDate>Tue, 20 Sep 2011 00:24:40 +0000</pubDate> <dc:creator>Kevin McKelvin</dc:creator> <category><![CDATA[Ruby]]></category> <category><![CDATA[Testing]]></category><guid isPermaLink="false">http://www.mcdev.za.net/?p=282</guid> <description><![CDATA[I was testing a client I wrote to a server API recently. &#160;Being relatively new to testing with RSpec and Ruby, I initially took the naive approach of building a node.js application to behave as a dummy test server. Originally when I wrote the code I knew there had to be a better way, but ...]]></description> <content:encoded><![CDATA[<p>I was testing a client I wrote to a server API recently. &nbsp;Being relatively new to testing with RSpec and Ruby, I initially took the naive approach of building a node.js application to behave as a dummy test server.</p><p>Originally when I wrote the code I knew there had to be a better way, but I only found that better way today.</p><p>I was revisiting some of that code and discovered FakeWeb. &nbsp;It&#8217;s a Ruby framework that makes it simple to test code that involves HTTP requests. &nbsp;It intercepts HTTP calls made through <code>Net::HTTP</code> and makes it dead simple to create predictable responses for those calls.</p><p>This means that tests that would have been regarded as integration tests before can be isolated from the dependency on an external server and can be executed as unit tests. &nbsp;Big win!</p><p>Here&#8217;s a sample of how it works in context of RSpec:</p><pre class="brush: ruby; title: ; notranslate">
  before do
    FakeWeb.allow_net_connect = false
    register_body = {
      :id =&gt; 1
    }.to_json
    FakeWeb.register_uri(:post, 'http://localhost/register', :body =&gt; register_body)
  end
</pre><p>The first line in the before block tells FakeWeb to disallow any real network connections from happening. &nbsp;Every &#8216;connection&#8217; must be handled inside FakeWeb. &nbsp;An exception is raised if a request can&#8217;t be handled by FakeWeb directly.</p><p>The <code>register_body</code> variable simply contains the key-value pairs to be returned in the HTTP response&#8217;s body as JSON.</p><p><code>FakeWeb.register_uri</code> then registers a verb and URI to be handled by FakeWeb, and sets the body of the response. &nbsp;It&#8217;s also possible to set a status code and to handle <code>:any</code> verb.</p><p>Once the URI has been registered, any call made to that URI from <code>Net::HTTP</code> will be responded to by FakeWeb.</p><p>My tests are now running marginally faster and are far less flaky since all the external dependencies are now being substituted with a controlled and predictable stub.</p><p>To get going, just add the gem to your Gemfile and run bundler:</p><pre class="brush: ruby; title: ; notranslate">
gem 'fakeweb'
</pre><p>Also check out the <a
href="http://fakeweb.rubyforge.org/" target="_blank">FakeWeb docs at RubyForge</a></p> <img src="http://feeds.feedburner.com/~r/mcdev/~4/c4g6LO9OvVs" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://www.mcdev.za.net/2011/09/fakeweb/feed/</wfw:commentRss> <slash:comments>0</slash:comments> <feedburner:origLink>http://www.mcdev.za.net/2011/09/fakeweb/</feedburner:origLink></item> <item><title>Slim Templates</title><link>http://feedproxy.google.com/~r/mcdev/~3/CUdfqHqv_6w/</link> <comments>http://www.mcdev.za.net/2011/09/slim-templates/#comments</comments> <pubDate>Sun, 18 Sep 2011 17:48:18 +0000</pubDate> <dc:creator>Kevin McKelvin</dc:creator> <category><![CDATA[Open Source]]></category> <category><![CDATA[Ruby]]></category><guid isPermaLink="false">http://www.mcdev.za.net/?p=273</guid> <description><![CDATA[The Slim template engine seems to have gained a lot of popularity in the Rails community recently. Their site describes it as &#8216;A lightweight templating engine.&#8217; For a long time I&#8217;ve loved Haml, taking the approach that I&#8217;d rather describe my intent than hard code HTML tags all over the place. However, in hindsight having used Slim ...]]></description> <content:encoded><![CDATA[<p>The <a
href="http://slim-lang.com" target="_blank">Slim</a> template engine seems to have gained a lot of popularity in the Rails community recently.  Their site describes it as &#8216;A lightweight templating engine.&#8217; For a long time I&#8217;ve loved Haml, taking the approach that I&#8217;d rather <em>describe</em> my intent than hard code HTML tags all over the place.</p><p>However, in hindsight having used Slim for a while it appears Haml might have stepped a bit too far away from HTML, including some cryptic syntax like &#8216;%&#8217; signs to declare tags.  Slim takes a step back towards HTML.  It still uses the significant whitespace element of Haml and removes the annoying &lt;&gt;&#8217;s, but keeps you closer to the actual HTML that you&#8217;re describing.</p><p>Here&#8217;s an example of Slim (taken from a presentation I gave recently)</p><pre class="brush: plain; title: ; notranslate">
p = link_to &quot;New Link&quot;, new_link_path
- @links.each do |link|
  div class=&quot;link&quot;
    div class=&quot;title&quot; = link_to link.title, link.url, :target =&gt; &quot;_blank&quot;
    div class=&quot;description&quot; = link.description
    div class=&quot;manage&quot;
      = link_to &quot;Delete&quot;, link, :method =&gt; :delete, :confirm =&gt; 'Are you sure?'
= paginate @links
</pre><p>Nice and clean.  The way it should be <img
src='http://www.mcdev.za.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p><p>To install it in your Rails app, just add it to your <code>Gemfile</code>:</p><pre class="brush: plain; title: ; notranslate">gem 'slim-rails'</pre><p>Then create a view using the .slim file extension to start using Slim.</p><p><strong>Resources to check out:</strong><br
/> <a
href="http://slim-lang.com/" target="_blank">Slim Templates</a><br
/> <a
href="https://github.com/stonean/slim" target="_blank">Slim &#8211; Github Repo</a><br
/> <a
href="https://github.com/bbommarito/vim-slim" target="_blank">vim-slim plugin (syntax highlighting and indent assistance)</a><br
/> <a
href="http://haml-lang.com/" target="_blank">Haml</a></p><p>For those using vim and the rails.vim plugin &#8211; the most recent version of the plugin supports .slim extensions for templates.</p> <img src="http://feeds.feedburner.com/~r/mcdev/~4/CUdfqHqv_6w" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://www.mcdev.za.net/2011/09/slim-templates/feed/</wfw:commentRss> <slash:comments>0</slash:comments> <feedburner:origLink>http://www.mcdev.za.net/2011/09/slim-templates/</feedburner:origLink></item> <item><title>Out and about</title><link>http://feedproxy.google.com/~r/mcdev/~3/wdlhxe4tpOc/</link> <comments>http://www.mcdev.za.net/2011/09/out-and-about/#comments</comments> <pubDate>Fri, 16 Sep 2011 14:22:00 +0000</pubDate> <dc:creator>Kevin McKelvin</dc:creator> <category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">http://www.mcdev.za.net/?p=267</guid> <description><![CDATA[I&#8217;ve spent the better part of the last 4 months looking into what the open source communities have been up to.&#160; The .NET stack was great to work with for 2.5 years, but I always find I get a thrill out of working with new things. My books collection has been growing, particularly with PragProg ...]]></description> <content:encoded><![CDATA[<p>I&#8217;ve spent the better part of the last 4 months looking into what the open source communities have been up to.&nbsp; The .NET stack was great to work with for 2.5 years, but I always find I get a thrill out of working with new things.</p><p>My books collection has been growing, particularly with PragProg titles.&nbsp; In the last 4 months I&#8217;ve read:</p><ul><li>Seven Languages in Seven Weeks &#8211; Bruce Tate</li><li>HTML5 and CSS3 &#8211; Brian Hogan</li><li>Programming Ruby 1.9 (1.9.2 update) &#8211; Dave Thomas</li><li>The Rails 3 Way &#8211; Obie Fernandez</li></ul><p>In the mean time I&#8217;ve come to love the Ruby programming language and the Rails framework &#8211; which has just recently&nbsp;<a
href="http://weblog.rubyonrails.org/2011/8/31/rails-3-1-0-has-been-released" target="_blank">released version 3.1</a>.</p><p>I&#8217;ve been doing some learning projects over the last few weeks, including <a
href="http://platform45.com/" target="_blank">Platform45</a>&#8216;s <a
href="http://battle.platform45.com/" target="_blank">battleships developer challenge</a> and I&#8217;ve been rewriting this blog using Rails 3.1.</p> <img src="http://feeds.feedburner.com/~r/mcdev/~4/wdlhxe4tpOc" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://www.mcdev.za.net/2011/09/out-and-about/feed/</wfw:commentRss> <slash:comments>0</slash:comments> <feedburner:origLink>http://www.mcdev.za.net/2011/09/out-and-about/</feedburner:origLink></item> <item><title>jQuery PJAX @ Devs4Devs – 13 August 2011</title><link>http://feedproxy.google.com/~r/mcdev/~3/Bh9x4L2OAyk/</link> <comments>http://www.mcdev.za.net/2011/08/jquery-pjax-devs4devs-13-august-2011/#comments</comments> <pubDate>Wed, 31 Aug 2011 10:25:36 +0000</pubDate> <dc:creator>Kevin McKelvin</dc:creator> <category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">http://www.mcdev.za.net/?p=264</guid> <description><![CDATA[Saturday 13 August was Devs4Devs at Microsoft&#8217;s Bryanston offices.  Apologies that I&#8217;ve taken so long to get my slides and code out, but they&#8217;re attached at the bottom of this post Thanks everyone who attended my talk on using jQuery PJAX with ASP.NET MVC3. Here are my slides and code from the talk. Slides Code]]></description> <content:encoded><![CDATA[<p>Saturday 13 August was Devs4Devs at Microsoft&#8217;s Bryanston offices.  Apologies that I&#8217;ve taken so long to get my slides and code out, but they&#8217;re attached at the bottom of this post</p><p>Thanks everyone who attended my talk on using jQuery PJAX with ASP.NET MVC3.</p><p>Here are my slides and code from the talk.</p><p><a
href="http://mcdev.za.net/downloads/jQueryPJAX.pptx" target="_blank">Slides</a><br
/> <a
href="http://mcdev.za.net/downloads/jQueryPJAXMVCApplication.zip" target="_blank">Code</a></p> <img src="http://feeds.feedburner.com/~r/mcdev/~4/Bh9x4L2OAyk" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://www.mcdev.za.net/2011/08/jquery-pjax-devs4devs-13-august-2011/feed/</wfw:commentRss> <slash:comments>0</slash:comments> <feedburner:origLink>http://www.mcdev.za.net/2011/08/jquery-pjax-devs4devs-13-august-2011/</feedburner:origLink></item> <item><title>Devs4Devs Jo’burg – 13 August</title><link>http://feedproxy.google.com/~r/mcdev/~3/4AImR0okYHA/</link> <comments>http://www.mcdev.za.net/2011/08/devs4devs-joburg-13-august/#comments</comments> <pubDate>Tue, 09 Aug 2011 15:19:22 +0000</pubDate> <dc:creator>Kevin McKelvin</dc:creator> <category><![CDATA[Speaking]]></category><guid isPermaLink="false">http://www.mcdev.za.net/?p=260</guid> <description><![CDATA[Calling all developers!  Microsoft&#8217;s Devs4Devs is happening on 13 August 2011 at their Bryanston offices. Devs4Devs has to be my favourite developer event of the year.  There&#8217;s time to socialize with fellow geeks and learn how to use some really cool new technologies. I will be presenting on using jQuery PJAX to speed up client ...]]></description> <content:encoded><![CDATA[<p>Calling all developers!  Microsoft&#8217;s Devs4Devs is happening on 13 August 2011 at their Bryanston offices.</p><p>Devs4Devs has to be my favourite developer event of the year.  There&#8217;s time to socialize with fellow geeks and learn how to use some really cool new technologies.</p><p>I will be presenting on using jQuery PJAX to speed up client side performance with the ASP.NET MVC framework.</p><p>A list of presentations and the registration link can be found on Microsoft&#8217;s South Africa Developer Platform blog, <a
href="http://blogs.msdn.com/b/southafrica/archive/2011/08/02/devs4devs-johannesburg.aspx" target="_blank">here</a></p> <img src="http://feeds.feedburner.com/~r/mcdev/~4/4AImR0okYHA" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://www.mcdev.za.net/2011/08/devs4devs-joburg-13-august/feed/</wfw:commentRss> <slash:comments>0</slash:comments> <feedburner:origLink>http://www.mcdev.za.net/2011/08/devs4devs-joburg-13-august/</feedburner:origLink></item> <item><title>Dynamic Languages &amp; DLR Presentation – Languages UG</title><link>http://feedproxy.google.com/~r/mcdev/~3/xSg0BrUQZww/</link> <comments>http://www.mcdev.za.net/2011/07/dynamic-languages-dlr-languages-ug/#comments</comments> <pubDate>Thu, 14 Jul 2011 09:20:39 +0000</pubDate> <dc:creator>Kevin McKelvin</dc:creator> <category><![CDATA[.NET]]></category> <category><![CDATA[Speaking]]></category><guid isPermaLink="false">http://www.mcdev.za.net/?p=250</guid> <description><![CDATA[Thanks for the great turn-out at the Microsoft Community Night on 12 July, we had a full room for the languages UG! For those who weren&#8217;t there &#8211; I gave a talk on Dynamic Languages and the DLR on Tuesday 12 July. Here are the resources from the talk: IronPython: http://ironpython.codeplex.com Clay: http://clay.codeplex.com System.Dynamic: http://msdn.microsoft.com/en-us/library/system.dynamic.aspx ...]]></description> <content:encoded><![CDATA[<p>Thanks for the great turn-out at the Microsoft Community Night on 12 July, we had a full room for the languages UG!</p><p>For those who weren&#8217;t there &#8211; I gave a talk on Dynamic Languages and the DLR on Tuesday 12 July.</p><p>Here are the resources from the talk:</p><p>IronPython: <a
href="http://ironpython.codeplex.com" target="_blank">http://ironpython.codeplex.com</a><br
/> Clay: <a
href="http://clay.codeplex.com/" target="_blank">http://clay.codeplex.com</a><br
/> System.Dynamic: <a
href="http://msdn.microsoft.com/en-us/library/system.dynamic.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/system.dynamic.aspx</a></p><p>And here&#8217;s the code used to call a Python script from C#, using the DLR interop and dynamic keyword:</p><pre class="brush: csharp; title: ; notranslate">
            var engine = IronPython.Hosting.Python.CreateEngine();
            var scope = engine.Runtime.UseFile(&quot;greeter.py&quot;);
            dynamic greeterClass = scope.GetVariable(&quot;Greeter&quot;);
            dynamic greeter = greeterClass();

            dynamic s = greeter.sayHello(&quot;Kevin!&quot;);

            Console.WriteLine(s);
            Console.Read();
</pre><img src="http://feeds.feedburner.com/~r/mcdev/~4/xSg0BrUQZww" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://www.mcdev.za.net/2011/07/dynamic-languages-dlr-languages-ug/feed/</wfw:commentRss> <slash:comments>0</slash:comments> <feedburner:origLink>http://www.mcdev.za.net/2011/07/dynamic-languages-dlr-languages-ug/</feedburner:origLink></item> <item><title>Entity Framework 4.1 Hooks – DRYing it up with EFHooks</title><link>http://feedproxy.google.com/~r/mcdev/~3/WOgq1elYbWc/</link> <comments>http://www.mcdev.za.net/2011/06/entity-framework-4-1-hooks-drying-it-up-efhooks/#comments</comments> <pubDate>Tue, 21 Jun 2011 17:05:38 +0000</pubDate> <dc:creator>Kevin McKelvin</dc:creator> <category><![CDATA[Entity Framework]]></category> <category><![CDATA[Open Source]]></category><guid isPermaLink="false">http://www.mcdev.za.net/2011/06/entity-framework-4-1-hooks-drying-it-up-efhooks/</guid> <description><![CDATA[One of the things I fell in love with about Rails is its automatic management of timestamps on data.  When you create a new entity, it sets the created_at field.  When you Update it, it sets the modified_at timestamp. For a long time I’ve used NHibernate as my ORM of choice for .NET and registered ...]]></description> <content:encoded><![CDATA[<p>One of the things I fell in love with about Rails is its automatic management of timestamps on data.  When you create a new entity, it sets the created_at field.  When you Update it, it sets the modified_at timestamp.</p><p>For a long time I’ve used NHibernate as my ORM of choice for .NET and registered listeners for the pre-insert and pre-update events in NHibernate to handle this for me.  Now that Entity Framework 4.1 is out and becoming more useful I was interested in seeing how similar things could be done.</p><p>Entity Framework’s extension points are very limited compared to what NHibernate is capable of, but there is enough there to get you through most borderline scenarios you’ll hit while working with Entity Framework.</p><p>The problem I have with using the extension points is that you have to embed code inside your DbContext class to hook into the inserts, updates and deletes.  This means you’re mixing concerns of hooking into the extension point and the logic of what the hook must actually do.  This means it becomes difficult to test your hooks in isolation and that your DbContext class can become exceptionally long.</p><p>In comes <strong>EFHooks</strong>.  It’s a project I’ve just started to make it easier to hook into Entity Framework.  Check the code out on <a
href="https://github.com/kmckelvin/EFHooks" target="_blank">Github here</a>.</p><p>EFHooks allows you to separate the concerns of writing pre-action hook code from accessing the extension points and registering your hooked code for execution.  This means unit testing your hook without using a DbContext becomes easy.</p><p>Here’s an example of a hook to run before any entity that inherits from ITimeStamped gets inserted.  Everything is strongly typed, so only ITimeStamped entities will be passed into this hook.</p><pre class="brush: csharp; title: ; notranslate">
public class TimestampPreInsertHook : PreInsertHook&lt;ITimeStamped&gt;
{
    public override void Hook(ITimeStamped entity, HookEntityMetadata metadata)
    {
        entity.CreatedAt = DateTime.Now;
    }
}
</pre><p>This means you don’t need to write code to set your CreatedAt date every time you create an entity that implements ITimeStamped.  By the same pattern you could use .NET reflection on System.Object and not even have to use an interface.</p><p>Note I said “pre-action” – This handles 99% of the use cases I’ve ever hit.  I’m working on a way to handle post-action hooks as well and I’ll have it all in a Nuget package as soon as it’s stable.</p><p>Check the code out, build it, play with it and please let me know if you have any problems with it.</p><p>(Update: Post-actions are also implemented and the package is available on NuGet <a
title="EFHooks on Nuget" href="http://nuget.org/List/Packages/EFHooks" target="_blank">here</a>)</p><p>Links:</p><p><a
href="http://github.com/kmckelvin/EFHooks" target="_blank">EFHooks on Github</a></p> <img src="http://feeds.feedburner.com/~r/mcdev/~4/WOgq1elYbWc" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://www.mcdev.za.net/2011/06/entity-framework-4-1-hooks-drying-it-up-efhooks/feed/</wfw:commentRss> <slash:comments>2</slash:comments> <feedburner:origLink>http://www.mcdev.za.net/2011/06/entity-framework-4-1-hooks-drying-it-up-efhooks/</feedburner:origLink></item> <item><title>Android vs WP7</title><link>http://feedproxy.google.com/~r/mcdev/~3/gP6M7TOuLUQ/</link> <comments>http://www.mcdev.za.net/2011/06/android-vs-wp7/#comments</comments> <pubDate>Wed, 15 Jun 2011 22:41:37 +0000</pubDate> <dc:creator>Kevin McKelvin</dc:creator> <category><![CDATA[Hardware]]></category><guid isPermaLink="false">http://www.mcdev.za.net/?p=231</guid> <description><![CDATA[A couple of months ago I blogged about my experiences with WP7 on the HTC Trophy. Well soon after that I sat playing with Android 2.3.3 and began seeing holes in WP7 that I didn’t even know were there before. The first point is location based, Google has got far more market penetration here in ...]]></description> <content:encoded><![CDATA[<p>A couple of months ago I <a
href="http://www.mcdev.za.net/2011/05/windows-phone-a-few-months-later/" target="_blank">blogged about my experiences with WP7 on the HTC Trophy</a>.</p><p>Well soon after that I sat playing with Android 2.3.3 and began seeing holes in WP7 that I didn’t even know were there before.</p><p>The first point is location based, Google has got far more market penetration here in South Africa than bing has.&#160; In preparation for the Soccer world cup last year, Google beefed up their maps of South Africa including Street View, local business references, their geolocation quality and their routing engines.&#160; If I type something like “Roman’s Pizza” into my droid device it shows me the nearest Roman’s Pizza restaurants.&#160; If I type that into bing, it asks if I meant Romania.</p><p>If I were sitting in the USA this wouldn’t be an issue since bing’s market penetration seems to be far better there.</p><p>The next thing I noticed was the smoothness of apps.&#160; WP7 still has a few bugs to kill in its threading implementation which will hopefully be resolved by WP7.1.&#160; The result is that WP7 apps tend to jitter as you’re scrolling through them while visual states are updating, or when items are being added or removed from a list.&#160; The Facebook and Twitter apps demonstrate this clearly.</p><p>On Android I fire up TweetDeck and it’s silky smooth from the moment I open it.&#160; No jittering, no lagging.</p><p>That brings me to my next point, community apps.&#160; WP7 is still young and I was willing to hold on a bit for the community to catch up with apps, but it’s been slower than anyone expected to the point that it’s actually painful.&#160; At this point there is still no decent instant messenger for WP7.&#160; Whatsapp is nowhere to be seen, nor is Skype or Google Talk. (Yes… I know that Skype is on its way with WP7.1, but at the moment we’ve got nothing).</p><p>There’s just a much broader support for Android than WP7.&#160; A few other examples that have no close matching app on WP7 are the Formula 1 live timing app which I now use for every F1 race, TweetDeck, Winamp, SoundHound, Guitar tuner and Harvest time tracker.</p><p>I’ve also found that similar apps have better functionality on Droid – e.g. YouVersion Bible can stream an audio version of a passage in Droid which can’t be done in the WP7 version.&#160; I mentioned TweetDeck before, I know Birdsong is decent on WP7, but Tweetdeck is free and does an equally good job as the paid app on WP7.</p><p>When the WP7.1 update hits, I believe the two operating systems will be pretty much on par with each other – with WP7 in the lead for enterprise integration with Exchange and Lync Server.</p><p>WP7 has a great edge in a few areas already.&#160; I definitely prefer the IE based web browser in WP7 over any of the browsers on Droid.&#160; 3D graphics in games are absolutely stunning on WP7 with its Direct X based hardware accelerated rendering.&#160; Also the simple ability to fire up the camera from the lock screen is very useful.</p><p>App development for WP7 is also light years ahead of Android’s.&#160; While the tools for Android are very good (Eclipse + Java + ADK with Android Emulator), the tools for WP7 have the edge with the Blend + Visual Studio + Silverlight combination.</p><p> As things stand right now, WP7 really is a great phone OS, but its community is lacking and bing <strong>really</strong> sucks in South Africa.&#160; When the Mango update hits, when Whatsapp finally releases a client for the WP7 platform and when bing’s search in South Africa improves (or we can change over to Google search in WP7) I will probably change back over to using Windows Phone.</p> <img src="http://feeds.feedburner.com/~r/mcdev/~4/gP6M7TOuLUQ" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://www.mcdev.za.net/2011/06/android-vs-wp7/feed/</wfw:commentRss> <slash:comments>4</slash:comments> <feedburner:origLink>http://www.mcdev.za.net/2011/06/android-vs-wp7/</feedburner:origLink></item> </channel> </rss><!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 7/10 queries in 0.163 seconds using disk: basic

Served from: www.mcdev.za.net @ 2012-02-20 18:24:41 -->

