<?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:blogChannel="http://backend.userland.com/blogChannelModule" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
  <channel>
    <title>Rickard Nilsson</title>
    <description>on .NET</description>
    <link>http://www.rickardnilsson.net/</link>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <generator>BlogEngine.NET 1.5.0.7</generator>
    <language>en-GB</language>
    <blogChannel:blogRoll>http://www.rickardnilsson.net/opml.axd</blogChannel:blogRoll>
    <blogChannel:blink>http://www.rickardnilsson.net/syndication.axd</blogChannel:blink>
    <dc:creator>Rickard</dc:creator>
    <dc:title>Rickard Nilsson</dc:title>
    <geo:lat>0.000000</geo:lat>
    <geo:long>0.000000</geo:long>
    <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/RickardNilsson" type="application/rss+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
      <title>Code Kata Cast</title>
      <description>&lt;p&gt;Have you ever come across&amp;nbsp;the concept&amp;nbsp;of a&amp;nbsp;Code Kata?&lt;/p&gt;
&lt;p&gt;For me it really took off after reading blog posts (&lt;a href="http://butunclebob.com/ArticleS.UncleBob.TheBowlingGameKata" target="_blank"&gt;1&lt;/a&gt;, &lt;a href="http://butunclebob.com/ArticleS.UncleBob.ThePrimeFactorsKata" target="_blank"&gt;2&lt;/a&gt;, &lt;a href="http://codekata.pragprog.com/" target="_blank"&gt;3&lt;/a&gt;)&amp;nbsp;by &lt;a href="http://butunclebob.com/ArticleS.UncleBob" target="_blank"&gt;Unce Bob Martin&lt;/a&gt; and &lt;em&gt;Pragmatic Programmer&lt;/em&gt; &lt;a href="http://pragdave.pragprog.com/" target="_blank"&gt;Dave Thomas&lt;/a&gt;. The concept is really simple: how can we, as programmers, better our selves and improve our techniques and&amp;nbsp;proficiency&amp;nbsp;in using&amp;nbsp;the tools and processes in our every day work?&lt;/p&gt;
&lt;p&gt;The suggested solution is inspired by the martial arts kata. You learn&amp;nbsp;how to implement a solution to a specific problem and you practice all the moves in the exact same order over and over again. The point is that you should know the moves so well that you forget about them and focus on improving your key strokes and the use of your tool set. The never ending goal is to perform the kata with the least amount of key strokes.&lt;/p&gt;
&lt;p&gt;The promice is that practicing these kata's often and regularly makes you a&amp;nbsp;better and more productive programmer in that you are trained to act instinctively in certain reoccurring&amp;nbsp;situations.&lt;/p&gt;
&lt;h4&gt;Calculator kata cast&lt;/h4&gt;
&lt;p&gt;Anyway, I've been practicing a kata based on a &lt;a href="http://osherove.com/tdd-kata-1/" target="_blank"&gt;problem&lt;/a&gt; initiated by &lt;a href="http://osherove.com/" target="_blank"&gt;Roy Osherove&lt;/a&gt; and I decied to record it to get some feedback and maybe spread some knowledge on how I practice Test-driven development using &lt;a href="http://www.jetbrains.com/resharper/" target="_blank"&gt;ReSharper&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;object width="400" height="300"&gt;&lt;param name="allowfullscreen" value="true" /&gt;&lt;param name="allowscriptaccess" value="always" /&gt;&lt;param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=7293092&amp;amp;server=vimeo.com&amp;amp;show_title=1&amp;amp;show_byline=1&amp;amp;show_portrait=0&amp;amp;color=&amp;amp;fullscreen=1" /&gt;&lt;embed src="http://vimeo.com/moogaloop.swf?clip_id=7293092&amp;amp;server=vimeo.com&amp;amp;show_title=1&amp;amp;show_byline=1&amp;amp;show_portrait=0&amp;amp;color=&amp;amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="300"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;p&gt;&lt;a href="http://vimeo.com/7293092"&gt;Calculator Code Kata Cast 1&lt;/a&gt; from &lt;a href="http://vimeo.com/rickardn"&gt;Rickard Nilsson&lt;/a&gt; on &lt;a href="http://vimeo.com"&gt;Vimeo&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/RickardNilsson/~4/5fsms7pfLoM" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/RickardNilsson/~3/5fsms7pfLoM/post.aspx</link>
      <author>Rickard</author>
      <comments>http://www.rickardnilsson.net/post/2009/10/27/Code-Kata-Cast.aspx#comment</comments>
      <guid isPermaLink="false">http://www.rickardnilsson.net/post.aspx?id=d9ed9448-29bd-4202-80ec-74a3783a8dbe</guid>
      <pubDate>Tue, 27 Oct 2009 21:28:00 +0100</pubDate>
      <category>C# 3.0</category>
      <category>TDD</category>
      <category>User tip</category>
      <dc:publisher>Rickard</dc:publisher>
      <pingback:server>http://www.rickardnilsson.net/pingback.axd</pingback:server>
      <pingback:target>http://www.rickardnilsson.net/post.aspx?id=d9ed9448-29bd-4202-80ec-74a3783a8dbe</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://www.rickardnilsson.net/trackback.axd?id=d9ed9448-29bd-4202-80ec-74a3783a8dbe</trackback:ping>
      <wfw:comment>http://www.rickardnilsson.net/post/2009/10/27/Code-Kata-Cast.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.rickardnilsson.net/syndication.axd?post=d9ed9448-29bd-4202-80ec-74a3783a8dbe</wfw:commentRss>
    <feedburner:origLink>http://www.rickardnilsson.net/post.aspx?id=d9ed9448-29bd-4202-80ec-74a3783a8dbe</feedburner:origLink></item>
    <item>
      <title>TDD Masterclass in the UK with Roy Osherove</title>
      <description>&lt;p&gt;&lt;span style="font-family: 'Lucida Sans Unicode'; font-size: 12px; line-height: 19px;"&gt;
&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.2em; margin-left: 0px; padding: 0px; border: 0px initial initial;"&gt;Roy Osherove is giving an hands-on TDD Masterclass in the UK, September 21-25. Roy is author of "The Art of Unit Testing" (&lt;a style="color: #285090;" href="http://www.artofunittesting.com/"&gt;http://www.artofunittesting.com/&lt;/a&gt;), a leading tdd &amp;amp; unit testing book; he maintains a blog at&amp;nbsp;&lt;a style="color: #333333;" href="http://iserializable.com/"&gt;http://iserializable.com&lt;/a&gt;&amp;nbsp;(which amoung other things has critiqued tests written by Microsoft for&amp;nbsp;&lt;a style="color: #285090;" href="http://asp.net/"&gt;asp.net&lt;/a&gt;&amp;nbsp;MVC - check out the testreviews category) and has recently been on the Scott Hanselman podcast (&lt;a style="color: #285090;" href="http://bit.ly/psgYO"&gt;http://bit.ly/psgYO&lt;/a&gt;) where he educated Scott on best practices in Unit Testing techniques. For a further insight into Roy's style, be sure to also check out Roy's talk at the recent Norwegian Developer's Conference (&lt;a style="color: #285090;" href="http://bit.ly/NuJVa"&gt;http://bit.ly/NuJVa&lt;/a&gt;).&amp;nbsp;&lt;/p&gt;
&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.2em; margin-left: 0px; padding: 0px; border: 0px initial initial;"&gt;Full Details here:&amp;nbsp;&lt;a style="color: #285090;" href="http://bbits.co.uk/tddmasterclass"&gt;http://bbits.co.uk/tddmasterclass&lt;/a&gt;&lt;/p&gt;
&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.2em; margin-left: 0px; padding: 0px; border: 0px initial initial;"&gt;bbits are holding a raffle for a free ticket for the event. To be eligible to win the ticket (worth &amp;pound;2395!) you MUST paste this text, including all links, into your blog and email&amp;nbsp;&lt;a style="color: #285090;" href="mailto:Ian@bbits.co.uk"&gt;Ian@bbits.co.uk&lt;/a&gt;with the url to the blog entry.&amp;nbsp; The draw will be made on September 1st and the winner informed by email and on&amp;nbsp;&lt;a style="color: #285090;" href="http://bbits.co.uk/blog"&gt;bbits.co.uk/blog&lt;/a&gt;&lt;/p&gt;
&lt;/span&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/RickardNilsson/~4/IvW3MFfv8lo" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/RickardNilsson/~3/IvW3MFfv8lo/post.aspx</link>
      <author>Rickard</author>
      <comments>http://www.rickardnilsson.net/post/2009/08/31/TDD-Masterclass-in-the-UK-with-Roy-Osherove.aspx#comment</comments>
      <guid isPermaLink="false">http://www.rickardnilsson.net/post.aspx?id=d618d271-1146-4e9b-b6da-56906e8a86ed</guid>
      <pubDate>Mon, 31 Aug 2009 10:41:00 +0100</pubDate>
      <category>TDD</category>
      <dc:publisher>Rickard</dc:publisher>
      <pingback:server>http://www.rickardnilsson.net/pingback.axd</pingback:server>
      <pingback:target>http://www.rickardnilsson.net/post.aspx?id=d618d271-1146-4e9b-b6da-56906e8a86ed</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://www.rickardnilsson.net/trackback.axd?id=d618d271-1146-4e9b-b6da-56906e8a86ed</trackback:ping>
      <wfw:comment>http://www.rickardnilsson.net/post/2009/08/31/TDD-Masterclass-in-the-UK-with-Roy-Osherove.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.rickardnilsson.net/syndication.axd?post=d618d271-1146-4e9b-b6da-56906e8a86ed</wfw:commentRss>
    <feedburner:origLink>http://www.rickardnilsson.net/post.aspx?id=d618d271-1146-4e9b-b6da-56906e8a86ed</feedburner:origLink></item>
    <item>
      <title>ReSharper User tip #2: Refactor rename namespace</title>
      <description>&lt;p&gt;Have you ever wanted to rename&amp;nbsp;a namespace&amp;nbsp;but you have too many classes in the namespace that it would be an infeasible&amp;nbsp;hassle changing all of them individually. Even using a tool like ReSharper to refactor the namespaces&amp;nbsp;class by class is a hassle. I'm gonna show how to rename a namespace for all&amp;nbsp;of its classes in a couple of key strokes using ReSharper.&lt;/p&gt;
&lt;h3&gt;Example&lt;/h3&gt;
&lt;p&gt;&lt;img src="http://www.rickardnilsson.net/image.axd?picture=before.png" alt="" width="343" height="254" /&gt;&lt;/p&gt;
&lt;div style="text-align: center"&gt;&lt;img src="http://www.rickardnilsson.net/image.axd?picture=downarrow.png" alt="" width="35" height="45" /&gt;&lt;/div&gt;
&lt;p&gt;&lt;img src="http://www.rickardnilsson.net/image.axd?picture=after.png" alt="" width="344" height="254" /&gt;&lt;/p&gt;
&lt;h3&gt;Mechanics&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Open Class View (Ctrl + Shift + C)&lt;/li&gt;
&lt;li&gt;Choose the namespace you want to rename&lt;/li&gt;
&lt;li&gt;Press Ctrl + R, R&lt;a title="Visual Studio scheme" href="#sheme"&gt;*&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Pick another name&lt;/li&gt;
&lt;li&gt;Hit Next&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;and you're done!&lt;/p&gt;
&lt;p&gt;Please leave a comment if you found this useful.&lt;/p&gt;
&lt;p&gt;&lt;a title="scheme" name="scheme"&gt;&lt;/a&gt;* Visual Studio scheme&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/RickardNilsson/~4/SnsBUCj51iU" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/RickardNilsson/~3/SnsBUCj51iU/post.aspx</link>
      <author>Rickard</author>
      <comments>http://www.rickardnilsson.net/post/2008/08/26/ReSharper-User-tip-2-Refactor-rename-namespace.aspx#comment</comments>
      <guid isPermaLink="false">http://www.rickardnilsson.net/post.aspx?id=ddcec3ac-d58a-470b-aa35-ccc10cfdb394</guid>
      <pubDate>Tue, 26 Aug 2008 09:30:00 +0100</pubDate>
      <category>.NET</category>
      <category>User tip</category>
      <dc:publisher>Rickard</dc:publisher>
      <pingback:server>http://www.rickardnilsson.net/pingback.axd</pingback:server>
      <pingback:target>http://www.rickardnilsson.net/post.aspx?id=ddcec3ac-d58a-470b-aa35-ccc10cfdb394</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://www.rickardnilsson.net/trackback.axd?id=ddcec3ac-d58a-470b-aa35-ccc10cfdb394</trackback:ping>
      <wfw:comment>http://www.rickardnilsson.net/post/2008/08/26/ReSharper-User-tip-2-Refactor-rename-namespace.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.rickardnilsson.net/syndication.axd?post=ddcec3ac-d58a-470b-aa35-ccc10cfdb394</wfw:commentRss>
    <feedburner:origLink>http://www.rickardnilsson.net/post.aspx?id=ddcec3ac-d58a-470b-aa35-ccc10cfdb394</feedburner:origLink></item>
    <item>
      <title>Building a Photo Album widget for BlogEngine.NET</title>
      <description>&lt;p&gt;&lt;a href="http://www.dotnetblogengine.net"&gt;BlogEngine.NET&lt;/a&gt; has a widget framework from version 1.4 which are web part like components that can be added and removed, configured and dragged around directly in the page.&amp;nbsp;Simple widgets are very easy to create and plug in to your blog and there are several blog posts explaining how to do that. In this post I'm gonna go through a more advanced example featuring Web services and Ajax.&lt;/p&gt;
