<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" 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:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Tim Barcz - .NET</title>
    <link>http://www.timbarcz.com/blog/</link>
    <description>My Code is My Craft</description>
    <image>
      <url>http://www.timbarcz.com/blog/content/binary/channelImage.jpg</url>
      <title>Tim Barcz - .NET</title>
      <link>http://www.timbarcz.com/blog/</link>
    </image>
    <language>en-us</language>
    <copyright>Tim Barcz</copyright>
    <lastBuildDate>Fri, 13 Mar 2009 19:42:59 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.0.7226.0</generator>
    <managingEditor>blog@timbarcz.com</managingEditor>
    <webMaster>blog@timbarcz.com</webMaster>
    <item>
      <trackback:ping>http://www.timbarcz.com/blog/Trackback.aspx?guid=9632ffeb-3e82-4bdc-9e84-9444ce05dc46</trackback:ping>
      <pingback:server>http://www.timbarcz.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.timbarcz.com/blog/PermaLink,guid,9632ffeb-3e82-4bdc-9e84-9444ce05dc46.aspx</pingback:target>
      <dc:creator>Tim Barcz</dc:creator>
      <wfw:comment>http://www.timbarcz.com/blog/CommentView,guid,9632ffeb-3e82-4bdc-9e84-9444ce05dc46.aspx</wfw:comment>
      <wfw:commentRss>http://www.timbarcz.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=9632ffeb-3e82-4bdc-9e84-9444ce05dc46</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I have a penchant for taking "unsolvable" computer problems and getting
to the bottom of them.  Often times this means I'm exploring the contents of
a memory dump, that is, all of the data held in RAM of the process you're inspecting. 
When I got started in this area about 2+ years ago I found <a href="http://blogs.msdn.com/tess/">Tess
Fernandez's blog</a> blog was a great resource.  In fact <a href="http://www.timbarcz.com/blog/DebuggingNetApplicationsWithWinDBG.aspx">I've
blogged about Tess and WinDBG before</a>.  Her blog is one of my favorites when
it comes to debugging and troubleshooting .NET applications (web or otherwise).
</p>
        <p>
Debugging and troubleshooting is a skill I think too many developers lack.  By
debugging and troubleshooting I don't mean stepping your way through code.  I
mean, "Holy Crap our production app is failing and we don't know why," kind
of debugging.  I think debugging is so valuable that I used to ask specific questions
about it during interviews.  Too many times I could ask questions and see the
developer try to answer, but often it was easy to see that if this was a real world
scenario and not an interview question, they would have long ago thrown up their arms
in defeat.  Computers are predictable, they don't "decide" anything,
they're told what to do. If you understand that you're a step ahead of the average
developer when it comes to debugging and troubleshooting.
</p>
        <p>
Earlier this week <a href="http://www.dotnetrocks.com">DotNetRocks</a> interviewed <a href="http://blogs.msdn.com/tess/">Tess
Fernandez</a>, an escalation engineer with Microsoft.  She's Tier 2 support.
In other words, when you have a problem and call Microsoft you get Tier 1 support. 
Then "when thinks get too sticky" she comes to the rescue.  
</p>
        <p>
(I'd like to take a moment and have you consider the types of problems she gets. 
The typical engineer will encounter many issues over their career.  I'm sure
you've had them.  I've had them.  However, I typically will peruse articles,
blog posts, and forum posts to find the answers I look for.  When faced with
a problem, how many times have you ever resorted to calling Microsoft? Me? Zero. So
imagine for a moment that you've not found an answer on any of the typical resources
and have called Microsoft.  You're working with their Tier 1 support but they
can't seem to help you.  It as it this point that you get a person like Tess. 
She's smart.  She know .NET like I know Mt. Dew).
</p>
        <p>
If you're sitting at a desk download the podcast and listen now:
</p>
        <ul>
          <li>
MP3: <a href="http://perseus.franklins.net/dotnetrocks_0427_tess_ferrandez.mp3">http://perseus.franklins.net/dotnetrocks_0427_tess_ferrandez.mp3</a></li>
          <li>
WMA: <a title="http://perseus.franklins.net/dotnetrocks_0427_tess_ferrandez.wma" href="http://perseus.franklins.net/dotnetrocks_0427_tess_ferrandez.wma">http://perseus.franklins.net/dotnetrocks_0427_tess_ferrandez.wma</a></li>
          <li>
WMA Lo-Fi: <a title="http://perseus.franklins.net/dotnetrocks_0427_tess_ferrandez_lo.wma" href="http://perseus.franklins.net/dotnetrocks_0427_tess_ferrandez_lo.wma">http://perseus.franklins.net/dotnetrocks_0427_tess_ferrandez_lo.wma</a></li>
          <li>
iPod: <a title="http://perseus.franklins.net/dotnetrocks_0427_tess_ferrandez.m4b" href="http://perseus.franklins.net/dotnetrocks_0427_tess_ferrandez.m4b">http://perseus.franklins.net/dotnetrocks_0427_tess_ferrandez.m4b</a></li>
        </ul>
        <img width="0" height="0" src="http://www.timbarcz.com/blog/aggbug.ashx?id=9632ffeb-3e82-4bdc-9e84-9444ce05dc46" />
      </body>
      <title>Debugging .NET Applications - Podcast Alert</title>
      <guid isPermaLink="false">http://www.timbarcz.com/blog/PermaLink,guid,9632ffeb-3e82-4bdc-9e84-9444ce05dc46.aspx</guid>
      <link>http://www.timbarcz.com/blog/DebuggingNETApplicationsPodcastAlert.aspx</link>
      <pubDate>Fri, 13 Mar 2009 19:42:59 GMT</pubDate>
      <description>&lt;p&gt;
I have a penchant for taking &amp;quot;unsolvable&amp;quot; computer problems and getting
to the bottom of them.&amp;#160; Often times this means I'm exploring the contents of
a memory dump, that is, all of the data held in RAM of the process you're inspecting.&amp;#160;
When I got started in this area about 2+ years ago I found &lt;a href="http://blogs.msdn.com/tess/"&gt;Tess
Fernandez's blog&lt;/a&gt; blog was a great resource.&amp;#160; In fact &lt;a href="http://www.timbarcz.com/blog/DebuggingNetApplicationsWithWinDBG.aspx"&gt;I've
blogged about Tess and WinDBG before&lt;/a&gt;.&amp;#160; Her blog is one of my favorites when
it comes to debugging and troubleshooting .NET applications (web or otherwise).
&lt;/p&gt;
&lt;p&gt;
Debugging and troubleshooting is a skill I think too many developers lack.&amp;#160; By
debugging and troubleshooting I don't mean stepping your way through code.&amp;#160; I
mean, &amp;quot;Holy Crap our production app is failing and we don't know why,&amp;quot; kind
of debugging.&amp;#160; I think debugging is so valuable that I used to ask specific questions
about it during interviews.&amp;#160; Too many times I could ask questions and see the
developer try to answer, but often it was easy to see that if this was a real world
scenario and not an interview question, they would have long ago thrown up their arms
in defeat.&amp;#160; Computers are predictable, they don't &amp;quot;decide&amp;quot; anything,
they're told what to do. If you understand that you're a step ahead of the average
developer when it comes to debugging and troubleshooting.
&lt;/p&gt;
&lt;p&gt;
Earlier this week &lt;a href="http://www.dotnetrocks.com"&gt;DotNetRocks&lt;/a&gt; interviewed &lt;a href="http://blogs.msdn.com/tess/"&gt;Tess
Fernandez&lt;/a&gt;, an escalation engineer with Microsoft.&amp;#160; She's Tier 2 support.
In other words, when you have a problem and call Microsoft you get Tier 1 support.&amp;#160;
Then &amp;quot;when thinks get too sticky&amp;quot; she comes to the rescue.&amp;#160; 
&lt;/p&gt;
&lt;p&gt;
(I'd like to take a moment and have you consider the types of problems she gets.&amp;#160;
The typical engineer will encounter many issues over their career.&amp;#160; I'm sure
you've had them.&amp;#160; I've had them.&amp;#160; However, I typically will peruse articles,
blog posts, and forum posts to find the answers I look for.&amp;#160; When faced with
a problem, how many times have you ever resorted to calling Microsoft? Me? Zero. So
imagine for a moment that you've not found an answer on any of the typical resources
and have called Microsoft.&amp;#160; You're working with their Tier 1 support but they
can't seem to help you.&amp;#160; It as it this point that you get a person like Tess.&amp;#160;
She's smart.&amp;#160; She know .NET like I know Mt. Dew).
&lt;/p&gt;
&lt;p&gt;
If you're sitting at a desk download the podcast and listen now:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
MP3: &lt;a href="http://perseus.franklins.net/dotnetrocks_0427_tess_ferrandez.mp3"&gt;http://perseus.franklins.net/dotnetrocks_0427_tess_ferrandez.mp3&lt;/a&gt; 
&lt;/li&gt;
&lt;li&gt;
WMA: &lt;a title="http://perseus.franklins.net/dotnetrocks_0427_tess_ferrandez.wma" href="http://perseus.franklins.net/dotnetrocks_0427_tess_ferrandez.wma"&gt;http://perseus.franklins.net/dotnetrocks_0427_tess_ferrandez.wma&lt;/a&gt; 
&lt;/li&gt;
&lt;li&gt;
WMA Lo-Fi: &lt;a title="http://perseus.franklins.net/dotnetrocks_0427_tess_ferrandez_lo.wma" href="http://perseus.franklins.net/dotnetrocks_0427_tess_ferrandez_lo.wma"&gt;http://perseus.franklins.net/dotnetrocks_0427_tess_ferrandez_lo.wma&lt;/a&gt; 
&lt;/li&gt;
&lt;li&gt;
iPod: &lt;a title="http://perseus.franklins.net/dotnetrocks_0427_tess_ferrandez.m4b" href="http://perseus.franklins.net/dotnetrocks_0427_tess_ferrandez.m4b"&gt;http://perseus.franklins.net/dotnetrocks_0427_tess_ferrandez.m4b&lt;/a&gt; 
&lt;/li&gt;
&lt;/ul&gt;
&lt;img width="0" height="0" src="http://www.timbarcz.com/blog/aggbug.ashx?id=9632ffeb-3e82-4bdc-9e84-9444ce05dc46" /&gt;</description>
      <comments>http://www.timbarcz.com/blog/CommentView,guid,9632ffeb-3e82-4bdc-9e84-9444ce05dc46.aspx</comments>
      <category>.NET</category>
      <category>Debugging</category>
    </item>
    <item>
      <trackback:ping>http://www.timbarcz.com/blog/Trackback.aspx?guid=42570527-952b-4d9f-a25a-84ef7abad9fb</trackback:ping>
      <pingback:server>http://www.timbarcz.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.timbarcz.com/blog/PermaLink,guid,42570527-952b-4d9f-a25a-84ef7abad9fb.aspx</pingback:target>
      <dc:creator>Tim Barcz</dc:creator>
      <wfw:comment>http://www.timbarcz.com/blog/CommentView,guid,42570527-952b-4d9f-a25a-84ef7abad9fb.aspx</wfw:comment>
      <wfw:commentRss>http://www.timbarcz.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=42570527-952b-4d9f-a25a-84ef7abad9fb</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://www.timbarcz.com/blog/content/binary/WindowsLiveWriter/Logging_EA32/image_2.png">
            <img style="border-width: 0px;" alt="image" src="http://www.timbarcz.com/blog/content/binary/WindowsLiveWriter/Logging_EA32/image_thumb.png" width="305" align="right" border="0" height="324" />
          </a>I
have what I believe to be a fairly simple problem in theory, yet in reality it proves
to be a bit more hairy.  Below I present the problem and the requirements as
I see them as well as a few possible solutions.  The solution I've settled on
may or may not be correct, so I'm tossing out here to see what you guys think. 
By all means please post some feedback.
</p>
        <h3>Problem
</h3>
        <p>
To have a common, consistent logging access across multiple assemblies (that I own)
in an application.
</p>
        <h4>
        </h4>
        <h3>Requirements
</h3>
        <ul>
          <li>
I want to be able to have logging capabilities in any method of any class in my application. 
</li>
          <li>
I want to define logging once and only once for my application.  
</li>
          <li>
I want to maintain testability by not having any unnecessary dependencies or unmockable
objects.  
</li>
          <li>
I want as few assemblies to be aware of dependencies as possible.</li>
          <li>
If at all possible I wanted to avoid having all of my classes have an external dependency
on some interface (such as ILog) 
<ul><li>
I also want to avoid every class having a public property which exposes an ILog (for
setter injection) 
</li></ul></li>
        </ul>
        <h3>The Structure
</h3>
        <p>
To the right is a picture of the assembly dependency diagram. 
</p>
        <h3>Solution #1
</h3>
        <p>
I could use <a href="http://devlicio.us/blogs/casey/archive/2008/06/18/logging-with-castle-windsor-the-logging-facility-and-log4net.aspx">Windsor's
logging facility</a> as suggested by <a href="http://devlicio.us/blogs/casey/">Casey
Charlton</a> except that the solution provided only seemingly works for my top level
assembly, ABCCompany.MVC.Web.  I don't want my other assemblies to be aware that
I'm using an IoC Container.  I especially don't want the assemblies to know I'm
bound to a particular IoC container (in this case I'm using Castle's Windsor container). 
I've emailed Casey about this and we are going to try to talk this through. 
I'm interested to hear what his thoughts are given that on <a href="http://www.castleproject.org">Castle's
site</a> it says about the <a href="http://www.castleproject.org/container/facilities/v1rc3/logging/index.html">logging
facility</a> (emphasis mine):
</p>
        <blockquote>
          <p>
The logging facility provides a seamless way to add logging capabilities to your application.
There are two levels of integration. 
</p>
          <ul>
            <li>
Allow your classes to receive an ILogger instance for logging support 
</li>
            <li>
              <strong>Allow you to ask for an ILoggerFactory instance to provide logging support
to classes that are not managed by Windsor.</strong>
            </li>
          </ul>
        </blockquote>
        <p>
While I wait to talk with Casey I have to discount this solution since I cannot see
past the first assembly on how this would work and therefore cannot use this as my
solution of choice.
</p>
        <h3>Solution #2
</h3>
        <p>
This is what I've come up with so far.  Please comment if you see issues.  
</p>
        <p>
I have set up a static class inside of the ABCCompany.Framework assembly from which
all methods could call for Logging purposes.  This satisfies the requirements
above which states that I do not want constructor dependencies nor public setters
on all classes.  This solution however does mean that every assembly much also
ship with the ABCCompany.Framework assembly and all of it's dependent assemblies. 
I'm okay with this until I hear a reason that this is bad.  I view this much
like when I do work with Castle that in order to get any behavior I have to bring
Castle.Core along to the party.
</p>
        <p>
I liked Casey's solution (Solution #1) except that I cannot see past it working in
one and only one assembly.  I thought I could modify his solution by simply having
a static class, which any assembly can reference and call.  By default the Logger
would be set up with a NullLogger.  The Logging class would have a method available
to change the underlying logger.  It would then be incumbent upon the application
layer to change the logger if they actually wanted logging.  In my app this is
the first thing that happens, the NullLogger is replaced by an actual logger by calling
Log.SetLogger().
</p>
        <p>
As you can see from the code below I've followed much of Casey's example.
</p>
        <div>
          <div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);">
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;">
              <span style="color: rgb(96, 96, 96);"> 1:</span>
              <span style="color: rgb(0, 0, 255);">private</span>
              <span style="color: rgb(0, 0, 255);">static</span> ILogger
logger;</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);">
              <span style="color: rgb(96, 96, 96);"> 2:</span>  </pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;">
              <span style="color: rgb(96, 96, 96);"> 3:</span>
              <span style="color: rgb(0, 0, 255);">public</span>
              <span style="color: rgb(0, 0, 255);">static</span> ILogger
