<feed xmlns:dc="http://purl.org/dc/elements/1.1/" 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="http://www.w3.org/2005/Atom" xml:lang="en-US">
    <title>A Technical Debtor</title>
    <link rel="self" type="application/xml" href="http://blog.dotnetspeech.net/Atom.aspx" />
    <subtitle type="html">Toward continuous improvment</subtitle>
    <id>http://blog.dotnetspeech.net/Default.aspx</id>
    <author>
        <name>Jeff Certain</name>
        <uri>http://blog.dotnetspeech.net/Default.aspx</uri>
    </author>
    <generator uri="http://subtextproject.com" version="Subtext Version 0.0.0.0">Subtext</generator>
    <updated>2009-01-06T16:12:20Z</updated>
    <entry>
        <title>VS Live San Francisco</title>
        <link rel="self" type="text/html" href="http://blog.dotnetspeech.net/archive/2009/01/06/vs-live-san-francisco.aspx" />
        <id>http://blog.dotnetspeech.net/archive/2009/01/06/vs-live-san-francisco.aspx</id>
        <published>2009-01-06T16:12:20-07:00:00</published>
        <updated>2009-01-06T16:12:20Z</updated>
        <content type="html">&lt;p&gt;I've got the paperwork now, so I guess this is official.&lt;/p&gt;  &lt;p&gt;I submitted a &lt;a href="http://vslive.com/2009/sf/corenet.aspx#VTH22" target="_blank"&gt;talk on writing concurrent applications&lt;/a&gt; for &lt;a href="http://vslive.com/2009/sf/" target="_blank"&gt;VS Live in San Francisco in February&lt;/a&gt;. I'll be speaking on Thursday Feb 26th -- if you happen to be making the conference, look me up! I'm looking forward to this; there's lots of great content being presented, including a full day post-con on Azure.&lt;/p&gt;&lt;img src="http://blog.dotnetspeech.net/aggbug/128419.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://blog.dotnetspeech.net/comments/128419.aspx</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://blog.dotnetspeech.net/comments/commentRss/128419.aspx</wfw:commentRss>
        <trackback:ping>http://blog.dotnetspeech.net/services/trackbacks/128419.aspx</trackback:ping>
    </entry>
    <entry>
        <title>Using Exception Handling to Retry an Operation</title>
        <link rel="self" type="text/html" href="http://blog.dotnetspeech.net/archive/2008/12/18/using-exception-handling-to-retry-an-operation.aspx" />
        <id>http://blog.dotnetspeech.net/archive/2008/12/18/using-exception-handling-to-retry-an-operation.aspx</id>
        <published>2008-12-18T09:37:15-07:00:00</published>
        <updated>2008-12-18T09:37:15Z</updated>
        <content type="html">&lt;p&gt;I got the following question via e-mail:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;I want to catch timeout errors when I execute a script. Catching the error is easy, but I then want to retry 3 times. In VB6 I could just resume a command when I caught the error. How can I do this with vb 2008 using try..catch?&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;This is a case where two different techniques come into play. The first is using a number of Catch statements to allow you to catch specific types of exceptions. The second is to make essentially a recursive call to the function, with a counter to ensure that you don't end up in an infinite loop.&lt;/p&gt;  &lt;pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt;  1: &lt;span style="color: #0000ff"&gt;Module&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Module&lt;/span&gt;1
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt;  2:     &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; Main()
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt;  3:         Foo()
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt;  4:         Console.ReadLine()
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt;  5:         Foo()
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt;  6:         Console.ReadLine()
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt;  7:     &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt;  8: 
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt;  9:     &lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; tryCounter &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt; = 0
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 10:     &lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; maxAttempts &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt; = 3
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 11:     &lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; Foo()
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 12:         &lt;span style="color: #0000ff"&gt;Try&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 13:             &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; tryCounter = maxAttempts &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt; tryCounter = 0
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 14:             tryCounter += 1
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 15:             FooWithTimeout()
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 16:         &lt;span style="color: #0000ff"&gt;Catch&lt;/span&gt; toex &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; TimeoutException
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 17:             &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; tryCounter = maxAttempts &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 18:                 Console.WriteLine("&lt;span style="color: #8b0000"&gt;Too many failures.&lt;/span&gt;")
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 19:             &lt;span style="color: #0000ff"&gt;Else&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 20:                 Foo()
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 21:             &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 22:         &lt;span style="color: #0000ff"&gt;Catch&lt;/span&gt; ex &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; Exception
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 23:             &lt;span style="color: #0000ff"&gt;Throw&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 24:         &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Try&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 25:     &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 26: 
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 27:     &lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; FooWithTimeout()
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 28:         Console.WriteLine("&lt;span style="color: #8b0000"&gt;Attempt &lt;/span&gt;" &amp;amp; tryCounter)
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 29:         &lt;span style="color: #0000ff"&gt;Throw&lt;/span&gt; &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; TimeoutException
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 30:     &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 31: &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Module&lt;/span&gt;&lt;/pre&gt;&lt;/pre&gt;
I've called Foo() twice from Main() simply to show that the function resets the attempt counter properly.&lt;img src="http://blog.dotnetspeech.net/aggbug/128031.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://blog.dotnetspeech.net/comments/128031.aspx</wfw:comment>
        <slash:comments>2</slash:comments>
        <wfw:commentRss>http://blog.dotnetspeech.net/comments/commentRss/128031.aspx</wfw:commentRss>
        <trackback:ping>http://blog.dotnetspeech.net/services/trackbacks/128031.aspx</trackback:ping>
    </entry>
    <entry>
        <title>VB Dev Center Article Published</title>
        <link rel="self" type="text/html" href="http://blog.dotnetspeech.net/archive/2008/12/17/vb-dev-center-article-published-again.aspx" />
        <id>http://blog.dotnetspeech.net/archive/2008/12/17/vb-dev-center-article-published-again.aspx</id>
        <published>2008-12-17T13:59:06-07:00:00</published>
        <updated>2008-12-17T13:59:06Z</updated>
        <content type="html">&lt;p&gt;The work I did on benchmarking DataTable performance (or lack thereof *cough cough*) has been published in an &lt;a href="http://msdn.microsoft.com/en-us/library/dd364983.aspx" target="_blank"&gt;article&lt;/a&gt; on the &lt;a href="http://msdn.microsoft.com/en-us/vbasic/default.aspx" target="_blank"&gt;MSDN VB Dev Center&lt;/a&gt;. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/TechnicalDebtor/WindowsLiveWriter/VBDevCenterArticlePublished_C491/image_4.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="269" alt="image" src="http://geekswithblogs.net/images/geekswithblogs_net/TechnicalDebtor/WindowsLiveWriter/VBDevCenterArticlePublished_C491/image_thumb_1.png" width="396" border="0" /&gt;&lt;/a&gt;  &lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;For those of you wondering about the results I mentioned a few months ago, they're included there. I've also included some work on benchmarking LINQ select queries and aggregation in comparison to the DataTable equivalents.&lt;/p&gt;  &lt;p&gt;Many thanks to Beth Massi for helping get this published.&lt;/p&gt;&lt;img src="http://blog.dotnetspeech.net/aggbug/128015.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://blog.dotnetspeech.net/comments/128015.aspx</wfw:comment>
        <slash:comments>1</slash:comments>
        <wfw:commentRss>http://blog.dotnetspeech.net/comments/commentRss/128015.aspx</wfw:commentRss>
        <trackback:ping>http://blog.dotnetspeech.net/services/trackbacks/128015.aspx</trackback:ping>
    </entry>
    <entry>
        <title>How to keep VS2010 CTP working past 1/1/2009</title>
        <link rel="self" type="text/html" href="http://blog.dotnetspeech.net/archive/2008/12/10/how-to-keep-vs2010-ctp-working-past-112009.aspx" />
        <id>http://blog.dotnetspeech.net/archive/2008/12/10/how-to-keep-vs2010-ctp-working-past-112009.aspx</id>
        <published>2008-12-10T08:34:18-07:00:00</published>
        <updated>2008-12-10T08:34:18Z</updated>
        <content type="html">&lt;p&gt;For those of you playing with the VS2010 CTP, you've probably noticed that it's going to stop working around New Years. Jeff Beehler just posted &lt;a href="http://blogs.msdn.com/jeffbe/archive/2008/12/09/dealing-with-the-team-system-2010-ctp-expiration.aspx" target="_blank"&gt;this blog entry&lt;/a&gt; on how to extend the life of your (new) VS2010 VPC beyond that time.&lt;/p&gt;&lt;img src="http://blog.dotnetspeech.net/aggbug/127793.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://blog.dotnetspeech.net/comments/127793.aspx</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://blog.dotnetspeech.net/comments/commentRss/127793.aspx</wfw:commentRss>
        <trackback:ping>http://blog.dotnetspeech.net/services/trackbacks/127793.aspx</trackback:ping>
    </entry>
    <entry>
        <title>Accidental Perplexity</title>
        <link rel="self" type="text/html" href="http://blog.dotnetspeech.net/archive/2008/12/09/accidental-perplexity.aspx" />
        <id>http://blog.dotnetspeech.net/archive/2008/12/09/accidental-perplexity.aspx</id>
        <published>2008-12-09T14:40:54-07:00:00</published>
        <updated>2008-12-09T14:40:54Z</updated>
        <content type="html">&lt;p&gt;I was discussing accidental complexity with some co-workers after reading &lt;a href="http://blog.davebouwman.net/2008/12/09/MoreOnSimplicityEssentialVsAccidentalComplexity.aspx" target="_blank"&gt;Dave Bouwman's recent post&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;One of them coined the phrase "accidental perplexity," which we quickly defined as "when you look at a code base and can't figure out what on earth the developer was thinking." This is especially bad when the core reason for the perplexity is in the architecture.&lt;/p&gt;&lt;img src="http://blog.dotnetspeech.net/aggbug/127771.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://blog.dotnetspeech.net/comments/127771.aspx</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://blog.dotnetspeech.net/comments/commentRss/127771.aspx</wfw:commentRss>
        <trackback:ping>http://blog.dotnetspeech.net/services/trackbacks/127771.aspx</trackback:ping>
    </entry>
    <entry>
        <title>Try/Catch Performance</title>
        <link rel="self" type="text/html" href="http://blog.dotnetspeech.net/archive/2008/12/01/trycatch-performance.aspx" />
        <id>http://blog.dotnetspeech.net/archive/2008/12/01/trycatch-performance.aspx</id>
        <published>2008-12-01T17:06:36-07:00:00</published>
        <updated>2008-12-01T17:06:36Z</updated>
        <content type="html">&lt;p&gt;I'm really not obsessed with performance -- honest!&lt;/p&gt;  &lt;p&gt;However, when a co-worker asked me today exception handling was an acceptable way of coding defensively, my reaction was rather predictable. Exceptions are pure evil, and should be... well, exceptional. &lt;/p&gt;  &lt;p&gt;Yes, you guessed it. The next question was "How bad is try/catch really?"&lt;/p&gt;  &lt;p&gt;The short answer is that is involves minimal overhead... unless an exception is thrown. In that case, the .NET exception handling mechanism does a few nice things, like providing the stack trace as part of the exception. Great for debugging... lousy for performance. Of course, if exceptions are treated as being exceptional -- that is, they're only raised when something you haven't predicted occurs -- then you really shouldn't care about performance. Since your application is most likely left in an unknown or unstable state after an exception, the odds are you're going to reset a substantial part of your application, if not shut it down entirely.&lt;/p&gt;  &lt;p&gt;As a rule, you can predict that users will provide data that is, to put it politely, suspect. This isn't a reflection on the users; if anything, it's more a comment on the tendency of developers to know how their own code works, and to continually feed it good data. But, both for this reason, and for security reasons, the ASP.NET mantra of "never trust any input" applies in pretty much any application. Code defensively against user input, so that you don't have to rely on try/catch blocks to deal with exceptions.&lt;/p&gt;  &lt;p&gt;How significant is the overhead of catching an exception? Here's the code for a console application to illustrate:&lt;/p&gt;  &lt;pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt;  1: &lt;span style="color: #0000ff"&gt;Module&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Module&lt;/span&gt;1
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt;  2:     &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; Main()
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt;  3:         TestNaive(1)
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt;  4:         TestDefensive(1)
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt;  5:         TestWithTryCatch(1)
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt;  6:         TestWithException(1)
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt;  7: 
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt;  8:         &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; maxCount &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt; = 1000000
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt;  9: 
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 10:         Console.WriteLine("&lt;span style="color: #8b0000"&gt;Naive: &lt;/span&gt;" &amp;amp; TestNaive(maxCount) &amp;amp; "&lt;span style="color: #8b0000"&gt; ticks&lt;/span&gt;")
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 11:         Console.WriteLine("&lt;span style="color: #8b0000"&gt;Defensive coding, no try/catch: &lt;/span&gt;" &amp;amp; TestDefensive(maxCount) &amp;amp; "&lt;span style="color: #8b0000"&gt; ticks&lt;/span&gt;")
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 12:         Console.WriteLine("&lt;span style="color: #8b0000"&gt;Naive with try/catch: &lt;/span&gt;" &amp;amp; TestWithTryCatch(maxCount) &amp;amp; "&lt;span style="color: #8b0000"&gt; ticks&lt;/span&gt;")
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 13:         Console.WriteLine("&lt;span style="color: #8b0000"&gt;Exception: &lt;/span&gt;" &amp;amp; TestWithException(maxCount) &amp;amp; "&lt;span style="color: #8b0000"&gt; ticks&lt;/span&gt;")
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 14:         Console.ReadLine()
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 15:     &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 16: 
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 17:     &lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt; TestNaive(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; iterationCount &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt;) &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 18:         &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; sw &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; Stopwatch
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 19:         sw.Start()
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 20:         &lt;span style="color: #0000ff"&gt;For&lt;/span&gt; i &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt; = 1 &lt;span style="color: #0000ff"&gt;To&lt;/span&gt; iterationCount
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 21:             &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; x &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt; = i / (iterationCount - i + 1)
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 22:         &lt;span style="color: #0000ff"&gt;Next&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 23:         sw.&lt;span style="color: #0000ff"&gt;Stop&lt;/span&gt;()
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 24: 
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 25:         &lt;span style="color: #0000ff"&gt;Return&lt;/span&gt; sw.ElapsedTicks / iterationCount
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 26:     &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 27: 
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 28:     &lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt; TestDefensive(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; iterationCount &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt;) &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 29:         &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; sw &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; Stopwatch
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 30:         sw.Start()
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 31:         &lt;span style="color: #0000ff"&gt;For&lt;/span&gt; i &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt; = 1 &lt;span style="color: #0000ff"&gt;To&lt;/span&gt; iterationCount
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 32:             &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; y &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt; = (iterationCount - i + 1)
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 33:             &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Not&lt;/span&gt; y = 0 &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 34:                 &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; x &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt; = i / y
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 35:             &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 36:         &lt;span style="color: #0000ff"&gt;Next&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 37:         sw.&lt;span style="color: #0000ff"&gt;Stop&lt;/span&gt;()
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 38: 
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 39:         &lt;span style="color: #0000ff"&gt;Return&lt;/span&gt; sw.ElapsedTicks / iterationCount
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 40:     &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 41: 
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 42:     &lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt; TestWithTryCatch(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; iterationCount &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt;) &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 43:         &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; sw &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; Stopwatch
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 44:         sw.Start()
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 45:         &lt;span style="color: #0000ff"&gt;For&lt;/span&gt; i &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt; = 1 &lt;span style="color: #0000ff"&gt;To&lt;/span&gt; iterationCount
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 46:             &lt;span style="color: #0000ff"&gt;Try&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 47:                 &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; x &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt; = i / (iterationCount - i + 1)
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 48:             &lt;span style="color: #0000ff"&gt;Catch&lt;/span&gt; ex &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; Exception
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 49: 
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 50:             &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Try&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 51:         &lt;span style="color: #0000ff"&gt;Next&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 52:         sw.&lt;span style="color: #0000ff"&gt;Stop&lt;/span&gt;()
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 53: 
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 54:         &lt;span style="color: #0000ff"&gt;Return&lt;/span&gt; sw.ElapsedTicks / iterationCount
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 55:     &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 56: 
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 57:     &lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt; TestWithException(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; iterationCount &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt;) &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 58:         &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; sw &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; Stopwatch
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 59:         sw.Start()
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 60:         &lt;span style="color: #0000ff"&gt;For&lt;/span&gt; i &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt; = 1 &lt;span style="color: #0000ff"&gt;To&lt;/span&gt; iterationCount
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 61:             &lt;span style="color: #0000ff"&gt;Try&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 62:                 &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; x &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt; = i / 0
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 63:             &lt;span style="color: #0000ff"&gt;Catch&lt;/span&gt; ex &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; Exception
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 64: 
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 65:             &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Try&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 66:         &lt;span style="color: #0000ff"&gt;Next&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 67:         sw.&lt;span style="color: #0000ff"&gt;Stop&lt;/span&gt;()
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 68: 
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 69:         &lt;span style="color: #0000ff"&gt;Return&lt;/span&gt; sw.ElapsedTicks / iterationCount
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 70:     &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt; 71: &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Module&lt;/span&gt;
&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;My results tend to vary a little bit, since the work done in each loop so trivial that it is susceptible to noise. The first three tests are generally pretty close to each other. The fourth test -- testing with an exception raised -- is always much longer. Generally it's somewhat more than 5x longer than the other tests.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/TechnicalDebtor/WindowsLiveWriter/TryCatchPerformance_EF7A/TryCatchPerfTest.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="105" alt="TryCatchPerfTest" src="http://geekswithblogs.net/images/geekswithblogs_net/TechnicalDebtor/WindowsLiveWriter/TryCatchPerformance_EF7A/TryCatchPerfTest_thumb.jpg" width="566" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/TechnicalDebtor/WindowsLiveWriter/TryCatchPerformance_EF7A/TryCatchPerfTest2_1.jpg"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="100" alt="TryCatchPerfTest2" src="http://geekswithblogs.net/images/geekswithblogs_net/TechnicalDebtor/WindowsLiveWriter/TryCatchPerformance_EF7A/TryCatchPerfTest2_thumb_1.jpg" width="563" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;What I find really interesting is that the inclusion of the try/catch block appears to make the naive implementation run faster. I don't have the .NET debugging symbols loaded on my machine, and dotTrace really didn't provide any insight. Anyone out there who has dug deeply into the CLR and can provide insight, it would be much appreciated.&lt;/p&gt;

&lt;p&gt;However, the moral of the story is straight-forward. Treat exceptions as exceptional. Code defensively rather than catching exceptions wherever possible. No surprise there.&lt;/p&gt;&lt;img src="http://blog.dotnetspeech.net/aggbug/127505.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://blog.dotnetspeech.net/comments/127505.aspx</wfw:comment>
        <slash:comments>8</slash:comments>
        <wfw:commentRss>http://blog.dotnetspeech.net/comments/commentRss/127505.aspx</wfw:commentRss>
        <trackback:ping>http://blog.dotnetspeech.net/services/trackbacks/127505.aspx</trackback:ping>
    </entry>
    <entry>
        <title>XamlFest: WPF/Silverlight Tools</title>
        <link rel="self" type="text/html" href="http://blog.dotnetspeech.net/archive/2008/11/25/xamlfest-wpfsilverlight-tools.aspx" />
        <id>http://blog.dotnetspeech.net/archive/2008/11/25/xamlfest-wpfsilverlight-tools.aspx</id>
        <published>2008-11-25T11:49:19-07:00:00</published>
        <updated>2008-11-25T11:50:47Z</updated>
        <content type="html">&lt;p&gt;Both &lt;a href="http://blois.us/Snoop/" target="_blank"&gt;Snoop&lt;/a&gt; (WPF) and &lt;a href="http://firstfloorsoftware.com/silverlightspy/download-silverlight-spy/" target="_blank"&gt;Silverlight Spy&lt;/a&gt; (Silverlight, obviously) allow you to connect to running processes and see what's going on inside them. Very powerful tools.&lt;/p&gt;  &lt;p&gt;With Silverlight Spy, you can see the contents of any Silverlight app... and reflect against them. The temptation with Silverlight is to put more code in the stateful .NET client, but the consequence is that your code is essentially available to the world. This also applies to any keys, passwords, etc that may be stored within your code.&lt;/p&gt;  &lt;p&gt;Time-sensitive encrypt keys from the server may be worth investigating as a means of protecting your secrets.&lt;/p&gt;  &lt;p&gt;Really, it drives home the point that you need to be cognizant of where you store your secrets. In addition, you simply shouldn't trust anything coming from the client. Other strategies include routing all traffic through your secure server, rather than allowing direct access to web services. Treat your production Silverlight apps like any public-facing web site -- expect attacks, expect people to hammer at it and try to destroy it.&lt;/p&gt;&lt;img src="http://blog.dotnetspeech.net/aggbug/127382.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://blog.dotnetspeech.net/comments/127382.aspx</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://blog.dotnetspeech.net/comments/commentRss/127382.aspx</wfw:commentRss>
        <trackback:ping>http://blog.dotnetspeech.net/services/trackbacks/127382.aspx</trackback:ping>
    </entry>
    <entry>
        <title>XamlFest: View-Model-ViewModel Pattern</title>
        <link rel="self" type="text/html" href="http://blog.dotnetspeech.net/archive/2008/11/25/xamlfest-view-model-viewmodel-pattern.aspx" />
        <id>http://blog.dotnetspeech.net/archive/2008/11/25/xamlfest-view-model-viewmodel-pattern.aspx</id>
        <published>2008-11-25T11:48:19-07:00:00</published>
        <updated>2008-11-25T11:48:19Z</updated>
        <content type="html">&lt;p&gt;Some quick notes about one architectural pattern for WPF apps -- this is a modified version of MVC/MVP.&lt;/p&gt;  &lt;p&gt;&lt;u&gt;The Model&lt;/u&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;bottom layer of the pattern &lt;/li&gt;    &lt;li&gt;no knowledge of the View (UI) &lt;/li&gt;    &lt;li&gt;variables should be named in UI-agnostic terms ("available" vs "visible") &lt;/li&gt;    &lt;li&gt;.NET class &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;u&gt;The View&lt;/u&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;WPF/Silverlight representation of the UI &lt;/li&gt;    &lt;li&gt;should have minimal code &lt;/li&gt;    &lt;li&gt;connects to the ViewModel through the DataContext property &lt;/li&gt;    &lt;li&gt;should be editable in either Blend or Visual Studio &lt;/li&gt;    &lt;li&gt;XAML file &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;u&gt;The ViewModel&lt;/u&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;represents the "glue" between the UI and the back end &lt;/li&gt;    &lt;li&gt;presents data and interacts with code &lt;/li&gt;    &lt;li&gt;responsible for property change notifications &lt;/li&gt;    &lt;li&gt;exposes RoutedCommand and DelegateCommand commands &lt;/li&gt;    &lt;li&gt;shouldn't contain references to specific UI elements &lt;/li&gt; &lt;/ul&gt;&lt;img src="http://blog.dotnetspeech.net/aggbug/127381.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://blog.dotnetspeech.net/comments/127381.aspx</wfw:comment>
        <slash:comments>2</slash:comments>
        <wfw:commentRss>http://blog.dotnetspeech.net/comments/commentRss/127381.aspx</wfw:commentRss>
        <trackback:ping>http://blog.dotnetspeech.net/services/trackbacks/127381.aspx</trackback:ping>
    </entry>
    <entry>
        <title>LiveWriter Code Formatting Plug-In</title>
        <link rel="self" type="text/html" href="http://blog.dotnetspeech.net/archive/2008/11/18/livewriter-code-formatting-plug-in.aspx" />
        <id>http://blog.dotnetspeech.net/archive/2008/11/18/livewriter-code-formatting-plug-in.aspx</id>
        <published>2008-11-18T17:14:46-07:00:00</published>
        <updated>2008-11-18T17:14:46Z</updated>
        <content type="html">&lt;p&gt;Another thing that took me far too long to find today... there's a lot of links to Steve Dunn's tool, including the CodePlex version, which hasn't been updated since 2006. And, since it doesn't have an installer or the DLLs readily available, you'll waste a lot of time looking for that too.&lt;/p&gt;  &lt;p&gt;You might consider trying &lt;a href="http://www.amergerzic.com/post/WLWSourceCodePlugin.aspx" target="_blank"&gt;this tool.&lt;/a&gt; Looks pretty good to me so far. And, yes, it supports a few languages. And line numbers. And highlighting.&lt;/p&gt;  &lt;pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt;&lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Class&lt;/span&gt; ThisRocks
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt;  &lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt; URL &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;String&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt;    &lt;span style="color: #0000ff"&gt;Return&lt;/span&gt; "&lt;span style="color: #8b0000"&gt;http://www.amergerzic.com/post/WLWSourceCodePlugin.aspx&lt;/span&gt;"
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt;  &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Class&lt;/span&gt;&lt;/pre&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt;  1: &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; ThisIsOkToo
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt;  2: {
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt;  3:   &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; URL()
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt;  4:   {
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt;  5:     &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; "&lt;span style="color: #8b0000"&gt;http://www.amergerzic.com/post/WLWSourceCodePlugin.aspx&lt;/span&gt;";
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt;  6:   }
&lt;/pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt;  7: }&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;A word of caution. There's a little silliness around seeing the formatted code properly in WLW. You'll end up getting used to switching to the HTML source and back... or just learning to trust the tool.&lt;/p&gt;&lt;img src="http://blog.dotnetspeech.net/aggbug/127209.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://blog.dotnetspeech.net/comments/127209.aspx</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://blog.dotnetspeech.net/comments/commentRss/127209.aspx</wfw:commentRss>
        <trackback:ping>http://blog.dotnetspeech.net/services/trackbacks/127209.aspx</trackback:ping>
    </entry>
    <entry>
        <title>VB.NET Generics with Multiple Constraints</title>
        <link rel="self" type="text/html" href="http://blog.dotnetspeech.net/archive/2008/11/18/vb.net-generics-with-multiple-constraints.aspx" />
        <id>http://blog.dotnetspeech.net/archive/2008/11/18/vb.net-generics-with-multiple-constraints.aspx</id>
        <published>2008-11-18T17:05:48-07:00:00</published>
        <updated>2008-11-18T17:05:48Z</updated>
        <content type="html">&lt;p&gt;I had a case today where I needed -- well, wanted -- to implement a generic class that was a little... unusual. &lt;/p&gt;  &lt;p&gt;Essentially, I'm working on a queuing mechanism based on Joe Duffy's BlockingBoundedQueue(Of T). Mind you, unlike Joe's sample, mine is written in VB.NET. ;)&lt;/p&gt;  &lt;p&gt;Taking it a bit further, I created a wrapper that specifies the number of producers and consumers of queued objects, as well as the queue capacity. Since I'm going to be turning this over to a bunch of developers to play with, I also wanted to be able to specify more tightly what types can be used for producers and consumers. This type specification also lets me raise events for diagnostics. &lt;/p&gt;  &lt;p&gt;Now, this all sounds kind of easy, doesn't it? Well, it is... until you go looking for a good example of the syntax for generics with multiple constraints. I usually get good results from Google, and this took me far too long to find, so I thought I'd post it here. &lt;/p&gt;  &lt;p&gt;The key is wrapping the multiple constraints for a single generic argument in the dreaded curly braces. A simple example is:&lt;/p&gt;  &lt;pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt;&lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Class&lt;/span&gt; &lt;span style="color: #0000ff"&gt;myClass&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;Of&lt;/span&gt; T &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; {&lt;span style="color: #0000ff"&gt;New&lt;/span&gt;, myBaseClass})&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;A more complicated example could look something like this:&lt;/p&gt;

&lt;pre&gt;&lt;pre style="font-size: 14px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"&gt;&lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Class&lt;/span&gt; DataQueue(&lt;span style="color: #0000ff"&gt;Of&lt;/span&gt; P &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; {&lt;span style="color: #0000ff"&gt;New&lt;/span&gt;, Producer(&lt;span style="color: #0000ff"&gt;Of&lt;/span&gt; T)}, C &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; {&lt;span style="color: #0000ff"&gt;New&lt;/span&gt;, Consumer(&lt;span style="color: #0000ff"&gt;Of&lt;/span&gt; T)}, T)&lt;/pre&gt;&lt;/pre&gt;&lt;img src="http://blog.dotnetspeech.net/aggbug/127208.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://blog.dotnetspeech.net/comments/127208.aspx</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://blog.dotnetspeech.net/comments/commentRss/127208.aspx</wfw:commentRss>
        <trackback:ping>http://blog.dotnetspeech.net/services/trackbacks/127208.aspx</trackback:ping>
    </entry>
</feed>