&lt;p&gt;&lt;img style="width: 274px; height: 205px;" title="The Photo Album Widget" src="http://www.rickardnilsson.net/image.axd?picture=photoalbumwidget.gif" alt="The Photo Album Widget" width="274" height="205" /&gt;&lt;br /&gt; &lt;em&gt;The Photo Album Widget&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: x-small;"&gt;Download: &lt;/span&gt;&lt;a rel="enclosure" href="http://www.rickardnilsson.net/file.axd?file=PhotoAlbumWidget-0.1.zip"&gt;&lt;span style="font-size: x-small;"&gt;PhotoAlbumWidget-0.1.zip (7,96 kb)&lt;/span&gt;&lt;/a&gt;&lt;br /&gt; Unzip to&amp;nbsp;~/widget/ folder. Requires jQuery library.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt; First we start with some requirements for the widget we're creating.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;BlogEngine.NET 1.4+ Widget&lt;/li&gt;
&lt;li&gt;Show thumbnail pictures&lt;/li&gt;
&lt;li&gt;Get pictures from Picasa web album&lt;/li&gt;
&lt;li&gt;Ajax style&amp;nbsp;asynchronous&amp;nbsp;loading&lt;/li&gt;
&lt;li&gt;&lt;span style="color: gray"&gt;Configurable number of pictures&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="color: gray"&gt;Clickable pictures to&amp;nbsp;show full size picture&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="color: gray"&gt;Picture repository provider model&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="color: gray"&gt;Flickr repository provider&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="color: gray"&gt;Folder repository provider&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="color: gray"&gt;Configurable picture count&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="color: gray"&gt;Provider specific configuration&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="color: gray"&gt;Configurable choice of provider&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="color: gray"&gt;Full size picture pops up in Lightbox&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="color: gray"&gt;Web 2.0 style controls for scrolling&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="color: gray"&gt;Larger preview on mouse over picture&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The list above is a prioritized backlog and the first version should include items 1 - 4.&lt;/p&gt;
&lt;h3&gt;Widget&amp;nbsp;&lt;/h3&gt;
&lt;p&gt;We start off with number one, a BlogEngine Widget. To create a widget we add a new folder&amp;nbsp;to the /widget/ folder and we call it PhotoAlbum. Then we create two user controls, one for widget presentation and one for configuration UI. They must be named, by convention,&amp;nbsp;widget.ascx and edit.ascx respectively and&amp;nbsp;should derive from WidgetBase and&amp;nbsp;WidgetEditBase respectively. See more on basic widgetry&amp;nbsp;&lt;a href="http://rtur.net/blog/post/2008/03/24/BlogEngine-Widgets-Tutorial.aspx"&gt;here by Rtur&lt;/a&gt; and &lt;a href="http://blog.madskristensen.dk/post/Creating-widgets-for-BlogEngineNET-14.aspx"&gt;here by Mads&lt;/a&gt; as well as&amp;nbsp;&lt;a href="http://blog.madskristensen.dk/post/Twitter-widget-example.aspx"&gt;this&lt;/a&gt;,&amp;nbsp;&lt;a href="http://blog.madskristensen.dk/post/Video-widget-framework.aspx"&gt;that&lt;/a&gt;&amp;nbsp;and &lt;a href="http://rtur.net/blog/post/2008/04/13/Using-custom-objects-in-Widgets-framework.aspx"&gt;whatnot&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;That was the easy part.&lt;/p&gt;
&lt;h3&gt;Picasa web album&lt;/h3&gt;
&lt;p&gt;With the next requirement we first need to get the pictures from somewhere so we skip to the next requirement. Picasa is Google's web album and it has its own REST API as well as a .NET client library. Conveniently there is also a public feed which contains all public photos uploaded to Picasa. (You&amp;nbsp;can of course use your own Picasa album,&amp;nbsp;see the &lt;a href="http://code.google.com/apis/picasaweb/developers_guide_dotnet.html#ListPhotos"&gt;Data API docs&lt;/a&gt; for more information).&amp;nbsp;All we need to do is provide a query tag/tags to limit the search or we'll get an error message. The following code retrieves a couple of photos picturing cats:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;&lt;p&gt;&lt;span class="type"&gt;PicasaService&lt;/span&gt; service = &lt;br /&gt;     &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="type"&gt;PicasaService&lt;/span&gt;(&lt;span class="str"&gt;"exampleCo-exampleApp-1"&lt;/span&gt;); &lt;br /&gt; &lt;br /&gt; &lt;span class="type"&gt;PhotoQuery&lt;/span&gt; query = &lt;br /&gt;     &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="type"&gt;PhotoQuery&lt;/span&gt;(&lt;span class="str"&gt;"http://picasaweb.google.com/data/feed/api/all"&lt;/span&gt;);&lt;br /&gt; query.Query = &lt;span class="str"&gt;"cat"&lt;/span&gt;;&lt;br /&gt; query.NumberToRetrieve = 5;&lt;br /&gt; &lt;span class="type"&gt;PicasaFeed&lt;/span&gt; feed = service.Query(query);&lt;/p&gt;
&lt;p&gt;&lt;span class="kwrd"&gt;foreach&lt;/span&gt; (&lt;span class="type"&gt;PicasaEntry&lt;/span&gt; entry &lt;span class="kwrd"&gt;in&lt;/span&gt; feed.Entries) {&lt;br /&gt;     &lt;span class="kwrd"&gt;string&lt;/span&gt; firstThumbUrl = entry.Media.Thumbnails[0].Attributes[&lt;span class="str"&gt;"url"&lt;/span&gt;] &lt;span class="kwrd"&gt;as&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt;;&lt;br /&gt;     writer.Write(&lt;span class="str"&gt;"&amp;lt;img src=\"{0}\" alt=\"{1}\" /&amp;gt;"&lt;/span&gt;,&lt;br /&gt;                  firstThumbUrl, entry.Title.Text);&lt;br /&gt; }&lt;/p&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;If we drop the code above into the widget.ascx.cs we affectivally fullfills both requirements 2 and 3 so lets get on with number 4.&lt;/p&gt;
&lt;h3&gt;Ajax&lt;/h3&gt;
&lt;p&gt;Requirement number four implies the Incremental Page Display pattern where the main part of the page is shown quickly and portions of the page that takes longer to load are fetched and displayed asynchronously. To give the user feedback of the loading we place an animated gif image in the widget which is later swapped out when the real pictures arrive. To accomplish this we're using the jQuery JavaScript library which let us get away with very little code for pretty advanced stuff.&lt;/p&gt;
&lt;p&gt;First we need to do a little refactoring since the widget needs to do an asynchronous call somewhere to get its content, i.e. the pictures to display. We're gonna go with the simplest possible solution here, just enough to satisfy the requirement. The simplest thing from the widget's point of view is to have the html containing a number of &amp;lt;img&amp;gt; elements returned from the call. Then it's very simple to insert the html into the widget using jQuery. Given that the widget contains a div with the id "photoalbum" this is all it takes:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;&lt;p&gt;&lt;span class="kwrd"&gt;$&lt;/span&gt;(&lt;span class="str"&gt;"#photoalbum"&lt;/span&gt;).html(the_html_to_insert);&lt;/p&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;As it is now, the widget codebehind is rendering the requested html and this is not god. We need to move the code to some place which we can&amp;nbsp;make a http request to and get the html in response. This can be done with a regular aspx page. All we need to do is to put a simple Repeater control on a page and bind it to a list of image URLs which we get from Picasa web album. So, we add a new aspx page to the /widgets/Photo Album/ folder and call it PhotoService.aspx. All we want in response is the &amp;lt;img&amp;gt; tags which should be inserted into the widget so we clear the page from html and put a single Repeater on it like this:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;&lt;p&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;asp:Repeater&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;="pictureRepeater"&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;="server"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;     &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ItemTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;         &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;asp:Image&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;="image"&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;="server"&lt;/span&gt;              &lt;span class="attr"&gt;ImageUrl&lt;/span&gt;&lt;span class="kwrd"&gt;="&amp;lt;%# Container.DataItem.ToString() %&amp;gt;"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;     &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ItemTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;asp:Repeater&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;In the codebehind we insert something like before and makes sure we bind to the Repeater control.&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;&lt;p&gt;&lt;span class="rem"&gt;// Error checking is omitted for clarity&lt;/span&gt;&lt;br /&gt; &lt;span class="type"&gt;List&lt;/span&gt;&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt; pictures = &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="type"&gt;List&lt;/span&gt;&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt;();&lt;br /&gt; &lt;span class="type"&gt;PicasaService&lt;/span&gt; service = &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="type"&gt;PicasaService&lt;/span&gt;(&lt;span class="str"&gt;"exampleCo-testApp-1"&lt;/span&gt;);&lt;/p&gt;
&lt;p&gt;&lt;span class="kwrd"&gt;string&lt;/span&gt; picasaUri = &lt;span class="str"&gt;"http://picasaweb.google.com/data/feed/api/all"&lt;/span&gt;;&lt;br /&gt; &lt;span class="type"&gt;PhotoQuery&lt;/span&gt; query = &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="type"&gt;PhotoQuery&lt;/span&gt;(picasaUri);&lt;br /&gt; query.Query = &lt;span class="str"&gt;"cat"&lt;/span&gt;;&lt;br /&gt; query.NumberToRetrieve = 6;&lt;br /&gt; &lt;span class="type"&gt;PicasaFeed&lt;/span&gt; feed = service.Query(query);&lt;/p&gt;
&lt;p&gt;&lt;span class="kwrd"&gt;foreach&lt;/span&gt; (&lt;span class="type"&gt;PicasaEntry&lt;/span&gt; entry &lt;span class="kwrd"&gt;in&lt;/span&gt; feed.Entries) {&lt;br /&gt;     &lt;span class="kwrd"&gt;string&lt;/span&gt; firstThumbUrl = entry.Media.Thumbnails[0]&lt;br /&gt;                                .Attributes[&lt;span class="str"&gt;"url"&lt;/span&gt;] &lt;span class="kwrd"&gt;as&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt;;&lt;br /&gt;     pictures.Add(firstThumbUrl);&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;pictureRepeater.DataSource = pictures;&lt;br /&gt; pictureRepeater.DataBind();&lt;/p&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;To test the service we point a web browser to /widgets/Photo Album/PhotoService.aspx which should show a bunch of cats!&amp;nbsp;Everything looks good and all we need to do to get the pictures into the widget&amp;nbsp;are two things. First we need to register the jQuery JavaScript file, either localy or a referer to the jQuery official site. Last we need to add some custom JavaScript that makes the Ajax call and puts the html at the right place.&lt;/p&gt;
&lt;p&gt;JavaScript blocks should allways, if possible, be placed as close to the &amp;lt;/body&amp;gt; tag as possible. The reason is that the browser won't continue to load the remainder of the page when it hits a JavaScript block but rather wait until it is fully loaded. This is not a problem if we're dealing with short scripts but the jQuery library is relatively large in this context so we need to put it as far down the page as possible. Our own script that does the actual work depends on jQuery, thus it must be loaded last. The problem is that we need to do this in a User control in the middle of the page. To our help to solve this we have the ClientScriptManager that every aspx page has. With the method RegisterStartupScript we get to insert arbitrary scripts just before the &amp;lt;/form&amp;gt; tag (which is close enough) of the surrounding page. We make the registrations when the widget is loaded, i.e. in the LoadWidget() method.&lt;/p&gt;
&lt;p&gt;With this final step done we have our first version of the Photo Album Widget which is ready for&amp;nbsp;demo.&lt;/p&gt;
&lt;h3&gt;Problems with the solution&lt;/h3&gt;
&lt;p&gt;Before the second iteration I'd like to summarize a couple of things with version one that are not of production quality.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;PhotoService mimics the behavior of a Web service (kind of) but is really a simple&amp;nbsp;aspx page&lt;br /&gt; - We could have done a Generic handler (ashx) instead but then we couldn't have used a Repeater&lt;br /&gt; - We could have done a custom HttpHandler but that need to go into App_Code and edit web.config which is harder to install&lt;/li&gt;
&lt;li&gt;The requirements maybe fullfilled but no one cares for a widget that only display cats! &lt;br /&gt; - We need to be able to configure the feed as well as the query.&lt;/li&gt;
&lt;/ol&gt;&lt;img src="http://feeds.feedburner.com/~r/RickardNilsson/~4/cHufM2PZ7fE" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/RickardNilsson/~3/cHufM2PZ7fE/post.aspx</link>
      <author>Rickard</author>
      <comments>http://www.rickardnilsson.net/post/2008/08/14/Building-a-Photo-Album-widget-for-BlogEngineNET.aspx#comment</comments>
      <guid isPermaLink="false">http://www.rickardnilsson.net/post.aspx?id=a3988f31-ed80-4694-b4ca-85641d66c15d</guid>
      <pubDate>Thu, 14 Aug 2008 01:07:00 +0100</pubDate>
      <category>BlogEngine.NET</category>
      <category>JavaScript</category>
      <dc:publisher>Rickard</dc:publisher>
      <pingback:server>http://www.rickardnilsson.net/pingback.axd</pingback:server>
      <pingback:target>http://www.rickardnilsson.net/post.aspx?id=a3988f31-ed80-4694-b4ca-85641d66c15d</pingback:target>
      <slash:comments>10</slash:comments>
      <trackback:ping>http://www.rickardnilsson.net/trackback.axd?id=a3988f31-ed80-4694-b4ca-85641d66c15d</trackback:ping>
      <wfw:comment>http://www.rickardnilsson.net/post/2008/08/14/Building-a-Photo-Album-widget-for-BlogEngineNET.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.rickardnilsson.net/syndication.axd?post=a3988f31-ed80-4694-b4ca-85641d66c15d</wfw:commentRss>
    <feedburner:origLink>http://www.rickardnilsson.net/post.aspx?id=a3988f31-ed80-4694-b4ca-85641d66c15d</feedburner:origLink></item>
    <item>
      <title>Applying stylesheets dynamically with jQuery</title>
      <description>&lt;p&gt;A colleague of mine asked me how to apply a stylesheet to a web page dynamically using jQuery and I had never done such a thing but my first thought was that is must be pretty simple. I've spent a lot of time thinking of so many things other than web et. al. so it was nice to delv into some of that stuff again. &lt;a title="Live Demo!" href="http://www.rickardnilsson.net/demo/dynamiccss/dynamicCss.html" target="_blank"&gt;Check out the live demo&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;As we know stylesheets are defined in the head section of an html file like this&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;&lt;p&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;html&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;     &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;head&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;         &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;link&lt;/span&gt; &lt;span class="attr"&gt;rel&lt;/span&gt;&lt;span class="kwrd"&gt;="stylesheet"&lt;/span&gt; &lt;span class="attr"&gt;href&lt;/span&gt;&lt;span class="kwrd"&gt;="stylesheet.css"&lt;/span&gt; &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;="text/css"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;     &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;head&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;     &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;body&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;     ... &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;html&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Now, say that we want to apply another stylesheet dynamically after the fact, so to speak, triggered by some event. This could be a button click or some other arbitrary event that is triggered. So, what we want to do is simply&amp;nbsp;insert a new &amp;lt;link/&amp;gt; element into the head section of the page &lt;a title="Document Object Model" href="http://www.w3schools.com/dhtml/dhtml_dom.asp"&gt;DOM&lt;/a&gt;. This can be done in a couple of lines of jQuery:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;&lt;p&gt;&lt;span class="kwrd"&gt;$&lt;/span&gt;(document).ready(&lt;span class="kwrd"&gt;function&lt;/span&gt;() {&lt;br /&gt;     &lt;span class="kwrd"&gt;$&lt;/span&gt;(&lt;span class="str"&gt;"a"&lt;/span&gt;).click(&lt;span class="kwrd"&gt;function&lt;/span&gt;() {&lt;br /&gt;         &lt;span class="kwrd"&gt;$&lt;/span&gt;(&lt;span class="str"&gt;'head'&lt;/span&gt;).append(&lt;span class="str"&gt;'&amp;lt;link rel="stylesheet" href="style2.css" type="text/css" /&amp;gt;'&lt;/span&gt;);&lt;br /&gt;     });&lt;br /&gt; });&lt;/p&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;The key is&amp;nbsp;at what time&amp;nbsp;we add the link to the style sheet. The first line in the code above repeated here asserts that the DOM is ready for manipulation.&lt;br /&gt; &lt;br /&gt; &lt;div class="code"&gt;&lt;p&gt;&lt;span class="kwrd"&gt;$&lt;/span&gt;(document).ready(&lt;span class="kwrd"&gt;function&lt;/span&gt;() {&lt;br /&gt;     &lt;span class="rem"&gt;//...&lt;/span&gt;&lt;br /&gt; });&lt;/p&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;The second part repeated here adds a click event to all hyperlinks in the page.&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;&lt;p&gt;&lt;span class="kwrd"&gt;$&lt;/span&gt;(&lt;span class="str"&gt;"a"&lt;/span&gt;).click(&lt;span class="kwrd"&gt;function&lt;/span&gt;() { &lt;span class="rem"&gt;//...&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;And the very task is performed by the last piece of code where the head element is appended with a new link element.&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;&lt;p&gt;&lt;span class="kwrd"&gt;$&lt;/span&gt;(&lt;span class="str"&gt;'head'&lt;/span&gt;).append(&lt;span class="str"&gt;'&amp;lt;link rel="stylesheet" href="style2.css" type="text/css" /&amp;gt;'&lt;/span&gt;);&lt;/p&gt;&lt;/div&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/RickardNilsson/~4/ffk3lj0thok" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/RickardNilsson/~3/ffk3lj0thok/post.aspx</link>
      <author>Rickard</author>
      <comments>http://www.rickardnilsson.net/post/2008/08/02/Applying-stylesheets-dynamically-with-jQuery.aspx#comment</comments>
      <guid isPermaLink="false">http://www.rickardnilsson.net/post.aspx?id=5c25bdf1-2101-472d-ac43-4f9582f2455c</guid>
      <pubDate>Sat, 02 Aug 2008 21:58:00 +0100</pubDate>
      <category>CSS</category>
      <category>JavaScript</category>
      <dc:publisher>Rickard</dc:publisher>
      <pingback:server>http://www.rickardnilsson.net/pingback.axd</pingback:server>
      <pingback:target>http://www.rickardnilsson.net/post.aspx?id=5c25bdf1-2101-472d-ac43-4f9582f2455c</pingback:target>
      <slash:comments>5</slash:comments>
      <trackback:ping>http://www.rickardnilsson.net/trackback.axd?id=5c25bdf1-2101-472d-ac43-4f9582f2455c</trackback:ping>
      <wfw:comment>http://www.rickardnilsson.net/post/2008/08/02/Applying-stylesheets-dynamically-with-jQuery.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.rickardnilsson.net/syndication.axd?post=5c25bdf1-2101-472d-ac43-4f9582f2455c</wfw:commentRss>
    <feedburner:origLink>http://www.rickardnilsson.net/post.aspx?id=5c25bdf1-2101-472d-ac43-4f9582f2455c</feedburner:origLink></item>
    <item>
      <title>ReSharper User tip: Refactor magical strings to variable</title>
      <description>&lt;p&gt;I've been using &lt;a href="http://www.jetbrains.com/resharper/"&gt;Jetbrains ReSharper&lt;/a&gt; a while now and I love it. I can't even imagine going back to plain Visual Studio anymore because there are so many things in my daily work that involves ReSharper, even simple tasks like editing source code and navigating through code and source files, let alone creating files and running unit tests.&lt;/p&gt;
&lt;p&gt;Now I want to share a user tip I found that isn't obvious to find nor part of any context menu. It's&amp;nbsp;actually a refactoring and I call it &lt;em&gt;Magical strings to variable&lt;/em&gt;. You can use it when you end up with&amp;nbsp;multiple equal&amp;nbsp;string literals in a piece of code. You would probably want to gather all of the string literals in a variable and reuse it through out the code.&amp;nbsp;You can use ReSharper to do it for you in a couple of key strokes.&lt;/p&gt;
&lt;h3&gt;Example&lt;/h3&gt;
&lt;p&gt;&lt;div class="code"&gt;&lt;p&gt;[&lt;span class="type"&gt;Test&lt;/span&gt;]&lt;br /&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; ParentPresenter_Update_should_update_view() {&lt;br /&gt;     &lt;span class="kwrd"&gt;var&lt;/span&gt; model = &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="type"&gt;User&lt;/span&gt; {&lt;br /&gt;                         Name = &lt;span class="str"&gt;"foo"&lt;/span&gt;&lt;br /&gt;                     };&lt;/p&gt;
&lt;p&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; (mockery.Record()) {&lt;br /&gt;         &lt;span class="type"&gt;Expect&lt;/span&gt;.Call(parentView.Username = &lt;span class="str"&gt;"foo"&lt;/span&gt;);&lt;br /&gt;     }&lt;/p&gt;
&lt;p&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; (mockery.Playback()) {&lt;br /&gt;         &lt;span class="type"&gt;IParentPresenter&lt;/span&gt; presenter = &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="type"&gt;ParentPresenter&lt;/span&gt;(parentView) {&lt;br /&gt;                                 Model = model&lt;br /&gt;                             };&lt;br /&gt;         presenter.Update();&lt;br /&gt;         &lt;span class="type"&gt;Assert&lt;/span&gt;.That(presenter.Model.Name, &lt;span class="type"&gt;Is&lt;/span&gt;.EqualTo(&lt;span class="str"&gt;"foo"&lt;/span&gt;));&lt;br /&gt;     }&lt;br /&gt; }&lt;/p&gt;&lt;/div&gt;&lt;/p&gt;
&lt;div style="text-align: center"&gt;&lt;img src="http://www.rickardnilsson.net/image.axd?picture=downarrow.png" alt="" width="35" height="45" /&gt;&lt;/div&gt;
&lt;p&gt;&lt;div class="code"&gt;&lt;p&gt;[&lt;span class="type"&gt;Test&lt;/span&gt;]&lt;br /&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; ParentPresenter_Update_should_update_view() {&lt;br /&gt;     &lt;span class="kwrd"&gt;var&lt;/span&gt; name = &lt;span class="str"&gt;"foo"&lt;/span&gt;;&lt;br /&gt;     &lt;span class="kwrd"&gt;var&lt;/span&gt; model = &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="type"&gt;User&lt;/span&gt; {&lt;br /&gt;                         Name = name&lt;br /&gt;                     };&lt;/p&gt;
&lt;p&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; (mockery.Record()) {&lt;br /&gt;         &lt;span class="type"&gt;Expect&lt;/span&gt;.Call(parentView.Username = name);&lt;br /&gt;     }&lt;/p&gt;
&lt;p&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; (mockery.Playback()) {&lt;br /&gt;         &lt;span class="type"&gt;IParentPresenter&lt;/span&gt; presenter = &lt;br /&gt;             &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="type"&gt;ParentPresenter&lt;/span&gt;(parentView) {Model = model};&lt;br /&gt;         presenter.Update();&lt;br /&gt;         &lt;span class="type"&gt;Assert&lt;/span&gt;.That(presenter.Model.Name, &lt;span class="type"&gt;Is&lt;/span&gt;.EqualTo(name));&lt;br /&gt;     }&lt;br /&gt; }&lt;/p&gt;&lt;/div&gt;&lt;/p&gt;
&lt;h3&gt;Mechanics&lt;/h3&gt;
&lt;p&gt;1. Highlight one of the string literals&lt;/p&gt;
&lt;p&gt;2. Press Ctrl+R, V &lt;span style="color: gray"&gt;(Ctrl+Alt+V)&lt;/span&gt;&lt;a title="Visual Studio scheme (ReSharper 2.x / IDEA scheme)" href="#Footnote1"&gt;*&lt;/a&gt; to introduce a variable&lt;/p&gt;
&lt;p&gt;3. Select to replace all occurrences (default option)&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.rickardnilsson.net/image.axd?picture=introducevariable.png" alt="" width="493" height="292" /&gt;&lt;/p&gt;
&lt;p&gt;4. Pick a name for the variable&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.rickardnilsson.net/image.axd?picture=pickaname.png" alt="" width="484" height="308" /&gt;&lt;/p&gt;
&lt;p&gt;..and you're done! Please leave a comment if you find this usefull.&lt;/p&gt;
&lt;p&gt;&lt;a title="Footnote1" name="Footnote1"&gt;&lt;/a&gt;* Visual Studio scheme (ReSharper 2.x / IDEA scheme)&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/RickardNilsson/~4/PAqsYFcc7-8" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/RickardNilsson/~3/PAqsYFcc7-8/post.aspx</link>
      <author>Rickard</author>
      <comments>http://www.rickardnilsson.net/post/2008/07/31/ReSharper-User-tip-Refactor-magical-strings-to-variable.aspx#comment</comments>
      <guid isPermaLink="false">http://www.rickardnilsson.net/post.aspx?id=c10c5f10-8f62-4ef6-8fde-670c0b683e60</guid>
      <pubDate>Thu, 31 Jul 2008 00:28:00 +0100</pubDate>
      <category>C# 3.0</category>
      <category>User tip</category>
      <dc:publisher>Rickard</dc:publisher>
      <pingback:server>http://www.rickardnilsson.net/pingback.axd</pingback:server>
      <pingback:target>http://www.rickardnilsson.net/post.aspx?id=c10c5f10-8f62-4ef6-8fde-670c0b683e60</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://www.rickardnilsson.net/trackback.axd?id=c10c5f10-8f62-4ef6-8fde-670c0b683e60</trackback:ping>
      <wfw:comment>http://www.rickardnilsson.net/post/2008/07/31/ReSharper-User-tip-Refactor-magical-strings-to-variable.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.rickardnilsson.net/syndication.axd?post=c10c5f10-8f62-4ef6-8fde-670c0b683e60</wfw:commentRss>
    <feedburner:origLink>http://www.rickardnilsson.net/post.aspx?id=c10c5f10-8f62-4ef6-8fde-670c0b683e60</feedburner:origLink></item>
    <item>
      <title>Blogging with MS Word 2007</title>
      <description>&lt;p&gt;
Thanks to the new &lt;a href="http://www.nyveldt.com/blog/post/Blogging-Tools-and-BlogEngineNET.aspx"&gt;MetaWebLog&lt;/a&gt; API in &lt;a href="http://www.dotnetblogengine.net/"&gt;BlogEngine.NET&lt;/a&gt; you can use MS Word 2007 to write your blog posts&amp;nbsp;including using graphics, charts and the full feature set of Word 2007. Read about how you set it up at &lt;a href="http://rtur.net/blog/post/Publishing-to-BlogEngine-from-Word-2007.aspx"&gt;Rtur.net&lt;/a&gt;. You can even use Word 2007 to edit posts on the blog server. 
&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;Note:&lt;/em&gt; This post was published using Word 2007. 
&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/RickardNilsson/~4/am8qq0m7_Bs" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/RickardNilsson/~3/am8qq0m7_Bs/post.aspx</link>
      <author>Rickard</author>
      <comments>http://www.rickardnilsson.net/post/2008/07/28/Blogging-with-MS-Word-2007.aspx#comment</comments>
      <guid isPermaLink="false">http://www.rickardnilsson.net/post.aspx?id=9cd94949-db79-4d60-b0f2-33d1af825313</guid>
      <pubDate>Mon, 28 Jul 2008 19:13:00 +0100</pubDate>
      <category>BlogEngine.NET</category>
      <dc:publisher>Rickard</dc:publisher>
      <pingback:server>http://www.rickardnilsson.net/pingback.axd</pingback:server>
      <pingback:target>http://www.rickardnilsson.net/post.aspx?id=9cd94949-db79-4d60-b0f2-33d1af825313</pingback:target>
      <slash:comments>1</slash:comments>
      <trackback:ping>http://www.rickardnilsson.net/trackback.axd?id=9cd94949-db79-4d60-b0f2-33d1af825313</trackback:ping>
      <wfw:comment>http://www.rickardnilsson.net/post/2008/07/28/Blogging-with-MS-Word-2007.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.rickardnilsson.net/syndication.axd?post=9cd94949-db79-4d60-b0f2-33d1af825313</wfw:commentRss>
    <feedburner:origLink>http://www.rickardnilsson.net/post.aspx?id=9cd94949-db79-4d60-b0f2-33d1af825313</feedburner:origLink></item>
    <item>
      <title>Problem with Related Posts in BlogEngine.NET 1.4</title>
      <description>&lt;p&gt;
With the new release of &lt;a href="http://www.dotnetblogengine.net/"&gt;BlogEngine.NET&lt;/a&gt; a new feature was added that shows the description or part of the post when listing related posts. If the description is empty a small part of the post content is listed instead and here in lies the problem. The post content is simply clipped as a certain length without regard to any tags in the post. Let&amp;#39;s say a related posts goes like this: 
&lt;/p&gt;
&lt;p&gt;
&lt;div class="code"&gt;&lt;p&gt;With the new release of &lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;a&lt;/span&gt; &lt;span class="attr"&gt;href&lt;/span&gt;&lt;span class="kwrd"&gt;="http://www.dotnetblogengine.net"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;BlogEngine.NET&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;a&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; a new feature was added.&lt;/p&gt;&lt;/div&gt; 
&lt;/p&gt;
&lt;p&gt;
Now, when the post is clipped it may end up cutting in the middle of the href: 
&lt;/p&gt;
&lt;p&gt;
&lt;div class="code"&gt;&lt;p&gt;With the new release of &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;a href="http://www.dotnetblo...&lt;/p&gt;&lt;/div&gt; 
&lt;/p&gt;
&lt;p&gt;
And this may probably screw up the layout and content of the remainder of the page, besides producing an html that will not validate. 
&lt;/p&gt;
&lt;h3&gt;Solution&lt;/h3&gt;
&lt;p&gt;
This issue has been &lt;a href="http://www.codeplex.com/blogengine/WorkItem/View.aspx?WorkItemId=6848"&gt;discovered&lt;/a&gt; and fixed for a&amp;nbsp;future release of &lt;a href="http://blog.madskristensen.dk/post/New-BlogEngineNET-release-coming-up.aspx"&gt;BlogEngine.NET&lt;/a&gt;. However, if you, like me don&amp;#39;t or can&amp;#39;t wait that long here&amp;#39;s a fix: 
&lt;/p&gt;
&lt;p&gt;
The problem is that the html tags are not closed so the simple solution is to strip the related post of all html. My first thought was to parse the post and close all open tags but when I thought about the actual intent of the related posts I realized that it is to provide a preview of the post content, not to show part of the actual post. So, by stripping all html tags all images and links are removed and only the text remains, which provides a really nice preview. 
&lt;/p&gt;
&lt;p&gt;
To implement the solution you only have to edit one line of code in the App_Code/Controls/RelatedPosts.cs file on row 139: 
&lt;/p&gt;
&lt;p&gt;
&lt;div class="code"&gt;&lt;p&gt;&lt;span class="kwrd"&gt;string&lt;/span&gt; content = post.Content;&lt;/p&gt;&lt;/div&gt; 
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;div style="text-align: center"&gt;
&lt;img src="http://www.rickardnilsson.net/image.axd?picture=downarrow.png" alt="" width="35" height="45" /&gt; 
&lt;/div&gt;
&lt;p&gt;
&lt;div class="code"&gt;&lt;p&gt;&lt;span class="kwrd"&gt;string&lt;/span&gt; content = &lt;span class="type"&gt;Utils&lt;/span&gt;.StripHtml(post.Content);&lt;/p&gt;&lt;/div&gt; 
&lt;/p&gt;
&lt;p&gt;
Or you can download the appended file and replace the one in the App_Code/Controls/ folder. 
&lt;/p&gt;
&lt;p&gt;
&lt;br /&gt;
&lt;a rel="enclosure" href="http://www.rickardnilsson.net/file.axd?file=RelatedPosts.cs"&gt;RelatedPosts.cs (3,77 kb)&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/RickardNilsson/~4/cpaXaWdvoII" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/RickardNilsson/~3/cpaXaWdvoII/post.aspx</link>
      <author>Rickard</author>
      <comments>http://www.rickardnilsson.net/post/2008/07/27/Problem-with-Related-Posts-in-BlogEngineNET-14.aspx#comment</comments>
      <guid isPermaLink="false">http://www.rickardnilsson.net/post.aspx?id=8e71f70b-132b-4dd0-8d89-7bdffeec05b1</guid>
      <pubDate>Sun, 27 Jul 2008 03:35:00 +0100</pubDate>
      <category>BlogEngine.NET</category>
      <dc:publisher>Rickard</dc:publisher>
      <pingback:server>http://www.rickardnilsson.net/pingback.axd</pingback:server>
      <pingback:target>http://www.rickardnilsson.net/post.aspx?id=8e71f70b-132b-4dd0-8d89-7bdffeec05b1</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://www.rickardnilsson.net/trackback.axd?id=8e71f70b-132b-4dd0-8d89-7bdffeec05b1</trackback:ping>
      <wfw:comment>http://www.rickardnilsson.net/post/2008/07/27/Problem-with-Related-Posts-in-BlogEngineNET-14.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.rickardnilsson.net/syndication.axd?post=8e71f70b-132b-4dd0-8d89-7bdffeec05b1</wfw:commentRss>
    <feedburner:origLink>http://www.rickardnilsson.net/post.aspx?id=8e71f70b-132b-4dd0-8d89-7bdffeec05b1</feedburner:origLink></item>
    <item>
      <title>The Humble dialog v.2</title>
      <description>&lt;div style="border: gray 1px solid; padding: 10px"&gt;Update! Download source: &lt;a rel="enclosure" href="http://www.rickardnilsson.net/file.axd?file=TheHumbleDialog2.zip"&gt;TheHumbleDialog2.zip (29,96 kb)&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;I've been working to get my head around the Model-View-Presenter pattern and I've focused primarily on a Winforms scenario. As it turns out there are numerous sources out there on MVP, some of which are focused on Winforms, e.g. [&lt;a href="#Bunea"&gt;2&lt;/a&gt;, &lt;a href="#HumbleDialogBoxExample"&gt;8&lt;/a&gt;] and some which are&amp;nbsp;not focused on Winforms&amp;nbsp;but highly valuable just the same, e.g. [&lt;a href="#JPBoodhoo"&gt;1&lt;/a&gt;,&amp;nbsp;&lt;a href="#HumbleDialogBox"&gt;4&lt;/a&gt;].&lt;/p&gt;
&lt;p&gt;&lt;a title="Screens.png" name="Screens.png"&gt;&lt;/a&gt;&lt;img src="http://www.rickardnilsson.net/image.axd?picture=Screens.png" alt="" width="364" height="240" /&gt; &lt;br /&gt; &lt;em&gt;Figure A. Screen mock up&lt;/em&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;However, none of the referenced sources discusses the issue of communication between MVP triads. All of them thoroughly discusses the ins and outs when you have&amp;nbsp;a single presenter talking to a single view and a single model, but nothing about communicating with other MVP sets. I've also found that &lt;a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2278583&amp;amp;SiteID=1&amp;amp;wa=wsignin1.0"&gt;other people&lt;/a&gt; are also struggling with this problem and how to best solve it but no really good solution has presented itself.&lt;/p&gt;
&lt;h6&gt;The problem&lt;/h6&gt;
&lt;p&gt;Well, we start with an example to formulate the problem. If we look at the example of the &lt;a href="#HumbleDialogBoxExample"&gt;humble dialog&lt;/a&gt; [8] this only covers a single triad so we make it slightly more complicated. We have two views, a parent view and a dialog view, and each view has an associated presenter, i.e. parent presenter and dialog presenter. Now, the requirement is that when a user clicks a button on the main view the dialog should pop up modally giving the user the possibility to change a property value. The value change should then be reflected in the parent view. Sounds simple enough, right?&lt;/p&gt;
&lt;p&gt;The problem is to implement this leveraging the MVP pattern to achieve a loosely coupled, highly cohesive, and test friendly solution. Some of the questions are; who has the responsibility to create the dialog view, who has the responsibility to show the view, what is the result from the dialog view and who should act on it.&lt;/p&gt;
&lt;h6&gt;MVP Solution&lt;/h6&gt;
&lt;p&gt;There are many different ways we can go about doing this but since I'm into Test-Driven Development I'm gonna do it test first. I also like to do UI up front so I create a Winforms project in Visual Studio and start dragging and dropping. The simplest possible screens are&amp;nbsp;shown in &lt;a href="#Screens.png"&gt;figure A&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;OK, now let's start with our first test. We want the dialog to appear when the "Edit user name" button is clicked and following MVP the view should simply pass on control to its presenter. The parent presenter should then have the dialog view popping up. This is the first test using &lt;a href="#RhinoMocks"&gt;Rhino Mocks&lt;/a&gt; [3]:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;&lt;p&gt;[&lt;span class="type"&gt;Test&lt;/span&gt;]&lt;br /&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; ParentPresenter_EditUsername_should_open_a_dialog() {&lt;br /&gt;     &lt;span class="kwrd"&gt;var&lt;/span&gt; view = mockery.DynamicMock&amp;lt;&lt;span class="type"&gt;IParentView&lt;/span&gt;&amp;gt;();&lt;br /&gt;     &lt;span class="kwrd"&gt;var&lt;/span&gt; dialogPresenter = mockery.CreateMock&amp;lt;&lt;span class="type"&gt;IDialogPresenter&lt;/span&gt;&amp;gt;();&lt;br /&gt;     &lt;br /&gt;     &lt;span class="kwrd"&gt;using&lt;/span&gt; (mockery.Record()) {&lt;br /&gt;         dialogPresenter.Load();&lt;br /&gt;     }&lt;/p&gt;
&lt;p&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; (mockery.Playback()) {&lt;br /&gt;         &lt;span class="kwrd"&gt;var&lt;/span&gt; presenter = &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="type"&gt;ParentPresenter&lt;/span&gt;(view)&lt;br /&gt;                             {&lt;br /&gt;                                 DialogPresenter = dialogPresenter&lt;br /&gt;                             };&lt;br /&gt;         presenter.EditValue();&lt;br /&gt;     }&lt;br /&gt; }&lt;/p&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;The parent presenter should simply pass the control to the presenter of the dialog. Thus, the parent presenter has a dependency on the presenter of the dialog and the dependency is injected through a property:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;&lt;p&gt;&lt;span class="kwrd"&gt;var&lt;/span&gt; presenter = &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="type"&gt;ParentPresenter&lt;/span&gt;(view)&lt;br /&gt;                     {&lt;br /&gt;                         DialogPresenter = dialogPresenter&lt;br /&gt;                     };&lt;/p&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Now, these&amp;nbsp;interfaces and classes doesn't exists&amp;nbsp;so first we have&amp;nbsp;to&amp;nbsp;create them. But before we do I see some code that has no test, namely dialogPresenter.Load(), so let's write&amp;nbsp;another test:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;&lt;p&gt;[&lt;span class="type"&gt;Test&lt;/span&gt;]&lt;br /&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; DialogPresenter_Load_should_call_show_on_view() {&lt;br /&gt;     &lt;span class="kwrd"&gt;var&lt;/span&gt; view = mockery.DynamicMock&amp;lt;&lt;span class="type"&gt;IDialogView&lt;/span&gt;&amp;gt;();&lt;/p&gt;
&lt;p&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; (mockery.Record()) {&lt;br /&gt;         view.Show();&lt;br /&gt;     }&lt;/p&gt;
&lt;p&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; (mockery.Playback()) {&lt;br /&gt;         &lt;span class="kwrd"&gt;var&lt;/span&gt; presenter = &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="type"&gt;DialogPresenter&lt;/span&gt;(view);&lt;br /&gt;         presenter.Load();&lt;br /&gt;     }&lt;br /&gt; }&lt;/p&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;So, the presenter simply tells the view to show itself. Remember that we're talking to an interface and that the view in the test is not the real implementation. We're only driving out the behavior of the presenter at this point but we're doing it in such a way&amp;nbsp;that the view implementation should be as thin a possible.&lt;/p&gt;
&lt;h6&gt;Code generation&lt;/h6&gt;
&lt;p&gt;I'm using &lt;a href="#ReSharper"&gt;ReSharper&lt;/a&gt; [7] to generate the interfaces and classes that I dreamed up in the tests.&lt;/p&gt;
&lt;h6&gt;More testing&lt;/h6&gt;
&lt;p&gt;When the initial tests are passing let's move on. The next thing that should happen is the user providing a new user name in the dialog and clicks on OK. So lets write a test for the OK event. I realize that some refactoring is also in place:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;&lt;p&gt;[&lt;span class="type"&gt;Test&lt;/span&gt;]&lt;br /&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; DialogPresenter_ChangeName_should_change_value_and_close_dialog() {&lt;br /&gt;     &lt;span class="kwrd"&gt;var&lt;/span&gt; model = mockery.CreateMock&amp;lt;&lt;span class="type"&gt;User&lt;/span&gt;&amp;gt;();&lt;br /&gt;     &lt;span class="kwrd"&gt;var&lt;/span&gt; callBack = mockery.CreateMock&amp;lt;&lt;span class="type"&gt;Action&lt;/span&gt;&amp;gt;();&lt;br /&gt;     &lt;span class="kwrd"&gt;var&lt;/span&gt; expectedName = &lt;span class="str"&gt;"foo"&lt;/span&gt;;&lt;/p&gt;
&lt;p&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; (mockery.Record()) {&lt;br /&gt;         &lt;span class="type"&gt;Expect&lt;/span&gt;.Call(dialogView.Username).Return(expectedName);&lt;br /&gt;         dialogView.Close();&lt;br /&gt;         callBack();&lt;br /&gt;     }&lt;/p&gt;
&lt;p&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; (mockery.Playback()) {&lt;br /&gt;         &lt;span class="type"&gt;IDialogPresenter&lt;/span&gt; presenter = &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="type"&gt;DialogPresenter&lt;/span&gt;(dialogView)&lt;br /&gt;                                          {&lt;br /&gt;                                              Model = model&lt;br /&gt;                                          };&lt;br /&gt;         presenter.NameChanged += callBack;&lt;br /&gt;         presenter.EditName();&lt;/p&gt;
&lt;p&gt;        &lt;span class="type"&gt;Assert&lt;/span&gt;.That(model.Name, &lt;span class="type"&gt;Is&lt;/span&gt;.EqualTo(expectedName));&lt;br /&gt;     }&lt;br /&gt; }&lt;/p&gt;&lt;/div&gt;&lt;/p&gt;
&lt;h6&gt;Passive view and Observer synchronization&lt;/h6&gt;
&lt;p&gt;The last requirement states that the user name change should be reflected in the parent view. There are a couple of ways to do this but in this example I'm gonna go with the&amp;nbsp;&lt;a href="#FowlerObserverSynchronization"&gt;Observer synchronization&lt;/a&gt;&amp;nbsp;[6] strategy because it provides a nice separation of concerns and is easy enough to mock. Note, however, that it is the presenter which acts as the Observable, not the domain object itself (User in this case). This is because I do not want to polute the domain model with event code. The previous test&amp;nbsp;verified&amp;nbsp;that a callback method is called whenever the name in the dialog is changed. Now, the parent presenter only has to hook up an event handler to the dialog presenter's event. Our next test shoes what should happen in the parent presenter when the event is triggered:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;&lt;p&gt;[&lt;span class="type"&gt;Test&lt;/span&gt;]&lt;br /&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; ParentPresenter_Update_should_update_view() {&lt;br /&gt;     &lt;span class="kwrd"&gt;var&lt;/span&gt; model = &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="type"&gt;User&lt;/span&gt; {Name = &lt;span class="str"&gt;"foo"&lt;/span&gt;};&lt;/p&gt;
&lt;p&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; (mockery.Record()) {&lt;br /&gt;         &lt;span class="type"&gt;Expect&lt;/span&gt;.Call(parentView.Username = &lt;span class="str"&gt;"foo"&lt;/span&gt;);&lt;br /&gt;     }&lt;/p&gt;
&lt;p&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; (mockery.Playback()) {&lt;br /&gt;         &lt;span class="kwrd"&gt;var&lt;/span&gt; presenter = &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="type"&gt;ParentPresenter&lt;/span&gt;(parentView)&lt;br /&gt;                             {&lt;br /&gt;                                 Model = model&lt;br /&gt;                             };&lt;br /&gt;         presenter.Update();&lt;br /&gt;     }&lt;br /&gt; }&lt;/p&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;So, the presenter&amp;nbsp;explicitly&amp;nbsp;tells the view&amp;nbsp;what to do. The parent view is an example of&amp;nbsp;a &lt;a href="#FowlerPassiveView"&gt;Passive view&lt;/a&gt; [5]. The presenter's code is included below for completeness:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;&lt;p&gt;&lt;span class="rem"&gt;// Parent Presenter&lt;/span&gt;&lt;br /&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; &lt;span class="type"&gt;ParentPresenter&lt;/span&gt; {&lt;br /&gt;     &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;readonly&lt;/span&gt; &lt;span class="type"&gt;IParentView&lt;/span&gt; view;&lt;/p&gt;
&lt;p&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; ParentPresenter(&lt;span class="type"&gt;IParentView&lt;/span&gt; view) {&lt;br /&gt;         &lt;span class="kwrd"&gt;this&lt;/span&gt;.view = view;&lt;br /&gt;         &lt;span class="kwrd"&gt;this&lt;/span&gt;.view.Presenter = &lt;span class="kwrd"&gt;this&lt;/span&gt;;&lt;br /&gt;         Model = &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="type"&gt;User&lt;/span&gt;();&lt;br /&gt;         DialogPresenter = &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="type"&gt;DialogPresenter&lt;/span&gt;(&lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="type"&gt;DialogView&lt;/span&gt;())&lt;br /&gt;                               {&lt;br /&gt;                                   Model = Model&lt;br /&gt;                               };&lt;br /&gt;         &lt;span class="type"&gt;DialogPresenter&lt;/span&gt;.NameChanged += Update;&lt;br /&gt;     }&lt;/p&gt;
&lt;p&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="type"&gt;IDialogPresenter&lt;/span&gt; DialogPresenter { &lt;span class="kwrd"&gt;get&lt;/span&gt;; &lt;span class="kwrd"&gt;set&lt;/span&gt;; }&lt;br /&gt;     &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="type"&gt;User&lt;/span&gt; Model { &lt;span class="kwrd"&gt;get&lt;/span&gt;; &lt;span class="kwrd"&gt;set&lt;/span&gt;; }&lt;/p&gt;
&lt;p&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Load() {&lt;br /&gt;         view.Show();&lt;br /&gt;     }&lt;/p&gt;
&lt;p&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; EditValue() {&lt;br /&gt;         &lt;span class="type"&gt;DialogPresenter&lt;/span&gt;.Load();&lt;br /&gt;     }&lt;/p&gt;
&lt;p&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Update() {&lt;br /&gt;         view.Username = &lt;span class="type"&gt;Model&lt;/span&gt;.Name;&lt;br /&gt;     }&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;&lt;span class="rem"&gt;// Dialog Presenter&lt;/span&gt;&lt;br /&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; &lt;span class="type"&gt;DialogPresenter&lt;/span&gt; : &lt;span class="type"&gt;IDialogPresenter&lt;/span&gt; {&lt;br /&gt;     &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;event&lt;/span&gt; &lt;span class="type"&gt;Action&lt;/span&gt; NameChanged;&lt;br /&gt;     &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;readonly&lt;/span&gt; &lt;span class="type"&gt;IDialogView&lt;/span&gt; view;&lt;/p&gt;
&lt;p&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; DialogPresenter(&lt;span class="type"&gt;IDialogView&lt;/span&gt; view) {&lt;br /&gt;         &lt;span class="kwrd"&gt;this&lt;/span&gt;.view = view;&lt;br /&gt;         &lt;span class="kwrd"&gt;this&lt;/span&gt;.view.Presenter = &lt;span class="kwrd"&gt;this&lt;/span&gt;;&lt;br /&gt;     }&lt;/p&gt;
&lt;p&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="type"&gt;User&lt;/span&gt; Model { &lt;span class="kwrd"&gt;get&lt;/span&gt;; &lt;span class="kwrd"&gt;set&lt;/span&gt;; }&lt;/p&gt;
&lt;p&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;virtual&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Load() {&lt;br /&gt;         view.Show();&lt;br /&gt;     }&lt;/p&gt;
&lt;p&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; EditName() {&lt;br /&gt;         &lt;span class="type"&gt;Model&lt;/span&gt;.Name = view.Username;&lt;br /&gt;         view.Close();&lt;/p&gt;
&lt;p&gt;        &lt;span class="kwrd"&gt;if&lt;/span&gt; (NameChanged != &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;br /&gt;             NameChanged();&lt;br /&gt;     }&lt;br /&gt; }&lt;/p&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;And then the view implementation which is as minimalistic as possible:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;&lt;p&gt;&lt;span class="rem"&gt;// Parent View&lt;/span&gt;&lt;br /&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;partial&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; &lt;span class="type"&gt;ParentView&lt;/span&gt; : &lt;span class="type"&gt;Form&lt;/span&gt; , &lt;span class="type"&gt;IParentView&lt;/span&gt; {&lt;br /&gt;     &lt;span class="kwrd"&gt;public&lt;/span&gt; ParentView() {&lt;br /&gt;         InitializeComponent();&lt;br /&gt;     }&lt;/p&gt;
&lt;p&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="type"&gt;ParentPresenter&lt;/span&gt; Presenter { &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;get&lt;/span&gt;; &lt;span class="kwrd"&gt;set&lt;/span&gt;; }&lt;/p&gt;
&lt;p&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Username {&lt;br /&gt;         &lt;span class="kwrd"&gt;set&lt;/span&gt; { username.Text = &lt;span class="kwrd"&gt;value&lt;/span&gt;; }&lt;br /&gt;     }&lt;/p&gt;
&lt;p&gt;    &lt;span class="kwrd"&gt;void&lt;/span&gt; &lt;span class="type"&gt;IParentView&lt;/span&gt;.Show() {&lt;br /&gt;         &lt;span class="type"&gt;Application&lt;/span&gt;.Run(&lt;span class="kwrd"&gt;this&lt;/span&gt;);&lt;br /&gt;     }&lt;/p&gt;
&lt;p&gt;    &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; editValueButton_Click(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, &lt;span class="type"&gt;EventArgs&lt;/span&gt; e) {&lt;br /&gt;         &lt;span class="type"&gt;Presenter&lt;/span&gt;.EditValue();&lt;br /&gt;     }&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;&lt;span class="rem"&gt;// Dialog View&lt;/span&gt;&lt;br /&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;partial&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; &lt;span class="type"&gt;DialogView&lt;/span&gt; : &lt;span class="type"&gt;Form&lt;/span&gt; , &lt;span class="type"&gt;IDialogView&lt;/span&gt; {&lt;br /&gt;     &lt;span class="kwrd"&gt;public&lt;/span&gt; DialogView() {&lt;br /&gt;         InitializeComponent();&lt;br /&gt;     }&lt;/p&gt;
&lt;p&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="type"&gt;IDialogPresenter&lt;/span&gt; Presenter { &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;get&lt;/span&gt;; &lt;span class="kwrd"&gt;set&lt;/span&gt;; }&lt;/p&gt;
&lt;p&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Username {&lt;br /&gt;         &lt;span class="kwrd"&gt;get&lt;/span&gt; { &lt;span class="kwrd"&gt;return&lt;/span&gt; nameTextBox.Text; }&lt;br /&gt;     }&lt;/p&gt;
&lt;p&gt;    &lt;span class="kwrd"&gt;void&lt;/span&gt; &lt;span class="type"&gt;IDialogView&lt;/span&gt;.Show() {&lt;br /&gt;         ShowDialog();&lt;br /&gt;     }&lt;/p&gt;
&lt;p&gt;    &lt;span class="kwrd"&gt;void&lt;/span&gt; &lt;span class="type"&gt;IDialogView&lt;/span&gt;.Close() {&lt;br /&gt;         Close();&lt;br /&gt;     }&lt;/p&gt;
&lt;p&gt;    &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; acceptButton_Click(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, &lt;span class="type"&gt;EventArgs&lt;/span&gt; e) {&lt;br /&gt;         &lt;span class="type"&gt;Presenter&lt;/span&gt;.EditName();&lt;br /&gt;     }&lt;br /&gt; }&lt;/p&gt;&lt;/div&gt;&lt;/p&gt;
&lt;h6&gt;Conclusion&lt;/h6&gt;
&lt;p&gt;The way the MVP parts are separated makes&amp;nbsp;a&amp;nbsp;UI with allmost 100% test coverage but above&amp;nbsp;all the UI logic is in a separate class which is not tied to a frame, thus enabling us to discover duplicated code and oportunities to refactor and keep the UI maintainable. I think that this is a great way of driving out a design since I start out with the client hat on and not the other way around were I&amp;nbsp;first list a bunch of methods and properties on a class. IMO&amp;nbsp;this kind of interaction based testing really lends itself to driving out&amp;nbsp;interaction design, and tools like ReSharper really makes the&amp;nbsp;developer experience pleasant and productive.&lt;/p&gt;
&lt;h6&gt;References&lt;/h6&gt;
&lt;p&gt;&lt;a title="JPBoodhoo" name="JPBoodhoo"&gt;&lt;/a&gt;[1] Jean-Paul Boodhoo. &lt;a href="http://msdn.microsoft.com/msdnmag/issues/06/08/DesignPatterns/"&gt;Design Patterns: Model View Presenter&lt;/a&gt;&lt;br /&gt; &lt;a title="Bunea" name="Bunea"&gt;&lt;/a&gt;[2] Dan Bunea. &lt;a href="http://danbunea.blogspot.com/2005/11/model-view-presenter-is-testing_27.html"&gt;Model View Presenter - is testing the presenter enough&lt;/a&gt;&lt;br /&gt; &lt;a title="RhinoMocks" name="RhinoMocks"&gt;&lt;/a&gt;[3] Oren Eini. &lt;a href="http://www.ayende.com/projects/rhino-mocks.aspx"&gt;Rhino Mocks - dynamic mocking framework&lt;/a&gt;&lt;br /&gt; &lt;a title="HumbleDialogBox" name="HumbleDialogBox"&gt;&lt;/a&gt;[4] Michael Feathers. &lt;a href="http://www.objectmentor.com/resources/articles/TheHumbleDialogBox.pdf"&gt;The Humble Dialog Box&lt;/a&gt;&lt;br /&gt; &lt;a title="FowlerPassiveView" name="FowlerPassiveView"&gt;&lt;/a&gt;[5] Martin Fowler. &lt;a href="http://martinfowler.com/eaaDev/PassiveScreen.html"&gt;Passive View&lt;/a&gt; &lt;br /&gt; &lt;a title="FowlerObserverSynchronization" name="FowlerObserverSynchronization"&gt;&lt;/a&gt;[6] Martin Fowler. &lt;a href="http://martinfowler.com/eaaDev/MediatedSynchronization.html"&gt;Observer Synchronization&lt;/a&gt;&lt;br /&gt; &lt;a title="ReSharper" name="ReSharper"&gt;&lt;/a&gt;[7] JetBrains. &lt;a href="http://www.jetbrains.com/resharper/"&gt;ReSharper&lt;/a&gt;&lt;br /&gt; &lt;a title="HumbleDialogBoxExample" name="HumbleDialogBoxExample"&gt;&lt;/a&gt;[8] Jeremy Miller. &lt;a href="http://codebetter.com/blogs/jeremy.miller/articles/129546.aspx"&gt;A&amp;nbsp;Simple&amp;nbsp;Example of the "Humble Dialog Box"&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/RickardNilsson/~4/FbNNuhwhQqY" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/RickardNilsson/~3/FbNNuhwhQqY/post.aspx</link>
      <author>Rickard</author>
      <comments>http://www.rickardnilsson.net/post/2008/07/15/The-Humble-dialog-v2.aspx#comment</comments>
      <guid isPermaLink="false">http://www.rickardnilsson.net/post.aspx?id=3a386a58-6c19-421c-b641-d83055e84ead</guid>
      <pubDate>Tue, 15 Jul 2008 20:41:00 +0100</pubDate>
      <category>C# 3.0</category>
      <category>Design Patterns</category>
      <category>TDD</category>
      <dc:publisher>Rickard</dc:publisher>
      <pingback:server>http://www.rickardnilsson.net/pingback.axd</pingback:server>
      <pingback:target>http://www.rickardnilsson.net/post.aspx?id=3a386a58-6c19-421c-b641-d83055e84ead</pingback:target>
      <slash:comments>8</slash:comments>
      <trackback:ping>http://www.rickardnilsson.net/trackback.axd?id=3a386a58-6c19-421c-b641-d83055e84ead</trackback:ping>
      <wfw:comment>http://www.rickardnilsson.net/post/2008/07/15/The-Humble-dialog-v2.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.rickardnilsson.net/syndication.axd?post=3a386a58-6c19-421c-b641-d83055e84ead</wfw:commentRss>
    <feedburner:origLink>http://www.rickardnilsson.net/post.aspx?id=3a386a58-6c19-421c-b641-d83055e84ead</feedburner:origLink></item>
    <item>
      <title>Syntax Highlighter Release 0.2 Beta</title>
      <description>&lt;p&gt;Thanks to a great deal of interest on my post on &lt;a href="http://www.rickardnilsson.net/post/Syntax-highlighting-in-BlogEngineNET.aspx"&gt;syntax highlighting in BlogEngine.NET&lt;/a&gt; a while ago I'm now releasing a new version. It is&amp;nbsp;based on&amp;nbsp;the version that ships with BlogEngine.NET but it has been augmented as well as refactored to support more language elements like types in C#. The code formatter has been&amp;nbsp;extracted&amp;nbsp;and the new version is released through &lt;a href="http://www.codeplex.com/syntaxhighlighter"&gt;&lt;span style="font-size: x-small;"&gt;CodePlex&lt;/span&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Additional features compared to version 0.1&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Highlighting of types in C#&lt;/li&gt;