Logger</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);">
              <span style="color: rgb(96, 96, 96);"> 4:</span> {</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;">
              <span style="color: rgb(96, 96, 96);"> 5:</span> get</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);">
              <span style="color: rgb(96, 96, 96);"> 6:</span> {</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;">
              <span style="color: rgb(96, 96, 96);"> 7:</span>
              <span style="color: rgb(0, 0, 255);">if</span> (logger
== <span style="color: rgb(0, 0, 255);">null</span>)</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);">
              <span style="color: rgb(96, 96, 96);"> 8:</span> {</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;">
              <span style="color: rgb(96, 96, 96);"> 9:</span> logger
= NullLogger.Instance;</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);">
              <span style="color: rgb(96, 96, 96);"> 10:</span> }</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;">
              <span style="color: rgb(96, 96, 96);"> 11:</span>
              <span style="color: rgb(0, 0, 255);">return</span> logger;</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);">
              <span style="color: rgb(96, 96, 96);"> 12:</span> }</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;">
              <span style="color: rgb(96, 96, 96);"> 13:</span> }</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);">
              <span style="color: rgb(96, 96, 96);"> 14:</span>  </pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;">
              <span style="color: rgb(96, 96, 96);"> 15:</span>
              <span style="color: rgb(0, 0, 255);">public</span>
              <span style="color: rgb(0, 0, 255);">static</span>
              <span style="color: rgb(0, 0, 255);">void</span> SetLogger(ILogger <span style="color: rgb(0, 0, 255);">value</span>)</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);">
              <span style="color: rgb(96, 96, 96);"> 16:</span> {</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;">
              <span style="color: rgb(96, 96, 96);"> 17:</span> logger
= <span style="color: rgb(0, 0, 255);">value</span>;</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);">
              <span style="color: rgb(96, 96, 96);"> 18:</span> }</pre>
          </div>
        </div>
        <p>
I do have a dependency on the Castle.Core assembly (due to usage of types in Castle.Core.Logging). 
However none of the classes using the Log static class have to reference anything
to do with Castle since I've have methods which pass through to every method in ILogger
(see example below):
</p>
        <div>
          <div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);">
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;">
              <span style="color: rgb(96, 96, 96);"> 1:</span>
              <span style="color: rgb(0, 0, 255);">public</span>
              <span style="color: rgb(0, 0, 255);">static</span>
              <span style="color: rgb(0, 0, 255);">void</span> Debug(<span style="color: rgb(0, 0, 255);">string</span> message)</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);">
              <span style="color: rgb(96, 96, 96);"> 2:</span> {</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;">
              <span style="color: rgb(96, 96, 96);"> 3:</span> Logger.Debug(message);</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);">
              <span style="color: rgb(96, 96, 96);"> 4:</span> }</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;">
              <span style="color: rgb(96, 96, 96);"> 5:</span>  </pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);">
              <span style="color: rgb(96, 96, 96);"> 6:</span>
              <span style="color: rgb(0, 0, 255);">public</span>
              <span style="color: rgb(0, 0, 255);">static</span>
              <span style="color: rgb(0, 0, 255);">void</span> Debug(<span style="color: rgb(0, 0, 255);">string</span> message,
Exception exception)</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;">
              <span style="color: rgb(96, 96, 96);"> 7:</span> {</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);">
              <span style="color: rgb(96, 96, 96);"> 8:</span> Logger.Debug(message,exception);</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;">
              <span style="color: rgb(96, 96, 96);"> 9:</span> }</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);">
              <span style="color: rgb(96, 96, 96);"> 10:</span>  </pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;">
              <span style="color: rgb(96, 96, 96);"> 11:</span>
              <span style="color: rgb(0, 0, 255);">public</span>
              <span style="color: rgb(0, 0, 255);">static</span>
              <span style="color: rgb(0, 0, 255);">void</span> Debug(<span style="color: rgb(0, 0, 255);">string</span> format, <span style="color: rgb(0, 0, 255);">params</span><span style="color: rgb(0, 0, 255);">object</span>[]
args)</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);">
              <span style="color: rgb(96, 96, 96);"> 12:</span> {</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;">
              <span style="color: rgb(96, 96, 96);"> 13:</span> Logger.Debug(format,
args);</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);">
              <span style="color: rgb(96, 96, 96);"> 14:</span> }</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;">
              <span style="color: rgb(96, 96, 96);"> 15:</span>  </pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);">
              <span style="color: rgb(96, 96, 96);"> 16:</span>
              <span style="color: rgb(0, 0, 255);">public</span>
              <span style="color: rgb(0, 0, 255);">static</span>
              <span style="color: rgb(0, 0, 255);">void</span> DebugFormat(<span style="color: rgb(0, 0, 255);">string</span> format, <span style="color: rgb(0, 0, 255);">params</span><span style="color: rgb(0, 0, 255);">object</span>[]
args)</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;">
              <span style="color: rgb(96, 96, 96);"> 17:</span> {</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);">
              <span style="color: rgb(96, 96, 96);"> 18:</span> Logger.DebugFormat(format,
args);</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;">
              <span style="color: rgb(96, 96, 96);"> 19:</span> }</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);">
              <span style="color: rgb(96, 96, 96);"> 20:</span>  </pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;">
              <span style="color: rgb(96, 96, 96);"> 21:</span>
              <span style="color: rgb(0, 0, 255);">public</span>
              <span style="color: rgb(0, 0, 255);">static</span>
              <span style="color: rgb(0, 0, 255);">void</span> DebugFormat(Exception
exception, <span style="color: rgb(0, 0, 255);">string</span> format, <span style="color: rgb(0, 0, 255);">params</span><span style="color: rgb(0, 0, 255);">object</span>[]
args)</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);">
              <span style="color: rgb(96, 96, 96);"> 22:</span> {</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;">
              <span style="color: rgb(96, 96, 96);"> 23:</span> Logger.DebugFormat(exception,format,
args);</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);">
              <span style="color: rgb(96, 96, 96);"> 24:</span> }</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;">
              <span style="color: rgb(96, 96, 96);"> 25:</span>  </pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);">
              <span style="color: rgb(96, 96, 96);"> 26:</span>
              <span style="color: rgb(0, 0, 255);">public</span>
              <span style="color: rgb(0, 0, 255);">static</span>
              <span style="color: rgb(0, 0, 255);">void</span> DebugFormat(IFormatProvider
formatProvider, <span style="color: rgb(0, 0, 255);">string</span> format, <span style="color: rgb(0, 0, 255);">params</span><span style="color: rgb(0, 0, 255);">object</span>[]
args)</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;">
              <span style="color: rgb(96, 96, 96);"> 27:</span> {</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);">
              <span style="color: rgb(96, 96, 96);"> 28:</span> Logger.DebugFormat(formatProvider,
format, args);</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;">
              <span style="color: rgb(96, 96, 96);"> 29:</span> }</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);">
              <span style="color: rgb(96, 96, 96);"> 30:</span>  </pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;">
              <span style="color: rgb(96, 96, 96);"> 31:</span>
              <span style="color: rgb(0, 0, 255);">public</span>
              <span style="color: rgb(0, 0, 255);">static</span>
              <span style="color: rgb(0, 0, 255);">void</span> DebugFormat(Exception
exception, IFormatProvider formatProvider, <span style="color: rgb(0, 0, 255);">string</span> format, <span style="color: rgb(0, 0, 255);">params</span><span style="color: rgb(0, 0, 255);">object</span>[]
args)</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);">
              <span style="color: rgb(96, 96, 96);"> 32:</span> {</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;">
              <span style="color: rgb(96, 96, 96);"> 33:</span> Logger.DebugFormat(exception,
formatProvider, format, args);</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);">
              <span style="color: rgb(96, 96, 96);"> 34:</span> }</pre>
          </div>
        </div>
        <p>
The usage pattern becomes quite simple in that any class that references ABCCompany.Framework
can use the ABCCompany.Framework.Logging.Log class.  No external references needs
</p>
        <p>
The reason I chose to bind myself at the framework level to Castle's ILogger interface
and not something like ILog (log4net) was because ILogger is an abstraction over the
ILog interface.  Castle also provides some concrete implementations of ILogger,
one of which is for log4net 
</p>
        <ul>
          <li>
log4net (requires Castle.Services.Logging.Log4netIntegration.dll) 
</li>
          <li>
NLog (requires Castle.Services.Logging.NLogIntegration.dll) 
</li>
          <li>
ConsoleLogger 
</li>
          <li>
DiagnosticsLogger 
</li>
          <li>
StreamLogger 
</li>
          <li>
WebLogger (TraceContext) 
</li>
          <li>
NullLogger (used as placeholder) 
</li>
        </ul>
        <p>
As far as testing is concerned, the solution imposes no restrictions on testing. 
In my testing assemblies my logging calls are swallowed by the null logger. 
If I want to ensure the logger is called in my testing (interaction based tests),
I can mock an instance of ILogger and call Log.SetLogger() and set up expectations
on the mock ILogger.
</p>
        <p>
As I've mulled over this solution now for about a day it feels pretty solid. 
As I go through the requirements above they are all satisfied.  However I can
only see as far as my current knowledge so I'm hoping that if you see issues with
the above that you'll let me know.
</p>
        <img width="0" height="0" src="http://www.timbarcz.com/blog/aggbug.ashx?id=42570527-952b-4d9f-a25a-84ef7abad9fb" />
      </body>
      <title>Single Source Logging In Multiple Assemblies</title>
      <guid isPermaLink="false">http://www.timbarcz.com/blog/PermaLink,guid,42570527-952b-4d9f-a25a-84ef7abad9fb.aspx</guid>
      <link>http://www.timbarcz.com/blog/SingleSourceLoggingInMultipleAssemblies.aspx</link>
      <pubDate>Tue, 05 Aug 2008 13:48:30 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://www.timbarcz.com/blog/content/binary/WindowsLiveWriter/Logging_EA32/image_2.png"&gt;&lt;img style="border-width: 0px;" alt="image" src="http://www.timbarcz.com/blog/content/binary/WindowsLiveWriter/Logging_EA32/image_thumb.png" width="305" align="right" border="0" height="324"&gt;&lt;/a&gt;I
have what I believe to be a fairly simple problem in theory, yet in reality it proves
to be a bit more hairy.&amp;nbsp; Below I present the problem and the requirements as
I see them as well as a few possible solutions.&amp;nbsp; The solution I've settled on
may or may not be correct, so I'm tossing out here to see what you guys think.&amp;nbsp;
By all means please post some feedback.
&lt;/p&gt;
&lt;h3&gt;Problem
&lt;/h3&gt;
&lt;p&gt;
To have a common, consistent logging access across multiple assemblies (that I own)
in an application.
&lt;/p&gt;
&lt;h4&gt;
&lt;/h4&gt;
&lt;h3&gt;Requirements
&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
I want to be able to have logging capabilities in any method of any class in my application. 
&lt;/li&gt;
&lt;li&gt;
I want to define logging once and only once for my application.&amp;nbsp; 
&lt;/li&gt;
&lt;li&gt;
I want to maintain testability by not having any unnecessary dependencies or unmockable
objects.&amp;nbsp; 
&lt;/li&gt;
&lt;li&gt;
I want as few assemblies to be aware of dependencies as possible.&lt;/li&gt;
&lt;li&gt;
If at all possible I wanted to avoid having all of my classes have an external dependency
on some interface (such as ILog) 
&lt;ul&gt;
&lt;li&gt;
I also want to avoid every class having a public property which exposes an ILog (for
setter injection) 
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;The Structure
&lt;/h3&gt;
&lt;p&gt;
To the right is a picture of the assembly dependency diagram. 
&lt;/p&gt;
&lt;h3&gt;Solution #1
&lt;/h3&gt;
&lt;p&gt;
I could use &lt;a href="http://devlicio.us/blogs/casey/archive/2008/06/18/logging-with-castle-windsor-the-logging-facility-and-log4net.aspx"&gt;Windsor's
logging facility&lt;/a&gt; as suggested by &lt;a href="http://devlicio.us/blogs/casey/"&gt;Casey
Charlton&lt;/a&gt; except that the solution provided only seemingly works for my top level
assembly, ABCCompany.MVC.Web.&amp;nbsp; I don't want my other assemblies to be aware that
I'm using an IoC Container.&amp;nbsp; I especially don't want the assemblies to know I'm
bound to a particular IoC container (in this case I'm using Castle's Windsor container).&amp;nbsp;
I've emailed Casey about this and we are going to try to talk this through.&amp;nbsp;
I'm interested to hear what his thoughts are given that on &lt;a href="http://www.castleproject.org"&gt;Castle's
site&lt;/a&gt; it says about the &lt;a href="http://www.castleproject.org/container/facilities/v1rc3/logging/index.html"&gt;logging
facility&lt;/a&gt; (emphasis mine):
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
The logging facility provides a seamless way to add logging capabilities to your application.
There are two levels of integration. 
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Allow your classes to receive an ILogger instance for logging support 
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Allow you to ask for an ILoggerFactory instance to provide logging support
to classes that are not managed by Windsor.&lt;/strong&gt; 
&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
While I wait to talk with Casey I have to discount this solution since I cannot see
past the first assembly on how this would work and therefore cannot use this as my
solution of choice.
&lt;/p&gt;
&lt;h3&gt;Solution #2
&lt;/h3&gt;
&lt;p&gt;
This is what I've come up with so far.&amp;nbsp; Please comment if you see issues.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
I have set up a static class inside of the ABCCompany.Framework assembly from which
all methods could call for Logging purposes.&amp;nbsp; This satisfies the requirements
above which states that I do not want constructor dependencies nor public setters
on all classes.&amp;nbsp; This solution however does mean that every assembly much also
ship with the ABCCompany.Framework assembly and all of it's dependent assemblies.&amp;nbsp;
I'm okay with this until I hear a reason that this is bad.&amp;nbsp; I view this much
like when I do work with Castle that in order to get any behavior I have to bring
Castle.Core along to the party.
&lt;/p&gt;
&lt;p&gt;
I liked Casey's solution (Solution #1) except that I cannot see past it working in
one and only one assembly.&amp;nbsp; I thought I could modify his solution by simply having
a static class, which any assembly can reference and call.&amp;nbsp; By default the Logger
would be set up with a NullLogger.&amp;nbsp; The Logging class would have a method available
to change the underlying logger.&amp;nbsp; It would then be incumbent upon the application
layer to change the logger if they actually wanted logging.&amp;nbsp; In my app this is
the first thing that happens, the NullLogger is replaced by an actual logger by calling
Log.SetLogger().
&lt;/p&gt;
&lt;p&gt;
As you can see from the code below I've followed much of Casey's example.
&lt;/p&gt;
&lt;div&gt;
&lt;div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 1:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;static&lt;/span&gt; ILogger
logger;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 2:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 3:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;static&lt;/span&gt; ILogger
Logger&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 4:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 5:&lt;/span&gt; get&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 6:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 7:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (logger
== &lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;)&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 8:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 9:&lt;/span&gt; logger
= NullLogger.Instance;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 10:&lt;/span&gt; }&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 11:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; logger;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 12:&lt;/span&gt; }&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 13:&lt;/span&gt; }&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 14:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 15:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;static&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; SetLogger(ILogger &lt;span style="color: rgb(0, 0, 255);"&gt;value&lt;/span&gt;)&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 16:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 17:&lt;/span&gt; logger
= &lt;span style="color: rgb(0, 0, 255);"&gt;value&lt;/span&gt;;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 18:&lt;/span&gt; }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
I do have a dependency on the Castle.Core assembly (due to usage of types in Castle.Core.Logging).&amp;nbsp;
However none of the classes using the Log static class have to reference anything
to do with Castle since I've have methods which pass through to every method in ILogger
(see example below):
&lt;/p&gt;
&lt;div&gt;
&lt;div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 1:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;static&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; Debug(&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; message)&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 2:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 3:&lt;/span&gt; Logger.Debug(message);&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 4:&lt;/span&gt; }&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 5:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 6:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;static&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; Debug(&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; message,
Exception exception)&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 7:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 8:&lt;/span&gt; Logger.Debug(message,exception);&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 9:&lt;/span&gt; }&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 10:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 11:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;static&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; Debug(&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; format, &lt;span style="color: rgb(0, 0, 255);"&gt;params&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;object&lt;/span&gt;[]
args)&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 12:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 13:&lt;/span&gt; Logger.Debug(format,
args);&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 14:&lt;/span&gt; }&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 15:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 16:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;static&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; DebugFormat(&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; format, &lt;span style="color: rgb(0, 0, 255);"&gt;params&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;object&lt;/span&gt;[]
args)&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 17:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 18:&lt;/span&gt; Logger.DebugFormat(format,
args);&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 19:&lt;/span&gt; }&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 20:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 21:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;static&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; DebugFormat(Exception
exception, &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; format, &lt;span style="color: rgb(0, 0, 255);"&gt;params&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;object&lt;/span&gt;[]
args)&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 22:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 23:&lt;/span&gt; Logger.DebugFormat(exception,format,
args);&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 24:&lt;/span&gt; }&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 25:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 26:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;static&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; DebugFormat(IFormatProvider
formatProvider, &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; format, &lt;span style="color: rgb(0, 0, 255);"&gt;params&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;object&lt;/span&gt;[]
args)&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 27:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 28:&lt;/span&gt; Logger.DebugFormat(formatProvider,
format, args);&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 29:&lt;/span&gt; }&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 30:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 31:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;static&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; DebugFormat(Exception
exception, IFormatProvider formatProvider, &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; format, &lt;span style="color: rgb(0, 0, 255);"&gt;params&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;object&lt;/span&gt;[]
args)&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 32:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 33:&lt;/span&gt; Logger.DebugFormat(exception,
formatProvider, format, args);&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 34:&lt;/span&gt; }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
The usage pattern becomes quite simple in that any class that references ABCCompany.Framework
can use the ABCCompany.Framework.Logging.Log class.&amp;nbsp; No external references needs
&lt;/p&gt;
&lt;p&gt;
The reason I chose to bind myself at the framework level to Castle's ILogger interface
and not something like ILog (log4net) was because ILogger is an abstraction over the
ILog interface.&amp;nbsp; Castle also provides some concrete implementations of ILogger,
one of which is for log4net 
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
log4net (requires Castle.Services.Logging.Log4netIntegration.dll) 
&lt;/li&gt;
&lt;li&gt;
NLog (requires Castle.Services.Logging.NLogIntegration.dll) 
&lt;/li&gt;
&lt;li&gt;
ConsoleLogger 
&lt;/li&gt;
&lt;li&gt;
DiagnosticsLogger 
&lt;/li&gt;
&lt;li&gt;
StreamLogger 
&lt;/li&gt;
&lt;li&gt;
WebLogger (TraceContext) 
&lt;/li&gt;
&lt;li&gt;
NullLogger (used as placeholder) 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
As far as testing is concerned, the solution imposes no restrictions on testing.&amp;nbsp;
In my testing assemblies my logging calls are swallowed by the null logger.&amp;nbsp;
If I want to ensure the logger is called in my testing (interaction based tests),
I can mock an instance of ILogger and call Log.SetLogger() and set up expectations
on the mock ILogger.
&lt;/p&gt;
&lt;p&gt;
As I've mulled over this solution now for about a day it feels pretty solid.&amp;nbsp;
As I go through the requirements above they are all satisfied.&amp;nbsp; However I can
only see as far as my current knowledge so I'm hoping that if you see issues with
the above that you'll let me know.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.timbarcz.com/blog/aggbug.ashx?id=42570527-952b-4d9f-a25a-84ef7abad9fb" /&gt;</description>
      <comments>http://www.timbarcz.com/blog/CommentView,guid,42570527-952b-4d9f-a25a-84ef7abad9fb.aspx</comments>
      <category>.NET</category>
      <category>Programming</category>
    </item>
    <item>
      <trackback:ping>http://www.timbarcz.com/blog/Trackback.aspx?guid=6c8e3d51-a59c-4325-92f1-deb8d28c2a88</trackback:ping>
      <pingback:server>http://www.timbarcz.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.timbarcz.com/blog/PermaLink,guid,6c8e3d51-a59c-4325-92f1-deb8d28c2a88.aspx</pingback:target>
      <dc:creator>Tim Barcz</dc:creator>
      <wfw:comment>http://www.timbarcz.com/blog/CommentView,guid,6c8e3d51-a59c-4325-92f1-deb8d28c2a88.aspx</wfw:comment>
      <wfw:commentRss>http://www.timbarcz.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=6c8e3d51-a59c-4325-92f1-deb8d28c2a88</wfw:commentRss>
      <slash:comments>12</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I posted earlier this year with the basic question, <a href="http://www.timbarcz.com/blog/IsVarBetter.aspx">Is