&lt;li&gt;Architecture to support additional language elements&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Syntax Highlighter Extension&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The code block is recognized anywhere&amp;nbsp;in the blog post and&amp;nbsp;does not require any special formatting before or after the code tags&lt;/li&gt;
&lt;/ul&gt;
&lt;h6&gt;Download&lt;/h6&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.codeplex.com/syntaxhighlighter"&gt;&lt;span style="font-size: x-small;"&gt;www.codeplex.com/syntaxhighlighter&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I will start a series of blog posts on using and developing the new version. I thank those who have shown interest.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/RickardNilsson/~4/5OP6I6xZynY" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/RickardNilsson/~3/5OP6I6xZynY/post.aspx</link>
      <author>Rickard</author>
      <comments>http://www.rickardnilsson.net/post/2008/05/05/Syntax-Highlighter-Release-02-Beta.aspx#comment</comments>
      <guid isPermaLink="false">http://www.rickardnilsson.net/post.aspx?id=0d3dca08-f8e1-4ffb-abc5-d3919c69ea9d</guid>
      <pubDate>Mon, 05 May 2008 21:50:00 +0100</pubDate>
      <category>BlogEngine.NET</category>
      <dc:publisher>Rickard</dc:publisher>
      <pingback:server>http://www.rickardnilsson.net/pingback.axd</pingback:server>
      <pingback:target>http://www.rickardnilsson.net/post.aspx?id=0d3dca08-f8e1-4ffb-abc5-d3919c69ea9d</pingback:target>
      <slash:comments>19</slash:comments>
      <trackback:ping>http://www.rickardnilsson.net/trackback.axd?id=0d3dca08-f8e1-4ffb-abc5-d3919c69ea9d</trackback:ping>
      <wfw:comment>http://www.rickardnilsson.net/post/2008/05/05/Syntax-Highlighter-Release-02-Beta.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.rickardnilsson.net/syndication.axd?post=0d3dca08-f8e1-4ffb-abc5-d3919c69ea9d</wfw:commentRss>
    <feedburner:origLink>http://www.rickardnilsson.net/post.aspx?id=0d3dca08-f8e1-4ffb-abc5-d3919c69ea9d</feedburner:origLink></item>
    <item>
      <title>Syntax highlighting in BlogEngine.NET</title>
      <description>&lt;p&gt;BlogEngine.NET ships with an extension that automatically highlights source code in blog posts. All that is required is that the source code block is surrounded with [&lt;!-- not a code block--&gt;code:lang][&lt;!-- nacb --&gt;/code] tags. The extension will markup the code with CSS classes and the default theme includes a default color scheme for code elements like keywords, comments, and so forth. The extension ships with support for HTML, C#, JavaScript, T-SQL, MSH, and&amp;nbsp;Visual Basic.&lt;/p&gt;
&lt;p&gt;In forums and blogs in the BlogEngine community issues with the syntax highlighter extension has been brought up.&amp;nbsp;Some&amp;nbsp;of it can be found &lt;a href="http://www.codeplex.com/blogengine/Thread/View.aspx?ThreadId=19668"&gt;&lt;span style="font-size: x-small;"&gt;here&lt;/span&gt;&lt;/a&gt;, &lt;a href="http://www.codeplex.com/blogengine/Thread/View.aspx?ThreadId=16193"&gt;&lt;span style="font-size: x-small;"&gt;here&lt;/span&gt;&lt;/a&gt;, and &lt;a href="http://www.codeplex.com/blogengine/Thread/View.aspx?ThreadId=22314"&gt;&lt;span style="font-size: x-small;"&gt;here&lt;/span&gt;&lt;/a&gt;.&amp;nbsp;Many has complained about how hard it is to use and lack of&amp;nbsp;proper documentation. To get the tags to be recognized by the extension you have to format your post&amp;nbsp;in a&amp;nbsp;really precise manor with a leading and trailing &lt;span style="color: #0040b6"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;p&lt;/span&gt;&lt;span style="color: #0040b6"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon"&gt;p&lt;/span&gt;&lt;span style="color: #0040b6"&gt;&amp;gt;&lt;/span&gt;. Besides&amp;nbsp;taking up a lot of unnecessary space when editing the post, this is why so many has complained that they can't get it to work. If the block is not correctly surrounded with the right amount of line breaks two things can happen. Either the whole code block is masked or the code is shown but the tags are rendered as part of the code block.&lt;/p&gt;
&lt;p&gt;My own experience with this is pretty much the same and the only way to find out how it works was for me to read and step through the code. Since the extension is open source there is no hinder for improving the code base, hence I've been working&amp;nbsp;to improve&amp;nbsp;it to meet the community need, as well as my own. In addition to the mentioned usability issues&amp;nbsp;I missed highlighting of types in C#, that is class, interface, and struct names which we are used to see&amp;nbsp;in Visual Studio&amp;nbsp;colored in cyan.&lt;/p&gt;
&lt;h6&gt;New version&lt;/h6&gt;
&lt;p&gt;I'm about to present a new version of the extension which&amp;nbsp;will include&amp;nbsp;the following&amp;nbsp;improvements:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Highlighting of&amp;nbsp;types&amp;nbsp;in C#&lt;/li&gt;
&lt;li&gt;The code block is recognized anywhere&amp;nbsp;in the blog post and&amp;nbsp;does not require any special formatting before or after the code tags.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Leave a comment on this post if you wish to&amp;nbsp;be notified when the new version is available.&lt;/p&gt;
&lt;h6&gt;&lt;span style="font-size: xx-small;"&gt;Example of syntax highlighting in BlogEngine.NET using the improved version&lt;/span&gt;&lt;/h6&gt;
&lt;p&gt;&lt;div class="code"&gt;&lt;p&gt;&lt;span class="type"&gt;ICustomer&lt;/span&gt; customer = &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="type"&gt;Customer&lt;/span&gt;(&lt;span class="str"&gt;"kalle"&lt;/span&gt;);&lt;br /&gt; &lt;span class="type"&gt;RegEx&lt;/span&gt; regex;&lt;br /&gt; &lt;span class="type"&gt;ICollection&lt;/span&gt;&amp;lt;&lt;span class="type"&gt;Customer&lt;/span&gt;&amp;gt; coll = &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="type"&gt;ICollection&lt;/span&gt;&amp;lt;&lt;span class="type"&gt;Customer&lt;/span&gt;&amp;gt;();&lt;br /&gt; &lt;span class="type"&gt;Stack&lt;/span&gt;&amp;lt;Name.Space.&lt;span class="type"&gt;Customer&lt;/span&gt;&amp;gt; stack = &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="type"&gt;Stack&lt;/span&gt;&amp;lt;Name.Space.&lt;span class="type"&gt;Customer&lt;/span&gt;&amp;gt;();&lt;br /&gt; stack.Put(customer);&lt;br /&gt; customer.Age = 24;&lt;/p&gt;
&lt;p&gt;[&lt;span class="type"&gt;Serializable&lt;/span&gt;]&lt;br /&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; &lt;span class="type"&gt;Customer&lt;/span&gt; : &lt;span class="type"&gt;ICustomer&lt;/span&gt; , &lt;span class="type"&gt;IComparable&lt;/span&gt;&amp;lt;&lt;span class="type"&gt;ICustomer&lt;/span&gt;&amp;gt; {&lt;br /&gt;     &lt;span class="kwrd"&gt;public&lt;/span&gt; Customer(&lt;span class="kwrd"&gt;string&lt;/span&gt; name) { &lt;br /&gt;         &lt;span class="kwrd"&gt;this&lt;/span&gt;.name = name; &lt;br /&gt;         person = &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="type"&gt;Person&lt;/span&gt;(name); &lt;br /&gt;     }&lt;br /&gt;     &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; Age {&lt;br /&gt;         &lt;span class="kwrd"&gt;get&lt;/span&gt; { &lt;span class="kwrd"&gt;return&lt;/span&gt; age; }&lt;br /&gt;         &lt;span class="kwrd"&gt;set&lt;/span&gt; { age = &lt;span class="kwrd"&gt;value&lt;/span&gt;; }&lt;br /&gt;     }&lt;br /&gt;     &lt;span class="type"&gt;IPerson&lt;/span&gt; _p = &lt;span class="type"&gt;Person&lt;/span&gt;.CurrentUser;&lt;br /&gt;     &lt;span class="type"&gt;IPerson&lt;/span&gt; person;&lt;br /&gt;     &lt;span class="kwrd"&gt;internal&lt;/span&gt; &lt;span class="type"&gt;IPerson&lt;/span&gt; Person {&lt;br /&gt;         &lt;span class="kwrd"&gt;get&lt;/span&gt; {&lt;br /&gt;             &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;this&lt;/span&gt;.person;&lt;br /&gt;         }&lt;br /&gt;     }&lt;/p&gt;
&lt;p&gt;    &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="type"&gt;ShopingCart&lt;/span&gt; cart = &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="type"&gt;ShopingCart&lt;/span&gt;();&lt;br /&gt;     &lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="type"&gt;ShopingCart&lt;/span&gt; GetCart() { &lt;span class="kwrd"&gt;return&lt;/span&gt; cart; }&lt;br /&gt; }&lt;/p&gt;&lt;/div&gt;&lt;/p&gt;
&lt;h6&gt;Related work&lt;/h6&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size: x-small;"&gt;&lt;a href="http://www.manoli.net/csharpformat/"&gt;C# code format&lt;/a&gt;&lt;/span&gt; 
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size: xx-small;"&gt;by Jean-Claude Manoli&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size: xx-small;"&gt;author of the syntax highlighter extension for BlogEngine.NET&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size: xx-small;"&gt;Not the same code as shiped with BlogEngine.NET&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size: xx-small;"&gt;&lt;span style="color: red"&gt;&lt;strong&gt;does not support types in C#&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size: x-small;"&gt;&lt;a href="http://blog.furred.net/post/Syntax-Highlighting-for-BlogEnginenet.aspx"&gt;Syntax highlighter&lt;/a&gt;&lt;/span&gt; 
&lt;ul&gt;
&lt;li&gt;by Wilco Bauwer &lt;/li&gt;
&lt;li&gt;linked from&amp;nbsp;the &lt;a href="http://www.dotnetblogengine.net/page/extensions.aspx"&gt;extensions list&lt;/a&gt; on dotnetblogengine.net&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;span style="color: red"&gt;&lt;span style="font-size: xx-small;"&gt;does not support types in C#&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/RickardNilsson/~4/hj_0P2V11mA" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/RickardNilsson/~3/hj_0P2V11mA/post.aspx</link>
      <author>Rickard</author>
      <comments>http://www.rickardnilsson.net/post/2008/04/12/Syntax-highlighting-in-BlogEngineNET.aspx#comment</comments>
      <guid isPermaLink="false">http://www.rickardnilsson.net/post.aspx?id=ac496c26-4832-4a53-ae23-d3917ea0689e</guid>
      <pubDate>Sat, 12 Apr 2008 00:22:00 +0100</pubDate>
      <category>ASP.NET 2.0</category>
      <category>BlogEngine.NET</category>
      <category>C# 2.0</category>
      <category>CSS</category>
      <dc:publisher>Rickard</dc:publisher>
      <pingback:server>http://www.rickardnilsson.net/pingback.axd</pingback:server>
      <pingback:target>http://www.rickardnilsson.net/post.aspx?id=ac496c26-4832-4a53-ae23-d3917ea0689e</pingback:target>
      <slash:comments>17</slash:comments>
      <trackback:ping>http://www.rickardnilsson.net/trackback.axd?id=ac496c26-4832-4a53-ae23-d3917ea0689e</trackback:ping>
      <wfw:comment>http://www.rickardnilsson.net/post/2008/04/12/Syntax-highlighting-in-BlogEngineNET.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.rickardnilsson.net/syndication.axd?post=ac496c26-4832-4a53-ae23-d3917ea0689e</wfw:commentRss>
    <feedburner:origLink>http://www.rickardnilsson.net/post.aspx?id=ac496c26-4832-4a53-ae23-d3917ea0689e</feedburner:origLink></item>
    <item>
      <title>Week and strong contracts in Design by Contact</title>
      <description>&lt;p&gt;