Var Better?</a>  I'm not the only one to question the reintroduction of var. 
Rhys Campbell went as far as to say some <a href="http://rhysc.blogspot.com/2008/07/var-abuse.html">abuse
the new keyword</a>. I will say that my initial aversion to using var has softened
a bit.  However there are at least two issues I have with them.
</p>
        <ol>
          <li>
Implicit conversions</li>
          <li>
Intellisense</li>
        </ol>
        <h3>Implicit Conversions
</h3>
        <p>
In my latest project I've encapsulated all domain knowledge in it's own assembly in
DDD fashion.  We have the notion of a ProductSku, a unique identifier for a product. 
A Product object therefore has a ProductSku property which identifies it.  I
could have implemented the ProductSku property as a string type, but in thinking about
my domain and remembering <a href="http://www.enterpriseintegrationpatterns.com/ramblings/40_marchnan.html">March
is Not a Number</a> ProductSku is now it's own first-class citizen type.
</p>
        <p>
I have the following code to perform implicit conversion from a ProductSku to a string:
</p>
        <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4">
          <div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 1:</span>
              <span style="color: #008000">///
&lt;summary&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 2:</span>
              <span style="color: #008000">///
Performs an implicit conversion from &lt;see cref="JPCycles.Domain.ProductSKU"/&gt;
to &lt;see cref="System.String"/&gt;.</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 3:</span>
              <span style="color: #008000">///
&lt;/summary&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 4:</span>
              <span style="color: #008000">///
&lt;param name="sku"&gt;The sku.&lt;/param&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 5:</span>
              <span style="color: #008000">///
&lt;returns&gt;The result of the conversion.&lt;/returns&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 6:</span>
              <span style="color: #0000ff">public</span>
              <span style="color: #0000ff">static</span>
              <span style="color: #0000ff">implicit</span>
              <span style="color: #0000ff">operator</span>
              <span style="color: #0000ff">string</span>(ProductSKU
sku)</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 7:</span> {</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 8:</span>
              <span style="color: #0000ff">return</span> sku.<span style="color: #0000ff">value</span>;</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 9:</span> }</pre>
          </div>
        </div>
        <p>
In order to test this method I have the following code:
</p>
        <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4">
          <div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 1:</span> [Test]</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 2:</span>
              <span style="color: #0000ff">public</span>
              <span style="color: #0000ff">void</span> Implicit_conversion_of_sku_to_string()</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 3:</span> {</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 4:</span>
              <span style="color: #0000ff">string</span> skuValue
= <span style="color: #006080">"ZZ123456"</span>;</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 5:</span> var
sku = <span style="color: #0000ff">new</span> ProductSKU(skuValue);</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 6:</span>  </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 7:</span> var
converted = sku;</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 8:</span>  </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 9:</span> Assert.That(converted,
Is.EqualTo(skuValue));</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 10:</span> }</pre>
          </div>
        </div>
        <p>
As you can see in line 7, I'm using the var keyword.  The problem with this is
that using var in the scenario keeps me from testing the code that I want to test. 
The goal of the test is to confirm the implicit conversion of a ProductSku to string. 
This happens in line 7.  However when using the var keyword, the compiler interprets
the "converted" variable as a ProductSku object and not a string object,
as I really want.  
</p>
        <p>
See below for confirmation:
</p>
        <p>
          <a href="http://www.timbarcz.com/blog/content/binary/WindowsLiveWriter/MyIssuesWithVar_FE/image_4.png">
            <img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="272" alt="image" src="http://www.timbarcz.com/blog/content/binary/WindowsLiveWriter/MyIssuesWithVar_FE/image_thumb_1.png" width="551" border="0" />
          </a>
        </p>
        <p>
(You might be saying to yourself that the conversion still happens in line 9, when
the ProductSku object is evaluated against a string.  You might be right? 
Or...does the string get implicitly converted to a ProductSku object?  If you
don't know the answer to that question off the top of you head you cannot rely on
line 9 for your conversion.  Also you shouldn't be using your asserts to perform
the work for which you are testing)
</p>
        <p>
If I leave the var keyword in place in line seven, my test will pass and possibly
deceive me into thinking I've properly tested my code.  Only when running a coverage
report do I see that the implicit conversion method is never being called.
</p>
        <p>
The use of var is fine, except that now I have to think about how the compiler will
interpret a statement versus what I want in programming it.  The var keyword
does the best it can, but sometimes that's not good enough.  As another example,
compare the following code:
</p>
        <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4">
          <div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 1:</span> IUser
user1 = <span style="color: #0000ff">new</span> User();</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 2:</span> var
user2 = <span style="color: #0000ff">new</span> User();</pre>
          </div>
        </div>
The two users above have different type signatures, which on some level bothers me
a bit, since you can see that the code is clearly the same. 
<h3>Intellisense
</h3><p>
The use of var makes intellisense less effective.  It's not the compilers fault
though.  Given the point where you use var, the compiler has no idea what you're
going to type on the right-hand side of the expression, so it cannot help.  
</p><p>
Say, for example, I want to define a Dictionary&lt;string,string&gt; called "my
list".  When I use the var keyword, I have to type out enough information
from which intellisense can narrow down what I'm looking for.  I hear a lot from
the proponents of var how great it is because complex declarations, especially with
generics, can be avoided.  I disagree and only need to show you the example below
to prove my point.  In the example below I'm writing the exact same line of code. 
The first example uses var, the second does not, which would you prefer?
</p><p><a href="http://www.timbarcz.com/blog/content/binary/WindowsLiveWriter/MyIssuesWithVar_FE/image_6.png"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="262" alt="image" src="http://www.timbarcz.com/blog/content/binary/WindowsLiveWriter/MyIssuesWithVar_FE/image_thumb_2.png" width="450" border="0" /></a> 
</p><p><a href="http://www.timbarcz.com/blog/content/binary/WindowsLiveWriter/MyIssuesWithVar_FE/image_8.png"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="139" alt="image" src="http://www.timbarcz.com/blog/content/binary/WindowsLiveWriter/MyIssuesWithVar_FE/image_thumb_3.png" width="526" border="0" /></a></p><p>
When using var I had to type everything since the compile cannot help me, only I had
to type on the right hand side of the expression.  So I really have saved nothing.
</p><p><a href="http://www.codinghorror.com">Jeff Atwood</a> posted that <a href="http://www.codinghorror.com/blog/archives/001136.html">by
not using var, you're being redundant</a>.  I would say that by not being redundant,
for which the compiler penalizes you nothing, you're being slower, because you cannot
take advantage of build-in assistance, ie intellisense.
</p><p>
These two annoyances won't stop me from using var in various (read: limited) situations. 
The point of this post is to caution the reader to not be too quick to jump on the
var bandwagon.  In the first example it may cause you headaches in performing
proper testing and in the second, it may slow you down with the loss of intellisense.
</p><img width="0" height="0" src="http://www.timbarcz.com/blog/aggbug.ashx?id=6c8e3d51-a59c-4325-92f1-deb8d28c2a88" /></body>
      <title>My Issues With Var</title>
      <guid isPermaLink="false">http://www.timbarcz.com/blog/PermaLink,guid,6c8e3d51-a59c-4325-92f1-deb8d28c2a88.aspx</guid>
      <link>http://www.timbarcz.com/blog/MyIssuesWithVar.aspx</link>
      <pubDate>Mon, 04 Aug 2008 14:55:55 GMT</pubDate>
      <description>&lt;p&gt;
I posted earlier this year with the basic question, &lt;a href="http://www.timbarcz.com/blog/IsVarBetter.aspx"&gt;Is
Var Better?&lt;/a&gt;&amp;#160; I'm not the only one to question the reintroduction of var.&amp;#160;
Rhys Campbell went as far as to say some &lt;a href="http://rhysc.blogspot.com/2008/07/var-abuse.html"&gt;abuse
the new keyword&lt;/a&gt;. I will say that my initial aversion to using var has softened
a bit.&amp;#160; However there are at least two issues I have with them.
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
Implicit conversions&lt;/li&gt;
&lt;li&gt;
Intellisense&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Implicit Conversions
&lt;/h3&gt;
&lt;p&gt;
In my latest project I've encapsulated all domain knowledge in it's own assembly in
DDD fashion.&amp;#160; We have the notion of a ProductSku, a unique identifier for a product.&amp;#160;
A Product object therefore has a ProductSku property which identifies it.&amp;#160; I
could have implemented the ProductSku property as a string type, but in thinking about
my domain and remembering &lt;a href="http://www.enterpriseintegrationpatterns.com/ramblings/40_marchnan.html"&gt;March
is Not a Number&lt;/a&gt; ProductSku is now it's own first-class citizen type.
&lt;/p&gt;
&lt;p&gt;
I have the following code to perform implicit conversion from a ProductSku to a string:
&lt;/p&gt;
&lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4"&gt;
&lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 1:&lt;/span&gt; &lt;span style="color: #008000"&gt;///
&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 2:&lt;/span&gt; &lt;span style="color: #008000"&gt;///
Performs an implicit conversion from &amp;lt;see cref=&amp;quot;JPCycles.Domain.ProductSKU&amp;quot;/&amp;gt;
to &amp;lt;see cref=&amp;quot;System.String&amp;quot;/&amp;gt;.&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 3:&lt;/span&gt; &lt;span style="color: #008000"&gt;///
&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 4:&lt;/span&gt; &lt;span style="color: #008000"&gt;///
&amp;lt;param name=&amp;quot;sku&amp;quot;&amp;gt;The sku.&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 5:&lt;/span&gt; &lt;span style="color: #008000"&gt;///
&amp;lt;returns&amp;gt;The result of the conversion.&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 6:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;implicit&lt;/span&gt; &lt;span style="color: #0000ff"&gt;operator&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt;(ProductSKU
sku)&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 7:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 8:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; sku.&lt;span style="color: #0000ff"&gt;value&lt;/span&gt;;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 9:&lt;/span&gt; }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
In order to test this method I have the following code:
&lt;/p&gt;
&lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4"&gt;
&lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 1:&lt;/span&gt; [Test]&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 2:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Implicit_conversion_of_sku_to_string()&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 3:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 4:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; skuValue
= &lt;span style="color: #006080"&gt;&amp;quot;ZZ123456&amp;quot;&lt;/span&gt;;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 5:&lt;/span&gt; var
sku = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; ProductSKU(skuValue);&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 6:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 7:&lt;/span&gt; var
converted = sku;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 8:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 9:&lt;/span&gt; Assert.That(converted,
Is.EqualTo(skuValue));&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 10:&lt;/span&gt; }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
As you can see in line 7, I'm using the var keyword.&amp;#160; The problem with this is
that using var in the scenario keeps me from testing the code that I want to test.&amp;#160;
The goal of the test is to confirm the implicit conversion of a ProductSku to string.&amp;#160;
This happens in line 7.&amp;#160; However when using the var keyword, the compiler interprets
the &amp;quot;converted&amp;quot; variable as a ProductSku object and not a string object,
as I really want.&amp;#160; 
&lt;/p&gt;
&lt;p&gt;
See below for confirmation:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.timbarcz.com/blog/content/binary/WindowsLiveWriter/MyIssuesWithVar_FE/image_4.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="272" alt="image" src="http://www.timbarcz.com/blog/content/binary/WindowsLiveWriter/MyIssuesWithVar_FE/image_thumb_1.png" width="551" border="0" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
(You might be saying to yourself that the conversion still happens in line 9, when
the ProductSku object is evaluated against a string.&amp;#160; You might be right?&amp;#160;
Or...does the string get implicitly converted to a ProductSku object?&amp;#160; If you
don't know the answer to that question off the top of you head you cannot rely on
line 9 for your conversion.&amp;#160; Also you shouldn't be using your asserts to perform
the work for which you are testing)
&lt;/p&gt;
&lt;p&gt;
If I leave the var keyword in place in line seven, my test will pass and possibly
deceive me into thinking I've properly tested my code.&amp;#160; Only when running a coverage
report do I see that the implicit conversion method is never being called.
&lt;/p&gt;
&lt;p&gt;
The use of var is fine, except that now I have to think about how the compiler will
interpret a statement versus what I want in programming it.&amp;#160; The var keyword
does the best it can, but sometimes that's not good enough.&amp;#160; As another example,
compare the following code:
&lt;/p&gt;
&lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4"&gt;
&lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 1:&lt;/span&gt; IUser
user1 = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; User();&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 2:&lt;/span&gt; var
user2 = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; User();&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
The two users above have different type signatures, which on some level bothers me
a bit, since you can see that the code is clearly the same. 
&lt;h3&gt;Intellisense
&lt;/h3&gt;
&lt;p&gt;
The use of var makes intellisense less effective.&amp;#160; It's not the compilers fault
though.&amp;#160; Given the point where you use var, the compiler has no idea what you're
going to type on the right-hand side of the expression, so it cannot help.&amp;#160; 
&lt;/p&gt;
&lt;p&gt;
Say, for example, I want to define a Dictionary&amp;lt;string,string&amp;gt; called &amp;quot;my
list&amp;quot;.&amp;#160; When I use the var keyword, I have to type out enough information
from which intellisense can narrow down what I'm looking for.&amp;#160; I hear a lot from
the proponents of var how great it is because complex declarations, especially with
generics, can be avoided.&amp;#160; I disagree and only need to show you the example below
to prove my point.&amp;#160; In the example below I'm writing the exact same line of code.&amp;#160;
The first example uses var, the second does not, which would you prefer?
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.timbarcz.com/blog/content/binary/WindowsLiveWriter/MyIssuesWithVar_FE/image_6.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="262" alt="image" src="http://www.timbarcz.com/blog/content/binary/WindowsLiveWriter/MyIssuesWithVar_FE/image_thumb_2.png" width="450" border="0" /&gt;&lt;/a&gt;&amp;#160;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.timbarcz.com/blog/content/binary/WindowsLiveWriter/MyIssuesWithVar_FE/image_8.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="139" alt="image" src="http://www.timbarcz.com/blog/content/binary/WindowsLiveWriter/MyIssuesWithVar_FE/image_thumb_3.png" width="526" border="0" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
When using var I had to type everything since the compile cannot help me, only I had
to type on the right hand side of the expression.&amp;#160; So I really have saved nothing.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.codinghorror.com"&gt;Jeff Atwood&lt;/a&gt; posted that &lt;a href="http://www.codinghorror.com/blog/archives/001136.html"&gt;by
not using var, you're being redundant&lt;/a&gt;.&amp;#160; I would say that by not being redundant,
for which the compiler penalizes you nothing, you're being slower, because you cannot
take advantage of build-in assistance, ie intellisense.
&lt;/p&gt;
&lt;p&gt;
These two annoyances won't stop me from using var in various (read: limited) situations.&amp;#160;
The point of this post is to caution the reader to not be too quick to jump on the
var bandwagon.&amp;#160; In the first example it may cause you headaches in performing
proper testing and in the second, it may slow you down with the loss of intellisense.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.timbarcz.com/blog/aggbug.ashx?id=6c8e3d51-a59c-4325-92f1-deb8d28c2a88" /&gt;</description>
      <comments>http://www.timbarcz.com/blog/CommentView,guid,6c8e3d51-a59c-4325-92f1-deb8d28c2a88.aspx</comments>
      <category>.NET</category>
      <category>Programming</category>
    </item>
    <item>
      <trackback:ping>http://www.timbarcz.com/blog/Trackback.aspx?guid=35f9b06f-2017-4953-a5ca-dd265353a280</trackback:ping>
      <pingback:server>http://www.timbarcz.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.timbarcz.com/blog/PermaLink,guid,35f9b06f-2017-4953-a5ca-dd265353a280.aspx</pingback:target>
      <dc:creator>Tim Barcz</dc:creator>
      <wfw:comment>http://www.timbarcz.com/blog/CommentView,guid,35f9b06f-2017-4953-a5ca-dd265353a280.aspx</wfw:comment>
      <wfw:commentRss>http://www.timbarcz.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=35f9b06f-2017-4953-a5ca-dd265353a280</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I'm on vacation and am sitting in a coffee shop catching up on some blogs.  <a href="http://devlicio.us/blogs/sergio_pereira/">Sergio
Pereira</a> posted the other day his praises of the <a href="http://devlicio.us/blogs/sergio_pereira/archive/2008/07/20/the-new-crop-of-net-screencasts.aspx">new
crop of .NET screencasts</a>.  His post explicitly calls out <a href="http://unhandled-exceptions.com/blog/">Steve
Bohlen</a> and his <a href="http://www.summerofnhibernate.com/">Summer of NHibernate</a> series. 
I wanted to echo Sergio's sentiments about the .NET screencasts and in particular
Steve's new series.  I have used the quiet evening in the cabin to watch the
excellent videos that <a href="http://unhandled-exceptions.com/blog/">Steve Bohlen</a> has
put out.  The quality of the videos both in production and content are unsurpassed. 
I've used NHibernate before but this is a much better primer than reading a few blog
posts/tutorials here and there when a roadblock is hit.
</p>
        <p>
If you've not seen these videos yet and are looking for a good introduction to NHibernate,
check out the <a href="http://www.summerofnhibernate.com/">Summer of NHibernate series</a>. 
When you do, <a href="http://www.timbarcz.com/blog/2008/07/10/UnappreciatedOpenSource.aspx">make
sure you donate</a> (<a href="http://www.timbarcz.com/blog/2008/07/10/UnappreciatedOpenSource.aspx">at
least a dollar</a>).
</p>
        <img width="0" height="0" src="http://www.timbarcz.com/blog/aggbug.ashx?id=35f9b06f-2017-4953-a5ca-dd265353a280" />
      </body>
      <title>Summer of NHibernate Video Series</title>
      <guid isPermaLink="false">http://www.timbarcz.com/blog/PermaLink,guid,35f9b06f-2017-4953-a5ca-dd265353a280.aspx</guid>
      <link>http://www.timbarcz.com/blog/SummerOfNHibernateVideoSeries.aspx</link>
      <pubDate>Wed, 23 Jul 2008 22:04:30 GMT</pubDate>
      <description>&lt;p&gt;
I'm on vacation and am sitting in a coffee shop catching up on some blogs.&amp;#160; &lt;a href="http://devlicio.us/blogs/sergio_pereira/"&gt;Sergio
Pereira&lt;/a&gt; posted the other day his praises of the &lt;a href="http://devlicio.us/blogs/sergio_pereira/archive/2008/07/20/the-new-crop-of-net-screencasts.aspx"&gt;new
crop of .NET screencasts&lt;/a&gt;.&amp;#160; His post explicitly calls out &lt;a href="http://unhandled-exceptions.com/blog/"&gt;Steve
Bohlen&lt;/a&gt; and his &lt;a href="http://www.summerofnhibernate.com/"&gt;Summer of NHibernate&lt;/a&gt; series.&amp;#160;
I wanted to echo Sergio's sentiments about the .NET screencasts and in particular
Steve's new series.&amp;#160; I have used the quiet evening in the cabin to watch the
excellent videos that &lt;a href="http://unhandled-exceptions.com/blog/"&gt;Steve Bohlen&lt;/a&gt; has
put out.&amp;#160; The quality of the videos both in production and content are unsurpassed.&amp;#160;
I've used NHibernate before but this is a much better primer than reading a few blog
posts/tutorials here and there when a roadblock is hit.
&lt;/p&gt;
&lt;p&gt;
If you've not seen these videos yet and are looking for a good introduction to NHibernate,
check out the &lt;a href="http://www.summerofnhibernate.com/"&gt;Summer of NHibernate series&lt;/a&gt;.&amp;#160;
When you do, &lt;a href="http://www.timbarcz.com/blog/2008/07/10/UnappreciatedOpenSource.aspx"&gt;make
sure you donate&lt;/a&gt; (&lt;a href="http://www.timbarcz.com/blog/2008/07/10/UnappreciatedOpenSource.aspx"&gt;at
least a dollar&lt;/a&gt;).
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.timbarcz.com/blog/aggbug.ashx?id=35f9b06f-2017-4953-a5ca-dd265353a280" /&gt;</description>
      <comments>http://www.timbarcz.com/blog/CommentView,guid,35f9b06f-2017-4953-a5ca-dd265353a280.aspx</comments>
      <category>.NET</category>
      <category>Open Source Software</category>
      <category>ORM</category>
    </item>
    <item>
      <trackback:ping>http://www.timbarcz.com/blog/Trackback.aspx?guid=7ba78de9-2bb3-408a-876e-e19f08dda65c</trackback:ping>
      <pingback:server>http://www.timbarcz.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.timbarcz.com/blog/PermaLink,guid,7ba78de9-2bb3-408a-876e-e19f08dda65c.aspx</pingback:target>
      <dc:creator>Tim Barcz</dc:creator>
      <wfw:comment>http://www.timbarcz.com/blog/CommentView,guid,7ba78de9-2bb3-408a-876e-e19f08dda65c.aspx</wfw:comment>
      <wfw:commentRss>http://www.timbarcz.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=7ba78de9-2bb3-408a-876e-e19f08dda65c</wfw:commentRss>
      <slash:comments>4</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
This is the third in an ongoing series of articles about my team's transition to the <a href="http://www.timbarcz.com/blog/UsingMVCFrameworkInTheWildOurTransitionToTheASPNETMVCFramework.aspx">Asp.NET
MVC Framework</a>.  In my <a href="http://www.timbarcz.com/blog/MVCFrameworkLearningToWalk.aspx">last
post</a> I blogged a bit about how I haven't quite got comfortable enough with the
new MVC framework to feel über productive.  What augments the feeling is
the difficulty of finding quality information.  The data is few and far between
and only sometimes relevant.
</p>
        <p>
I was struggling yesterday to find information on the ComponentController class. 
Things I was finding were from the Preview 2 release but finding something on the
Preview 3 release was a bit more challenging.  Things are rapidly changing in
the framework and the MVC team is not afraid to refactor, rename , or even remove
a class.  For example, with the release last night, ComponentController is no
longer a worry of mine because it's now gone, removed completely from the framework.  
</p>
        <p>
The MVC framework has been around for under a year (Nov 2007 I believe).  It
is now in it's fourth iteration (Preview four, released last night).  While a
number of people have downloaded and are using the framework the amount of data/tutorials/blogs/articles
pales in comparison to the same information about web forms.  This makes finding
the info you need much much tougher.  It's exciting though and must say I enjoy
the challenge.  The change in releases doesn't bother me.  It's a bit of
a nuisance but I signed up for this trip.  Also the changes are for the better. 
The ComponentController class that was replaced yesterday was not easily testable. 
The MVC team removed it in favor of the Controller class, which is testable! 
Fundamentally it boils down to the fact that I trust the guys on the MVC team and
where they're going with the framework.
</p>
        <p>
That trust doesn't help me day to day in moving my project forward though.  In
order to find the data I need I've had to be both resourceful and thorough in my reading. 
The trick I've found is following a few bloggers closely and reading all of their
posts regarding MVC and all comments made to the posts (that's where I find the real
gems, in the comments).
</p>
        <p>
Here is a list of bloggers I'm following, obviously some are well-known, others are
not.  <strong>If you follow some bloggers who post about the MVC framework that
aren't on my list please share!!</strong> My list:
</p>
        <ul>
          <li>
            <a href="http://weblogs.asp.net/scottgu/">Scott Guthrie</a>
          </li>
          <li>
            <a href="http://www.haacked.com">Phil Haack</a>
          </li>
          <li>
            <a href="http://www.hansleman.com">Scott Hanselman</a>
          </li>
          <li>
            <a href="http://blog.wekeroad.com/">Rob Conery</a>
          </li>
          <li>
            <a href="http://mhinze.com/">Matt Hinze</a>
          </li>
          <li>
            <a href="http://www.flux88.com">Ben Scheirman</a>
          </li>
          <li>
            <a href="http://blog.eworldui.net/">Matt Hawley</a>
          </li>
        </ul>
        <p>
Updated to add new blogs (7/23/2008) ... thanks Ben
</p>
        <ul>
          <li>
            <a href="http://blog.codeville.net/">Steve Sanderson</a>
          </li>
          <li>
            <a href="http://weblogs.asp.net/stephenwalther/">Stephen Walther</a>
          </li>
        </ul>
        <p>
Yesterday I reported that I was <a href="http://www.timbarcz.com/blog/MVCFrameworkLearningToWalk.aspx">learning
to walk</a> and while I can't quite say I'm walking yet,  I'm feeling a bit more
comfortable.  My velocity increased ever so slightly today and I'm encouraged
by that and excited for tomorrow!  And to be quite honest that's a perfectly
find place to be.
</p>
        <img width="0" height="0" src="http://www.timbarcz.com/blog/aggbug.ashx?id=7ba78de9-2bb3-408a-876e-e19f08dda65c" />
      </body>
      <title>MVC Framework - A Needle In a Haystack</title>
      <guid isPermaLink="false">http://www.timbarcz.com/blog/PermaLink,guid,7ba78de9-2bb3-408a-876e-e19f08dda65c.aspx</guid>
      <link>http://www.timbarcz.com/blog/MVCFrameworkANeedleInAHaystack.aspx</link>
      <pubDate>Fri, 18 Jul 2008 01:50:11 GMT</pubDate>
      <description>&lt;p&gt;
This is the third in an ongoing series of articles about my team's transition to the &lt;a href="http://www.timbarcz.com/blog/UsingMVCFrameworkInTheWildOurTransitionToTheASPNETMVCFramework.aspx"&gt;Asp.NET
MVC Framework&lt;/a&gt;.&amp;#160; In my &lt;a href="http://www.timbarcz.com/blog/MVCFrameworkLearningToWalk.aspx"&gt;last
post&lt;/a&gt; I blogged a bit about how I haven't quite got comfortable enough with the
new MVC framework to feel &amp;#252;ber productive.&amp;#160; What augments the feeling is
the difficulty of finding quality information.&amp;#160; The data is few and far between
and only sometimes relevant.
&lt;/p&gt;
&lt;p&gt;
I was struggling yesterday to find information on the ComponentController class.&amp;#160;
Things I was finding were from the Preview 2 release but finding something on the
Preview 3 release was a bit more challenging.&amp;#160; Things are rapidly changing in
the framework and the MVC team is not afraid to refactor, rename , or even remove
a class.&amp;#160; For example, with the release last night, ComponentController is no
longer a worry of mine because it's now gone, removed completely from the framework.&amp;#160; 
&lt;/p&gt;
&lt;p&gt;
The MVC framework has been around for under a year (Nov 2007 I believe).&amp;#160; It
is now in it's fourth iteration (Preview four, released last night).&amp;#160; While a
number of people have downloaded and are using the framework the amount of data/tutorials/blogs/articles
pales in comparison to the same information about web forms.&amp;#160; This makes finding
the info you need much much tougher.&amp;#160; It's exciting though and must say I enjoy
the challenge.&amp;#160; The change in releases doesn't bother me.&amp;#160; It's a bit of
a nuisance but I signed up for this trip.&amp;#160; Also the changes are for the better.&amp;#160;
The ComponentController class that was replaced yesterday was not easily testable.&amp;#160;
The MVC team removed it in favor of the Controller class, which is testable!&amp;#160;
Fundamentally it boils down to the fact that I trust the guys on the MVC team and
where they're going with the framework.
&lt;/p&gt;
&lt;p&gt;
That trust doesn't help me day to day in moving my project forward though.&amp;#160; In
order to find the data I need I've had to be both resourceful and thorough in my reading.&amp;#160;
The trick I've found is following a few bloggers closely and reading all of their
posts regarding MVC and all comments made to the posts (that's where I find the real
gems, in the comments).
&lt;/p&gt;
&lt;p&gt;
Here is a list of bloggers I'm following, obviously some are well-known, others are
not.&amp;#160; &lt;strong&gt;If you follow some bloggers who post about the MVC framework that
aren't on my list please share!!&lt;/strong&gt; My list:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://weblogs.asp.net/scottgu/"&gt;Scott Guthrie&lt;/a&gt; 
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://www.haacked.com"&gt;Phil Haack&lt;/a&gt; 
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://www.hansleman.com"&gt;Scott Hanselman&lt;/a&gt; 
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://blog.wekeroad.com/"&gt;Rob Conery&lt;/a&gt; 
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://mhinze.com/"&gt;Matt Hinze&lt;/a&gt; 
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://www.flux88.com"&gt;Ben Scheirman&lt;/a&gt; 
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://blog.eworldui.net/"&gt;Matt Hawley&lt;/a&gt; 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Updated to add new blogs (7/23/2008) ... thanks Ben
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://blog.codeville.net/"&gt;Steve Sanderson&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://weblogs.asp.net/stephenwalther/"&gt;Stephen Walther&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Yesterday I reported that I was &lt;a href="http://www.timbarcz.com/blog/MVCFrameworkLearningToWalk.aspx"&gt;learning
to walk&lt;/a&gt; and while I can't quite say I'm walking yet,&amp;#160; I'm feeling a bit more
comfortable.&amp;#160; My velocity increased ever so slightly today and I'm encouraged
by that and excited for tomorrow!&amp;#160; And to be quite honest that's a perfectly
find place to be.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.timbarcz.com/blog/aggbug.ashx?id=7ba78de9-2bb3-408a-876e-e19f08dda65c" /&gt;</description>
      <comments>http://www.timbarcz.com/blog/CommentView,guid,7ba78de9-2bb3-408a-876e-e19f08dda65c.aspx</comments>
      <category>.NET</category>
      <category>MVC</category>
    </item>
    <item>
      <trackback:ping>http://www.timbarcz.com/blog/Trackback.aspx?guid=e22cc57d-a5d3-4265-87b8-554d9796618a</trackback:ping>
      <pingback:server>http://www.timbarcz.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.timbarcz.com/blog/PermaLink,guid,e22cc57d-a5d3-4265-87b8-554d9796618a.aspx</pingback:target>
      <dc:creator>Tim Barcz</dc:creator>
      <wfw:comment>http://www.timbarcz.com/blog/CommentView,guid,e22cc57d-a5d3-4265-87b8-554d9796618a.aspx</wfw:comment>
      <wfw:commentRss>http://www.timbarcz.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=e22cc57d-a5d3-4265-87b8-554d9796618a</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <img src="http://farm2.static.flickr.com/1382/959864706_894bdfaa56.jpg?v=0" align="right" />A