Answer to Fredrik Norm&amp;eacute;n on &lt;a href="http://weblogs.asp.net/fredriknormen/archive/2007/11/28/defensive-programming-and-design-by-contract-on-a-routine-level.aspx"&gt;&lt;font size="2"&gt;Defensive programming and Design by Contract on a routine level&lt;/font&gt;&lt;/a&gt;. 
&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;&amp;quot;Design by Contract is about creating a contract between the client and the supplier. The idea of the Design by Contract theory is to associate a specification with every software elements. This specification will define a contract between client and the supplier. When a supplier writes a contract with the client, it should document the obligations and benefits&amp;quot;&lt;/em&gt; 
&lt;/p&gt;
&lt;p&gt;
There is always a contract between a software element and its client. The question is if the contract is implicit or explicitly stated. Lets look at an example from the .NET framework: 
&lt;/p&gt;
&lt;p&gt;
&lt;div class="code"&gt;&lt;p&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;virtual&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Add(&lt;span class="kwrd"&gt;object&lt;/span&gt; key, &lt;span class="kwrd"&gt;object&lt;/span&gt; &lt;span class="kwrd"&gt;value&lt;/span&gt;) &lt;br /&gt;
    &lt;span class="type"&gt;Member&lt;/span&gt; of System.&lt;span class="type"&gt;Collections&lt;/span&gt;.Hashtable&lt;/p&gt;&lt;/div&gt; 