few days ago I posted that our team was making the <a href="http://www.timbarcz.com/blog/UsingMVCFrameworkInTheWildOurTransitionToTheASPNETMVCFramework.aspx">transition
from webforms to MVC</a>.  Since then a few days have gone by and I wanted to
post my some struggles and successes (however few) in recent days. 
<p>
First, it's been tough wrapping my head around the shift from web forms to MVC. 
I would caution anyone making a similar shift or considering it, that despite the
recognized short comings of web forms and the postback model that one should approach
the change expecting a bit of a rough going in the beginning.  Never underestimate
what years of articles, blogs, and webcasts about web forms and working in web forms
will do to your perspective.  OnClick...gone.  PreRender...gone.
</p><p>
Does the experience thus far cause me to regret the choice to go MVC route? 
Absolutely not.  It was 100% the correct decision.  Despite the difficulties
of making the shift, there are points where something clicks and it feels better and
more natural.  I'm waiting for that shift and those clicks to be more permanent. 
The best analogy I can use to explain it is likening the experience to my one year
old son who is learning to walk. To him crawling feels right.  When crawling,
he's quicker, self-assured, and can generally get where he wants to go.  When
he attempts to walk however, he falls down, he struggles to keep his balance, and
generally getting anywhere takes longer.  It's temporary though, we know it and
that's why we encourage him to walk and push through the awkwardness. In a few years
Lincoln will realize (if not verbally but by the way he chooses to move) how much
more natural walking is than crawling, a fact that I'm reminded of every time I get
down on all fours with Lincoln.
</p><p>
So what am I doing to push through?  First I'm trying to keep in the project. 
With smaller tasks and projects always requiring attention, I'm trying to stay in
the project as much as possible.  Secondly, I'm thinking about how I think (<a href="http://en.wikipedia.org/wiki/Metacognition">Metacognition</a>). 
Thinking about MVC, testability, loose coupling and other such principles only aid
in the transition.  I'm hoping the next two days this week give way to breakthroughs. 
Near the end of the day I had some small wins and started to gain some velocity which
leaves me optimistic for tomorrow.
</p><img width="0" height="0" src="http://www.timbarcz.com/blog/aggbug.ashx?id=e22cc57d-a5d3-4265-87b8-554d9796618a" /></body>
      <title>MVC Framework - Learning to Walk</title>
      <guid isPermaLink="false">http://www.timbarcz.com/blog/PermaLink,guid,e22cc57d-a5d3-4265-87b8-554d9796618a.aspx</guid>
      <link>http://www.timbarcz.com/blog/MVCFrameworkLearningToWalk.aspx</link>
      <pubDate>Thu, 17 Jul 2008 01:27:19 GMT</pubDate>
      <description>&lt;img src="http://farm2.static.flickr.com/1382/959864706_894bdfaa56.jpg?v=0" align="right" /&gt;A
few days ago I posted that our team was making the &lt;a href="http://www.timbarcz.com/blog/UsingMVCFrameworkInTheWildOurTransitionToTheASPNETMVCFramework.aspx"&gt;transition
from webforms to MVC&lt;/a&gt;.&amp;#160; Since then a few days have gone by and I wanted to
post my some struggles and successes (however few) in recent days. 
&lt;p&gt;
First, it's been tough wrapping my head around the shift from web forms to MVC.&amp;#160;
I would caution anyone making a similar shift or considering it, that despite the
recognized short comings of web forms and the postback model that one should approach
the change expecting a bit of a rough going in the beginning.&amp;#160; Never underestimate
what years of articles, blogs, and webcasts about web forms and working in web forms
will do to your perspective.&amp;#160; OnClick...gone.&amp;#160; PreRender...gone.
&lt;/p&gt;
&lt;p&gt;
Does the experience thus far cause me to regret the choice to go MVC route?&amp;#160;
Absolutely not.&amp;#160; It was 100% the correct decision.&amp;#160; Despite the difficulties
of making the shift, there are points where something clicks and it feels better and
more natural.&amp;#160; I'm waiting for that shift and those clicks to be more permanent.&amp;#160;
The best analogy I can use to explain it is likening the experience to my one year
old son who is learning to walk. To him crawling feels right.&amp;#160; When crawling,
he's quicker, self-assured, and can generally get where he wants to go.&amp;#160; When
he attempts to walk however, he falls down, he struggles to keep his balance, and
generally getting anywhere takes longer.&amp;#160; It's temporary though, we know it and
that's why we encourage him to walk and push through the awkwardness. In a few years
Lincoln will realize (if not verbally but by the way he chooses to move) how much
more natural walking is than crawling, a fact that I'm reminded of every time I get
down on all fours with Lincoln.
&lt;/p&gt;
&lt;p&gt;
So what am I doing to push through?&amp;#160; First I'm trying to keep in the project.&amp;#160;
With smaller tasks and projects always requiring attention, I'm trying to stay in
the project as much as possible.&amp;#160; Secondly, I'm thinking about how I think (&lt;a href="http://en.wikipedia.org/wiki/Metacognition"&gt;Metacognition&lt;/a&gt;).&amp;#160;
Thinking about MVC, testability, loose coupling and other such principles only aid
in the transition.&amp;#160; I'm hoping the next two days this week give way to breakthroughs.&amp;#160;
Near the end of the day I had some small wins and started to gain some velocity which
leaves me optimistic for tomorrow.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.timbarcz.com/blog/aggbug.ashx?id=e22cc57d-a5d3-4265-87b8-554d9796618a" /&gt;</description>
      <comments>http://www.timbarcz.com/blog/CommentView,guid,e22cc57d-a5d3-4265-87b8-554d9796618a.aspx</comments>
      <category>.NET</category>
      <category>MVC</category>
    </item>
    <item>
      <trackback:ping>http://www.timbarcz.com/blog/Trackback.aspx?guid=96028e7e-ac48-4277-ba74-4d2602ae7989</trackback:ping>
      <pingback:server>http://www.timbarcz.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.timbarcz.com/blog/PermaLink,guid,96028e7e-ac48-4277-ba74-4d2602ae7989.aspx</pingback:target>
      <dc:creator>Tim Barcz</dc:creator>
      <wfw:comment>http://www.timbarcz.com/blog/CommentView,guid,96028e7e-ac48-4277-ba74-4d2602ae7989.aspx</wfw:comment>
      <wfw:commentRss>http://www.timbarcz.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=96028e7e-ac48-4277-ba74-4d2602ae7989</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
We recently decided that with the effort we're putting into <a href="http://www.jpcycles.com">our
website</a> and some changes that we're making that now would be as good of time as
ever to make the switch to the new <a href="http://www.asp.net/mvc">Asp.net MVC Framework</a>. 
We're no Google, but we're currently receiving around 18,000 unique visitors a day
and 300,000 page views and hope to grow that number as we make our site easier to
use for our customers.  I hope to rely heavily on <a href="http://www.haacked.com">Phil</a>, <a href="http://blog.wekeroad.com">Rob</a>,
and <a href="http://www.hanselman.com">Scott</a> for assistance if needed.  
</p>
        <p>
The MVC design appeals to us because the large amount of business logic that has crept
it's way into the codebehind.  Despite the best intentions, the current site,
which is programmed in asp.net 1.1, has had too much logic to creep into presentational
areas while running with webforms.  The biggest drawback to this is reduced testability. 
Testability should be important in any project but for us it is paramount. We have
business rules that if not adhered to amount to real-world fines:
</p>
        <blockquote>
          <p>
A few years ago a customer bought some lubricant that is sold in an aerosol can. 
Since 9/11 aerosol cans cannot be shipped as cargo on airplanes.  Somehow this
order made it though the checks we have for this type of thing in the warehouse and
made it onto the UPS truck.  At the UPS facility, a UPS employee heard something
emanating from a box that sounded like an aerosol can.  At that point he is required
by law to check the contents.  When he opened the box he found the aerosol cans. 
Despite knowing us and our reputation, he was required to call the FAA and say something
to the effect of, "I found some aerosol cans in a package that was scheduled
to be flown."  It didn't matter that this was an accident or "just
a few cans", we were still fined.  We were warned that if this were to happen
again that we would face a fine somewhere in the low six figures. The FAA doesn't
mess around.
</p>
        </blockquote>
        <p>
As we go forward I plan to document on this blog the highs and lows of our transition. 
I'll post questions and problems we're having that I hope you can help with as well
as tips and tricks our team has found helpful.  Stay tuned as we make the transition.
</p>
        <img width="0" height="0" src="http://www.timbarcz.com/blog/aggbug.ashx?id=96028e7e-ac48-4277-ba74-4d2602ae7989" />
      </body>
      <title>Using MVC Framework In the Wild, Our Transition to the ASP.NET MVC Framework</title>
      <guid isPermaLink="false">http://www.timbarcz.com/blog/PermaLink,guid,96028e7e-ac48-4277-ba74-4d2602ae7989.aspx</guid>
      <link>http://www.timbarcz.com/blog/UsingMVCFrameworkInTheWildOurTransitionToTheASPNETMVCFramework.aspx</link>
      <pubDate>Mon, 14 Jul 2008 15:51:29 GMT</pubDate>
      <description>&lt;p&gt;
We recently decided that with the effort we're putting into &lt;a href="http://www.jpcycles.com"&gt;our
website&lt;/a&gt; and some changes that we're making that now would be as good of time as
ever to make the switch to the new &lt;a href="http://www.asp.net/mvc"&gt;Asp.net MVC Framework&lt;/a&gt;.&amp;#160;
We're no Google, but we're currently receiving around 18,000 unique visitors a day
and 300,000 page views and hope to grow that number as we make our site easier to
use for our customers.&amp;#160; I hope to rely heavily on &lt;a href="http://www.haacked.com"&gt;Phil&lt;/a&gt;, &lt;a href="http://blog.wekeroad.com"&gt;Rob&lt;/a&gt;,
and &lt;a href="http://www.hanselman.com"&gt;Scott&lt;/a&gt; for assistance if needed.&amp;#160; 
&lt;/p&gt;
&lt;p&gt;
The MVC design appeals to us because the large amount of business logic that has crept
it's way into the codebehind.&amp;#160; Despite the best intentions, the current site,
which is programmed in asp.net 1.1, has had too much logic to creep into presentational
areas while running with webforms.&amp;#160; The biggest drawback to this is reduced testability.&amp;#160;
Testability should be important in any project but for us it is paramount. We have
business rules that if not adhered to amount to real-world fines:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
A few years ago a customer bought some lubricant that is sold in an aerosol can.&amp;#160;
Since 9/11 aerosol cans cannot be shipped as cargo on airplanes.&amp;#160; Somehow this
order made it though the checks we have for this type of thing in the warehouse and
made it onto the UPS truck.&amp;#160; At the UPS facility, a UPS employee heard something
emanating from a box that sounded like an aerosol can.&amp;#160; At that point he is required
by law to check the contents.&amp;#160; When he opened the box he found the aerosol cans.&amp;#160;
Despite knowing us and our reputation, he was required to call the FAA and say something
to the effect of, &amp;quot;I found some aerosol cans in a package that was scheduled
to be flown.&amp;quot;&amp;#160; It didn't matter that this was an accident or &amp;quot;just
a few cans&amp;quot;, we were still fined.&amp;#160; We were warned that if this were to happen
again that we would face a fine somewhere in the low six figures. The FAA doesn't
mess around.
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
As we go forward I plan to document on this blog the highs and lows of our transition.&amp;#160;
I'll post questions and problems we're having that I hope you can help with as well
as tips and tricks our team has found helpful.&amp;#160; Stay tuned as we make the transition.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.timbarcz.com/blog/aggbug.ashx?id=96028e7e-ac48-4277-ba74-4d2602ae7989" /&gt;</description>
      <comments>http://www.timbarcz.com/blog/CommentView,guid,96028e7e-ac48-4277-ba74-4d2602ae7989.aspx</comments>
      <category>.NET</category>
      <category>MVC</category>
      <category>Software</category>
    </item>
    <item>
      <trackback:ping>http://www.timbarcz.com/blog/Trackback.aspx?guid=4fe51b35-8314-4092-a496-c6c226037868</trackback:ping>
      <pingback:server>http://www.timbarcz.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.timbarcz.com/blog/PermaLink,guid,4fe51b35-8314-4092-a496-c6c226037868.aspx</pingback:target>
      <dc:creator>Tim Barcz</dc:creator>
      <wfw:comment>http://www.timbarcz.com/blog/CommentView,guid,4fe51b35-8314-4092-a496-c6c226037868.aspx</wfw:comment>
      <wfw:commentRss>http://www.timbarcz.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=4fe51b35-8314-4092-a496-c6c226037868</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
A coworker ran across the following and shared with me. 
</p>
        <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4">
          <div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 1:</span>
              <span style="color: #0000ff">Dim</span> strpage</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 2:</span> strpage
= pageNumber.ToString()</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 3:</span>
              <span style="color: #0000ff">If</span> Len(strpage)
= 1 <span style="color: #0000ff">Then</span></pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 4:</span> strpage
= <span style="color: #006080">"000"</span> &amp; strpage</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 5:</span>
              <span style="color: #0000ff">ElseIf</span> Len(strpage)
= 2 <span style="color: #0000ff">Then</span></pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 6:</span> strpage
= <span style="color: #006080">"00"</span> &amp; strpage</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 7:</span>
              <span style="color: #0000ff">ElseIf</span> Len(strpage)
= 3 <span style="color: #0000ff">Then</span></pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 8:</span> strpage
= <span style="color: #006080">"0"</span> &amp; strpage</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 9:</span>
              <span style="color: #0000ff">End</span>
              <span style="color: #0000ff">If</span>
            </pre>
          </div>
        </div>
        <p>
The programmer is trying to ensure that the page number, when printed out, is always
four characters long.  This is not the best way to write this code.  I thought
I'd keep this post to myself but unfortunately this isn't the first time I've seen
code like this, it is quite common.
</p>
        <p>
The better way to write the above is:
</p>
        <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4">
          <div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 1:</span>
              <span style="color: #0000ff">Dim</span> strpage</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 2:</span> strpage
= pagenumber.ToString(<span style="color: #006080">"0000"</span>)</pre>
          </div>
        </div>
        <p>
It's shorter, more concise, and easier to read.  Further the second example is
more extensible.  If the requirements change to say the page number should be
five characters, the first example must recompile.  The second example must be
recompiled as well in it's current state, however the string "0000" could
be moved to a configuration file somewhere and then wouldn't need to be.
</p>
        <img width="0" height="0" src="http://www.timbarcz.com/blog/aggbug.ashx?id=4fe51b35-8314-4092-a496-c6c226037868" />
      </body>
      <title>Formatting Output with ToString()</title>
      <guid isPermaLink="false">http://www.timbarcz.com/blog/PermaLink,guid,4fe51b35-8314-4092-a496-c6c226037868.aspx</guid>
      <link>http://www.timbarcz.com/blog/FormattingOutputWithToString.aspx</link>
      <pubDate>Sun, 13 Jul 2008 01:25:51 GMT</pubDate>
      <description>&lt;p&gt;
A coworker ran across the following and shared with me. 
&lt;/p&gt;
&lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4"&gt;
&lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; strpage&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 2:&lt;/span&gt; strpage
= pageNumber.ToString()&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 3:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; Len(strpage)
= 1 &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 4:&lt;/span&gt; strpage
= &lt;span style="color: #006080"&gt;&amp;quot;000&amp;quot;&lt;/span&gt; &amp;amp; strpage&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 5:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;ElseIf&lt;/span&gt; Len(strpage)
= 2 &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 6:&lt;/span&gt; strpage
= &lt;span style="color: #006080"&gt;&amp;quot;00&amp;quot;&lt;/span&gt; &amp;amp; strpage&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 7:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;ElseIf&lt;/span&gt; Len(strpage)
= 3 &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 8:&lt;/span&gt; strpage
= &lt;span style="color: #006080"&gt;&amp;quot;0&amp;quot;&lt;/span&gt; &amp;amp; strpage&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 9:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; &lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
The programmer is trying to ensure that the page number, when printed out, is always
four characters long.&amp;#160; This is not the best way to write this code.&amp;#160; I thought
I'd keep this post to myself but unfortunately this isn't the first time I've seen
code like this, it is quite common.
&lt;/p&gt;
&lt;p&gt;
The better way to write the above is:
&lt;/p&gt;
&lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4"&gt;
&lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; strpage&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 2:&lt;/span&gt; strpage
= pagenumber.ToString(&lt;span style="color: #006080"&gt;&amp;quot;0000&amp;quot;&lt;/span&gt;)&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
It's shorter, more concise, and easier to read.&amp;#160; Further the second example is
more extensible.&amp;#160; If the requirements change to say the page number should be
five characters, the first example must recompile.&amp;#160; The second example must be
recompiled as well in it's current state, however the string &amp;quot;0000&amp;quot; could
be moved to a configuration file somewhere and then wouldn't need to be.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.timbarcz.com/blog/aggbug.ashx?id=4fe51b35-8314-4092-a496-c6c226037868" /&gt;</description>
      <comments>http://www.timbarcz.com/blog/CommentView,guid,4fe51b35-8314-4092-a496-c6c226037868.aspx</comments>
      <category>.NET</category>
      <category>Programming</category>
    </item>
    <item>
      <trackback:ping>http://www.timbarcz.com/blog/Trackback.aspx?guid=1136e7c9-b88d-4f52-a572-e2ec389dd24e</trackback:ping>
      <pingback:server>http://www.timbarcz.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.timbarcz.com/blog/PermaLink,guid,1136e7c9-b88d-4f52-a572-e2ec389dd24e.aspx</pingback:target>
      <dc:creator>Tim Barcz</dc:creator>
      <wfw:comment>http://www.timbarcz.com/blog/CommentView,guid,1136e7c9-b88d-4f52-a572-e2ec389dd24e.aspx</wfw:comment>
      <wfw:commentRss>http://www.timbarcz.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=1136e7c9-b88d-4f52-a572-e2ec389dd24e</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Compare the following two error messages and think about which you would find more
helpful.  Then, the next time you are throwing exceptions with messages remember
this post.
</p>
        <h3>Error Message from Castle's Windsor IoC libraries:
</h3>
        <blockquote>
          <h4>
            <i>Can't create component 'ProductService' as it has dependencies to be satisfied. </i>
          </h4>
          <h4>
            <i>ProductService is waiting for the following dependencies:</i>
          </h4>
          <h4>
            <i>Services: </i>
            <i>
              <br />
- ABCCompany.Framework.Services.IInventoryService which was registered but is also
waiting for dependencies. </i>
          </h4>
          <h4>
            <i>ControllerInventory is waiting for the following dependencies: </i>
          </h4>
          <h4>
            <i>Services: 
<br />
- ABCCompany.Controller.IInventoryRequestInterpreter which was not registered. 
<br /></i>
            <p>
            </p>
            <b>Description: </b>An unhandled exception occurred during the execution of the current
web request. Please review the stack trace for more information about the error and
where it originated in the code.
</h4>
          <p>
            <b>Exception Details: </b>Castle.MicroKernel.Handlers.HandlerException: Can't create
component 'ProductService' as it has dependencies to be satisfied. 
</p>
          <p>
ProductService is waiting for the following dependencies: 
</p>
          <p>
Services: 
<br />
- ABCCompany.Framework.Services.IInventoryService which was registered but is also
waiting for dependencies. 
</p>
          <p>
ControllerInventory is waiting for the following dependencies: 
</p>
          <p>
Services: 
<br />
- ABCCompany.Controller.IInventoryRequestInterpreter which was not registered. 
</p>
        </blockquote>
        <h3>
        </h3>
        <h3>Error Message from .NET framework:
</h3>
        <blockquote>
          <h4>
            <i>Object reference not set to an instance of an object.</i>
          </h4>
          <b>Description: </b>An unhandled exception occurred during the execution of the current
web request. Please review the stack trace for more information about the error and
where it originated in the code. 
<br /><b>Exception Details: </b>System.NullReferenceException: Object reference not set
to an instance of an object.</blockquote>
        <img width="0" height="0" src="http://www.timbarcz.com/blog/aggbug.ashx?id=1136e7c9-b88d-4f52-a572-e2ec389dd24e" />
      </body>
      <title>Assistive Exception Messages</title>
      <guid isPermaLink="false">http://www.timbarcz.com/blog/PermaLink,guid,1136e7c9-b88d-4f52-a572-e2ec389dd24e.aspx</guid>
      <link>http://www.timbarcz.com/blog/AssistiveExceptionMessages.aspx</link>
      <pubDate>Tue, 17 Jun 2008 20:05:47 GMT</pubDate>
      <description>&lt;p&gt;
Compare the following two error messages and think about which you would find more
helpful.&amp;nbsp; Then, the next time you are throwing exceptions with messages remember
this post.
&lt;/p&gt;
&lt;h3&gt;Error Message from Castle's Windsor IoC libraries:
&lt;/h3&gt;
&lt;blockquote&gt; 
&lt;h4&gt;&lt;i&gt;Can't create component 'ProductService' as it has dependencies to be satisfied. &lt;/i&gt;
&lt;/h4&gt;
&lt;h4&gt;&lt;i&gt;ProductService is waiting for the following dependencies:&lt;/i&gt;
&lt;/h4&gt;
&lt;h4&gt;&lt;i&gt;Services: &lt;/i&gt;&lt;i&gt; 
&lt;br&gt;
- ABCCompany.Framework.Services.IInventoryService which was registered but is also
waiting for dependencies. &lt;/i&gt;
&lt;/h4&gt;
&lt;h4&gt;&lt;i&gt;ControllerInventory is waiting for the following dependencies: &lt;/i&gt;
&lt;/h4&gt;
&lt;h4&gt;&lt;i&gt;Services: 
&lt;br&gt;
- ABCCompany.Controller.IInventoryRequestInterpreter which was not registered. 
&lt;br&gt;
&lt;/i&gt; 
&lt;p&gt;
&lt;/p&gt;
&lt;b&gt;Description: &lt;/b&gt;An unhandled exception occurred during the execution of the current
web request. Please review the stack trace for more information about the error and
where it originated in the code.
&lt;/h4&gt;
&lt;p&gt;
&lt;b&gt;Exception Details: &lt;/b&gt;Castle.MicroKernel.Handlers.HandlerException: Can't create
component 'ProductService' as it has dependencies to be satisfied. 
&lt;/p&gt;
&lt;p&gt;
ProductService is waiting for the following dependencies: 
&lt;/p&gt;
&lt;p&gt;
Services: 
&lt;br&gt;
- ABCCompany.Framework.Services.IInventoryService which was registered but is also
waiting for dependencies. 
&lt;/p&gt;
&lt;p&gt;
ControllerInventory is waiting for the following dependencies: 
&lt;/p&gt;
&lt;p&gt;
Services: 
&lt;br&gt;
- ABCCompany.Controller.IInventoryRequestInterpreter which was not registered. 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;h3&gt;
&lt;/h3&gt;
&lt;h3&gt;Error Message from .NET framework:
&lt;/h3&gt;
&lt;blockquote&gt; 
&lt;h4&gt;&lt;i&gt;Object reference not set to an instance of an object.&lt;/i&gt;
&lt;/h4&gt;
&lt;b&gt;Description: &lt;/b&gt;An unhandled exception occurred during the execution of the current
web request. Please review the stack trace for more information about the error and
where it originated in the code. 
&lt;br&gt;
&lt;b&gt;Exception Details: &lt;/b&gt;System.NullReferenceException: Object reference not set
to an instance of an object.&lt;/blockquote&gt;&lt;img width="0" height="0" src="http://www.timbarcz.com/blog/aggbug.ashx?id=1136e7c9-b88d-4f52-a572-e2ec389dd24e" /&gt;</description>
      <comments>http://www.timbarcz.com/blog/CommentView,guid,1136e7c9-b88d-4f52-a572-e2ec389dd24e.aspx</comments>
      <category>.NET</category>
      <category>Programming</category>
      <category>Software</category>
    </item>
    <item>
      <trackback:ping>http://www.timbarcz.com/blog/Trackback.aspx?guid=f9c13a9a-b67f-4d0f-b510-1f02fedb7ab2</trackback:ping>
      <pingback:server>http://www.timbarcz.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.timbarcz.com/blog/PermaLink,guid,f9c13a9a-b67f-4d0f-b510-1f02fedb7ab2.aspx</pingback:target>
      <dc:creator>Tim Barcz</dc:creator>
      <wfw:comment>http://www.timbarcz.com/blog/CommentView,guid,f9c13a9a-b67f-4d0f-b510-1f02fedb7ab2.aspx</wfw:comment>
      <wfw:commentRss>http://www.timbarcz.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=f9c13a9a-b67f-4d0f-b510-1f02fedb7ab2</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
"But you have the source!"
</p>
        <p>
I heard that statement a little over a month ago at the <a href="http://altdotnet.org/events/seattle" target="_blank">Alt.Net
Open Spaces event in Seattle</a>.  It's no secret to those who know the community,
that open source technologies are at the very least promoted and in many cases you'll
find many open source project committers within the Alt.Net community.  Heck, <a href="http://laribee.com/blog/" target="_blank">David
Laribee</a>, a founding member if there is such a thing, <a href="http://laribee.com/blog/2007/04/10/altnet/" target="_blank">in
a post</a> defined Alt.Net as (emphasis mine):
</p>
        <blockquote>
          <ol>
            <li>
You’re the type of developer who uses what works while keeping an eye out for a better
way. 
</li>
            <li>
              <strong>You reach outside the mainstream to adopt the best of any community: Open
Source</strong>, Agile, Java, Ruby, etc. 
</li>
            <li>
You’re not content with the status quo. Things can always be better expressed, more
elegant and simple, more mutable, higher quality, etc. 
</li>
            <li>
You know tools are great, but they only take you so far. It’s the principles and knowledge
that really matter. The best tools are those that embed the knowledge and encourage
the principles (e.g. Resharper.)</li>
          </ol>
        </blockquote>
        <p>
The quote, and many like it, came in a session titled "Mature Open Source projects
versus first generation Microsoft projects".  The discussion centered around
why some (many) developers, managers, and executives feel comfortable choosing a brand-new
Microsoft product when a far more mature open source alternative exists.  One
the fears surrounding the adoption of open source is the lack of surety that open
source project will exist in perpetuity.  One needs to look no further than two
projects, NVelocity and NDoc, to find historical evidence of an open source project
vanishing.  The main counter-point to that argument, and many others, was the
quote above, that with open source, you were never truly left high-and-dry, since
you had the source.
</p>
        <p>
It's a noble thought, but really, who wants to manage another codebase in addition
to their own?  In fact I turn to open source project many times so I don't have
to write my own code.  Why re-invent what someone else has already done and guided
to maturity?  The idea that I can compile and manage another, possibly large,
and probably complex codebase is hardly a comfort to me.  It wasn't until a few
weeks ago that I realize that the open source pundits were correct.
</p>
        <p>
I have been working on a project for the last year that has, as of two versions ago,
started using <a href="http://watin.sourceforge.net/" target="_blank">Watin</a> to
automate the downloading of a file from the internet.  Watin is a testing framework
but is used by many to automate business processes, which is what I use it for. 
If you haven't checked it out yet, it's beautifully simple.
</p>
        <p>
Watin provides handlers to download a file, however, the code was hanging at the point
where it should've cleared the download.  I looked at every documentation page,
blog post, and blog comment I could to see if I was missing something.  My usage
was correct.  So I dug in a bit further using <a href="http://www.greatis.com/delphicb/windowse/" target="_blank">WinDowse</a> to
find the handle of the button that should be clicked.  As it turns out the handle
of the Save button in a FileDownload Dialog changed from 4424 to 4427 in IE7, who
would've guessed it right?  Well, since I had the source I went in and made the
change, and voila, I'm back in business.
</p>
        <p>
It gave me some confidence that if an open source project does cease, I can pick it
up and patch it up.  I still don't want to manage multiple codebases from many
different source, but in the end the pro open-source guys were right, "You have the
source!"
</p>
        <img width="0" height="0" src="http://www.timbarcz.com/blog/aggbug.ashx?id=f9c13a9a-b67f-4d0f-b510-1f02fedb7ab2" />
      </body>
      <title>Open Source - You Have the Source</title>
      <guid isPermaLink="false">http://www.timbarcz.com/blog/PermaLink,guid,f9c13a9a-b67f-4d0f-b510-1f02fedb7ab2.aspx</guid>
      <link>http://www.timbarcz.com/blog/OpenSourceYouHaveTheSource.aspx</link>
      <pubDate>Tue, 10 Jun 2008 06:48:50 GMT</pubDate>
      <description>&lt;p&gt;
"But you have the source!"
&lt;/p&gt;
&lt;p&gt;
I heard that statement a little over a month ago at the &lt;a href="http://altdotnet.org/events/seattle" target="_blank"&gt;Alt.Net
Open Spaces event in Seattle&lt;/a&gt;.&amp;nbsp; It's no secret to those who know the community,
that open source technologies are at the very least promoted and in many cases you'll
find many open source project committers within the Alt.Net community.&amp;nbsp; Heck, &lt;a href="http://laribee.com/blog/" target="_blank"&gt;David
Laribee&lt;/a&gt;, a founding member if there is such a thing, &lt;a href="http://laribee.com/blog/2007/04/10/altnet/" target="_blank"&gt;in
a post&lt;/a&gt; defined Alt.Net as (emphasis mine):
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;ol&gt;
&lt;li&gt;
You’re the type of developer who uses what works while keeping an eye out for a better
way. 
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You reach outside the mainstream to adopt the best of any community: Open
Source&lt;/strong&gt;, Agile, Java, Ruby, etc. 
&lt;/li&gt;
&lt;li&gt;
You’re not content with the status quo. Things can always be better expressed, more
elegant and simple, more mutable, higher quality, etc. 
&lt;/li&gt;
&lt;li&gt;
You know tools are great, but they only take you so far. It’s the principles and knowledge
that really matter. The best tools are those that embed the knowledge and encourage
the principles (e.g. Resharper.)&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
The quote, and many like it, came in a session titled "Mature Open Source projects
versus first generation Microsoft projects".&amp;nbsp; The discussion centered around
why some (many) developers, managers, and executives feel comfortable choosing a brand-new
Microsoft product when a far more mature open source alternative exists.&amp;nbsp; One
the fears surrounding the adoption of open source is the lack of surety that open
source project will exist in perpetuity.&amp;nbsp; One needs to look no further than two
projects, NVelocity and NDoc, to find historical evidence of an open source project
vanishing.&amp;nbsp; The main counter-point to that argument, and many others, was the
quote above, that with open source, you were never truly left high-and-dry, since
you had the source.
&lt;/p&gt;
&lt;p&gt;
It's a noble thought, but really, who wants to manage another codebase in addition
to their own?&amp;nbsp; In fact I turn to open source project many times so I don't have
to write my own code.&amp;nbsp; Why re-invent what someone else has already done and guided
to maturity?&amp;nbsp; The idea that I can compile and manage another, possibly large,
and probably complex codebase is hardly a comfort to me.&amp;nbsp; It wasn't until a few
weeks ago that I realize that the open source pundits were correct.
&lt;/p&gt;
&lt;p&gt;
I have been working on a project for the last year that has, as of two versions ago,
started using &lt;a href="http://watin.sourceforge.net/" target="_blank"&gt;Watin&lt;/a&gt; to
automate the downloading of a file from the internet.&amp;nbsp; Watin is a testing framework
but is used by many to automate business processes, which is what I use it for.&amp;nbsp;
If you haven't checked it out yet, it's beautifully simple.
&lt;/p&gt;
&lt;p&gt;
Watin provides handlers to download a file, however, the code was hanging at the point
where it should've cleared the download.&amp;nbsp; I looked at every documentation page,
blog post, and blog comment I could to see if I was missing something.&amp;nbsp; My usage
was correct.&amp;nbsp; So I dug in a bit further using &lt;a href="http://www.greatis.com/delphicb/windowse/" target="_blank"&gt;WinDowse&lt;/a&gt; to
find the handle of the button that should be clicked.&amp;nbsp; As it turns out the handle
of the Save button in a FileDownload Dialog changed from 4424 to 4427 in IE7, who
would've guessed it right?&amp;nbsp; Well, since I had the source I went in and made the
change, and voila, I'm back in business.
&lt;/p&gt;
&lt;p&gt;
It gave me some confidence that if an open source project does cease, I can pick it
up and patch it up.&amp;nbsp; I still don't want to manage multiple codebases from many
different source, but in the end the pro open-source guys were right, "You have the
source!"
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.timbarcz.com/blog/aggbug.ashx?id=f9c13a9a-b67f-4d0f-b510-1f02fedb7ab2" /&gt;</description>
      <comments>http://www.timbarcz.com/blog/CommentView,guid,f9c13a9a-b67f-4d0f-b510-1f02fedb7ab2.aspx</comments>
      <category>.NET</category>
      <category>ALT.NET</category>
      <category>Musings</category>
      <category>Open Source Software</category>
      <category>Software</category>
    </item>
    <item>
      <trackback:ping>http://www.timbarcz.com/blog/Trackback.aspx?guid=7269a61b-1e48-4eaf-8b0b-0f5e816c22be</trackback:ping>
      <pingback:server>http://www.timbarcz.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.timbarcz.com/blog/PermaLink,guid,7269a61b-1e48-4eaf-8b0b-0f5e816c22be.aspx</pingback:target>
      <dc:creator>Tim Barcz</dc:creator>
      <wfw:comment>http://www.timbarcz.com/blog/CommentView,guid,7269a61b-1e48-4eaf-8b0b-0f5e816c22be.aspx</wfw:comment>
      <wfw:commentRss>http://www.timbarcz.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=7269a61b-1e48-4eaf-8b0b-0f5e816c22be</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Yesterday I attended the first ever <a href="http://www.iowacodecamp.com">Iowa Code