&lt;/p&gt;
&lt;blockquote&gt;
	&lt;p&gt;
	&lt;strong&gt;Summary:&lt;/strong&gt;&lt;br /&gt;
	Adds an element with the specified key and value into the System.Collections.Hashtable. 
	&lt;/p&gt;
	&lt;p&gt;
	&lt;strong&gt;Parameters:&lt;/strong&gt;&lt;br /&gt;
	key: The key of the element to add.&lt;br /&gt;
	value: The value of the element to add. The value can be null. 
	&lt;/p&gt;
	&lt;p&gt;
	&lt;strong&gt;Exceptions:&lt;/strong&gt;&lt;br /&gt;
	System.ArgumentNullException: key is null.&lt;br /&gt;
	System.ArgumentException: An element with the same key already exists in the System.Collections.Hashtable.&lt;br /&gt;
	System.NotSupportedException: The System.Collections.Hashtable is read-only.-or- The System.Collections.Hashtable has a fixed size. 
	&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
A short analysis conducts that the method&amp;#39;s contract can be expressed like this: 
&lt;/p&gt;
&lt;p&gt;
Precondition: &lt;br /&gt;
&amp;nbsp;○ true&lt;br /&gt;
Postcondition: &lt;br /&gt;
&amp;nbsp;○ If key is null ArgumentNullException is thrown&lt;br /&gt;
&amp;nbsp;○ If ContainsKey(key) ArgumentException is thrown&lt;br /&gt;
&amp;nbsp;○ Else this[key] == value&lt;br /&gt;
&amp;nbsp;○ And Count == old Count + 1&lt;br /&gt;
&amp;nbsp;&lt;br /&gt;
An analysis of the contract shows that the contract can be made stronger like this: 
&lt;/p&gt;
&lt;p&gt;
Precondition:&lt;br /&gt;
&amp;nbsp;○ Key != null&lt;br /&gt;
&amp;nbsp;○ !ContainsKey(key)&lt;br /&gt;
Postcondition:&lt;br /&gt;
&amp;nbsp;○ this[key] == value&lt;br /&gt;
&amp;nbsp;○ Count == old Count + 1&lt;br /&gt;
&amp;nbsp;&lt;br /&gt;
In the theory of contracts there is this concept of strong versus week contacts where the first is more demanding on the client than the last. Hence, the precondition is now more demanding on the client and this can be taken advantage of in the routine implementation. In the pseudo code below we can see the difference: 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Week contract supplier&lt;/strong&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;div class="code"&gt;&lt;p&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;virtual&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Add(&lt;span class="kwrd"&gt;object&lt;/span&gt; key, &lt;span class="kwrd"&gt;object&lt;/span&gt; &lt;span class="kwrd"&gt;value&lt;/span&gt;) {&lt;br /&gt;
 &lt;span class="kwrd"&gt;if&lt;/span&gt; (key == &lt;span class="kwrd"&gt;null&lt;/span&gt;) {&lt;br /&gt;
  &lt;span class="kwrd"&gt;throw&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="type"&gt;ArgumentException&lt;/span&gt;(…);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;span class="kwrd"&gt;if&lt;/span&gt; (ContainsKey(key)) {&lt;br /&gt;
  &lt;span class="kwrd"&gt;throw&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="type"&gt;ArgumentException&lt;/span&gt;(…);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;span class="kwrd"&gt;this&lt;/span&gt;.buckets[hashcode(key)] = &lt;span class="kwrd"&gt;value&lt;/span&gt;;&lt;br /&gt;
}&lt;/p&gt;&lt;/div&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Strong contract supplier&lt;/strong&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;div class="code"&gt;&lt;p&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;virtual&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Add(&lt;span class="kwrd"&gt;object&lt;/span&gt; key, &lt;span class="kwrd"&gt;object&lt;/span&gt; &lt;span class="kwrd"&gt;value&lt;/span&gt;) {&lt;br /&gt;
 &lt;span class="kwrd"&gt;this&lt;/span&gt;.buckets[hashcode(key)] = &lt;span class="kwrd"&gt;value&lt;/span&gt;;&lt;br /&gt;
}&lt;/p&gt;&lt;/div&gt; 
&lt;/p&gt;
&lt;p&gt;
Using the stronger contract we get a much cleaner implementation of the routine. How about the client code then? Well, take a look: 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Week contract client&lt;/strong&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;div class="code"&gt;&lt;p&gt;&lt;span class="kwrd"&gt;try&lt;/span&gt; {&lt;br /&gt;
 hashtable.Add(key, foo);&lt;br /&gt;
} &lt;span class="kwrd"&gt;catch&lt;/span&gt; (&lt;span class="type"&gt;ArgumentException&lt;/span&gt; ex) {&lt;br /&gt;
 &lt;span class="rem"&gt;// oops, we made a mistake!&lt;/span&gt;&lt;br /&gt;
}&lt;/p&gt;&lt;/div&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Strong contract client&lt;/strong&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;div class="code"&gt;&lt;p&gt;&lt;span class="kwrd"&gt;if&lt;/span&gt; (!hashtable.ContainsKey(key) {&lt;br /&gt;
 hashtable.Add(key, foo);&lt;br /&gt;
}&lt;/p&gt;&lt;/div&gt; 
&lt;/p&gt;
&lt;p&gt;
Of course, the code for the strong contract client can be used with the week contract as well. The main point is that with the strong contract no error handling should be made because then there is an error in the client code which should be corrected, not handled at runtime. The routine only promise to satisfy the post condition if and only if&amp;nbsp; the pre condition is satisfied by the client. If the pre condition is not met the outcome is undefined and anything can happen from nothing at all to the system crashing. This is where frameworks that permit developers to express the contract in code comes in. 
&lt;/p&gt;
&lt;h5&gt;Design-by-Contract Frameworks&lt;/h5&gt;As Fredrik mentions Eiffel was the first programming language to have syntactic support for expressively stating contracts. For .NET there has been several attempts to do the same in addition to &lt;font size="2"&gt;&lt;a href="http://research.microsoft.com/SpecSharp/"&gt;Spec#&lt;/a&gt;&lt;/font&gt;. Here is a list: 
&lt;ul&gt;
	&lt;li&gt;&lt;font size="2"&gt;&lt;a href="http://puzzleware.net/nContract/"&gt;nContract&lt;/a&gt;&lt;/font&gt; 
	&lt;ul&gt;
		&lt;li&gt;MS thesis by Wes Haggard&lt;/li&gt;
		&lt;li&gt;Example: &lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
	&lt;blockquote&gt;
		&lt;p&gt;
		&lt;div class="code"&gt;&lt;p&gt;[&lt;span class="type"&gt;FormallySpecified&lt;/span&gt;]&lt;br /&gt;
        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; &lt;span class="type"&gt;Test&lt;/span&gt; {&lt;br /&gt;
          [&lt;span class="type"&gt;Pre&lt;/span&gt;(&lt;span class="str"&gt;"i &amp;gt; 0"&lt;/span&gt;)]&lt;br /&gt;
          &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; DoWork(&lt;span class="kwrd"&gt;int&lt;/span&gt; i) { }&lt;br /&gt;
        }&lt;/p&gt;&lt;/div&gt; 
		&lt;/p&gt;
	&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
	&lt;li&gt;&lt;font size="2"&gt;&lt;a href="http://www.codeplex.com/ContractN"&gt;ContractN&lt;/a&gt;&lt;/font&gt; 
	&lt;ul&gt;
		&lt;li&gt;By &lt;a href="http://davesexton.com/blog/Blogs/Blog/"&gt;Dave Sexton&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;Example: &lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
	&lt;blockquote&gt;
		&lt;p&gt;
		&lt;div class="code"&gt;&lt;p&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; &lt;span class="type"&gt;Person&lt;/span&gt; : ContractN.&lt;span class="type"&gt;ProgrammingByContract&lt;/span&gt;&lt;br /&gt;
        {&lt;br /&gt;
          [&lt;span class="type"&gt;InRequired&lt;/span&gt;, &lt;span class="type"&gt;OutRequired&lt;/span&gt;]&lt;br /&gt;
          &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Name { &lt;span class="kwrd"&gt;get&lt;/span&gt;; &lt;span class="kwrd"&gt;set&lt;/span&gt;; }&lt;br /&gt;
        }&lt;/p&gt;&lt;/div&gt; 
		&lt;/p&gt;
	&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
	&lt;li&gt;&lt;font size="2"&gt;&lt;a href="http://www.codeproject.com/KB/cs/designbycontract.aspx"&gt;Design by Contract Framework&lt;/a&gt;&lt;/font&gt; 
	&lt;ul&gt;
		&lt;li&gt;By Kevin McFarlane&lt;/li&gt;
		&lt;li&gt;Example:&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
	&lt;blockquote&gt;
		&lt;div class="code"&gt;&lt;p&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;virtual&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; &lt;span class="type"&gt;B&lt;/span&gt;.Foo(&lt;span class="kwrd"&gt;int&lt;/span&gt; x)&lt;br /&gt;
        {&lt;br /&gt;
          &lt;span class="type"&gt;Check&lt;/span&gt;.Require(1 &amp;lt; x &amp;lt; 3);&lt;br /&gt;
          ...&lt;br /&gt;
          &lt;span class="type"&gt;Check&lt;/span&gt;.Ensure(result &amp;lt; 15);&lt;br /&gt;
          &lt;span class="kwrd"&gt;return&lt;/span&gt; result;&lt;br /&gt;
        }&lt;/p&gt;&lt;/div&gt; 
		&lt;/p&gt;
	&lt;/blockquote&gt;
&lt;/blockquote&gt;
I might find a reason to return with a more thorough review of the frameworks in the future.&lt;img src="http://feeds.feedburner.com/~r/RickardNilsson/~4/Fs3RgxlI5Y4" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/RickardNilsson/~3/Fs3RgxlI5Y4/post.aspx</link>
      <author>Rickard</author>
      <comments>http://www.rickardnilsson.net/post/2008/03/31/Week-and-strong-contracts-in-Design-by-Contact.aspx#comment</comments>
      <guid isPermaLink="false">http://www.rickardnilsson.net/post.aspx?id=afe77f7f-e460-465d-80a4-34ac5fb675b5</guid>
      <pubDate>Mon, 31 Mar 2008 02:22:00 +0100</pubDate>
      <category>C# 2.0</category>
      <category>Design by Contract</category>
      <dc:publisher>Rickard</dc:publisher>
      <pingback:server>http://www.rickardnilsson.net/pingback.axd</pingback:server>
      <pingback:target>http://www.rickardnilsson.net/post.aspx?id=afe77f7f-e460-465d-80a4-34ac5fb675b5</pingback:target>
      <slash:comments>3</slash:comments>
      <trackback:ping>http://www.rickardnilsson.net/trackback.axd?id=afe77f7f-e460-465d-80a4-34ac5fb675b5</trackback:ping>
      <wfw:comment>http://www.rickardnilsson.net/post/2008/03/31/Week-and-strong-contracts-in-Design-by-Contact.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.rickardnilsson.net/syndication.axd?post=afe77f7f-e460-465d-80a4-34ac5fb675b5</wfw:commentRss>
    <feedburner:origLink>http://www.rickardnilsson.net/post.aspx?id=afe77f7f-e460-465d-80a4-34ac5fb675b5</feedburner:origLink></item>
    <item>
      <title>JavaScript resources</title>
      <description>&lt;p&gt;
I thought that I should do a post about the JavaScript resources I&amp;#39;ve found most useful. There are an endless amount of JavaScript resources out there and and there is only so much time you can spend&amp;nbsp;going through them to find what you need.&amp;nbsp;This is my&amp;nbsp;attempt at&amp;nbsp;gathering some of the best I know.&amp;nbsp;So here goes. 
&lt;/p&gt;
&lt;h6&gt;JavaScript basics&lt;/h6&gt;
&lt;div style="background: #f3f5fa; float: right; margin-right: 15px; padding: 7px"&gt;
&lt;h6&gt;Tools&lt;/h6&gt;
&lt;ul&gt;
	&lt;li&gt;&lt;a href="http://www.jslint.com/" title="The JavaScript Verifier"&gt;JSLint&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href="http://fmarcia.info/jsmin/test.html" title="Minify your JavaScript code"&gt;JS Minifier&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href="http://elfz.laacz.lv/beautify/" title="Format your minified JavaScript"&gt;JS Beautifier&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;ul&gt;
	&lt;li&gt;&lt;font size="2"&gt;&lt;a href="http://www.w3schools.com/jsref/default.asp"&gt;JavaScript reference&lt;/a&gt;&lt;/font&gt; 
	&lt;ul&gt;
		&lt;li&gt;by W3School&lt;/li&gt;
		&lt;li&gt;nice comparison between browsers&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
	&lt;li&gt;&lt;font size="2"&gt;&lt;a href="http://msdn2.microsoft.com/en-us/library/z688wt03.aspx"&gt;JScript language reference&lt;/a&gt;&lt;/font&gt; 
	&lt;ul&gt;
		&lt;li&gt;by Microsoft&lt;/li&gt;
		&lt;li&gt;JScript 8.0&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
	&lt;li&gt;&lt;font size="2"&gt;&lt;a href="http://www.w3schools.com/htmldom/dom_reference.asp"&gt;HTML DOM reference&lt;/a&gt;&lt;/font&gt; 
	&lt;ul&gt;
		&lt;li&gt;by W3School&lt;/li&gt;
		&lt;li&gt;support comparison between browsers&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
	&lt;li&gt;&lt;a href="http://www.quirksmode.org/js/contents.html"&gt;&lt;font size="2"&gt;JavaScript tips and tricks&lt;/font&gt;&lt;/a&gt; 
	&lt;ul&gt;
		&lt;li&gt;by PPK at Quirksmode&lt;/li&gt;
		&lt;li&gt;everything&amp;nbsp;including core features, event handling, DOM, CSS modification and Data retrieval&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
	&lt;li&gt;&lt;font size="2"&gt;&lt;a href="http://www.crockford.com/javascript/"&gt;Douglas Crockford&amp;#39;s JavaScript resource collection&lt;/a&gt;&lt;/font&gt; 
	&lt;ul&gt;
		&lt;li&gt;Chief JavaScript architect at Yahoo!&lt;/li&gt;
		&lt;li&gt;Papers, tools, videos, links&lt;/li&gt;
		&lt;li&gt;&lt;strong style="color: red"&gt;A must see&lt;/strong&gt;&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
	&lt;li&gt;&lt;font size="2"&gt;&lt;a href="http://yuiblog.com/blog/2007/01/24/video-crockford-tjpl/"&gt;The JavaScript&amp;nbsp;Programming Language&lt;/a&gt;&lt;/font&gt; 
	&lt;ul&gt;
		&lt;li&gt;4-part lecture course with Douglas Crockford&lt;/li&gt;
		&lt;li&gt;The basics of JavaScript by the man who architected YUI&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
	&lt;li&gt;&lt;font size="2"&gt;&lt;a href="http://yuiblog.com/blog/2006/10/20/video-crockford-domtheory/"&gt;An Inconvenient API: The Theory of the DOM&lt;/a&gt;&lt;/font&gt; 
	&lt;ul&gt;
		&lt;li&gt;3-part lecture course with Douglas Crockford&lt;/li&gt;
		&lt;li&gt;Browser DOM talk by the man who invented JSON&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
	&lt;li&gt;&lt;font size="2"&gt;&lt;a href="http://yuiblog.com/blog/2006/11/27/video-crockford-advjs/"&gt;Advanced JavaScript&lt;/a&gt;&lt;/font&gt; 
	&lt;ul&gt;
		&lt;li&gt;3-part lecture course with Douglas Crockford&lt;/li&gt;
		&lt;li&gt;Advanced topics by the man who wrote JSLint and JSMin&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
	&lt;li&gt;&lt;font size="2"&gt;&lt;a href="http://com3.devnet.re3.yahoo.com/yui/theater/"&gt;Yahoo! YUI Theater&lt;/a&gt;&lt;/font&gt; 
	&lt;ul&gt;
		&lt;li&gt;Endless of hours of video content&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
This list&amp;nbsp;became long enough so I will do another post on Ajax resources later on. 
&lt;/p&gt;
&lt;p&gt;
What have I missed? 
&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/RickardNilsson/~4/xUfOEQDKZFA" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/RickardNilsson/~3/xUfOEQDKZFA/post.aspx</link>
      <author>Rickard</author>
      <comments>http://www.rickardnilsson.net/post/2008/03/20/JavaScript-resources.aspx#comment</comments>
      <guid isPermaLink="false">http://www.rickardnilsson.net/post.aspx?id=3184ce71-aa60-46b9-b1ec-113be42ebdb1</guid>
      <pubDate>Thu, 20 Mar 2008 11:55:00 +0100</pubDate>
      <category>JavaScript</category>
      <dc:publisher>Rickard</dc:publisher>
      <pingback:server>http://www.rickardnilsson.net/pingback.axd</pingback:server>
      <pingback:target>http://www.rickardnilsson.net/post.aspx?id=3184ce71-aa60-46b9-b1ec-113be42ebdb1</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://www.rickardnilsson.net/trackback.axd?id=3184ce71-aa60-46b9-b1ec-113be42ebdb1</trackback:ping>
      <wfw:comment>http://www.rickardnilsson.net/post/2008/03/20/JavaScript-resources.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.rickardnilsson.net/syndication.axd?post=3184ce71-aa60-46b9-b1ec-113be42ebdb1</wfw:commentRss>
    <feedburner:origLink>http://www.rickardnilsson.net/post.aspx?id=3184ce71-aa60-46b9-b1ec-113be42ebdb1</feedburner:origLink></item>
    <item>
      <title>Driving out a correct implementation of ISO week numbers using TDD #4</title>
      <description>&lt;ol&gt;
	&lt;li&gt;&lt;a href="http://www.rickardnilsson.net/post/Abstract-Driving-out-a-correct-implementation-of-week-numbers-using-TDD.aspx"&gt;Abstract&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
	&lt;li&gt;&lt;a href="http://www.rickardnilsson.net/post/Driving-out-a-correct-implementation-of-ISO-week-numbers-using-TDD.aspx"&gt;Refactoring&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href="http://www.rickardnilsson.net/post/Driving-out-a-correct-implementation-of-ISO-week-numbers-using-TDD-3.aspx"&gt;Test coverage&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
Proceeding with a solution there is no way of changing the implementation of the GregorianCalendar class to get the correct behavior so we have to go about this another way. One is to subclass the GregorianCalendar and override the GetWeekOfYear method. Another is to implement the GetWeekOfYear in a class totally separate from the .NET framework. I think that the first one is the way to go since the error that we&amp;#39;re trying to correct is in the framework itself. 
&lt;/p&gt;
&lt;p&gt;
So, first we alter the help method in the test case to use our sub classed IsoCalendar (which we haven&amp;#39;t written yet). 
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.rickardnilsson.net/image.axd?picture=getisoweek01.png" alt="" width="511" height="137" /&gt; 
&lt;/p&gt;
&lt;p&gt;
So, we are not in a compile state yet so lets do the simplest thing to get this running. I decided to subclass the GregorianCalendar class since what&amp;nbsp;is wrong&amp;nbsp;is the GetWeekOfYTear method of that class. I basically override that method like below. 
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.rickardnilsson.net/image.axd?picture=isocalendarclass01.png" alt="" width="528" height="120" /&gt; 
&lt;/p&gt;
&lt;p&gt;
We run the test a get a red bar. Fine, but now lets go ahead and implement the algorithm. However, this has been done over and over with varying elegantness. My favorite is the work of&amp;nbsp;programmer and mathematician Julian Bucknall. His &lt;a href="http://www.boyet.com/Articles/PublishedArticles/CalculatingtheISOweeknumb.html" target="_blank"&gt;original implementation&lt;/a&gt; can be found at his blog. So, instead of returning -1 I call the GetIsoWeek method from Bucknall&amp;#39;s implementation and take the modulus of 100 (since the result from the algorithm is of the form YYYYWW). We run the test and we get a green bar! 
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;&lt;img src="http://www.rickardnilsson.net/image.axd?picture=isocalendarclass03.png" alt="" width="537" height="240" /&gt; 
&lt;/p&gt;
&lt;p&gt;
Now when we get a green bar there&amp;#39;s just one more thing to add. The ISO 8601 week should only be returned when the parameters rule and firstDayOfWeek is set properly according to the documentation. In all other cases the GregorianCalendar implementation works just fine. We fix this with a guard clause at the top and we&amp;#39;re done. 
&lt;/p&gt;
&lt;h6&gt;Summary&lt;/h6&gt;
&lt;p&gt;
During this series we covered test coverage for the faulty implementation of weeks according to ISO 8601. We used Test-Driven Development to provide a fix using Julian Bucknall&amp;#39;s really smart implementation. Next we should take a look at refactoring to design patterns. 
&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/RickardNilsson/~4/NKuLW-eCA0g" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/RickardNilsson/~3/NKuLW-eCA0g/post.aspx</link>
      <author>Rickard</author>
      <comments>http://www.rickardnilsson.net/post/2008/03/18/Driving-out-a-correct-implementation-of-ISO-week-numbers-using-TDD-4.aspx#comment</comments>
      <guid isPermaLink="false">http://www.rickardnilsson.net/post.aspx?id=ef5aac6e-3c58-4678-9bfc-41ff318e5c52</guid>
      <pubDate>Tue, 18 Mar 2008 23:59:00 +0100</pubDate>
      <category>.NET</category>
      <category>C# 2.0</category>
      <category>TDD</category>
      <dc:publisher>Rickard</dc:publisher>
      <pingback:server>http://www.rickardnilsson.net/pingback.axd</pingback:server>
      <pingback:target>http://www.rickardnilsson.net/post.aspx?id=ef5aac6e-3c58-4678-9bfc-41ff318e5c52</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://www.rickardnilsson.net/trackback.axd?id=ef5aac6e-3c58-4678-9bfc-41ff318e5c52</trackback:ping>
      <wfw:comment>http://www.rickardnilsson.net/post/2008/03/18/Driving-out-a-correct-implementation-of-ISO-week-numbers-using-TDD-4.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.rickardnilsson.net/syndication.axd?post=ef5aac6e-3c58-4678-9bfc-41ff318e5c52</wfw:commentRss>
    <feedburner:origLink>http://www.rickardnilsson.net/post.aspx?id=ef5aac6e-3c58-4678-9bfc-41ff318e5c52</feedburner:origLink></item>
    <item>
      <title>Driving out a correct implementation of ISO week numbers using TDD #3</title>
      <description>&lt;ol&gt;
	&lt;li&gt;&lt;a href="http://www.rickardnilsson.net/post/Abstract-Driving-out-a-correct-implementation-of-week-numbers-using-TDD.aspx"&gt;Abstract&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href="http://www.rickardnilsson.net/post/Driving-out-a-correct-implementation-of-ISO-week-numbers-using-TDD.aspx"&gt;Refactoring&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
Our task at hand is to get as much coverage as possible when it comes to errors in the implementation. The ideal coverage is one where all dates are&amp;nbsp;tested. The problem is that the number of dates is infinite. This is of course always a an issue when testing software but it may be more obvious here. If we test all dates there will we a great deal of dates that we know are correct. It should suffice to test only the dates that are incorrect. However, this number is also infinite. We will have to limit our coverage but still get as much breadth as possible. Basically we need to get back to the definition. 
&lt;p&gt;
According to the ISO standard, in the period 4 January - 28 December the week number is always the same as the Gregorian week and the same also apply for all Thursdays. Thus, the mentioned dates can be safely excluded in our test coverage. Though we still have an infinite number of dates to cover, we are getting there. Finally, we can limit our test coverage to a set of years that can be reasonable argued to appear in the application which we are implementing. 
&lt;/p&gt;
&lt;p&gt;
To simplify it the resulting dates are non&amp;nbsp;Thursdays&amp;nbsp;1-3 January and 29-31 December every year from 2005 - 2015. 
&lt;/p&gt;
&lt;p&gt;
Using the calendar in Outlook I compile a matrix of the week numbers in the year interval. The dates that are grayed are Thursdays which should not be part of the test.&lt;br /&gt;
&lt;br /&gt;
&lt;table border="0" cellspacing="0" cellpadding="0" width="454" style="width: 341pt; border-collapse: collapse"&gt;
	&lt;tbody&gt;
		&lt;tr height="20" style="height: 15pt"&gt;
			&lt;td width="70" height="20" style="width: 53pt; height: 15pt; background-color: transparent; border: #f0f0f0"&gt;&amp;nbsp;&lt;/td&gt;
			&lt;td class="xl65" width="64" align="right" style="width: 48pt; background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;01-jan&lt;/font&gt;&lt;/td&gt;
			&lt;td class="xl65" width="64" align="right" style="width: 48pt; background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;02-jan&lt;/font&gt;&lt;/td&gt;
			&lt;td class="xl65" width="64" align="right" style="width: 48pt; background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;03-jan&lt;/font&gt;&lt;/td&gt;
			&lt;td class="xl65" width="64" align="right" style="width: 48pt; background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;29-dec&lt;/font&gt;&lt;/td&gt;
			&lt;td class="xl65" width="64" align="right" style="width: 48pt; background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;30-dec&lt;/font&gt;&lt;/td&gt;
			&lt;td class="xl65" width="64" align="right" style="width: 48pt; background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;31-dec&lt;/font&gt;&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr height="20" style="height: 15pt"&gt;
			&lt;td height="20" align="right" style="height: 15pt; background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;2005&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;53&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;53&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;1&lt;/font&gt;&lt;/td&gt;
			&lt;td class="xl66" align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2" color="#a5a5a5"&gt;52&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;52&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;52&lt;/font&gt;&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr height="20" style="height: 15pt"&gt;
			&lt;td height="20" align="right" style="height: 15pt; background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;2006&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;52&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;1&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;1&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;52&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;52&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;52&lt;/font&gt;&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr height="20" style="height: 15pt"&gt;
			&lt;td height="20" align="right" style="height: 15pt; background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;2007&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;1&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;1&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;1&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;52&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;52&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;1&lt;/font&gt;&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr height="20" style="height: 15pt"&gt;
			&lt;td height="20" align="right" style="height: 15pt; background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;2008&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;1&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;1&lt;/font&gt;&lt;/td&gt;
			&lt;td class="xl66" align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2" color="#a5a5a5"&gt;1&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;1&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;1&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;1&lt;/font&gt;&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr height="20" style="height: 15pt"&gt;
			&lt;td height="20" align="right" style="height: 15pt; background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;2009&lt;/font&gt;&lt;/td&gt;
			&lt;td class="xl66" align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2" color="#a5a5a5"&gt;1&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;1&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;1&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;53&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;53&lt;/font&gt;&lt;/td&gt;
			&lt;td class="xl66" align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2" color="#a5a5a5"&gt;53&lt;/font&gt;&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr height="20" style="height: 15pt"&gt;
			&lt;td height="20" align="right" style="height: 15pt; background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;2010&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;53&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;53&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;53&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;52&lt;/font&gt;&lt;/td&gt;
			&lt;td class="xl66" align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2" color="#a5a5a5"&gt;52&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;52&lt;/font&gt;&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr height="20" style="height: 15pt"&gt;
			&lt;td height="20" align="right" style="height: 15pt; background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;2011&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;52&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;52&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;1&lt;/font&gt;&lt;/td&gt;
			&lt;td class="xl66" align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2" color="#a5a5a5"&gt;52&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;52&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;52&lt;/font&gt;&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr height="20" style="height: 15pt"&gt;
			&lt;td height="20" align="right" style="height: 15pt; background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;2012&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;52&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;1&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;1&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;52&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;52&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;53&lt;/font&gt;&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr height="20" style="height: 15pt"&gt;
			&lt;td height="20" align="right" style="height: 15pt; background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;2013&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;1&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;1&lt;/font&gt;&lt;/td&gt;
			&lt;td class="xl66" align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2" color="#a5a5a5"&gt;1&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;52&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;1&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;1&lt;/font&gt;&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr height="20" style="height: 15pt"&gt;
			&lt;td height="20" align="right" style="height: 15pt; background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;2014&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;1&lt;/font&gt;&lt;/td&gt;
			&lt;td class="xl66" align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2" color="#a5a5a5"&gt;1&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;1&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;1&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;1&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;1&lt;/font&gt;&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr height="20" style="height: 15pt"&gt;
			&lt;td height="20" align="right" style="height: 15pt; background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;2015&lt;/font&gt;&lt;/td&gt;
			&lt;td class="xl66" align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2" color="#a5a5a5"&gt;1&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;1&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;1&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;53&lt;/font&gt;&lt;/td&gt;
			&lt;td align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2"&gt;53&lt;/font&gt;&lt;/td&gt;
			&lt;td class="xl66" align="right" style="background-color: transparent; border: #f0f0f0"&gt;&lt;font face="Calibri" size="2" color="#a5a5a5"&gt;53&lt;/font&gt;&lt;/td&gt;
		&lt;/tr&gt;
	&lt;/tbody&gt;
&lt;/table&gt;
&lt;/p&gt;
&lt;p&gt;
The matrix can be thought of as a set of { date, week number }&amp;nbsp;pairs which can easily be implemented in code. 
&lt;/p&gt;
&lt;p&gt;
I create a test which iterates over the set and makes assertions that the correct week was generated by the calendar. It turns out however, that only eleven of the dates generate a wrong week number. I refactor the code to only include the weeks that are wrong. I get a red bar and I see another opportunity for refactoring, the previous two tests can be integrated with this test by just adding the date - week pair to the set. The following is the resulting test: 
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;&lt;img src="http://www.rickardnilsson.net/image.axd?picture=test05.png" alt="" width="491" height="327" /&gt; 
&lt;/p&gt;
&lt;p&gt;
Now that we have a test that fails we can come up with a solution to get the test to pass. 
&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/RickardNilsson/~4/N--Zb0Wzz-k" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/RickardNilsson/~3/N--Zb0Wzz-k/post.aspx</link>
      <author>Rickard</author>
      <comments>http://www.rickardnilsson.net/post/2008/03/17/Driving-out-a-correct-implementation-of-ISO-week-numbers-using-TDD-3.aspx#comment</comments>
      <guid isPermaLink="false">http://www.rickardnilsson.net/post.aspx?id=8350996a-a141-433e-93cf-d5115e998831</guid>
      <pubDate>Mon, 17 Mar 2008 00:10:00 +0100</pubDate>
      <category>.NET</category>
      <category>C# 2.0</category>
      <category>TDD</category>
      <dc:publisher>Rickard</dc:publisher>
      <pingback:server>http://www.rickardnilsson.net/pingback.axd</pingback:server>
      <pingback:target>http://www.rickardnilsson.net/post.aspx?id=8350996a-a141-433e-93cf-d5115e998831</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://www.rickardnilsson.net/trackback.axd?id=8350996a-a141-433e-93cf-d5115e998831</trackback:ping>
      <wfw:comment>http://www.rickardnilsson.net/post/2008/03/17/Driving-out-a-correct-implementation-of-ISO-week-numbers-using-TDD-3.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.rickardnilsson.net/syndication.axd?post=8350996a-a141-433e-93cf-d5115e998831</wfw:commentRss>
    <feedburner:origLink>http://www.rickardnilsson.net/post.aspx?id=8350996a-a141-433e-93cf-d5115e998831</feedburner:origLink></item>
  </channel>
</rss>