Camp</a> in Iowa City, Iowa.  This was the first code camp I had ever attended
and that fact withstanding, I don't know how the event could have gone any better,
it was absolutely flawless.  There were well over 125 attendees and waiting list
to boot.
</p>
        <p>
I attended sessions on Java/Hibernate, Inversion of Control, Mocking and .NET Performance
Tuning. I enjoyed <a href="http://devlicio.us/blogs/derik_whittaker/default.aspx">Derik
Whittaker's</a> talk on mocking as it's something I've been into for the last few
months.
</p>
        <p>
Talking to other attendees it was very obvious that others enjoyed themselves as well. 
The feeling was that the materials presented were things we can take into work tomorrow. 
And that is what a code camp is all about.
</p>
        <p>
Thanks to Chris, Javier, Greg S. Greg W and the many others who helped make yesterday
a success, you guys set up a wonderful event!
</p>
        <img width="0" height="0" src="http://www.timbarcz.com/blog/aggbug.ashx?id=7269a61b-1e48-4eaf-8b0b-0f5e816c22be" />
      </body>
      <title>Iowa Code Camp - A Huge Success</title>
      <guid isPermaLink="false">http://www.timbarcz.com/blog/PermaLink,guid,7269a61b-1e48-4eaf-8b0b-0f5e816c22be.aspx</guid>
      <link>http://www.timbarcz.com/blog/IowaCodeCampAHugeSuccess.aspx</link>
      <pubDate>Sun, 04 May 2008 19:43:14 GMT</pubDate>
      <description>&lt;p&gt;
Yesterday I attended the first ever &lt;a href="http://www.iowacodecamp.com"&gt;Iowa Code
Camp&lt;/a&gt; in Iowa City, Iowa.&amp;nbsp; This was the first code camp I had ever attended
and that fact withstanding, I don't know how the event could have gone any better,
it was absolutely flawless.&amp;nbsp; There were well over 125 attendees and waiting list
to boot.
&lt;/p&gt;
&lt;p&gt;
I attended sessions on Java/Hibernate, Inversion of Control, Mocking and .NET Performance
Tuning. I enjoyed &lt;a href="http://devlicio.us/blogs/derik_whittaker/default.aspx"&gt;Derik
Whittaker's&lt;/a&gt; talk on mocking as it's something I've been into for the last few
months.
&lt;/p&gt;
&lt;p&gt;
Talking to other attendees it was very obvious that others enjoyed themselves as well.&amp;nbsp;
The feeling was that the materials presented were things we can take into work tomorrow.&amp;nbsp;
And that is what a code camp is all about.
&lt;/p&gt;
&lt;p&gt;
Thanks to Chris, Javier, Greg S. Greg W and the many others who helped make yesterday
a success, you guys set up a wonderful event!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.timbarcz.com/blog/aggbug.ashx?id=7269a61b-1e48-4eaf-8b0b-0f5e816c22be" /&gt;</description>
      <comments>http://www.timbarcz.com/blog/CommentView,guid,7269a61b-1e48-4eaf-8b0b-0f5e816c22be.aspx</comments>
      <category>.NET</category>
      <category>CRIneta</category>
    </item>
    <item>
      <trackback:ping>http://www.timbarcz.com/blog/Trackback.aspx?guid=42dd1eff-c521-495d-a2af-7148980b0f1a</trackback:ping>
      <pingback:server>http://www.timbarcz.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.timbarcz.com/blog/PermaLink,guid,42dd1eff-c521-495d-a2af-7148980b0f1a.aspx</pingback:target>
      <dc:creator>Tim Barcz</dc:creator>
      <wfw:comment>http://www.timbarcz.com/blog/CommentView,guid,42dd1eff-c521-495d-a2af-7148980b0f1a.aspx</wfw:comment>
      <wfw:commentRss>http://www.timbarcz.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=42dd1eff-c521-495d-a2af-7148980b0f1a</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
From the moment we got here it's been so absolutely incredible.  We (Chris Sutton
and I) arrived in Seattle about 11:00 and met up in our hotel lobby with a few guys
and went off to lunch.  The subject of mocking came up and got into an interesting
debate with the guys about mocking, among which was Roy Osherove.
</p>
        <p>
I'm generally a nobody, but that's not how it feels here, everyone comes here to learn
from others, so it actually tends to be a great group of developers.  Yesterday
afternoon I was chatting with Udi Dahan, Greg Young, Drew Sellers, and Evan Hoff about
event driven design.  I'm amazed that when surrounded by many celebreties in
our community that they are really just like us (Roy O is the most down to earth guy).
</p>
        <p>
The open spaces format is interesting, people get up and say what they want to talk
about and then we figure out what will be talked about.  Some topics from Friday
evening were mocking, agile scaling with teams, distributed design, and javascript
testing, just to name a few.
</p>
        <p>
A highlight was talking in a small group with Martin Fowler and Scott Hanselman about
languages and the importance of finding good code to learn from.
</p>
        <p>
All in all, I'm so far impressed and the conference really hasn't begun.  From
the time people showed the conference began, despite it not officially beginning until
6:00 last night.  After the conference everyone went out to eat and this morning
people are gathering for breakfast.
</p>
        <p>
Ultimately one cool group of people that I'm proud to be a part of.
</p>
        <p>
 
</p>
        <img width="0" height="0" src="http://www.timbarcz.com/blog/aggbug.ashx?id=42dd1eff-c521-495d-a2af-7148980b0f1a" />
      </body>
      <title>ALT.NET Day 1 Thoughts</title>
      <guid isPermaLink="false">http://www.timbarcz.com/blog/PermaLink,guid,42dd1eff-c521-495d-a2af-7148980b0f1a.aspx</guid>
      <link>http://www.timbarcz.com/blog/ALTNETDay1Thoughts.aspx</link>
      <pubDate>Sat, 19 Apr 2008 16:04:59 GMT</pubDate>
      <description>&lt;p&gt;
From the moment we got here it's been so absolutely incredible.&amp;nbsp; We (Chris Sutton
and I) arrived in Seattle about 11:00 and met up in our hotel lobby with a few guys
and went off to lunch.&amp;nbsp; The subject of mocking came up and got into an interesting
debate with the guys about mocking, among which was Roy Osherove.
&lt;/p&gt;
&lt;p&gt;
I'm generally a nobody, but that's not how it feels here, everyone comes here to learn
from others, so it actually tends to be a great group of developers.&amp;nbsp; Yesterday
afternoon I was chatting with Udi Dahan, Greg Young, Drew Sellers, and Evan Hoff about
event driven design.&amp;nbsp; I'm amazed that when surrounded by many celebreties in
our community that they are really just like us (Roy O is the most down to earth guy).
&lt;/p&gt;
&lt;p&gt;
The open spaces format is interesting, people get up and say what they want to talk
about and then we figure out what will be talked about.&amp;nbsp; Some topics from Friday
evening were mocking, agile scaling with teams, distributed design, and javascript
testing, just to name a few.
&lt;/p&gt;
&lt;p&gt;
A highlight was talking in a small group with Martin Fowler and Scott Hanselman about
languages and the importance of finding good code to learn from.
&lt;/p&gt;
&lt;p&gt;
All in all, I'm so far impressed and the conference really hasn't begun.&amp;nbsp; From
the time people showed the conference began, despite it not officially beginning until
6:00 last night.&amp;nbsp; After the conference everyone went out to eat and this morning
people are gathering for breakfast.
&lt;/p&gt;
&lt;p&gt;
Ultimately one cool group of people that I'm proud to be a part of.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.timbarcz.com/blog/aggbug.ashx?id=42dd1eff-c521-495d-a2af-7148980b0f1a" /&gt;</description>
      <comments>http://www.timbarcz.com/blog/CommentView,guid,42dd1eff-c521-495d-a2af-7148980b0f1a.aspx</comments>
      <category>.NET</category>
      <category>ALT.NET</category>
    </item>
    <item>
      <trackback:ping>http://www.timbarcz.com/blog/Trackback.aspx?guid=01d0d4ee-b620-4c3e-b04e-5690837b03c3</trackback:ping>
      <pingback:server>http://www.timbarcz.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.timbarcz.com/blog/PermaLink,guid,01d0d4ee-b620-4c3e-b04e-5690837b03c3.aspx</pingback:target>
      <dc:creator>Tim Barcz</dc:creator>
      <wfw:comment>http://www.timbarcz.com/blog/CommentView,guid,01d0d4ee-b620-4c3e-b04e-5690837b03c3.aspx</wfw:comment>
      <wfw:commentRss>http://www.timbarcz.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=01d0d4ee-b620-4c3e-b04e-5690837b03c3</wfw:commentRss>
      <slash:comments>5</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
The new <a href="http://www.jetbrains.com/resharper/">Resharper</a> seems to favor
the "var" keyword and I don't understand why.  Is it some performance
benefit?  To me, if you know the type, then write it as such.  Consider
the following:
</p>
        <blockquote>
          <p>
Person p = new Person("Tim", "Barcz");
</p>
        </blockquote>
        <p>
Resharper doesn't like this and suggests the following:
</p>
        <blockquote>
          <p>
var p = new Person("Tim", "Barcz");
</p>
        </blockquote>
        <p>
Why?  Just because you can do something, I don't think you should.  Maybe
my brain hasn't shifted back to a var world yet, but the second snippet is less readable
than the first.  To me it's a case of <a href="http://www.amazon.com/Common-Approach-Usability-Circle-Com-Library/dp/0789723107">Don't
Make Me Think</a>.  With "var", I now have to stop and think, even
for a second, what type is being returned.
</p>
        <img width="0" height="0" src="http://www.timbarcz.com/blog/aggbug.ashx?id=01d0d4ee-b620-4c3e-b04e-5690837b03c3" />
      </body>
      <title>Is Var Better?</title>
      <guid isPermaLink="false">http://www.timbarcz.com/blog/PermaLink,guid,01d0d4ee-b620-4c3e-b04e-5690837b03c3.aspx</guid>
      <link>http://www.timbarcz.com/blog/IsVarBetter.aspx</link>
      <pubDate>Mon, 10 Mar 2008 16:51:28 GMT</pubDate>
      <description>&lt;p&gt;
The new &lt;a href="http://www.jetbrains.com/resharper/"&gt;Resharper&lt;/a&gt; seems to favor
the &amp;quot;var&amp;quot; keyword and I don't understand why.&amp;#160; Is it some performance
benefit?&amp;#160; To me, if you know the type, then write it as such.&amp;#160; Consider
the following:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
Person p = new Person(&amp;quot;Tim&amp;quot;, &amp;quot;Barcz&amp;quot;);
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Resharper doesn't like this and suggests the following:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
var p = new Person(&amp;quot;Tim&amp;quot;, &amp;quot;Barcz&amp;quot;);
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Why?&amp;#160; Just because you can do something, I don't think you should.&amp;#160; Maybe
my brain hasn't shifted back to a var world yet, but the second snippet is less readable
than the first.&amp;#160; To me it's a case of &lt;a href="http://www.amazon.com/Common-Approach-Usability-Circle-Com-Library/dp/0789723107"&gt;Don't
Make Me Think&lt;/a&gt;.&amp;#160; With &amp;quot;var&amp;quot;, I now have to stop and think, even
for a second, what type is being returned.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.timbarcz.com/blog/aggbug.ashx?id=01d0d4ee-b620-4c3e-b04e-5690837b03c3" /&gt;</description>
      <comments>http://www.timbarcz.com/blog/CommentView,guid,01d0d4ee-b620-4c3e-b04e-5690837b03c3.aspx</comments>
      <category>.NET</category>
      <category>Musings</category>
      <category>Software</category>
    </item>
    <item>
      <trackback:ping>http://www.timbarcz.com/blog/Trackback.aspx?guid=445de521-8049-4f1a-a99b-e65b7590a7ac</trackback:ping>
      <pingback:server>http://www.timbarcz.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.timbarcz.com/blog/PermaLink,guid,445de521-8049-4f1a-a99b-e65b7590a7ac.aspx</pingback:target>
      <dc:creator>Tim Barcz</dc:creator>
      <wfw:comment>http://www.timbarcz.com/blog/CommentView,guid,445de521-8049-4f1a-a99b-e65b7590a7ac.aspx</wfw:comment>
      <wfw:commentRss>http://www.timbarcz.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=445de521-8049-4f1a-a99b-e65b7590a7ac</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://www.timbarcz.com/blog/content/binary/WindowsLiveWriter/RegularExpressionLearnthem_8736/image_9.png">
            <img style="border-width: 0px;" alt="image" src="http://www.timbarcz.com/blog/content/binary/WindowsLiveWriter/RegularExpressionLearnthem_8736/image_thumb_3.png" align="right" border="0" height="520" width="321" />
          </a>I've
thought about writing this post several times over the past two years.  Having
had regular expressions come up three times last week, I thought it time to address
the lack of programmers out there who understand regular expressions.  The sheer
amount of fear surrounding regular expressions and the work that goes into avoiding
them is astonishing.
</p>
        <p>
Last year I used to troll around the <a href="http://www.asp.net/forums/">asp.net
forums</a> and quite frequently I would answer the regex questions.  One <a href="http://forums.asp.net/t/1125123.aspx">question
was posted</a> which illustrates the problem with regexes among developers.
</p>
        <blockquote>
          <p>
"...and i also i need to add a validator for the password textbox where the user is
required to fill atleast [sic] 6 characters" 
</p>
        </blockquote>
        <p>
I suggested a solution to the problem using a regular expression validator. Making
sure there are at least 6 characters, is a simple regex (example: \w{6,}), and yet
my solution was met with skepticism.  The following was said, in the event a
change was requested, 
</p>
        <blockquote>
          <p>
"Putting a new version of a web site can take a surprising amount of time than can
go into man-weeks".  
</p>
        </blockquote>
        <p>
Man-weeks?!?!?  To change a regular expression?!?!?  I see two problems,
first the original developer who didn't know that regex would easily solve their problem. 
The second problem is the other developer who doesn't know regex advocating his way
as "the way", in effect, spreading his ignorance.  The first developer is easily
forgiven, the second is not.
</p>
        <p>
It's been said <a href="http://www.codinghorror.com/blog/archives/000781.html">programmers
can't program</a> when faced with a simple FizzBuzz test, <a href="http://tickletux.wordpress.com/">Imran</a> states:
</p>
        <blockquote>
          <p>
"Want to know something scary? - the majority of comp sci graduates can’t. I’ve also
seen self-proclaimed senior programmers take more than 10-15 minutes to write a solution."
</p>
        </blockquote>
        <p>
I'll pile on.  <strong>You want to know something scary?  The majority of
professional programmers can't write regular expressions, even simple ones</strong>. 
I'm not the first to say this.  Last year, at the <a href="http://altdotnet.org/">ALT.NET</a> conference, <a href="http://weblogs.asp.net/scottgu/">Scott
Guthrie</a> made the following statement when talking about routes in the new MVC
framework:
</p>
        <blockquote>
          <p>
"It's pluggable, so you can use Regexes...&lt;some incoherent stuff&gt;...if you wanna
use regexes you can.  What we found is, regexes are super powerful, but only
about 10% of people actually understand 'em."
</p>
        </blockquote>
        <p>
Are regular expressions easy to understand? Well, let me ask you, was HTML easy when
you started?  Were you born understanding the following HTML?
</p>
        <blockquote>
          <p>
            <font face="Courier" size="2">&lt;fieldset class="CheckRadio"&gt; 
<br />
    &lt;div id="OngoingEventContainer"&gt; 
<br />
        &lt;input type="checkbox" id="OngoingEvent"
name="OngoingEvent" value="1" /&gt; 
<br />
        &lt;label for="OngoingEvent"&gt; 
<br />
            This is an ongoing
event (no dates and times) 
<br />
        &lt;/label&gt; 
<br />
    &lt;/div&gt; 
<br />
&lt;/fieldset&gt;</font>
          </p>
        </blockquote>
        <p>
If you understand the above, you didn't always.  My guess is that at some point
you buckled down and learned HTML because you're job requires it.  Well, if you're
a programmer, web or windows, <strong>you need to know regular expressions, your job
requires it, it's that simple.</strong> 
</p>
        <p>
          <a href="http://www.timbarcz.com/blog/content/binary/WindowsLiveWriter/RegularExpressionLearnthem_8736/image_7.png">
            <img style="border-width: 0px;" alt="image" src="http://www.timbarcz.com/blog/content/binary/WindowsLiveWriter/RegularExpressionLearnthem_8736/image_thumb_2.png" align="right" border="0" height="325" width="344" />
          </a>Regular
expressions have been around so long that they're deeply ingrained in many of the
tools we use.  <a href="http://devlicious.com/blogs/christopher_bennage">Christopher
Bennage</a> illustrates how regular expressions solved a recent problems in Visual
Studio.  In a <a href="http://devlicious.com/blogs/christopher_bennage/archive/2008/02/21/discovering-empty-try-catch-blocks.aspx">recent
post</a> he posts:
</p>
        <blockquote>
          <p>
"Then I realized that I was missing the simple solution. Ctrl+F and a regular expression!"
</p>
        </blockquote>
        <p>
I don't know that many people would be able to come to the conclusion that Christoper
did.  It's my belief that regular expressions are fundamental, yet the average
developer doesn't treat them as such.  They're ultimately doing themselves a
disservice.
</p>
        <p>
Regular Expressions are a tool that should be in every programmers bag.  If you
don't understand regular expressions and do a google search every time you need a
regular expression, shame on you!  It's time to bite the bullet and learn regular
expressions.
</p>
        <img width="0" height="0" src="http://www.timbarcz.com/blog/aggbug.ashx?id=445de521-8049-4f1a-a99b-e65b7590a7ac" />
      </body>
      <title>Regular Expressions, Your Job Requires Them</title>
      <guid isPermaLink="false">http://www.timbarcz.com/blog/PermaLink,guid,445de521-8049-4f1a-a99b-e65b7590a7ac.aspx</guid>
      <link>http://www.timbarcz.com/blog/RegularExpressionsYourJobRequiresThem.aspx</link>
      <pubDate>Mon, 25 Feb 2008 20:51:08 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://www.timbarcz.com/blog/content/binary/WindowsLiveWriter/RegularExpressionLearnthem_8736/image_9.png"&gt;&lt;img style="border-width: 0px;" alt="image" src="http://www.timbarcz.com/blog/content/binary/WindowsLiveWriter/RegularExpressionLearnthem_8736/image_thumb_3.png" align="right" border="0" height="520" width="321"&gt;&lt;/a&gt;I've
thought about writing this post several times over the past two years.&amp;nbsp; Having
had regular expressions come up three times last week, I thought it time to address
the lack of programmers out there who understand regular expressions.&amp;nbsp; The sheer
amount of fear surrounding regular expressions and the work that goes into avoiding
them is astonishing.
&lt;/p&gt;
&lt;p&gt;
Last year I used to troll around the &lt;a href="http://www.asp.net/forums/"&gt;asp.net
forums&lt;/a&gt; and quite frequently I would answer the regex questions.&amp;nbsp; One &lt;a href="http://forums.asp.net/t/1125123.aspx"&gt;question
was posted&lt;/a&gt; which illustrates the problem with regexes among developers.
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
"...and i also i need to add a validator for the password textbox where the user is
required to fill atleast [sic] 6 characters" 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
I suggested a solution to the problem using a regular expression validator. Making
sure there are at least 6 characters, is a simple regex (example: \w{6,}), and yet
my solution was met with skepticism.&amp;nbsp; The following was said, in the event a
change was requested, 
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
"Putting a new version of a web site can take a surprising amount of time than can
go into man-weeks".&amp;nbsp; 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Man-weeks?!?!?&amp;nbsp; To change a regular expression?!?!?&amp;nbsp; I see two problems,
first the original developer who didn't know that regex would easily solve their problem.&amp;nbsp;
The second problem is the other developer who doesn't know regex advocating his way
as "the way", in effect, spreading his ignorance.&amp;nbsp; The first developer is easily
forgiven, the second is not.
&lt;/p&gt;
&lt;p&gt;
It's been said &lt;a href="http://www.codinghorror.com/blog/archives/000781.html"&gt;programmers
can't program&lt;/a&gt; when faced with a simple FizzBuzz test, &lt;a href="http://tickletux.wordpress.com/"&gt;Imran&lt;/a&gt; states:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
"Want to know something scary? - the majority of comp sci graduates can’t. I’ve also
seen self-proclaimed senior programmers take more than 10-15 minutes to write a solution."
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
I'll pile on.&amp;nbsp; &lt;strong&gt;You want to know something scary?&amp;nbsp; The majority of
professional programmers can't write regular expressions, even simple ones&lt;/strong&gt;.&amp;nbsp;
I'm not the first to say this.&amp;nbsp; Last year, at the &lt;a href="http://altdotnet.org/"&gt;ALT.NET&lt;/a&gt; conference, &lt;a href="http://weblogs.asp.net/scottgu/"&gt;Scott
Guthrie&lt;/a&gt; made the following statement when talking about routes in the new MVC
framework:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
"It's pluggable, so you can use Regexes...&amp;lt;some incoherent stuff&amp;gt;...if you wanna
use regexes you can.&amp;nbsp; What we found is, regexes are super powerful, but only
about 10% of people actually understand 'em."
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Are regular expressions easy to understand? Well, let me ask you, was HTML easy when
you started?&amp;nbsp; Were you born understanding the following HTML?
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&lt;font face="Courier" size="2"&gt;&amp;lt;fieldset class="CheckRadio"&amp;gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div id="OngoingEventContainer"&amp;gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;input type="checkbox" id="OngoingEvent"
name="OngoingEvent" value="1" /&amp;gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label for="OngoingEvent"&amp;gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; This is an ongoing
event (no dates and times) 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/label&amp;gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt; 
&lt;br&gt;
&amp;lt;/fieldset&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
If you understand the above, you didn't always.&amp;nbsp; My guess is that at some point
you buckled down and learned HTML because you're job requires it.&amp;nbsp; Well, if you're
a programmer, web or windows, &lt;strong&gt;you need to know regular expressions, your job
requires it, it's that simple.&lt;/strong&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.timbarcz.com/blog/content/binary/WindowsLiveWriter/RegularExpressionLearnthem_8736/image_7.png"&gt;&lt;img style="border-width: 0px;" alt="image" src="http://www.timbarcz.com/blog/content/binary/WindowsLiveWriter/RegularExpressionLearnthem_8736/image_thumb_2.png" align="right" border="0" height="325" width="344"&gt;&lt;/a&gt;Regular
expressions have been around so long that they're deeply ingrained in many of the
tools we use.&amp;nbsp; &lt;a href="http://devlicious.com/blogs/christopher_bennage"&gt;Christopher
Bennage&lt;/a&gt; illustrates how regular expressions solved a recent problems in Visual
Studio.&amp;nbsp; In a &lt;a href="http://devlicious.com/blogs/christopher_bennage/archive/2008/02/21/discovering-empty-try-catch-blocks.aspx"&gt;recent
post&lt;/a&gt; he posts:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
"Then I realized that I was missing the simple solution. Ctrl+F and a regular expression!"
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
I don't know that many people would be able to come to the conclusion that Christoper
did.&amp;nbsp; It's my belief that regular expressions are fundamental, yet the average
developer doesn't treat them as such.&amp;nbsp; They're ultimately doing themselves a
disservice.
&lt;/p&gt;
&lt;p&gt;
Regular Expressions are a tool that should be in every programmers bag.&amp;nbsp; If you
don't understand regular expressions and do a google search every time you need a
regular expression, shame on you!&amp;nbsp; It's time to bite the bullet and learn regular
expressions.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.timbarcz.com/blog/aggbug.ashx?id=445de521-8049-4f1a-a99b-e65b7590a7ac" /&gt;</description>
      <comments>http://www.timbarcz.com/blog/CommentView,guid,445de521-8049-4f1a-a99b-e65b7590a7ac.aspx</comments>
      <category>.NET</category>
      <category>Musings</category>
      <category>Software</category>
    </item>
    <item>
      <trackback:ping>http://www.timbarcz.com/blog/Trackback.aspx?guid=c04e330c-0d9b-47ab-9b98-013bd89163c0</trackback:ping>
      <pingback:server>http://www.timbarcz.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.timbarcz.com/blog/PermaLink,guid,c04e330c-0d9b-47ab-9b98-013bd89163c0.aspx</pingback:target>
      <dc:creator>Tim Barcz</dc:creator>
      <wfw:comment>http://www.timbarcz.com/blog/CommentView,guid,c04e330c-0d9b-47ab-9b98-013bd89163c0.aspx</wfw:comment>
      <wfw:commentRss>http://www.timbarcz.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=c04e330c-0d9b-47ab-9b98-013bd89163c0</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
After a snowy weekend being stuck in Minnesota I was greeted by an email in my inbox
saying that I was registered for the <a href="http://altdotnet.org/events/seattle/">2008
ALT.NET Open Spaces, Seattle conference</a>.  Last year the <a href="http://weblogs.asp.net/jgalloway/archive/2007/05/02/are-you-alt-net.aspx">Alt.NET</a> generated
a lot of post-conference buzz and was where the <a href="http://www.hanselman.com/silverlight/ScottGuAtAltNetConf/">.NET
MVC Framework was announced by Scott Guthrie</a>.
</p>
        <p>
After looking at the <a href="http://altdotnet.org/events/seattle/">list of participants</a> I'm
gushing with enthusiasm.  I feel like a 14 year old freshman who was just asked
to the homecoming dance by the homecoming queen.  For the sports enthusiast,
I feel like <a href="http://www.nba.com/playerfile/jason_kapono/index.html">Jason
Kapono</a> at the NBA All-Star game.  Kapono won the three point shootout, but
many of you are probably asking yourselves, "who is Jason Kapono?" 
Kapono, and his three-point skill, was overshadowed by the All-Star game itself and
all of the NBA talent on the floor at one time.  I am Jason Kapono.  I must
admit I have borderline unhealthy geek-love-man-crush on some of the attendees (listed
in no particular order):
</p>
        <ul>
          <ul>
            <li>
              <a href="http://www.hanselman.com/blog/">Scott Hanselman</a>
            </li>
            <li>
              <a href="http://codebetter.com/blogs/jeffrey.palermo/">Jeffrey Palermo</a>
            </li>
            <li>
              <a href="http://www.sellsbrothers.com/">Chris Sells</a>
            </li>
            <li>
              <a href="http://weblogs.asp.net/scottgu/">Scott Guthrie</a>
            </li>
            <li>
              <a href="http://martinfowler.com/">Martin Fowler</a>
            </li>
            <li>
              <a href="http://www.haacked.com/">Phil Haack</a>
            </li>
            <li>
              <a href="http://www.iunknown.com/">John Lam</a>
            </li>
            <li>
              <a href="http://weblogs.asp.net/rosherove/">Roy Osherove</a>
            </li>
            <li>
              <a href="http://www.ayende.com/Blog/">Ayende Rahien</a>
            </li>
            <li>
              <a href="http://en.wikipedia.org/wiki/Ward_Cunningham">Ward Cunningham</a>
            </li>
            <li>
              <a href="http://www.jpboodhoo.com/blog/">Jean-Paul Boodhoo</a>
            </li>
          </ul>
        </ul>
        <p>
Sure, these guy go to conferences and it's not rare that they're in the same place. 
What is rare, is that they're all together and there are only 150 participants. 
That means the geek-expert to journeyman ratio is going to be quite high.  In
other words, they can't avoid me.
</p>
        <p>
Martin, will you autograph my <a href="http://martinfowler.com/books.html">POEA</a> book?
</p>
        <img width="0" height="0" src="http://www.timbarcz.com/blog/aggbug.ashx?id=c04e330c-0d9b-47ab-9b98-013bd89163c0" />
      </body>
      <title>ALT.NET 2008 - Uncomfortable Geek-Love Is In the Air</title>
      <guid isPermaLink="false">http://www.timbarcz.com/blog/PermaLink,guid,c04e330c-0d9b-47ab-9b98-013bd89163c0.aspx</guid>
      <link>http://www.timbarcz.com/blog/ALTNET2008UncomfortableGeekLoveIsInTheAir.aspx</link>
      <pubDate>Tue, 19 Feb 2008 19:13:46 GMT</pubDate>
      <description>&lt;p&gt;
After a snowy weekend being stuck in Minnesota I was greeted by an email in my inbox
saying that I was registered for the &lt;a href="http://altdotnet.org/events/seattle/"&gt;2008
ALT.NET Open Spaces, Seattle conference&lt;/a&gt;.&amp;#160; Last year the &lt;a href="http://weblogs.asp.net/jgalloway/archive/2007/05/02/are-you-alt-net.aspx"&gt;Alt.NET&lt;/a&gt; generated
a lot of post-conference buzz and was where the &lt;a href="http://www.hanselman.com/silverlight/ScottGuAtAltNetConf/"&gt;.NET
MVC Framework was announced by Scott Guthrie&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
After looking at the &lt;a href="http://altdotnet.org/events/seattle/"&gt;list of participants&lt;/a&gt; I'm
gushing with enthusiasm.&amp;#160; I feel like a 14 year old freshman who was just asked
to the homecoming dance by the homecoming queen.&amp;#160; For the sports enthusiast,
I feel like &lt;a href="http://www.nba.com/playerfile/jason_kapono/index.html"&gt;Jason
Kapono&lt;/a&gt; at the NBA All-Star game.&amp;#160; Kapono won the three point shootout, but
many of you are probably asking yourselves, &amp;quot;who is Jason Kapono?&amp;quot;&amp;#160;
Kapono, and his three-point skill, was overshadowed by the All-Star game itself and
all of the NBA talent on the floor at one time.&amp;#160; I am Jason Kapono.&amp;#160; I must
admit I have borderline unhealthy geek-love-man-crush on some of the attendees (listed
in no particular order):
&lt;/p&gt;
&lt;ul&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://www.hanselman.com/blog/"&gt;Scott Hanselman&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://codebetter.com/blogs/jeffrey.palermo/"&gt;Jeffrey Palermo&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://www.sellsbrothers.com/"&gt;Chris Sells&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://weblogs.asp.net/scottgu/"&gt;Scott Guthrie&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://martinfowler.com/"&gt;Martin Fowler&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://www.haacked.com/"&gt;Phil Haack&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://www.iunknown.com/"&gt;John Lam&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://weblogs.asp.net/rosherove/"&gt;Roy Osherove&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://www.ayende.com/Blog/"&gt;Ayende Rahien&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://en.wikipedia.org/wiki/Ward_Cunningham"&gt;Ward Cunningham&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://www.jpboodhoo.com/blog/"&gt;Jean-Paul Boodhoo&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;p&gt;
Sure, these guy go to conferences and it's not rare that they're in the same place.&amp;#160;
What is rare, is that they're all together and there are only 150 participants.&amp;#160;
That means the geek-expert to journeyman ratio is going to be quite high.&amp;#160; In
other words, they can't avoid me.
&lt;/p&gt;
&lt;p&gt;
Martin, will you autograph my &lt;a href="http://martinfowler.com/books.html"&gt;POEA&lt;/a&gt; book?
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.timbarcz.com/blog/aggbug.ashx?id=c04e330c-0d9b-47ab-9b98-013bd89163c0" /&gt;</description>
      <comments>http://www.timbarcz.com/blog/CommentView,guid,c04e330c-0d9b-47ab-9b98-013bd89163c0.aspx</comments>
      <category>.NET</category>
    </item>
  </channel>
</rss>