<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Brian On Software</title>
	
	<link>http://blog.briandicroce.com</link>
	<description>On the infinite search for the silver bullet...</description>
	<pubDate>Mon, 20 Apr 2009 03:24:13 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.5</generator>
	<language>en</language>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/BrianDiCroce" type="application/rss+xml" /><feedburner:emailServiceId>BrianDiCroce</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>Quick access to useful documents inside Visual Studio</title>
		<link>http://feedproxy.google.com/~r/BrianDiCroce/~3/jh0uhHIyryo/</link>
		<comments>http://blog.briandicroce.com/2009/04/19/quick-access-to-useful-documents-inside-visual-studio/#comments</comments>
		<pubDate>Mon, 20 Apr 2009 03:22:56 +0000</pubDate>
		<dc:creator>Brian Di Croce</dc:creator>
		
		<category><![CDATA[.NET Programming]]></category>

		<guid isPermaLink="false">http://blog.briandicroce.com/2009/04/19/quick-access-to-useful-documents-inside-visual-studio/</guid>
		<description>Here’s one of those little tips that can save you time and useless brain processing when the need arises.&amp;#160; When developing in Visual Studio, does it ever happen that you need to read some documentation pertaining to your current work?&amp;#160; In my case it happens a lot.&amp;#160; I don’t like to switch context and fire [...]</description>
			<content:encoded><![CDATA[<p>Here’s one of those little tips that can save you time and useless brain processing when the need arises.&#160; When developing in Visual Studio, does it ever happen that you need to read some documentation pertaining to your current work?&#160; In my case it happens a lot.&#160; I don’t like to switch context and fire up a web browser to find the needed documentation, or even launch Windows Explorer to find that document in some obscure, deep directory hierarchy.&#160; No, instead I like to have everything I need, whether tools or documentations, under my fingers in one place: inside Visual Studio.&#160; </p>
<p>Two documentations that I use the most when programming in .NET are the <a href="http://www.jetbrains.com/resharper/documentation/documentation.html" target="_blank">ReSharper 4.5 Default Keymaps</a> and the <a href="http://www.ecma-international.org/publications/standards/Ecma-334.htm" target="_blank">C# Language Specification</a> (ECMA-334).&#160; In order to quickly access those two documents (and future documents I might need), I simply created an entry in the External Tools section of Visual Studio.&#160; In order to do this, you can follow these simple steps:</p>
<ol>
<li>Go to <strong>Tools </strong>-&gt;<strong> External Tools…</strong></li>
<li>In the External Tools window, click on the <strong>Add</strong> button to create a new entry</li>
<li>Fill in the required information, such as Title, Command, Arguments, etc.&#160; In my case, the Command is simply the path to the executable of my favorite PDF reader (Foxit Reader) and the Arguments is simply the path to the PDF file.&#160; You can also define a keyboard shortcut for them by prefixing the “<strong>&amp;”</strong> symbol to one of the letters that aren’t already defined as shortcuts.&#160; </li>
<li>When you’re done, click on <strong>OK</strong>.&#160; </li>
</ol>
<p>Take a look at the following screenshot:</p>
<p><img title="" style="border-right: 0px; border-top: 0px; display: block; float: none; margin-left: auto; border-left: 0px; margin-right: auto; border-bottom: 0px" height="458" alt="" src="http://blog.briandicroce.com/wp-content/uploads/2009/04/image19.png" width="471" border="0" /> </p>
<p>With this little setup, I don’t need to go to either the ReSharper or ECMA’s website, not even launch Windows Explorer to look for those files.&#160; I have access to those files directly from Visual Studio.&#160; No more context switching.</p>
                        <p><br />
My name is Brian Di Croce, a passionate software developer living, coding, blogging and working in Montreal, Canada.  Feel free to visit my <a href="http://www.briandicroce.com">website/blog</a> for more great content related to software development with .NET! &copy;2007-2008<br />
</p>                        <div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=jh0uhHIyryo:HbI5ypmNDcY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=jh0uhHIyryo:HbI5ypmNDcY:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=jh0uhHIyryo:HbI5ypmNDcY:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=jh0uhHIyryo:HbI5ypmNDcY:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=jh0uhHIyryo:HbI5ypmNDcY:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/BrianDiCroce/~4/jh0uhHIyryo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.briandicroce.com/2009/04/19/quick-access-to-useful-documents-inside-visual-studio/feed/</wfw:commentRss>
		<feedburner:origLink>http://blog.briandicroce.com/2009/04/19/quick-access-to-useful-documents-inside-visual-studio/</feedburner:origLink></item>
		<item>
		<title>Three talks you should watch this week (Series #1)</title>
		<link>http://feedproxy.google.com/~r/BrianDiCroce/~3/NMEg_0BYFjw/</link>
		<comments>http://blog.briandicroce.com/2009/04/16/three-talks-you-should-watch-this-week-series-1/#comments</comments>
		<pubDate>Thu, 16 Apr 2009 11:00:00 +0000</pubDate>
		<dc:creator>Brian Di Croce</dc:creator>
		
		<category><![CDATA[Media/Presentations]]></category>

		<guid isPermaLink="false">http://blog.briandicroce.com/2009/04/16/three-talks-you-should-watch-this-week-series-1/</guid>
		<description>Whenever I can’t get myself too tired to go to sleep, or I’m on the bus commuting to work or to a client, or plain simply have an hour or two open in my schedule, I often fill it up watching a few talks online.  Though I’m passionate about software development and technology in general, [...]</description>
			<content:encoded><![CDATA[<p>Whenever I can’t get myself too tired to go to sleep, or I’m on the bus commuting to work or to a client, or plain simply have an hour or two open in my schedule, I often fill it up watching a few talks online.  Though I’m passionate about software development and technology in general, I don’t always focus entirely on it, as it isn’t very fulfilling for the imaginative mind.  Recently, I’ve listened to some great talks about technologists speaking about starting online businesses, marketing, life, faith, etc., which really pump me up to a level that makes me thankful to live, to dream and to achieve what I value most in life.  I’ll start making a series out of this one, as I believe it can be as helpful and motivating to you, as it is for me.  That being said, here are the first three talks I recommend you to watch this week:</p>
<ol>
<li value="1">David Heinemeier Hansson on <a href="http://www.omnisio.com/startupschool08/david-heinemeier-hansson-at-startup-school-08" target="_blank"><strong>The Secret To Making Money Online</strong></a> (less than 30 minutes)</li>
</ol>
<blockquote><p>In this talk given in 2008, David Heinemeier, the creator of the Ruby on Rails framework and partner at 37Signals, gives a very creative and down-to-earth talk on how to create a profitable startup company.</p></blockquote>
<ol>
<li value="2">Guy Kawasaki on <a href="http://www.zentation.com/viewer/index.php?passcode=epbcSNExIQr" target="_blank"><strong>The Art of Innovation</strong></a> (less than 60 minutes)</li>
</ol>
<blockquote><p>This is the first time I heard Guy Kawasaki speak.  This guy is a one of my “online heroes”.  He’s smart, he’s funny, and he speaks from experience.  In this talk, Guy talks about innovation about products, services and marketing.  He shares his experience from his work at Apple to now as a venture capitalist.  You’ll also learn about the 10-20-30 rule that can increase your chances in not only getting fund for your business, but most importantly, getting your point across.</p></blockquote>
<ol>
<li value="3">Joel Spolsky on <a href="http://vodpod.com/watch/1019132-joel-spolsky-at-railsconf-2008" target="_blank"><strong>What Makes a Great Software</strong></a> (less than 60 minutes)</li>
</ol>
<blockquote><p>This is a talk that Joel Spolsky, founder of Fogcreek Software, gave as a keynote at RailsConf 2008, where he shares his valuable insight in what <em>really</em> makes a great software, so much so that we can actually qualify the software as <em>great</em>.  His talk is fantastic: it’s entertaining, it’s focused and it’s without a doubt an eye-opener for software developers to watch out some common pitfalls that can make your software not being adopted at all by potential users.</p></blockquote>
                        <p><br />
My name is Brian Di Croce, a passionate software developer living, coding, blogging and working in Montreal, Canada.  Feel free to visit my <a href="http://www.briandicroce.com">website/blog</a> for more great content related to software development with .NET! &copy;2007-2008<br />
</p>                        <div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=NMEg_0BYFjw:gO1Emuz5bic:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=NMEg_0BYFjw:gO1Emuz5bic:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=NMEg_0BYFjw:gO1Emuz5bic:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=NMEg_0BYFjw:gO1Emuz5bic:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=NMEg_0BYFjw:gO1Emuz5bic:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/BrianDiCroce/~4/NMEg_0BYFjw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.briandicroce.com/2009/04/16/three-talks-you-should-watch-this-week-series-1/feed/</wfw:commentRss>
		<feedburner:origLink>http://blog.briandicroce.com/2009/04/16/three-talks-you-should-watch-this-week-series-1/</feedburner:origLink></item>
		<item>
		<title>The Architectural Journal, a quarterly journal about software architecture</title>
		<link>http://feedproxy.google.com/~r/BrianDiCroce/~3/mjyIKvXIo3A/</link>
		<comments>http://blog.briandicroce.com/2009/04/15/the-architectural-journal-a-quarterly-journal-about-software-architecture/#comments</comments>
		<pubDate>Wed, 15 Apr 2009 10:04:00 +0000</pubDate>
		<dc:creator>Brian Di Croce</dc:creator>
		
		<category><![CDATA[.NET Programming]]></category>

		<guid isPermaLink="false">http://blog.briandicroce.com/2009/04/15/the-architectural-journal-a-quarterly-journal-about-software-architecture/</guid>
		<description>Microsoft has many valuable resources for .NET developers under its MSDN umbrella: newsgroups, blogs, forums, magazines, etc.&amp;#160; One very valuable resource from Microsoft that seems to be ignored by most developers is The Architectural Journal:
The Architectural Journal is an independent platform for free thinkers and practitioners of IT architecture.&amp;#160; New editions are issued quarterly [...]</description>
			<content:encoded><![CDATA[<p><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; margin: 0px 0px 10px 10px; border-right-width: 0px" height="135" alt="image" src="http://blog.briandicroce.com/wp-content/uploads/2009/04/image17.png" width="102" align="right" border="0" /> Microsoft has many valuable resources for .NET developers under its MSDN umbrella: newsgroups, blogs, forums, magazines, etc.&#160; One very valuable resource from Microsoft that seems to be ignored by most developers is <a href="http://msdn.microsoft.com/en-us/architecture/bb410935.aspx" target="_blank"><strong>The Architectural Journal</strong></a>:</p>
<blockquote><p>The Architectural Journal is an independent platform for free thinkers and practitioners of IT architecture.&#160; New editions are issued quarterly with articles designed to offer perspective, share knowledge, and help you learn the discipline and pursue the art of IT architecture.&#160; The Architectural Journal reaches over 67,00 subscribers worldwide.</p>
</blockquote>
<p>I think one reason that it isn’t getting much attention is because its “feedless”, meaning you can’t directly subscribe to a feed, through your browser, that will notify you whenever a new issue has been published.&#160; So in order to get notified when a new issue has been published, you need to subscribe through a fairly simple, but tedious, <a href="http://msdn.microsoft.com/en-us/architecture/aa699369.aspx#Subscribe" target="_blank">subscription workflow</a>.&#160; Once subscribed, you’ll get the quarterly journal as a PDF as soon as it’s released.&#160; In short, here are the steps you should follow in order to subscribe to The Architectural Journal:</p>
<p>Go to the <a href="https://profile.microsoft.com/RegSysProfileCenter/SubCntDefault.aspx" target="_blank">e-newsletters page</a> in the <strong>Profile Center</strong>.&#160; You may be required to sign up for a Windows Live ID account if you don’t have one already.&#160; You may use your current email account or create a new one if you don’t have one.&#160; From there, you follow these three steps:</p>
<ol>
<li>Find <strong>The Architectural Journal</strong> in the list of available communications on the left and select it. </li>
<li>Press the <em>Subscribe</em> button.&#160; You should now see your choices in the list on the right. </li>
<li>Select your delivery format: HTML (suggested) or plain text. </li>
</ol>
<p><img title="" style="border-right: 0px; border-top: 0px; display: block; float: none; margin-left: auto; border-left: 0px; margin-right: auto; border-bottom: 0px" height="343" alt="" src="http://blog.briandicroce.com/wp-content/uploads/2009/04/image18.png" width="624" border="0" /> </p>
<p>(<u>Note</u>: it would’ve been much easier had someone put an RSS feed link instead.)</p>
<p>So that’s it! Now, you should be getting four issues per year.&#160; All great content about software architecture topics.&#160; All free.&#160; Past topics include:</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/architecture/dd129905.aspx" target="_blank">Distributed Computing</a></li>
<li><a href="http://msdn.microsoft.com/en-us/architecture/cc505966.aspx" target="_blank">The Role of an Architect</a></li>
<li><a href="http://msdn.microsoft.com/en-us/architecture/bb985491.aspx" target="_blank">Mobile Architecture</a></li>
<li><a href="http://msdn.microsoft.com/en-us/architecture/bb906058.aspx" target="_blank">Software + Services</a></li>
<li><a href="http://msdn.microsoft.com/en-us/architecture/bb735857.aspx" target="_blank">Web Architecture</a></li>
<li>And more.</li>
</ul>
<p>You can also skip the whole subscription process and <a href="http://msdn.microsoft.com/en-us/architecture/bb201656.aspx" target="_blank">directly download the current and previous issues</a> in English, French, Spanish, etc., as a compressed (ZIP) file.</p>
                        <p><br />
My name is Brian Di Croce, a passionate software developer living, coding, blogging and working in Montreal, Canada.  Feel free to visit my <a href="http://www.briandicroce.com">website/blog</a> for more great content related to software development with .NET! &copy;2007-2008<br />
</p>                        <div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=mjyIKvXIo3A:O_Zu13pb--k:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=mjyIKvXIo3A:O_Zu13pb--k:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=mjyIKvXIo3A:O_Zu13pb--k:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=mjyIKvXIo3A:O_Zu13pb--k:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=mjyIKvXIo3A:O_Zu13pb--k:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/BrianDiCroce/~4/mjyIKvXIo3A" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.briandicroce.com/2009/04/15/the-architectural-journal-a-quarterly-journal-about-software-architecture/feed/</wfw:commentRss>
		<feedburner:origLink>http://blog.briandicroce.com/2009/04/15/the-architectural-journal-a-quarterly-journal-about-software-architecture/</feedburner:origLink></item>
		<item>
		<title>My five favorite features in ReSharper 4.5</title>
		<link>http://feedproxy.google.com/~r/BrianDiCroce/~3/PQtSwJBzETM/</link>
		<comments>http://blog.briandicroce.com/2009/04/13/my-five-favorite-features-in-resharper-45/#comments</comments>
		<pubDate>Mon, 13 Apr 2009 22:37:42 +0000</pubDate>
		<dc:creator>Brian Di Croce</dc:creator>
		
		<category><![CDATA[ReSharper]]></category>

		<guid isPermaLink="false">http://blog.briandicroce.com/2009/04/13/my-five-favorite-features-in-resharper-45/</guid>
		<description>With the recent release of ReSharper 4.5, many productive features have been added to this already great product, such as performance and memory usage improvements, solution-wide code inspections, VB9 support, and many more.&amp;#160; I’ve been using ReSharper as my pair programmer for many years as it helps me to enhance my C# refactoring whenever I [...]</description>
			<content:encoded><![CDATA[<p>With the recent release of <a href="http://www.jetbrains.com/resharper/index.html" target="_blank">ReSharper</a> 4.5, many productive <a href="http://www.jetbrains.com/resharper/features/index.html" target="_blank">features</a> have been added to this already great product, such as performance and memory usage improvements, solution-wide code inspections, VB9 support, and many more.&#160; I’ve been using ReSharper as my <em>pair programmer</em> for many years as it helps me to enhance my C# refactoring whenever I overlook some portions of code I’m writing, as well as to manage my unit tests.&#160; In this post, I will concentrate on sharing with you my five most favorite new features in ReSharper 4.5.</p>
<h4>1. Find dependent or referenced code</h4>
<p>Using this new feature, you can find dependent or referenced code at either a project or file level.&#160; Before going forward with this feature, it is important to understand what is meant by “dependent code” and “referenced code”.&#160; Both of these terms have to do with dependencies/coupling.&#160; When you ask ReSharper to tell you the <strong>dependent code at the project level</strong>, you are actually asking it to tell you which other projects (or assemblies) are dependent on that specific project.&#160; On the other hand, when you ask ReSharper to tell you the <strong>referenced code at the project level</strong>, you are asking it to tell you which other projects (or assemblies) that specific project depends on.&#160; For example, suppose the following UML class diagram:</p>
<p><img title="" style="border-top-width: 0px; display: block; border-left-width: 0px; float: none; border-bottom-width: 0px; margin-left: auto; margin-right: auto; border-right-width: 0px" height="271" alt="" src="http://blog.briandicroce.com/wp-content/uploads/2009/04/image6.png" width="309" border="0" /> </p>
<p>In this scenario, I have four different assemblies: one client console executable (Client), and three class libraries (Provider, Utilities and SecurityManager).&#160; Our Client executable references the three other assemblies because it’ll make use of their services.&#160; Those references were created when I asked Visual Studio to add me the references for those three projects at the project level.&#160; Now, if I were to ask ReSharper to tell me the <strong>dependent code at the project level</strong> (which means that you right-click on the Client project in the Solution Explorer, and then click on the <em>Find Dependent Code</em> contextual menu item), a message box will appear telling me that “Code dependent on project ‘Client.csproj’ was not found”:&#160; </p>
<p><img title="" style="border-top-width: 0px; display: block; border-left-width: 0px; float: none; border-bottom-width: 0px; margin-left: auto; margin-right: auto; border-right-width: 0px" height="171" alt="" src="http://blog.briandicroce.com/wp-content/uploads/2009/04/image7.png" width="422" border="0" /> </p>
<p>This is normal, because according to our class diagram above, Client has an <strong>afferent coupling</strong> of zero (Ca = 0).&#160; </p>
<blockquote><p><strong>Afferent coupling</strong>(s) is the number of class(es) outside this component (<em>i.e.,</em> Client) that depend on classes within this component (<em>i.e.,</em> Client).&#160; </p>
</blockquote>
<p>On the other hand, if we were to ask ReSharper to tell us the <strong>referenced code at the project level</strong> (for Client), by this time clicking on the <em>Find Referenced Code</em> contextual menu item, you will get the following results:</p>
<p><img title="" style="border-top-width: 0px; display: block; border-left-width: 0px; float: none; border-bottom-width: 0px; margin-left: auto; margin-right: auto; border-right-width: 0px" height="570" alt="" src="http://blog.briandicroce.com/wp-content/uploads/2009/04/image8.png" width="463" border="0" /> </p>
<p>In this case, ReSharper is telling us the types which are being used in that specific project (Client), even .NET types and assemblies like mscorlib.dll.&#160; Since the Client class has a positive non-zero <strong>efferent coupling</strong> (Ce &gt; 0), we actually get a result.</p>
<blockquote><p><strong>Efferent coupling</strong>(s) is the number of classes inside this component (<em>i.e.,</em> Client) that depend on classes outside this component (<em>i.e.,</em> Client).</p>
</blockquote>
<p>These results could look daunting at first sight, but that’s because the results window is showing too much information.&#160; All you have to do to get a more simplistic and lighter view of the results is simply to click on the <em>Filter Usages</em> button (that’s the one surrounded in red in the screenshot below) and unselect the <em>Show Attribute Usage</em> from the proposed choices, as you don’t really care that you’re depending on the AssemblyAttribute class for example.&#160; Furthermore, you should also click on the <em>Merge Occurences on the Same Line</em> button (that’s the one surrounded in green in the screenshot below), so that you eliminate some of the redundancy usages on the same line.&#160; Finally, choose an appropriate view to group your results (in this case, I have chosen to group the results by Namespaces and Types.&#160; That’s the one surrounded in blue in the screenshot below).&#160; This will give you the following (much more compact) result view:</p>
<p><img title="" style="border-top-width: 0px; display: block; border-left-width: 0px; float: none; border-bottom-width: 0px; margin-left: auto; margin-right: auto; border-right-width: 0px" height="324" alt="" src="http://blog.briandicroce.com/wp-content/uploads/2009/04/image9.png" width="463" border="0" /> </p>
<blockquote><p>NOTE: If you only reference external projects or assemblies in a project without actually using the public types or members in those external dependencies, ReSharper will not tell you that you are actually referencing those dependencies.&#160; This is pretty slick, as you can visually know whether or not a reference is unnecessary, and thus proceed with its removal.</p>
</blockquote>
<p>Ah, much better! And you know what?&#160; That’s pretty much right, because the Client class is actually using those classes (Provider, SecurityManager and Utilities), as shown in the screenshot below:</p>
<p><img title="" style="border-top-width: 0px; display: block; border-left-width: 0px; float: none; border-bottom-width: 0px; margin-left: auto; margin-right: auto; border-right-width: 0px" height="172" alt="" src="http://blog.briandicroce.com/wp-content/uploads/2009/04/image10.png" width="574" border="0" /> </p>
<p>At the <strong>file level</strong>, you only get to ask ReSharer to tell you the referenced code, through the <em><strong>Find Referenced Code</strong></em> contextual menu item.&#160; In this case, the results will include any type being used in that file.&#160; Suppose for example that in the SecurityManager class, you’re using an instance of a Logging class to log some errors in a few critical methods.&#160; In that case, the results will include the Logging class, as it is a type being referenced in that file.&#160; So far, so smart.</p>
<h4>2. Go to implementation (Ctrl+Shift+Alt+B)</h4>
<p>This one is pretty simple and very much useful.&#160; Suppose you have the following class hierarchy:</p>
<p><img title="image" style="border-top-width: 0px; display: block; border-left-width: 0px; float: none; border-bottom-width: 0px; margin-left: auto; margin-right: auto; border-right-width: 0px" height="367" alt="image" src="http://blog.briandicroce.com/wp-content/uploads/2009/04/image11.png" width="450" border="0" /> </p>
<p>In the previous versions of ReSharper, you couldn’t ask the tool to directly tell you which concrete classes derived from an abstract type.&#160; Instead, you had to select the abstract type and ask it to tell you the derived types (or inheritors) through the Ctrl+Alt+B shortcut, which would give you a list of all the types deriving from that abstract type…even if those derived types were abstract themselves.&#160; This was pretty frustrating when you had a hierarchy with a lot of abstract relationships amongst types, as it was the case in one WCF-driven project I was involved in, because you would lose a couple of seconds filtering out the concrete types from the abstract ones in the results list.&#160; Well, that’s an old story because now you can get the list of all the concrete types (or implementation types) directly from a new shortcut: <strong>Ctrl+Shift+Alt+B</strong>, or through the “Go to implementation” command in the “Go to” navigation menu.&#160; For example, if you asked ReSharper to tell you the concrete classes for IProvider, it’ll tell you that MembershipProvider and SecurityProvider are the only ones.&#160; It will ignore ProviderBase, as it is abstract.&#160; Well done!</p>
<h4>3. Naming styles</h4>
<p>With ReSharper 4.5, we get more flexibility in the naming style department.&#160; You can apply either a common naming style for both C# and VB code, or set one differently for each of them.&#160; It’s up to you.&#160; The UI interface to manage the naming styles is pretty simple.&#160; Here, for example, is the Naming Style window pertaining to both C# and VB:</p>
<p><img title="" style="border-top-width: 0px; display: block; border-left-width: 0px; float: none; border-bottom-width: 0px; margin-left: auto; margin-right: auto; border-right-width: 0px" height="715" alt="" src="http://blog.briandicroce.com/wp-content/uploads/2009/04/image12.png" width="734" border="0" /> </p>
<p>So you get a list of predefined styles out-of-the-box which might suit most of your basic needs.&#160; The flexibility offered by these features comes in handy when you want to create new styles, modify some existing ones, etc.&#160; Suppose you want to add a new naming style for private fields only, and make them prefixed by an underscore.&#160; You would simply click on the “Add” button under the <em>User defined naming rules</em> panel, which will show the following window:</p>
<p>&#160;<img title="" style="border-top-width: 0px; display: block; border-left-width: 0px; float: none; border-bottom-width: 0px; margin-left: auto; margin-right: auto; border-right-width: 0px" height="555" alt="" src="http://blog.briandicroce.com/wp-content/uploads/2009/04/image13.png" width="739" border="0" /> </p>
<p>All I have to do is select the affected entities, which in this case would be “Field” and “Readonly field”.&#160; Then I would specify the access modifiers, which sould be Private and Protected. Following that, I will specify the underscore as the name prefix and tick the lowerCamelCase naming style, as to be follow the <a href="http://msdn.microsoft.com/en-us/library/ms229042.aspx" target="_blank">.NET design guidelines</a>.&#160; Finally, I would set the rule description to something explicit, such as “Private fields”.&#160; That’s it!&#160; Now I can save and share the code style file with my team.</p>
<h4>4. Collapse all project nodes (in Solution Explorer)</h4>
<p>Suppose you have the following project structure in Solution Explorer:</p>
<p><img title="" style="border-top-width: 0px; display: block; border-left-width: 0px; float: none; border-bottom-width: 0px; margin-left: auto; margin-right: auto; border-right-width: 0px" height="612" alt="" src="http://blog.briandicroce.com/wp-content/uploads/2009/04/image14.png" width="277" border="0" /> </p>
<p>This would be a very typical folder structure in an ASP.NET MVC project, for example.&#160; Every time you collapse the node associated with the SecurityManager project, and you expand it later, you will see the same result as above.&#160; This can be very frustrating when you have dozens of projects with their child nodes expanded in a similar way in Solution Explorer, and God forbid you have also expanded the References node, because it tends to visually pollute the Solution Explorer.&#160; ReSharper 4.5 introduced a new feature that allows you to definitively collapse a node, be it a folder or the project node itself, so that the next time you expand the root node, the previously collapsed node stays closed!&#160; This might sound like nothing, but have you ever calculated how many seconds you probably were wasting trying to navigate the Solution Explorer when you have a multitude of projects with folders, or solution folders, all open at the same time even though you don’t really need them to be?&#160; That’s not being productive.&#160; That’s not being professional.</p>
<p>So here’s the trick: when you’re done with one node and you need to collapse it for good, simply right-click on it in the Solution Explorer, and choose “<strong>Collapse All</strong>”.&#160; This would permanently collapse the node until you explicitly expand it again.&#160; For example, if I decide to execute this “Collapse All” command on the Users folder, then each time I expand the SecurityManager node, the Users folder will stay collapsed, until I explicitly expand it.&#160; In my opinion, this should’ve been a standard option for Visual Studio.&#160; Good thinking once again!</p>
<h4>5. Inline field (Ctrl+Alt+N)</h4>
<p>The fifth of my favorite new features in ReSharper 4.5 is the possibility to inline a field.&#160; As to tweak the original <a href="http://www.refactoring.com/catalog/inlineTemp.html" target="_blank">Inline Temp</a> refactoring definition to suit this one: </p>
<blockquote><p><em>You have a <strong>field</strong> that is assigned to once with a simple expression, and the <strong>field</strong> is getting in the way of other refactorings.&#160; Replace all references to that <strong>field</strong> with the expression.</em></p>
</blockquote>
<p>I think that little definition sums it up well what Inline Field does.&#160; Simply highlight the field, then hit the <strong>Ctrl+Alt+N</strong> shortcut, and you’re done.&#160; Here’s a last example.&#160; Suppose you have the following class definition:</p>
<p><img title="" style="border-top-width: 0px; display: block; border-left-width: 0px; float: none; border-bottom-width: 0px; margin-left: auto; margin-right: auto; border-right-width: 0px" height="258" alt="" src="http://blog.briandicroce.com/wp-content/uploads/2009/04/image15.png" width="530" border="0" /> </p>
<p>As you can see, the <em>someString</em> field is used only once in this class, which is pretty much useless.&#160; In that case, I will place my cursor on it, then hit Ctrl+Alt+N to have it inlined:</p>
<p><img title="" style="border-top-width: 0px; display: block; border-left-width: 0px; float: none; border-bottom-width: 0px; margin-left: auto; margin-right: auto; border-right-width: 0px" height="230" alt="" src="http://blog.briandicroce.com/wp-content/uploads/2009/04/image16.png" width="454" border="0" /> </p>
<p>And that’s it! Now through all the code, the field’s expression will be inlined.&#160; This was a simple scenario, but I’m sure you can think how useful this refactoring could be in your codebase.</p>
<p><strong>[UPDATE: 2009-04-14]</strong> The <em>Inline Field</em> refactoring also works to inline methods and properties, not only fields! This is very sweet.&#160; They should call this command <em>Inline Construct</em> as it doesn’t just inline fields.</p>
<h4>But there’s more!!!</h4>
<p>Of course, my list of favorite new features in ReSharper 4.5 isn’t the whole story behind this new release.&#160; For a complete list of new feature in ReSharper 4.5, I’ll invite you to review its <a href="http://www.jetbrains.com/resharper/features/newfeatures.html" target="_blank">What’s New in ReSharper 4.5</a> features page. ReSharper is getting better and better through each release, and I can’t wait to see what the team is going to include in the 5.0 release.&#160; But meanwhile, if you haven’t upgraded to this new version, I urge you to do so.&#160; Plus, the upgrade is free if you’re already a ReSharper 4.x licensee, so you really have no excuse.&#160; And if you’re not currently using ReSharper at all, then I hope that the following post has incited you to ask your tech lead or manager to get a license for it (I would suggest to start with the trial, then demo it to your group).&#160; I’ll also invite you to read my post on <a href="http://blog.briandicroce.com/2008/05/12/the-case-for-resharper-in-the-enterprise/" target="_blank"><strong>The Case for ReSharper in the Enterprise</strong></a> which might give you some pointers on the necessity of this tool in your development toolbox.</p>
                        <p><br />
My name is Brian Di Croce, a passionate software developer living, coding, blogging and working in Montreal, Canada.  Feel free to visit my <a href="http://www.briandicroce.com">website/blog</a> for more great content related to software development with .NET! &copy;2007-2008<br />
</p>                        <div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=PQtSwJBzETM:Atlx7fwwRxg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=PQtSwJBzETM:Atlx7fwwRxg:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=PQtSwJBzETM:Atlx7fwwRxg:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=PQtSwJBzETM:Atlx7fwwRxg:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=PQtSwJBzETM:Atlx7fwwRxg:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/BrianDiCroce/~4/PQtSwJBzETM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.briandicroce.com/2009/04/13/my-five-favorite-features-in-resharper-45/feed/</wfw:commentRss>
		<feedburner:origLink>http://blog.briandicroce.com/2009/04/13/my-five-favorite-features-in-resharper-45/</feedburner:origLink></item>
		<item>
		<title>Book Review #10: 97 Things Every Software Architect Should Know</title>
		<link>http://feedproxy.google.com/~r/BrianDiCroce/~3/rWxPnSfoUOM/</link>
		<comments>http://blog.briandicroce.com/2009/04/12/book-review-10-97-things-every-software-architect-should-know/#comments</comments>
		<pubDate>Sun, 12 Apr 2009 13:09:06 +0000</pubDate>
		<dc:creator>Brian Di Croce</dc:creator>
		
		<category><![CDATA[Books]]></category>

		<guid isPermaLink="false">http://blog.briandicroce.com/2009/04/12/book-review-10-97-things-every-software-architect-should-know/</guid>
		<description>What started as an article a few years ago, titled 10 Things Every Software Architect Should Know, has morphed into a collection of essays written by software professionals and for software professionals. The author of the original article, Richard Monson-Haefel, did well on following the suggestion of Jay Zimmerman to publish a book as a [...]</description>
			<content:encoded><![CDATA[<p><a href="http://www.amazon.com/Things-Every-Software-Architect-Should/dp/059652269X%3FSubscriptionId%3D0JTCV5ZMHMF7ZYTXGFR2%26tag%3Dbrdicr-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D059652269X" target="_blank"><img style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; margin: 0px 0px 10px 10px; border-right-width: 0px" title="image" src="http://blog.briandicroce.com/wp-content/uploads/2009/04/image5.png" border="0" alt="image" width="180" height="260" align="right" /></a></p>
<p>What started as an article a few years ago, titled <a href="http://www.slideshare.net/oreillymedia/oreilly-webcast-ten-things-every-software-architect-should-know"><em>10 Things Every Software Architect Should Know</em></a>, has morphed into a collection of essays written by software professionals and for software professionals. The author of the original article, <a href="http://www.monson-haefel.com/" target="_blank">Richard Monson-Haefel</a>, did well on following the suggestion of Jay Zimmerman to publish a book as a collection of essays sharing pragmatic experience, wisdom, insight and diversity in the field of software architecture.  From the back cover, we can read the following:</p>
<blockquote><p><em>In this truly unique technical book, today’s leading software architects present valuable principles on key development issues that go way beyond technology.  More than four dozen architects - including Neal Ford, Michael Nygard, and Bill de hÒra - offer advice for communicating with stakeholders, eliminating complexity, empowering developers, and many more practical lessons they’ve learned from their years of experience.</em></p></blockquote>
<p>Published by O’Reilly, “<a href="http://www.amazon.com/Things-Every-Software-Architect-Should/dp/059652269X%3FSubscriptionId%3D0JTCV5ZMHMF7ZYTXGFR2%26tag%3Dbrdicr-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D059652269X"><strong>97 Things Every Software Architect Should Know</strong></a>” turns out to be authored by a multitude of different people from around the world and from diverse companies.  The common point of interest amongst all the contributors is their role on the job, that of a software architect.  As the title suggests, there are in fact 97 different essays written by many practicing software professionals that were willing to share their experience, wisdom, proven techniques, mistakes, lessons learned, etc., about their profession and role of that of a software architect.</p>
<p>But what exactly is a software architect?  Though there isn’t a specific definition for that title, there are many accepted ones.  According to Wikipedia (<a href="http://en.wikipedia.org/wiki/Chief_Software_Architect">source</a>),</p>
<blockquote><p>Despite the lack of an accepted overall definition, the role of software architect generally has certain common traits:</p>
<p><strong>Strategic thinking<br />
</strong>Architects address the technological aspects of business needs by considering <em>what</em> a given technology can contribute to the overall functions of the system, as distinct from <em>how</em> that technology will perform its own functions.  This encourages opportunities for re-use of the technology and ultimately contributes to the organization’s efficiency.</p>
<p><strong>System interactions<br />
</strong>Architects deal with the interactions of systems, whether between components written in different languages at different time and at different locations, or between components of the same software system that use the same coding language.</p>
<p><strong>Design<br />
</strong>The architect makes high-level design choices much more often that low-level choices.  In addition, the architect may sometimes dictate technical standards, including coding standards, tools, or platforms, so as to advance business goals rather than to place arbitrary restrictions on the choices of developers.</p>
<p><strong>Communication<br />
</strong>Architects also have to communicate effectively, not only to understand the business needs, but also to advance their own architectural vision.</p></blockquote>
<p>As there are many different traits pertaining to software architecture, there also many different roles a software architect can play, be it: Enterprise Architect, Application Architect, Infrastructure Architect, Security Architect, etc.  As the author acknowledges,</p>
<blockquote><p>“97 Things Every Software Architected Should Know” provides advice from software architects around the world on everything from how to avoid common pitfalls to how to build talented teams.  It’s a smorgasbord of advice from established software architects for other software architects or those who aspire to become software architects.</p></blockquote>
<p>Throughout the book, you will find many essays dealing with at least one of these traits and some specific to a role.  The essays aren’t categorized in any way, so each one you read can deal with something different than a previous one, which might be a good idea…or not.  I would’ve preferred if the essays were categorized by traits (or other subject) so that I can focus my reading on a group of them when I want or need to.  For example, if I want to read some essays pertaining to effective team building, I could focus on reading a subset of those essays.  As it stands, I have no much choice but to read each of them sequentially, which can become quite tedious as some essays can be lightly equivalent to another in terms of idea and interest.  Nevertheless, since the content of the essays are rich, insightful and resourceful, I don’t mind too much about the overall layout.  On a last note about the structure of the book, I was very pleased to see that each essay was presented on a two-page presentation (left page and right page).  In other words, if you turn a page, you get a new essay.  At the end of each essay, you also get a brief bio of the author who wrote it so that you can either stalk him…or Google him.  Finally, there aren’t only male authors who contributed in this project.  As a matter of fact, <a href="http://www.lohutok.net/">Allison Randal</a> and <a href="http://www.thoughtworks.ca/who-we-are/leadership-profiles/rebecca-parsons.html">Rebecca Parsons</a> (CTO of ThoughtWorks) also contributed their own insights.</p>
<p>Many of the co-authors that participated in this project were unknown to me, so reading this book actually allow me to plug into the world of some them through their personal websites or blogs.  Amongst the list of people who contributed to the book are <a href="http://erik.doernenburg.com/">Erik Doernenburg</a>, <a href="http://www.udidahan.com/">Udi Dahan</a>, <a href="http://niclasnilsson.se/">Niclas Nilsson</a>, <a href="http://www.nealford.com/">Neal Ford</a>, <a href="http://peripateticaxiom.blogspot.com/">Keith Braithwaite</a>, <a href="http://www.eaipatterns.com/ramblings.html">Gregor Hohpe</a>, and many, many more.  Funny thing is that two articles that I very much enjoyed  much reading were written by a guy I’ve never heard of before: <a href="http://timhigh.wordpress.com/">Timothy High</a>, a software architect working for Sakonnet Technologies.  In fact, he’s the author of two of my favorite essays in the book: the first one being <em><strong>Empower Developers</strong></em>, in which he urges managers and architects to essentially “<em>protect developers from nonessential parts of their job.  Too much paperwork and too many office chores add overhead and reduce their effectiveness.</em>” and making sure developers have the tools, the skills and the trust necessary to get the job done; and the second one being <em><strong>Record Your Rationale</strong></em> where he suggests that architects should write down their rationale behind some of their technical decisions, as it may come in handy in a number of situations, as he writes:</p>
<ul>
<li><em>As a means of communication to developers regarding important architectural principles that should be followed</em></li>
<li><em>To get the team “on the same page,” or even head off a mutiny, when developers question the logic behind the architecture (or even to humbly accept criticism if it turns out a decision doesn’t hold up under scrutiny)</em></li>
<li><em>To show managers and stakeholders exactly why the software is being built the way it is (such as why an expensive piece of hardware or software is necessary)</em></li>
<li><em>When handing off the project to a new architect (how many time have you inherited a piece of software and wondered exactly why the designers did it THAT way?)</em></li>
</ul>
<p>Another interesting thing about this book is that O’Reilly agreed that all of the <a href="http://oreilly.com/catalog/9780596522698/preview.html">content of the essays</a> should be freely available (<a href="http://en.wikipedia.org/wiki/Creative_Commons_licenses">Creative Commons</a>) for to anyone through the book’s website.  Excellent idea, O’Reilly!</p>
<p>In essence, this book is all about software architecture, but not <em>only</em> for software architecture, but rather anyone involved in the software development lifecycle (testers, developers, QA, analysts) and even up the corporate ladder (CIO or CTO).  The content being technology-agnostic, there’s no doubt that the audience for this book will be heterogeneous, so whether you’re a .NET, Java or Ruby fan, you will surely find the essays valuable.  And just like the <a href="http://headfirstlabs.com/" target="_blank">Head First</a> series, this book has sprung another series focused on a “97 Things Every [fill in the blank] Should Know” idea.  [Note from my wife, the environmentalist: “There goes more trees!”].  If you’re a developer aspiring to take on more responsibilities and challenges for a software project, I would highly recommend you get a copy of this book.  Furthermore, I would also recommend reading a good complement for this book: “<a href="http://download.microsoft.com/download/3/d/7/3d718c6c-e5f3-41e3-b346-6e9f114e2531/journal15_english.pdf.zip">The Role of an Architect</a>” published by <a href="http://msdn.microsoft.com/en-us/architecture/bb410935.aspx">The Architectural Journal</a><em></em> (Microsoft).</p>
<p><strong>[UPDATE: 2008-04-15]</strong> You can also read the <a href="http://97-things.near-time.net/wiki/other-things-software-architects-should-know">other proposals which didn&#8217;t make it to the final cut</a>.</p>
                        <p><br />
My name is Brian Di Croce, a passionate software developer living, coding, blogging and working in Montreal, Canada.  Feel free to visit my <a href="http://www.briandicroce.com">website/blog</a> for more great content related to software development with .NET! &copy;2007-2008<br />
</p>                        <div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=rWxPnSfoUOM:XTxt2c5hlAE:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=rWxPnSfoUOM:XTxt2c5hlAE:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=rWxPnSfoUOM:XTxt2c5hlAE:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=rWxPnSfoUOM:XTxt2c5hlAE:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=rWxPnSfoUOM:XTxt2c5hlAE:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/BrianDiCroce/~4/rWxPnSfoUOM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.briandicroce.com/2009/04/12/book-review-10-97-things-every-software-architect-should-know/feed/</wfw:commentRss>
		<feedburner:origLink>http://blog.briandicroce.com/2009/04/12/book-review-10-97-things-every-software-architect-should-know/</feedburner:origLink></item>
		<item>
		<title>Published my first Windows Live Writer plugin: Amazon Book Linker v1.0</title>
		<link>http://feedproxy.google.com/~r/BrianDiCroce/~3/nrezP4yviw0/</link>
		<comments>http://blog.briandicroce.com/2009/04/06/published-my-first-windows-live-writer-plugin-amazon-book-linker-v10/#comments</comments>
		<pubDate>Mon, 06 Apr 2009 14:58:49 +0000</pubDate>
		<dc:creator>Brian Di Croce</dc:creator>
		
		<category><![CDATA[Projects]]></category>

		<category><![CDATA[amazon book linker]]></category>

		<guid isPermaLink="false">http://blog.briandicroce.com/2009/04/06/published-my-first-windows-live-writer-plugin-amazon-book-linker-v10/</guid>
		<description>Well, after using Windows Live Writer as my default blogging platform for quite some time, I decided to play around with the provided API to build a little plugin which will speed up the process of finding and linking books from Amazon directly to a blog post.
Amazon Book Linker v1.0 is a free plugin for [...]</description>
			<content:encoded><![CDATA[<p>Well, after using <a href="http://download.live.com/writer">Windows Live Writer</a> as my default blogging platform for quite some time, I decided to play around with the provided API to build a little plugin which will speed up the process of finding and linking books from Amazon directly to a blog post.</p>
<p><a href="http://gallery.live.com/liveItemDetail.aspx?li=0aeb208a-81d1-4197-bbce-b4a42f5ec430&amp;pl=8&amp;bt=9">Amazon Book Linker v1.0</a> is a free plugin for Windows Live Writer which provides many innovative functionalities for searching and linking books from Amazon on your blog post.&#160; It allows you to specify your own Amazon Associate Tag to every link (you only have to provide this information once, and the plugin will remember it next time) so that you can make a sales commission out of a direct sale from one of the links.&#160; Furthermore, it empowers the HTML <em>ninja</em> (or <em>ninjette</em>) to also customize the HTML template to better match the link layout to your own design.&#160; In order to assist you with this process, the plugin also lists you a series of predefined macros to use.&#160; You can also choose your preferred Amazon locale (US, CA, CO.UK, JP, FR or DE) too!</p>
<p>For more information, I’ll invite you to check the brand new <a href="http://blog.briandicroce.com/projects/"><strong>Projects</strong></a> page on this site.&#160; Meanwhile, here are a few screenshots.</p>
<p><img title="image" style="border-top-width: 0px; display: block; border-left-width: 0px; float: none; border-bottom-width: 0px; margin-left: auto; margin-right: auto; border-right-width: 0px" height="648" alt="image" src="http://blog.briandicroce.com/wp-content/uploads/2009/04/image3.png" width="516" border="0" /> </p>
<p><img title="image" style="border-top-width: 0px; display: block; border-left-width: 0px; float: none; border-bottom-width: 0px; margin-left: auto; margin-right: auto; border-right-width: 0px" height="265" alt="image" src="http://blog.briandicroce.com/wp-content/uploads/2009/04/image4.png" width="477" border="0" /> </p>
<p>Now that this little project is out the door, I can resume posting new ideas on our beloved craft and technologies. <img src='http://blog.briandicroce.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
                        <p><br />
My name is Brian Di Croce, a passionate software developer living, coding, blogging and working in Montreal, Canada.  Feel free to visit my <a href="http://www.briandicroce.com">website/blog</a> for more great content related to software development with .NET! &copy;2007-2008<br />
</p>                        <div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=nrezP4yviw0:3vW4sOxHbws:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=nrezP4yviw0:3vW4sOxHbws:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=nrezP4yviw0:3vW4sOxHbws:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=nrezP4yviw0:3vW4sOxHbws:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=nrezP4yviw0:3vW4sOxHbws:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/BrianDiCroce/~4/nrezP4yviw0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.briandicroce.com/2009/04/06/published-my-first-windows-live-writer-plugin-amazon-book-linker-v10/feed/</wfw:commentRss>
		<feedburner:origLink>http://blog.briandicroce.com/2009/04/06/published-my-first-windows-live-writer-plugin-amazon-book-linker-v10/</feedburner:origLink></item>
		<item>
		<title>Dear VB Developer…</title>
		<link>http://feedproxy.google.com/~r/BrianDiCroce/~3/CnkN55AmLSQ/</link>
		<comments>http://blog.briandicroce.com/2009/03/10/dear-vb-developer/#comments</comments>
		<pubDate>Wed, 11 Mar 2009 03:15:52 +0000</pubDate>
		<dc:creator>Brian Di Croce</dc:creator>
		
		<category><![CDATA[.NET Programming]]></category>

		<guid isPermaLink="false">http://blog.briandicroce.com/2009/03/10/dear-vb-developer/</guid>
		<description>Whenever someone coming from a VB6 background asks me which language they should adopt to learn .NET, I recommend them C#.  I know that, intuitively, I should tell them to embark the journey with Visual Basic.NET (VB.NET) since that language should already be familiar to them.  However, the familiarity of the language is mostly a [...]</description>
			<content:encoded><![CDATA[<p>Whenever someone coming from a VB6 background asks me which language they should adopt to learn .NET, I recommend them C#.  I know that, intuitively, I should tell them to embark the journey with Visual Basic.NET (VB.NET) since that language should already be familiar to them.  However, the familiarity of the language is mostly a costume on its own, since underneath it lives a totally different beast.  The VB.NET compiler now speaks a very different language than its VB6 cousin did: <strong>the language of the object-oriented paradigm</strong>.  Though the first release version of Visual Basic for the .NET platform was an increment of VB6’s, Visual Basic v7.0, I consider it to be more of a v1.0, because it’s much more than a major revision.  Yes, the language is very much the same, but not the compiler.  According to Microsoft,</p>
<blockquote><p>“<em>Visual Basic .NET is not Visual Basic 6 with inheritance tacked onto it.  Rather, Visual Basic .NET has been <strong>entirely rewritten</strong> to be fully object-oriented.”</em> <em>For a programming language to be a true OOP language, the language must meet the following criteria:</em></p>
<ul>
<li><em><strong>Abstraction</strong>: Abstraction manages the complexities of a business problem by allowing you to identify a set of objects involved with that business problem.</em></li>
<li><em><strong>Encapsulation</strong>: Encapsulation hides the internal implementation of an abstraction within the particular object.</em></li>
<li><em><strong>Polymorphism</strong>: Polymorphism provides for multiple implementations of the same method.  For example, different objects can have a Save method, each of which perform different processing.</em></li>
<li><em><strong>Inheritance</strong>: The excitement of Visual Basic .NET lies in inheritance.  Visual Basic 5 introduced the concept of interface inheritance, which allows you to reuse the interface of a class, but not its implementation.  Visual Basic .NET provides for true implementation inheritance whereby you can reuse the implementation of a class. </em>[Source: <a href="http://msdn.microsoft.com/en-us/library/aa289512.aspx">MSDN</a>]</li>
</ul>
</blockquote>
<p>Chances are that a VB6 veteran, that has been programming with VB since its earliest versions, will tend to write VB.NET code in a more traditional “procedural” way, instead of an “object-oriented” way. This is sad because .NET itself is not only built around, but also provides a rich object-oriented model for programming.  However, that doesn’t rattle my cage too much, because with enough practice and mentorship, they <em>could</em> learn to embrace the OO way of analysis, design and programming, as well as to appreciate its <a href="http://www.rtis.com/nat/user/jfullerton/BENEFIT.HTM">benefits</a>.  What rather tends to rattle my cage is that I said <em>could</em> (in <em>italic</em> in case you haven’t noticed) because there’s not much out there that benefit Visual Basic (VB6 and VB.NET) programmers to really appreciate the OO paradigm to its fullest.</p>
<p>C++ and Java programmers coming to .NET via C# tend to reap more of the benefits from the platform than VB6 developers do when jumping on the .NET wagon with VB.NET, because they are already minded to the OO way of doing things.  I think the main reason that makes this balance shift more on one side than the other is because there is just SO MUCH MORE resources (open-source projects, books, blog posts, articles, training, etc.) that focus on the C-family languages, such as C++, JavaScript and C# (for the sake of this post, I will also include Java in this family).  OO concepts such as inheritance, encapsulation, polymorphism, and constructs such as interfaces or abstract classes, tends to be very hard subjects to grasp for VB6 and VB.NET developers (on a professional level, I can only support this fact through those same comments I get from VB developers taking my VB.NET courses and from fellow developers at user groups).   The VB development community will be in a much better position to take advantage of the OO model, the same way that C++, Java and C# developers did, if for every OO book, article or blog posts, there would be the equivalent counterpart code samples in VB.  Last time I checked on Amazon, there wasn’t many books focused on <a href="http://en.wikipedia.org/wiki/Design_pattern_(computer_science)">design patterns</a> for Visual Basic developers.  However, there is a ton available for C++, Java, C# and even Ruby developers.  It’s hard for VB developers to grasp the essence of design patterns if they struggle to understand the concept of inheritance and polymorphism.</p>
<p>You know what?  Let’s dig a little deeper on the programming books case.  Table 1 shows the total number of books found in Amazon for Visual Basic, C#, C++ and Java:</p>
<p style="text-align: center;"><strong>Table 1</strong>. Books results for various programming languages at Amazon.com (search made on March 10th, 2009)</p>
<div>
<table border="1" cellspacing="0" cellpadding="2" width="600" align="center">
<tbody>
<tr>
<td width="150" valign="top">
<p style="text-align: center;">Visual Basic</p>
</td>
<td width="149" valign="top">
<p style="text-align: center;">C#</p>
</td>
<td width="149" valign="top">
<p style="text-align: center;">C++</p>
</td>
<td width="150" valign="top">
<p style="text-align: center;">Java (not JavaScript)</p>
</td>
</tr>
<tr>
<td width="150" valign="top">
<p style="text-align: center;"><strong>12,788 </strong>books</p>
</td>
<td width="149" valign="top">
<p style="text-align: center;"><strong>16,527 </strong>books</p>
</td>
<td width="149" valign="top">
<p style="text-align: center;"><strong>22,248</strong> books</p>
</td>
<td width="151" valign="top">
<p style="text-align: center;"><strong>64,158</strong> books</p>
</td>
</tr>
</tbody>
</table>
</div>
<p><br/>&nbsp;<br />
This is very shocking, because if my memory serves me well, Visual Basic is much older than C# and Java! I’m going to spare you the proportions for each of these books, because I think the numbers speak for themselves.  However, I do want you to notice something important: if we consider C# and Java being almost equivalent (putting the CLR and JVM aside), that means that VB developers have close to <strong>68,000 </strong>books less to read from.  There’s a little “gotcha” in this study though: just for the programming related books for all these languages, <strong>Java</strong> comes first with <strong>12,241</strong> books, <strong>C++</strong> comes at second place with <strong>10,465</strong> books, <strong>Visual Basic</strong> comes at third position with <strong>6,351</strong> books and <strong>C#</strong> comes last with <strong>3,884</strong> books.  However, most of the VB books are for VB6 and older versions (and maybe VBA or VBScript).  Joking aside, <strong>there’s not even a Head First series on Visual Basic!!!</strong> There is though a <a href="http://www.amazon.com/exec/obidos/ASIN/0596514824/brdicr-20">Head First C#</a>, <a href="http://www.amazon.com/exec/obidos/ASIN/0596527748/brdicr-20">Head First JavaScript</a>, <a href="http://www.amazon.com/exec/obidos/ASIN/0596007124/brdicr-20">Head First Design Patterns</a> (Java), <a href="http://www.amazon.com/exec/obidos/ASIN/0596008678/brdicr-20">Head First Object-Oriented Analysis and Design</a> (Java), even a <a href="http://www.amazon.com/exec/obidos/ASIN/0596515774/brdicr-20">Head First Rails and Head First SQL</a>!  Here’s my point: some of the most influential books on software development and programming such as <a href="http://www.amazon.com/exec/obidos/ASIN/0201633612/brdicr-20">Design Patterns</a> (by the GoF), <a href="http://www.amazon.com/exec/obidos/ASIN/0321127420/brdicr-20">Patterns of Enterprise Application Architecture</a> (Fowler), <a href="http://www.amazon.com/exec/obidos/ASIN/0321213351/brdicr-20">Refactoring to Patterns</a> (Keriesky), <a href="http://www.amazon.com/exec/obidos/ASIN/0321413091/brdicr-20">Implementation Patterns</a> (Beck), <a href="http://www.amazon.com/exec/obidos/ASIN/0321125215/brdicr-20">Domain-Driven Design</a> (Evans), even hardcore .NET books like <a href="http://www.amazon.com/exec/obidos/ASIN/0735621632/brdicr-20">CLR via C#</a> (Richter) and the <a href="http://www.amazon.com/exec/obidos/ASIN/0321245660/brdicr-20">Effective C#</a> series (Wagner), without forgetting the books from the Robert C. Martin series (<a href="http://www.amazon.com/exec/obidos/ASIN/0131857258/brdicr-20">Agile Principles, Patterns, and Practices</a>; <a href="http://www.amazon.com/exec/obidos/ASIN/0132350882/brdicr-20">Clean Code</a> and <a href="http://www.amazon.com/exec/obidos/ASIN/0131177052/brdicr-20">Working Effectively with Legacy Code</a>) hold a vast, deep and rich knowledge of the craft of software development that VB/VB.NET developers are mostly ignorant of.  No wonder that I also tend to see more jobs offering for C# developers than VB.NET when it comes to .NET positions.  I don’t know about you, but that’s very unfortunate.  However, this paragraph was mostly about books.  What about tools and open-source projects?</p>
<p>When I teach the intermediate and advanced VB.NET courses, I tell the students that they should take a look at <a href="http://www.codeplex.com/entlib">Enterprise Library</a> from the <a href="http://msdn.microsoft.com/en-us/practices/default.aspx">Patterns and Practices Group</a> at Microsoft (<a href="http://www.microsoft.com/video/en/us/details/84f1b261-7e30-4a05-83fd-6025b446e815">watch a video of it here</a>) for it can save them time, cost and effort in common development situations.  I even tell them that it is open source, which means they have access to the code.  However, I don’t get much excitement from their part, mostly because the code is written in C#.  Code reading aside, I haven’t even heard of one VB developer simply using Enterprise Library in his projects.  The same goes for projects like nHibernate, the Castle project, NUnit, even mocking tools like Rhino.Mocks and Moq.  That’s very sad, because by not using some of these tools, VB developers tend to stay far behind common practices such as TDD and technologies like ORM tools.  What doesn’t help also, is that most of the screencasts where you see someone showing a piece of code or an utility, such as TDD with NUnit and Rhino.Mocks for example, the language is more often than not…wait for it…C#.  The only screencasts that I see a couple of developers programming in VB is in <a href="http://www.dnrtv.com">DNRtv</a>.  Furthermore, I don’t recall ever seeing a VB example from the guys at <a href="http://www.codebetter.com">CodeBetter</a>.  Worse, I don’t even have one example written in VB in any of my posts!</p>
<p>One H U G E advantage that VB6 (or even VB.NET) developers tend to have when learning C# to program with .NET is that they can also be more comfortable in reading C# and Java books and source code (which the latter being as most important as reading books IMHO).  By doing this, for example, a VB developer having trouble understanding the implementation of a design pattern in VB, can easily learn it from another example written in C# or Java (and perhaps C++ if the VB developer understand the notion of pointers).  The last remark I said in parenthesis is important, because of all the .NET constructs, it seems to me that the one that causes much headaches to VB/VB.NET developers are delegates, which are essentially lists of method references.  It’s one of those concepts that I tend to spend more time on explaining to VB developers jumping to VB.NET, than C++ or Java developers learning C#.</p>
<p>Though there isn’t a simple and easy solution for VB developers in this situation, I can only encourage them to take a look at C#.  By doing that, they will also be more comfortable in exploring the world of Java, and perhaps even play around the JVM and see how it compares to .NET.  As Benjamin Franklin once said,</p>
<blockquote><p>“An investment in knowledge always pays the best interest”, and</p>
<p>“The only thing more expensive than education is ignorance”.</p></blockquote>
<p>In his article, “<a href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2893"><strong>What VB Dev Should Know About C#</strong></a>”, Bill Wagner actually encourages VB developers to learn about C# (and C# developers to learn about VB) by saying that,</p>
<blockquote><p>&#8220;<em>Our discussion also covered the need for developers to get out of their comfort zones and learn something new.  Yes, the two languages are similar in features, but there are idiomatic differences between the languages, and some tasks are significantly easier in one language than the other.  In fact, you’ll find yourself much more skilled and much more in demand if you know the best features in both languages, as well as how to build applications that rely on both languages.”</em></p></blockquote>
<p>And if what I’m writing about isn’t encouraging you enough to learn a new language, then <a href="http://www.youtube.com/watch?v=kdxP85ouT9c"><strong>maybe President Barack Obama can persuade you to learn more than “one language”</strong></a>.</p>
<p>I personally speak three languages (Spanish, French and English) and I’m very grateful that I can speak and write in those languages as it gives me a lot of opportunity to learn and embrace foreign cultures, philosophies, relationships and literature.  On the more technical side, I’m also fluent in C++ (not as much as the other languages though), PHP, Java, C# and Visual Basic.  The same benefits apply here, as I can read code written in those languages and books using examples also written in any of those languages.   I can also more easily conduct code reviews with other developers as I’m in a better position to understand their intent, disregard the programming language that was used.</p>
<p>So next time you’re thinking about starting a new personal project, see to it that you write it in C# (if you’re targeting the .NET framework), or even in Java for a change.  If you struggle, don’t quit.  There are <a href="http://www.developerfusion.com/tools/convert/csharp-to-vb/">many</a> <a href="http://www.kamalpatel.net/ConvertCSharp2VB.aspx">online</a> <a href="http://www.carlosag.net/Tools/CodeTranslator/">language</a> <a href="http://tangiblesoftwaresolutions.com/">conversion</a> <a href="http://authors.aspalliance.com/sswafford/article625/CheatSheet.pdf">tools</a> out there to translate C# code to VB and vice-versa.  <a href="http://www.pragprog.com/">The Pragmatic Programmers</a> once advised developers that they should learn at least one new language every year.  This year, Dear VB developer, make a commitment to learn a new language (I’d recommend C#) as it will make you more valuable and employable, and also more comfortable in learning about new ideas emerging in the world of software development.</p>
                        <p><br />
My name is Brian Di Croce, a passionate software developer living, coding, blogging and working in Montreal, Canada.  Feel free to visit my <a href="http://www.briandicroce.com">website/blog</a> for more great content related to software development with .NET! &copy;2007-2008<br />
</p>                        <div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=CnkN55AmLSQ:oi-kEI1lcRE:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=CnkN55AmLSQ:oi-kEI1lcRE:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=CnkN55AmLSQ:oi-kEI1lcRE:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=CnkN55AmLSQ:oi-kEI1lcRE:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=CnkN55AmLSQ:oi-kEI1lcRE:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/BrianDiCroce/~4/CnkN55AmLSQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.briandicroce.com/2009/03/10/dear-vb-developer/feed/</wfw:commentRss>
		<feedburner:origLink>http://blog.briandicroce.com/2009/03/10/dear-vb-developer/</feedburner:origLink></item>
		<item>
		<title>Would Your Objects Praise You?</title>
		<link>http://feedproxy.google.com/~r/BrianDiCroce/~3/qmMXjZp9f1k/</link>
		<comments>http://blog.briandicroce.com/2009/03/04/would-your-objects-praise-you/#comments</comments>
		<pubDate>Thu, 05 Mar 2009 03:51:25 +0000</pubDate>
		<dc:creator>Brian Di Croce</dc:creator>
		
		<category><![CDATA[.NET Programming]]></category>

		<guid isPermaLink="false">http://blog.briandicroce.com/2009/03/04/would-your-objects-praise-you/</guid>
		<description>In the book of Psalms, we can read a passage where King David thanks and praises the Lord for making the human body and soul a wonderful creation:
Oh yes, you shaped me first inside, then out;      you formed me in my mother’s womb.       I [...]</description>
			<content:encoded><![CDATA[<p>In the book of Psalms, we can read a passage where <a href="http://en.wikipedia.org/wiki/David">King David</a> thanks and praises the Lord for making the human body and soul a wonderful creation:</p>
<blockquote><p>Oh yes, you shaped me first inside, then out;      <br />you formed me in my mother’s womb.       <br />I thank you, High God - you’re breathtaking!       <br />Body and soul, I am marvelously made!       <br />I worship in adoration - what a creation!       </p>
<p><strong>You know me inside and out,        <br />you know every bone in my body;         <br />You know exactly how I was made, bit by bit,         <br />how I was sculpted from nothing into something.         <br />Like an open book, you watched me grow from conception to birth</strong>;       <br />all the stages of my life were spread out before you,       <br />The days of my life all prepared       <br />before I’d even lived one day.</p>
<p><a href="http://www.biblegateway.com/passage/?search=psalms%20139:13-16;&amp;version=65;">Psalm 139:13-16</a> (The Message)</p>
</blockquote>
<p>Though I am not perfect, I am perfectly made.&#160; I did not ask for either a working set of eyes or a complex and functional brain.&#160; Never did it occur to me that my heart would be responsible for pumping my blood or that my lungs would filter the oxygen from the air that I breathe.&#160; I am not a creator of life, but I do create a virtual kind of life, where instead of blood and oxygen there is a complex symbiosis of binary mathematics and electrical pulses.&#160; As a software developer, I do bring life to objects that are responsible for the inner workings of my system.&#160; <strong>I sometimes wonder whether the objects and components that we build for our software would thank and praise us in the same degree that King David praised his Creator.</strong></p>
<p>Lately, there has been a popular trend going on in blogs and podcasts around object-oriented programming, notably with the <a href="http://blog.objectmentor.com/articles/2009/02/12/getting-a-solid-start">SOLID principles</a>, a composite of acronyms about key design principles introduced by <a href="http://en.wikipedia.org/wiki/Robert_Cecil_Martin">Robert C. Martin</a>.&#160; One of the principles that I adhere stronger than the others is the <a href="http://en.wikipedia.org/wiki/Single_responsibility_principle">Single Responsibility Principle</a> (SRP).&#160; According to Wikipedia’s definition,</p>
<blockquote><p>The <strong>single responsibility principle</strong> states that every object should have a single responsibility, and that all its services should be narrowly aligned with that responsibility.&#160; [<a href="http://en.wikipedia.org/wiki/Single_responsibility_principle">Wikipedia</a>].</p>
</blockquote>
<p>In the words of Uncle Bob, <strong>aside from a type having a well defined responsibility, it should have one, and only one, reason to change</strong>.&#160; Going to back to the human body, we can clearly see that our inner components are highly cohesive and loosely coupled.&#160; For example, when I pick up a broken piece of glass from my kitchen’s floor and suddenly I cut myself on the finger of my right hand, I shouldn’t expect my right eye to go blind.&#160; Nor do I expect the other fingers to stop working!&#160; Of course not!&#160; That’s because I am wonderfully made!&#160; And so are you!&#160; When I cut myself, my body knows how to heal itself and within days I have no scar.&#160; Leaving the “cutting” aside, we can clearly see how the eyes, the nose, the tongue, the teeth, the nails, the hair, the skin, etc., all have a single and specific responsibility, and if one member should stop working, it can be replaced by another compatible member.&#160; For example, we can do heart transplants, lungs transplants, etc.&#160; Given that the human body is so much more complex than any software ever created, how come that when my printer driver stops working, the whole operating system goes down with it?&#160; How come when a component in an application stops working, it affects other components as well?&#160; Take, for example, a tree: it looks very simple on the outside, but inside of it, God has clearly encapsulated the inner workings of the tree.&#160; A tree that’s been around for decades can still grow and participate in photosynthesis.&#160; It’s incredible.&#160; Software systems tend to be replaced every year or two.&#160; Anyhow, I want to keep writing on the topic of single responsibility for an object.</p>
<p>Suppose you have the following simple <strong>Car</strong> class:</p>
<p><img title="" style="border-top-width: 0px; display: block; border-left-width: 0px; float: none; border-bottom-width: 0px; margin-left: auto; margin-right: auto; border-right-width: 0px" height="215" alt="" src="http://blog.briandicroce.com/wp-content/uploads/2009/03/image.png" width="187" border="0" /></p>
<p>Now, what do you think about the methods (or responsibilities) of this class?&#160; Does it violate the SRP principle?&#160; Here’s a simple test you can do to answer these questions (if you answer ‘NO’ to any of these questions, then you know that your class doesn’t adhere to the SRP principle.&#160; Even better: if the question doesn’t seem to make any sense to you, then it’s a ‘NO’ by default):</p>
<ul>
<li>Can a <strong>car</strong> <u>change gears</u> by itself? </li>
<li>Can a <strong>car</strong> <u>change a radio station</u> by itself? </li>
<li>Can a <strong>car</strong> <u>drive</u> itself? </li>
<li>Can a <strong>car</strong> <u>idle</u> by itself? </li>
<li>Can a <strong>car</strong> <u>park</u> itself? </li>
<li>Can a <strong>car</strong> <u>start</u> itself? </li>
</ul>
<p><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; margin: 0px 0px 0px 10px; border-right-width: 0px" height="174" alt="image" src="http://blog.briandicroce.com/wp-content/uploads/2009/03/image1.png" width="244" align="right" border="0" /> Unless you’re the lucky owner of the <a href="http://en.wikipedia.org/wiki/Knight_Rider_(1982_TV_series)">Knight Rider</a>, you probably answered ‘NO’ to a few of these questions.&#160; For every question or observation you have answered ‘NO’, you should more than likely refactor the class and move some of its responsibilities elsewhere.&#160; But where exactly can you move these responsibilities?&#160; Well, before we dive to some of these answers, let’s see if we can directly some of the original questions pertaining to our Car class:</p>
<ul>
<li>Can a <strong>car</strong> <u>change gears</u> by itself? <strong><u>ANSWER:</u></strong> Sure, if it has an automatic transmission.&#160; Otherwise, only the <strong>driver</strong> can shift gears. </li>
<li>Can a <strong>car</strong> <u>change a radio station</u> by itself?&#160; <strong><u>ANSWER:</u></strong> Nope, only the <strong>driver</strong> (or the passenger) can change the radio station. </li>
<li>Can a <strong>car</strong> <u>drive</u> itself? <strong><u>ANSWER:</u></strong> Not unless it’s KITT!&#160; Only a <strong>driver</strong> can drive a car. </li>
<li>Can a <strong>car</strong> <u>idle</u> by itself? <strong><u>ANSWER:</u></strong> Sure it can. </li>
<li>Can a <strong>car</strong> <u>park</u> itself? <strong><u>ANSWER:</u></strong> Nope! Only a <strong>driver</strong> can know how to park a car. </li>
<li>Can a <strong>car</strong> <u>start</u> itself? <strong><u>ANSWER:</u></strong> Uh, no.&#160; Once again, only the <strong>driver</strong> can start the car. </li>
</ul>
<p>Do you see how by answering such questions or observations you can better get through a cleaner design?&#160; The pattern is pretty simple too: <strong>Can a [<em>type</em>] [<em>action in the infinitive</em>] itself?</strong> Though I picked a very trivial example, you could do the same test for any of your classes, e.g., an Order class, an Employee class, an Account class, a Repository&lt;T&gt; class, even interfaces!&#160; Continuing with our beloved <strong>Car</strong> class, we see that it has a couple of responsibilities it cannot fulfill by itself, because either it doesn’t make sense that it should, or plainly that it isn’t logical for the class to offer those services in the first place.&#160; From our answers, we can also see that we need another class to make all well orchestrated: a <strong>Driver</strong> class.&#160; The driver should know how to fulfill some of these responsibilities.&#160; How would you associate the <strong>Driver</strong> to a <strong>Car</strong>?&#160; You can go with the Dependency Injection pattern on this one if you like, or pick another strategy. </p>
<p><img title="image" style="border-top-width: 0px; display: block; border-left-width: 0px; float: none; border-bottom-width: 0px; margin-left: auto; margin-right: auto; border-right-width: 0px" height="294" alt="image" src="http://blog.briandicroce.com/wp-content/uploads/2009/03/image2.png" width="517" border="0" /></p>
<p>So we talked about a few things here: the Bible, Knight Rider and Uncle Bob.&#160; But more importantly in this post, we talked about some easy and simple techniques we can use to determine whether methods or properties (responsibilities) actually belong in the right type.&#160; Unfortunately, following this technique isn’t a silver bullet for every situation!&#160; You must still rely on your experience and wisdom to better answer that question.&#160; If you are part of a team, that’s even better because it is those deep and insightful conversations that actually bring about a much suitable solution.&#160; For example, what if our <strong>Car </strong>needs some reparations?&#160; Should we create a <strong>Repair()</strong> method in the <strong>Car</strong> class or the <strong>Driver</strong> class?&#160; Well, you can first of all use our little technique to answer this question:</p>
<ul>
<li>Should a <strong>car</strong> be able to <u>repair</u> itself? <strong><u>ANSWER:</u></strong> Not in this world, that’s for sure! </li>
<li>Should a <strong>driver</strong> be able to <u>repair</u> a car? <strong><u>ANSWER:</u></strong> Well, it depends!&#160; Maybe the driver can repair the car, and if not, maybe we should introduce a <strong>Mechanic</strong> class that knows how to repair the car.&#160; This is when we should discuss it in front of a whiteboard. </li>
</ul>
<p>I hope this little tip will help you to better evaluate your design.&#160; And don’t stress too much about it if your design doesn’t follow the SRP or any of the SOLID principles.&#160; Just be thankful that you’re wonderfully made and that you have Google at your disposal.</p>
                        <p><br />
My name is Brian Di Croce, a passionate software developer living, coding, blogging and working in Montreal, Canada.  Feel free to visit my <a href="http://www.briandicroce.com">website/blog</a> for more great content related to software development with .NET! &copy;2007-2008<br />
</p>                        <div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=qmMXjZp9f1k:o7a_ZarZzYY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=qmMXjZp9f1k:o7a_ZarZzYY:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=qmMXjZp9f1k:o7a_ZarZzYY:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=qmMXjZp9f1k:o7a_ZarZzYY:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=qmMXjZp9f1k:o7a_ZarZzYY:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/BrianDiCroce/~4/qmMXjZp9f1k" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.briandicroce.com/2009/03/04/would-your-objects-praise-you/feed/</wfw:commentRss>
		<feedburner:origLink>http://blog.briandicroce.com/2009/03/04/would-your-objects-praise-you/</feedburner:origLink></item>
		<item>
		<title>Avoid calling a virtual or abstract method from a constructor in C#…especially in VB!</title>
		<link>http://feedproxy.google.com/~r/BrianDiCroce/~3/jYwtIJiWjrw/</link>
		<comments>http://blog.briandicroce.com/2009/02/22/avoid-calling-a-virtual-or-abstract-method-from-a-constructor-in-cespecially-in-vb/#comments</comments>
		<pubDate>Sun, 22 Feb 2009 05:16:53 +0000</pubDate>
		<dc:creator>Brian Di Croce</dc:creator>
		
		<category><![CDATA[.NET Programming]]></category>

		<guid isPermaLink="false">http://blog.briandicroce.com/?p=513</guid>
		<description>Whenever I’m teaching our intermediate .NET development course, I mention to my students the pitfalls of calling a virtual method from a base class’ constructor.&amp;#160; The major drawback of calling a virtual method in such a context is that if a derived class overrides that method, the overridden method will be invoked prior to the [...]</description>
			<content:encoded><![CDATA[<p>Whenever I’m teaching our <a href="http://www.crim.ca/fr/services/Formation/Cours-inscription/index.html?uri=/ressources/fr/Services/formation/Cours-inscription/Application/point_net.html&amp;id=NET282">intermediate .NET development course</a>, I mention to my students the pitfalls of calling a virtual method from a base class’ constructor.&#160; The major drawback of calling a virtual method in such a context is that if a derived class overrides that method, the overridden method will be invoked prior to the derived class’ instance constructor.&#160; This is especially true in C#, and as you’ll see later in this post, it’s even more dangerous to do so in Visual Basic. </p>
<h4>The Marker class</h4>
<p>For this demonstration, I will be using a custom <strong>Marker</strong> class that will simply output text in the console.</p>
<p>This is the Marker class in C# (the class is equivalent in the Visual Basic module):</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, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<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, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">class</span> Marker
{
    <span style="color: #0000ff">public</span> Marker(<span style="color: #0000ff">string</span> text)
    {
        Console.WriteLine(text);
    }
}</pre>
</div>
<h4>The Base class</h4>
<p>Let’s kick off the idea with a single C# class (no inheritance whatsoever):</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, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<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, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">class</span> Base
{
    <span style="color: #0000ff">private</span> <span style="color: #0000ff">static</span> Marker staticField = <span style="color: #0000ff">new</span> Marker(<span style="color: #006080">&quot;base static field&quot;</span>);
    <span style="color: #0000ff">private</span> Marker instanceField = <span style="color: #0000ff">new</span> Marker(<span style="color: #006080">&quot;base instance field&quot;</span>);

    <span style="color: #0000ff">static</span> Base()
    {
        <span style="color: #0000ff">new</span> Marker(<span style="color: #006080">&quot;base static ctor&quot;</span>);
    }

    <span style="color: #0000ff">public</span> Base()
    {
        M();
        <span style="color: #0000ff">new</span> Marker(<span style="color: #006080">&quot;base instance ctor&quot;</span>);
    }

    <span style="color: #0000ff">protected</span>  <span style="color: #0000ff">virtual</span> <span style="color: #0000ff">void</span> M()
    {
        Console.WriteLine( <span style="color: #006080">&quot;base M() was called&quot;</span> );
    }
}</pre>
</div>
<p>Here’s the same class in Visual Basic:</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, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<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, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">Class</span> Base

    <span style="color: #0000ff">Private</span> <span style="color: #0000ff">Shared</span> staticField <span style="color: #0000ff">As</span> <span style="color: #0000ff">New</span> Marker(<span style="color: #006080">&quot;base static field&quot;</span>)
    <span style="color: #0000ff">Private</span> instanceField <span style="color: #0000ff">As</span> <span style="color: #0000ff">New</span> Marker(<span style="color: #006080">&quot;base instance field&quot;</span>)

    <span style="color: #0000ff">Shared</span> <span style="color: #0000ff">Sub</span> <span style="color: #0000ff">New</span>()
        <span style="color: #0000ff">Dim</span> temp <span style="color: #0000ff">As</span> <span style="color: #0000ff">New</span> Marker(<span style="color: #006080">&quot;base static ctor&quot;</span>)
    <span style="color: #0000ff">End</span> <span style="color: #0000ff">Sub</span>

    <span style="color: #0000ff">Public</span> <span style="color: #0000ff">Sub</span> <span style="color: #0000ff">New</span>()
        M()
        <span style="color: #0000ff">Dim</span> temp <span style="color: #0000ff">As</span> <span style="color: #0000ff">New</span> Marker(<span style="color: #006080">&quot;base instance ctor&quot;</span>)
    <span style="color: #0000ff">End</span> <span style="color: #0000ff">Sub</span>

    <span style="color: #0000ff">Protected</span> <span style="color: #0000ff">Overridable</span> <span style="color: #0000ff">Sub</span> M()
        Console.WriteLine(<span style="color: #006080">&quot;base M() was called&quot;</span>)
    <span style="color: #0000ff">End</span> <span style="color: #0000ff">Sub</span>

<span style="color: #0000ff">End</span> Class</pre>
</div>
<p>When we instantiate the <strong>Base</strong> class, we get the following output in C# and Visual Basic.&#160; <strong>The main point is that the results are the same whether we instantiate the C# or Visual Basic version of the Base class</strong>.</p>
<div align="center">
<table cellspacing="0" cellpadding="2" width="700" border="0">
<tbody>
<tr>
<td valign="top" width="350">
<p align="left"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="119" alt="image" src="http://blog.briandicroce.com/wp-content/uploads/2009/02/image7.png" width="325" border="0" /></p>
</td>
<td valign="top" width="350">
<p align="left"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="119" alt="image" src="http://blog.briandicroce.com/wp-content/uploads/2009/02/image8.png" width="328" border="0" /></p>
</td>
</tr>
</tbody>
</table>
</div>
<p>&#160;</p>
<h4>Instantiating a child class of Base in C# and Visual Basic</h4>
<p>Here’s now the entire code in C# of the Base class (same as before) and a Derived class inheriting from it:</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, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<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, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">class</span> Base
{
    <span style="color: #0000ff">private</span> <span style="color: #0000ff">static</span> Marker staticField = <span style="color: #0000ff">new</span> Marker(<span style="color: #006080">&quot;base static field&quot;</span>);
    <span style="color: #0000ff">private</span> Marker instanceField = <span style="color: #0000ff">new</span> Marker(<span style="color: #006080">&quot;base instance field&quot;</span>);

    <span style="color: #0000ff">static</span> Base()
    {
        <span style="color: #0000ff">new</span> Marker(<span style="color: #006080">&quot;base static ctor&quot;</span>);
    }

    <span style="color: #0000ff">public</span> Base()
    {
        M();
        <span style="color: #0000ff">new</span> Marker(<span style="color: #006080">&quot;base instance ctor&quot;</span>);
    }

    <span style="color: #0000ff">protected</span>  <span style="color: #0000ff">virtual</span> <span style="color: #0000ff">void</span> M()
    {
        Console.WriteLine( <span style="color: #006080">&quot;base M() was called&quot;</span> );
    }
}

<span style="color: #0000ff">class</span> Derived : Base
{
    <span style="color: #0000ff">private</span> <span style="color: #0000ff">static</span> Marker staticField = <span style="color: #0000ff">new</span> Marker(<span style="color: #006080">&quot;derived static field&quot;</span>);
    <span style="color: #0000ff">private</span> Marker instanceField = <span style="color: #0000ff">new</span> Marker(<span style="color: #006080">&quot;derived instance field&quot;</span>);

    <span style="color: #0000ff">static</span> Derived()
    {
        <span style="color: #0000ff">new</span> Marker(<span style="color: #006080">&quot;derived static ctor&quot;</span>);
    }

    <span style="color: #0000ff">public</span> Derived()
    {
        <span style="color: #0000ff">new</span> Marker(<span style="color: #006080">&quot;derived instance ctor&quot;</span>);
    }

    <span style="color: #0000ff">protected</span> <span style="color: #0000ff">override</span> <span style="color: #0000ff">void</span> M()
    {
        Console.WriteLine( <span style="color: #006080">&quot;derived M() was called&quot;</span> );
    }
}</pre>
</div>
<p>And here are the same classes in Visual Basic:</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, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<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, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">Class</span> Base

    <span style="color: #0000ff">Private</span> <span style="color: #0000ff">Shared</span> staticField <span style="color: #0000ff">As</span> <span style="color: #0000ff">New</span> Marker(<span style="color: #006080">&quot;base static field&quot;</span>)
    <span style="color: #0000ff">Private</span> instanceField <span style="color: #0000ff">As</span> <span style="color: #0000ff">New</span> Marker(<span style="color: #006080">&quot;base instance field&quot;</span>)

    <span style="color: #0000ff">Shared</span> <span style="color: #0000ff">Sub</span> <span style="color: #0000ff">New</span>()
        <span style="color: #0000ff">Dim</span> temp <span style="color: #0000ff">As</span> <span style="color: #0000ff">New</span> Marker(<span style="color: #006080">&quot;base static ctor&quot;</span>)
    <span style="color: #0000ff">End</span> <span style="color: #0000ff">Sub</span>

    <span style="color: #0000ff">Public</span> <span style="color: #0000ff">Sub</span> <span style="color: #0000ff">New</span>()
        M()
        <span style="color: #0000ff">Dim</span> temp <span style="color: #0000ff">As</span> <span style="color: #0000ff">New</span> Marker(<span style="color: #006080">&quot;base instance ctor&quot;</span>)
    <span style="color: #0000ff">End</span> <span style="color: #0000ff">Sub</span>

    <span style="color: #0000ff">Protected</span> <span style="color: #0000ff">Overridable</span> <span style="color: #0000ff">Sub</span> M()
        Console.WriteLine(<span style="color: #006080">&quot;base M() was called&quot;</span>)
    <span style="color: #0000ff">End</span> <span style="color: #0000ff">Sub</span>

<span style="color: #0000ff">End</span> <span style="color: #0000ff">Class</span>

<span style="color: #0000ff">Class</span> Derived : <span style="color: #0000ff">Inherits</span> Base

    <span style="color: #0000ff">Private</span> <span style="color: #0000ff">Shared</span> staticField <span style="color: #0000ff">As</span> <span style="color: #0000ff">New</span> Marker(<span style="color: #006080">&quot;derived static field&quot;</span>)
    <span style="color: #0000ff">Private</span> instanceField <span style="color: #0000ff">As</span> <span style="color: #0000ff">New</span> Marker(<span style="color: #006080">&quot;derived instance field&quot;</span>)

    <span style="color: #0000ff">Shared</span> <span style="color: #0000ff">Sub</span> <span style="color: #0000ff">New</span>()
        <span style="color: #0000ff">Dim</span> temp <span style="color: #0000ff">As</span> <span style="color: #0000ff">New</span> Marker(<span style="color: #006080">&quot;derived static ctor&quot;</span>)
    <span style="color: #0000ff">End</span> <span style="color: #0000ff">Sub</span>

    <span style="color: #0000ff">Sub</span> <span style="color: #0000ff">New</span>()
        <span style="color: #0000ff">Dim</span> temp <span style="color: #0000ff">As</span> <span style="color: #0000ff">New</span> Marker(<span style="color: #006080">&quot;derived instance ctor&quot;</span>)
    <span style="color: #0000ff">End</span> <span style="color: #0000ff">Sub</span>

    <span style="color: #0000ff">Protected</span> <span style="color: #0000ff">Overrides</span> <span style="color: #0000ff">Sub</span> M()
        Console.WriteLine(<span style="color: #006080">&quot;derived M() was called&quot;</span>)
    <span style="color: #0000ff">End</span> <span style="color: #0000ff">Sub</span>

<span style="color: #0000ff">End</span> Class</pre>
</div>
<p>Here’s the output generated when instantiating the Derived class in C# and Visual Basic (<strong>This is where the fun begins!&#160; Try to notice any difference between the C# and Visual Basic execution before continuing.</strong>) :</p>
<div align="center">
<table cellspacing="0" cellpadding="2" width="702" border="0">
<tbody>
<tr>
<td valign="top" width="350"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="185" alt="image" src="http://blog.briandicroce.com/wp-content/uploads/2009/02/image9.png" width="335" border="0" /> </p>
<p align="left">
</td>
<td valign="top" width="350"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="186" alt="image" src="http://blog.briandicroce.com/wp-content/uploads/2009/02/image10.png" width="333" border="0" /> </p>
<p align="left">
</td>
</tr>
</tbody>
</table>
</div>
<p>As you can see, the order of execution in an inheritance relationship is both different in C# and Visual Basic (regardless of whether or not a virtual/abstract method was called from either constructor).&#160; <strong>The danger of calling a virtual or abstract method from a constructor (in C# or Visual Basic) is that the overridden method will be invoked prior to the derived class’ constructor</strong>.&#160; If that method tries to access or modify the state of the yet-to-be-fully-constructed object, you might end up with a corrupt or invalid instance.&#160; The worse scenario is in Visual Basic.&#160; As you can see from the results, the overridden method gets called not only before the derived class’ constructor (as it was with the C# version), but also gets called before the class’ instance fields get initialized.&#160; Now, that’s even more dangerous if the overridden method tries to access any of its instance fields because chances are that they will default to Nothing (null in C#) for reference types since they haven’t even been initialized yet!</p>
<h4>Referencing a Visual Basic assembly from a C# application and instantiating the Visual Basic version of the Derived type</h4>
<p>Here’s another potential dangerous scenario: From a C# application, you reference a Visual Basic assembly that holds the exact same code as the Base and Derived classes shown above.&#160; You then decide to instantiate the Visual Basic version of the Derived class:</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, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<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, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">static</span> <span style="color: #0000ff">void</span> Main(<span style="color: #0000ff">string</span>[] args)
{
    Console.WriteLine( <span style="color: #006080">&quot;From C# Program&quot;</span> );
    Console.WriteLine(  );
    <span style="color: #0000ff">new</span> VBModule.Derived();
}</pre>
</div>
<p>Here’s the output generated from instantiating the Visual Basic version of the Derived class in the C# application: </p>
<p>&#160;<img title="image" style="border-top-width: 0px; display: block; border-left-width: 0px; float: none; border-bottom-width: 0px; margin-left: auto; margin-right: auto; border-right-width: 0px" height="183" alt="image" src="http://blog.briandicroce.com/wp-content/uploads/2009/02/image11.png" width="327" border="0" />As you can see, it is no longer having the same execution cycle as when instantiating the C# version of the Derived class from the C# code itself.</p>
<h4>Referencing a C# assembly from a Visual Basic application and instantiating the C# version of the Derived type</h4>
<p>This time, we’ll switch the roles and from a Visual Basic application, we’ll reference a C# assembly that holds the exact same code as the Base and Derived classes shown above.&#160; We then decide to instantiate the C# version of the Derived class:</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, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<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, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">Sub</span> Main()
    Console.WriteLine(<span style="color: #006080">&quot;From VB Program&quot;</span>)
    Console.WriteLine()

    <span style="color: #0000ff">Dim</span> d <span style="color: #0000ff">As</span> <span style="color: #0000ff">New</span> CSharp.Derived
<span style="color: #0000ff">End</span> Sub</pre>
</div>
<p>Here’s the output generated from instantiating the C# version of the Derived class in the Visual Basic application:</p>
<p><img title="image" style="border-top-width: 0px; display: block; border-left-width: 0px; float: none; border-bottom-width: 0px; margin-left: auto; margin-right: auto; border-right-width: 0px" height="181" alt="image" src="http://blog.briandicroce.com/wp-content/uploads/2009/02/image12.png" width="322" border="0" />As you can see, it is no longer having the same execution cycle as when instantiating the Visual Basic version of the Derived class from the Visual Basic code itself.</p>
<h4>Conclusion</h4>
<p>You should never be calling a virtual or abstract method from a constructor in C#, and even more in Visual Basic, because in either case a derived type will invoke an instance method prior to the object being fully constructed!&#160; In other words, the dynamic linking edition kicks in as soon as you instantiate a class.&#160; According to Microsoft,</p>
<blockquote>
<p>When a virtual method is called, the actual type that executes the method is not selected until run time.&#160; When a constructor calls a virtual method, it is possible that the constructor for the instance that invokes the method has not executed.&#160; <strong>The constructor should be redesigned to eliminate the call to the virtual method.</strong></p>
</blockquote>
<p>As you saw, the execution cycle is different for both languages even with the same codebase.&#160; It gets even more interesting when referencing either assembly (C# or Visual Basic) in either language, because you just wouldn’t know what you’ll get at the other end.&#160; Having a tool like <a href="http://www.jetbrains.com/resharper/">ReSharper</a> can be of a greater benefit in this circumstance as it’ll catch this kind of code and notify you about it.&#160; By default, this situation will be treated as a warning, but I’ll suggest you to treat it as an error as to make it stand out better (ReSharper-&gt;Options…-&gt;Inspection Severity): </p>
<p><img title="image" style="border-top-width: 0px; display: block; border-left-width: 0px; float: none; border-bottom-width: 0px; margin-left: auto; margin-right: auto; border-right-width: 0px" height="461" alt="image" src="http://blog.briandicroce.com/wp-content/uploads/2009/02/image14.png" width="472" border="0" /></p>
                        <p><br />
My name is Brian Di Croce, a passionate software developer living, coding, blogging and working in Montreal, Canada.  Feel free to visit my <a href="http://www.briandicroce.com">website/blog</a> for more great content related to software development with .NET! &copy;2007-2008<br />
</p>                        <div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=jYwtIJiWjrw:AGUZuhYC87M:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=jYwtIJiWjrw:AGUZuhYC87M:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=jYwtIJiWjrw:AGUZuhYC87M:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=jYwtIJiWjrw:AGUZuhYC87M:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=jYwtIJiWjrw:AGUZuhYC87M:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/BrianDiCroce/~4/jYwtIJiWjrw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.briandicroce.com/2009/02/22/avoid-calling-a-virtual-or-abstract-method-from-a-constructor-in-cespecially-in-vb/feed/</wfw:commentRss>
		<feedburner:origLink>http://blog.briandicroce.com/2009/02/22/avoid-calling-a-virtual-or-abstract-method-from-a-constructor-in-cespecially-in-vb/</feedburner:origLink></item>
		<item>
		<title>The Fuhrer’s take on Scrum, Agile and CI</title>
		<link>http://feedproxy.google.com/~r/BrianDiCroce/~3/yNWwlffXOs0/</link>
		<comments>http://blog.briandicroce.com/2009/02/19/the-fuhrers-take-on-scrum-agile-and-ci/#comments</comments>
		<pubDate>Fri, 20 Feb 2009 03:03:11 +0000</pubDate>
		<dc:creator>Brian Di Croce</dc:creator>
		
		<category><![CDATA[Humor/Funny]]></category>

		<guid isPermaLink="false">http://blog.briandicroce.com/2009/02/19/the-fuhrers-take-on-scrum-agile-and-ci/</guid>
		<description>I hope you’re not working in this kind of organization.&amp;#160; Period.



                        
My name is Brian Di Croce, a passionate software developer living, coding, blogging and working in Montreal, Canada.  Feel free [...]</description>
			<content:encoded><![CDATA[<p>I hope you’re not working in this kind of organization.&#160; Period.</p>
<div class="wlWriterEditableSmartContent" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:b66d9cd0-2896-4ae9-8404-047262ae3ad9" style="padding-right: 0px; display: block; padding-left: 0px; float: none; padding-bottom: 0px; margin-left: auto; width: 425px; margin-right: auto; padding-top: 0px">
<div><object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/Azl4nqLn4-Y&amp;hl=en"></param><embed src="http://www.youtube.com/v/Azl4nqLn4-Y&amp;hl=en" type="application/x-shockwave-flash" width="425" height="355"></embed></object></div>
</div>
                        <p><br />
My name is Brian Di Croce, a passionate software developer living, coding, blogging and working in Montreal, Canada.  Feel free to visit my <a href="http://www.briandicroce.com">website/blog</a> for more great content related to software development with .NET! &copy;2007-2008<br />
</p>                        <div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=yNWwlffXOs0:SGzpraO81dc:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=yNWwlffXOs0:SGzpraO81dc:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=yNWwlffXOs0:SGzpraO81dc:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=yNWwlffXOs0:SGzpraO81dc:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=yNWwlffXOs0:SGzpraO81dc:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/BrianDiCroce/~4/yNWwlffXOs0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.briandicroce.com/2009/02/19/the-fuhrers-take-on-scrum-agile-and-ci/feed/</wfw:commentRss>
		<feedburner:origLink>http://blog.briandicroce.com/2009/02/19/the-fuhrers-take-on-scrum-agile-and-ci/</feedburner:origLink></item>
		<item>
		<title>The History of Microsoft on Channel9</title>
		<link>http://feedproxy.google.com/~r/BrianDiCroce/~3/i9gfkE-6AQ0/</link>
		<comments>http://blog.briandicroce.com/2009/02/16/the-history-of-microsoft-on-channel9/#comments</comments>
		<pubDate>Tue, 17 Feb 2009 01:54:38 +0000</pubDate>
		<dc:creator>Brian Di Croce</dc:creator>
		
		<category><![CDATA[Media/Presentations]]></category>

		<guid isPermaLink="false">http://blog.briandicroce.com/2009/02/16/the-history-of-microsoft-on-channel9/</guid>
		<description>Recently, the folks over at Channel9 have put on a couple of episodes on the history of Microsoft since its inception.&amp;#160; At the time of this writing, two episodes have been uploaded so far, but we can expect more to be released in the near future.&amp;#160; Each episode is pretty interesting as it also introduces [...]</description>
			<content:encoded><![CDATA[<p>Recently, the folks over at <a href="http://channel9.msdn.com">Channel9</a> have put on a couple of episodes on the <a href="http://channel9.msdn.com/shows/History"><strong>history of Microsoft</strong></a> since its inception.&#160; At the time of this writing, two episodes have been uploaded so far, but we can expect more to be released in the near future.&#160; Each episode is pretty interesting as it also introduces other things that were major at that specific time, such as the unveiling of the Shugart 5.25-inch floppy disk drive for $390.&#160; Ouch.&#160; Anyways, since I wasn’t born in the 1970s, it’s a nice thing to see what was going in the computing industry in that period.</p>
                        <p><br />
My name is Brian Di Croce, a passionate software developer living, coding, blogging and working in Montreal, Canada.  Feel free to visit my <a href="http://www.briandicroce.com">website/blog</a> for more great content related to software development with .NET! &copy;2007-2008<br />
</p>                        <div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=i9gfkE-6AQ0:7KX32wBl-sM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=i9gfkE-6AQ0:7KX32wBl-sM:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=i9gfkE-6AQ0:7KX32wBl-sM:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=i9gfkE-6AQ0:7KX32wBl-sM:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=i9gfkE-6AQ0:7KX32wBl-sM:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/BrianDiCroce/~4/i9gfkE-6AQ0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.briandicroce.com/2009/02/16/the-history-of-microsoft-on-channel9/feed/</wfw:commentRss>
		<feedburner:origLink>http://blog.briandicroce.com/2009/02/16/the-history-of-microsoft-on-channel9/</feedburner:origLink></item>
		<item>
		<title>TweetDeck not showing up in primary monitor</title>
		<link>http://feedproxy.google.com/~r/BrianDiCroce/~3/4hGAZ93GcPk/</link>
		<comments>http://blog.briandicroce.com/2009/02/11/tweetdeck-not-showing-up-in-primary-monitor/#comments</comments>
		<pubDate>Wed, 11 Feb 2009 22:53:59 +0000</pubDate>
		<dc:creator>Brian Di Croce</dc:creator>
		
		<category><![CDATA[How To...]]></category>

		<guid isPermaLink="false">http://blog.briandicroce.com/2009/02/11/tweetdeck-not-showing-up-in-primary-monitor/</guid>
		<description>I’m currently using TweetDeck v0.21b as my default Tweeter client for my Windows Vista machine.&amp;#160; Having a dual-monitor setup at home (laptop and an external monitor), I always move TweetDeck to the external monitor as a personal preference.&amp;#160; While I’m waiting in the airport for my next flight, the sudden idea to tweet that specific [...]</description>
			<content:encoded><![CDATA[<p>I’m currently using <a href="http://www.tweetdeck.com/beta/">TweetDeck</a> v0.21b as my default <a href="http://www.tweeter.com">Tweeter</a> client for my Windows Vista machine.&#160; Having a dual-monitor setup at home (laptop and an external monitor), I always move TweetDeck to the external monitor as a personal preference.&#160; While I’m waiting in the airport for my next flight, the sudden idea to <em>tweet</em> that specific fact came to my mind.&#160; Unfortunately, TweetDeck’s UI doesn’t show up when I launch the application.&#160; I know it’s running because I can see the little black bird icon on the system tray, but it still thinks it’s suppose to show on my external monitor.&#160; That’s not good, because I don’t normally carry my external monitor with me when I’m on the go.&#160; Clearly this is a bug, but not one that will stop me from tweeting the fact that I’m waiting at the airport!&#160; </p>
<p>So these are the steps you should follow if your TweetDeck doesn’t show up in the primary (and only) monitor because it’s thinking it should display on an external monitor:</p>
<ol>
<li>If you’re using <strong>Windows Vista</strong>, browse to the following directory: C:\Users\&lt;username&gt;\AppData\Roaming.&#160; If you’re using <strong>Windows XP</strong>, browse to the following directory instead: C:\Documents and Settings\&lt;username&gt;\AppData.</li>
<li>Locate the folder that begins with <strong>TweetDeckFast</strong>.&#160; For example, the complete name of that folder on my PC is TweetDeckFast.F9107117265DB7542C1A806C8DB837742CE14C21.1.</li>
<li>Open the <strong>Local Store</strong> folder.</li>
<li>Edit the <strong>preferences_&lt;username&gt;.xml</strong> configuration file with your favorite text editor.</li>
<li>Change the <strong>windowState</strong> XML element’s <strong>x</strong> attribute to <strong>0</strong>.&#160; If you don’t see the TweetDeck UI, it is because the <strong>x</strong> attribute’s value is negative (which makes sense if the external monitor was on the left side).</li>
<li>Save your changes to that file and load TweetDeck.&#160; You should now be able to see the UI.</li>
</ol>
                        <p><br />
My name is Brian Di Croce, a passionate software developer living, coding, blogging and working in Montreal, Canada.  Feel free to visit my <a href="http://www.briandicroce.com">website/blog</a> for more great content related to software development with .NET! &copy;2007-2008<br />
</p>                        <div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=4hGAZ93GcPk:nVdpBYSKz4E:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=4hGAZ93GcPk:nVdpBYSKz4E:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=4hGAZ93GcPk:nVdpBYSKz4E:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=4hGAZ93GcPk:nVdpBYSKz4E:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=4hGAZ93GcPk:nVdpBYSKz4E:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/BrianDiCroce/~4/4hGAZ93GcPk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.briandicroce.com/2009/02/11/tweetdeck-not-showing-up-in-primary-monitor/feed/</wfw:commentRss>
		<feedburner:origLink>http://blog.briandicroce.com/2009/02/11/tweetdeck-not-showing-up-in-primary-monitor/</feedburner:origLink></item>
		<item>
		<title>The Broken Windows Theory in Software</title>
		<link>http://feedproxy.google.com/~r/BrianDiCroce/~3/WRGKqq4mwnc/</link>
		<comments>http://blog.briandicroce.com/2009/02/08/broken-windows-theory-in-software/#comments</comments>
		<pubDate>Mon, 09 Feb 2009 02:30:12 +0000</pubDate>
		<dc:creator>Brian Di Croce</dc:creator>
		
		<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://blog.briandicroce.com/2009/02/08/broken-windows-theory-in-software/</guid>
		<description>I first heard of the Broken Windows theory while reading Malcom Gladwell’s The Tipping Point.&amp;#160; In a nutshell, the theory goes like this:
If a window is broken and left unrepaired, people walking by will conclude that no one cares and no one is in charge.&amp;#160; Soon, more windows will be broken, and the sense [...]</description>
			<content:encoded><![CDATA[<p><img title="image" style="border-right: 0px; border-top: 0px; display: inline; margin: 0px 0px 10px 10px; border-left: 0px; border-bottom: 0px" height="240" alt="image" src="http://blog.briandicroce.com/wp-content/uploads/2009/02/image.png" width="158" align="right" border="0" /> I first heard of the Broken Windows theory while reading Malcom Gladwell’s <a href="http://www.amazon.com/exec/obidos/ASIN/0316346624/brdicr-20">The Tipping Point</a>.&#160; In a nutshell, the theory goes like this:</p>
<blockquote><p>If a window is broken and left unrepaired, people walking by will conclude that no one cares and no one is in charge.&#160; Soon, more windows will be broken, and the sense of anarchy will spread from the building to the street on which it faces, sending a signal that anything goes.</p>
</blockquote>
<p>I couldn’t help myself thinking how this theory fits well with the current state of software development.&#160; When a software project first begins, it is void of any imperfection for no one began to write a single line of code for it.&#160; Then as the team forms and the tasks are being assigned and executed, the team members start to breath life into the software.&#160; That software could have a very different life depending on various factors of the team in charge of developing it, such as the team members’ experience, skills, knowledge, professionalism and passion for the craft.&#160; </p>
<p>From my days of consulting and working as a team member, I more than often see a lack of responsibility from the individual team member for the most important organ of the software: the source code.&#160; Once the source code has started to rot, it doesn’t matter how colorful or beautiful your design documents are or how detailed your development plan is…your software has a cancer and it will die unless you do something about it.&#160; The typical scenario of the Broken Windows theory in software development goes like this: Robert, a programmer, is working on a subroutine for the Shipping module.&#160; While at it, he notices that the NotifySupplier method is lacking a couple of guard clauses and the comments don’t reflect the code at all.&#160; Since he wasn’t the one to write that code, he ignores it and continues working on his work item.&#160; Will he remember to ask the developer who wrote the NotifySupplier method that it is in need of some fixing?&#160; Who knows.&#160; One meeting here, one phone call there, and chances are that Robert will forget about it.&#160; Upon that time, the software has started to confirm the theory.&#160; It now has a broken window.&#160; What’s even more dangerous is that this theory can cascade all over the core of the software if its internals show a high degree of coupling with many components.&#160; A good analogy would be like a tree burning in a forest.&#160; It doesn’t take much time for the fire to spread to the other trees.&#160; The outcome of this is simple: <strong>chaos</strong>.&#160; The remedy is also simple: <strong>you</strong>.&#160; What are you going to do about it?&#160; Are you going to run from it or are you going to take corrective actions to prevent the cancer to spread all over the system?</p>
<p>Another potential risky situation that may arise from the Broken Window theory in software development is that if you don’t take care of fixing the broken code as soon as humanly possible, your junior developers and interns (if you have any) will have the impression that all this is normal in our industry.&#160; The result of this is that as they continue to build and ship software in the future, those junior developers and interns will have shipped products with broken windows in them.&#160; The theory can also backfire on your organization as the developers, sooner or later, realize that the organization isn’t mature enough and might decide to work somewhere else that will provide them the proper environment to appreciate the craft of building software and pay attention to the smallest details.&#160;&#160; Here are a few examples of what I consider a broken window in the code and that should get fixed as soon as possible:</p>
<ul>
<li>Missing unit tests</li>
<li>Comments out-of-sync with the target code</li>
<li>A method, class or module that should be refactored</li>
<li>A complex piece of code that could be replaced with a design pattern to better express its intent</li>
<li>A broken build</li>
<li>Etc.</li>
</ul>
<p>There are also some solutions to prevent this theory to hinder the software project: </p>
<ul>
<li>Performing code reviews at least once a week</li>
<li>Encouraging pair programming, as four eyes are better than two <img src='http://blog.briandicroce.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </li>
<li>Putting in place automated tools that will break the build when rules are broken (<a href="http://msdn.microsoft.com/en-us/library/bb429476(VS.80).aspx">FxCop</a>, <a href="http://www.ndepend.com/">NDepend</a>, <a href="http://www.ncover.com/">NCover</a>, etc.)</li>
<li>Having the programmer check in her modifications in a private build such that if it succeeds then the modifications are merged to the repository.&#160; Have a look at <a href="http://www.jetbrains.com/teamcity/">Team City</a> for it does that very well.</li>
<li>Providing intelligent tools to your developers so that they can work more effectively with the codebase.&#160; A tool like <a href="http://www.jetbrains.com/resharper/index.html">ReSharper</a> quickly comes into mind.</li>
<li>Instilling an atmosphere that considers quality as the most important instrument to drive the organization to success.</li>
</ul>
<p>But the tools and processes aren’t the heart of the solution.&#160; What will either make or break the software is the <strong>attitude</strong> of every single individual affected to the project.&#160; To encourage the growth and maturity of this attitude, developers should educate themselves on the trends of software development.&#160; Developers should constantly thrive to do as much as possible to become <a href="http://blog.briandicroce.com/2007/12/29/ten-simple-tips-to-become-a-valuable-software-professional/">more valuable software professionals</a>.&#160;&#160; </p>
<p>Though he doesn’t talk about this theory explicitly in his book, <a href="http://www.amazon.com/exec/obidos/ASIN/0131857258/brdicr-20">Agile Principles, Patterns, and Practices in C#</a>, Robert C. Martin does reflect on the basis of the Broken Windows theory and also does provide a remedy to fight this problem in software.&#160; According to him, and I agree with his statement, it’s all about having an attitude of being professional:</p>
<blockquote><p>The attitude that agile developers have toward the design of the software is the same attitude that surgeons have toward sterile procedure.&#160; Sterile procedure is what makes surgery <em>possible</em>.&#160; Without it, the risk of infection would be far too high to tolerate.&#160; Agile developers feel the same way about their designs.&#160; <strong>The risk of letting even the tiniest bit of rot begin is too high to tolerate</strong>.</p>
<p>The design must remain clean.&#160; And since the source code is the most important expression of the design, it too must remain clean.&#160; <strong>Professionalism dictates that we, as software developers, cannot tolerate code rot</strong>.</p>
</blockquote>
<p>Remember: Only <strong>YOU</strong> can prevent broken windows in your software project from spreading like cancer.&#160; You have access to a grand vast of online resources and tools to help you fix those broken windows before it’s too late.&#160; Do you have the attitude to do as such?</p>
                        <p><br />
My name is Brian Di Croce, a passionate software developer living, coding, blogging and working in Montreal, Canada.  Feel free to visit my <a href="http://www.briandicroce.com">website/blog</a> for more great content related to software development with .NET! &copy;2007-2008<br />
</p>                        <div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=WRGKqq4mwnc:6peH53xZmAU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=WRGKqq4mwnc:6peH53xZmAU:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=WRGKqq4mwnc:6peH53xZmAU:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=WRGKqq4mwnc:6peH53xZmAU:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=WRGKqq4mwnc:6peH53xZmAU:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/BrianDiCroce/~4/WRGKqq4mwnc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.briandicroce.com/2009/02/08/broken-windows-theory-in-software/feed/</wfw:commentRss>
		<feedburner:origLink>http://blog.briandicroce.com/2009/02/08/broken-windows-theory-in-software/</feedburner:origLink></item>
		<item>
		<title>Getting Familiar With Your Basic .NET Delegates</title>
		<link>http://feedproxy.google.com/~r/BrianDiCroce/~3/FEoTQ3xUhZ4/</link>
		<comments>http://blog.briandicroce.com/2009/02/01/getting-familiar-with-your-basic-net-delegates/#comments</comments>
		<pubDate>Mon, 02 Feb 2009 03:01:09 +0000</pubDate>
		<dc:creator>Brian Di Croce</dc:creator>
		
		<category><![CDATA[.NET Programming]]></category>

		<guid isPermaLink="false">http://blog.briandicroce.com/?p=490</guid>
		<description>The .NET framework is a complete toolbox of programming constructs that allows a developer to create any kind of software.&amp;#160; You’re practically limited by your imagination and knowledge on the framework.&amp;#160; Such a knowledge can be satisfied by getting more familiar with its interfaces, abstract classes, concrete types, events and delegates.&amp;#160; In this post, I [...]</description>
			<content:encoded><![CDATA[<p>The .NET framework is a complete toolbox of programming constructs that allows a developer to create any kind of software.&#160; You’re practically limited by your imagination and knowledge on the framework.&#160; Such a knowledge can be satisfied by getting more familiar with its interfaces, abstract classes, concrete types, events and delegates.&#160; In this post, I want to concentrate on inviting you to get familiar with some basic and powerful delegates provided by the .NET framework.&#160; The reason of this post is that I often see developers create their own delegates that have the same semantics of the ones provided in the framework mostly because they aren’t aware of them.&#160; Instead of violating the <a href="http://en.wikipedia.org/wiki/Don%27t_repeat_yourself">DRY</a> principle of programming, let’s discover and learn about them so that we can avoid reinventing the wheel.</p>
<p>The set of basic delegates that I think .NET developers should be familiar and comfortable using are the generic <strong>Action&lt;T&gt;</strong>, <strong>Comparison&lt;T&gt;</strong>, <strong>Converter&lt;TInput, TOutput&gt; </strong>and <strong>Predicate&lt;T&gt;</strong> delegates.&#160; I will introduce you to each of these delegates by describing their usage with a simple example so that you can start using them in your codebase where needed.</p>
<h4>The Action&lt;T&gt; delegate</h4>
<p>In .NET 2.0, the Action delegate, declared in <strong>mscorlib.dll</strong>, has the following signature:</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, &#39;Courier New&#39;, 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, &#39;Courier New&#39;, 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, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">public</span> <span style="color: #0000ff">delegate</span> <span style="color: #0000ff">void</span> Action&lt;T&gt;(T obj);</pre>
</p></div>
</div>
<p>When Microsoft released .NET 3.5, four more Action delegates were included in <strong>System.Core.dll</strong>:</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, &#39;Courier New&#39;, 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, &#39;Courier New&#39;, 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, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">public</span> <span style="color: #0000ff">delegate</span> <span style="color: #0000ff">void</span> Action()</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, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">public</span> <span style="color: #0000ff">delegate</span> <span style="color: #0000ff">void</span> Action&lt;T1,T2)(T1 arg1, T2 arg2)</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, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">public</span> <span style="color: #0000ff">delegate</span> <span style="color: #0000ff">void</span> Action&lt;T1,T2,T3)(T1 arg1, T2 arg2, T3 arg3)</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, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">public</span> <span style="color: #0000ff">delegate</span> <span style="color: #0000ff">void</span> Action&lt;T1,T2,T4)(T1 arg1, T2 arg2, T3 arg3, T4 arg4)</pre>
</p></div>
</div>
<p>Regardless of the different signatures of the Action delegate, its semantic is to <strong>encapsulate a method which doesn’t return a value, and which holds a variable number of parameters</strong>:</p>
<ul>
<li>If the method is parameterless, you should prefer the Action delegate. </li>
<li>If the method accepts one parameter, you should prefer the generic Action&lt;T&gt; delegate. </li>
<li>If the method accepts two parameters, you should prefer the generic Action&lt;T1, T2&gt; delegate. </li>
<li>If the method accepts three parameters, you should prefer the generic Action&lt;T1, T2, T3&gt; delegate. </li>
<li>If the method accepts four parameters, you should prefer the generic Action&lt;T1, T2, T3, T4&gt; delegate. </li>
<li>If the method accepts five (or more) parameters, you should prefer reviewing your design <img src='http://blog.briandicroce.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </li>
</ul>
<p>A quick analysis with <a href="http://www.red-gate.com/products/reflector/">Reflector</a> on the these delegates show that only the Action&lt;T&gt; delegate is being used by .NET in a couple of places, notably as a parameter for the ForEach method of both the static Array class and the generic List&lt;T&gt; class.&#160; The other locations where this delegate is being used aren’t publicly accessible, so we will restrain ourselves to understanding the use of this delegate with a simple usage with the ForEach method of the generic List&lt;T&gt;.</p>
<p>Suppose we have a collection of toys which we want to iterate to display each of its name on the console.&#160; A possible solution to satisfy this requirement without using the Action&lt;T&gt; delegate could be:</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, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<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, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #008000">// Create our toys collection</span>
List&lt;Toy&gt; toys = Repository&lt;Toy&gt;.FetchAll(); <span style="color: #008000">// Not that important how we get our toys collection here</span>

<span style="color: #008000">// Iterate through the collection using a foreach statement and display each toy's name on the console</span>
<span style="color: #0000ff">foreach</span>(var toy <span style="color: #0000ff">in</span> toys)
{
  System.Console.WriteLine(toy.Name);
}</pre>
</div>
<p>The above solution works and your unit tests should pass.&#160; But does it warrant a check-in to the source code repository?&#160; This code we have written to satisfy the requirement seems to me very imperative, almost like how a robot would think.&#160; I am mixing both the “how” and the “what” in this context.&#160; For instance, I am iterating on the collection with a foreach statement (the “how”) in order to fulfill my intent which is to display the toy’s name on the console (the “what”).&#160; Since my brain is better at processing one information at a time, I rather focus on the intention rather than the implementation.&#160; Maybe we can hold on that check-in and see if there’s a better way to do this.</p>
<p>As a matter of fact, there is.&#160; The generic List&lt;T&gt; class defines an instance method which iterates the collection and performs an <em>action</em> for each of its element via an Action&lt;T&gt; delegate.&#160; The Array class defines the same method but it is added as an extension method on that type.&#160; That being said, if there’s another data structure that implements IEnumerable&lt;T&gt; or IEnumerable which doesn’t have an equivalent of a ForEach method, there’s nothing stopping you from creating one on the type via an extension method.&#160; This is the second solution that satisfy this requirement and which clearly brings out my intention forward because I don’t care how the collection is being iterated or what algorithm is used for the iteration, I’m just concerned of doing something with each of its element in a sequential manner.</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, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<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, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #008000">// Create our toys collection</span>
List&lt;Toy&gt; toys = Repository&lt;Toy&gt;.FetchAll(); <span style="color: #008000">// Not that important how we get our toys collection here</span>

<span style="color: #008000">// Display each toy's name in the console (using a lambda expression)</span>
toys.ForEach(toy =&gt; System.Console.WriteLine(toy.Name));

<span style="color: #008000">// You can also use an anonymous delegate to do the same thing...only with more keyboard typing than is necessary</span>
toys.ForEach( <span style="color: #0000ff">delegate</span>(Toy toy)
              {
                System.Console.WriteLine(toy.Name);
              }
            );</pre>
</div>
<p>Ignoring the instruction using the anonymous delegate, and instead focusing on the one using the lambda expression, we can clearly see that our intention is much clearer.&#160; On a side note, I will use lambda expression whenever needed for the following examples to keep them shorter.&#160; I just added the anonymous delegate if you weren’t too familiar with lambdas.&#160; As you see by using the lambda expression that I don’t have to use the delegate keyword and I can safely rest on the compiler’s type inference&#160; functionality which are both a time saver.&#160; The bottom line with the Action delegate is that it is there for you to do something (perform an <em>action</em>) on an element.&#160; It is commonly used when some action must be performed on an element during an iteration over a collection, but keep in mind that it doesn’t have to be used <em>just</em> in the context of an iteration over a collection.&#160; The Action delegate is also a powerful move to consider when, for example, a collection doesn’t offer a specific iterator that you’re looking for, such as an EvenNumberIterator.&#160; In this case, for every iterated element, you’ll do something specific if the number is even, such as displaying it on the screen (notice that to use multiple statements with lambdas, those statements should be enclosed within braces):</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, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<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, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">List&lt;<span style="color: #0000ff">int</span>&gt; numbers = Generator&lt;<span style="color: #0000ff">int</span>&gt;.GenerateSequence( 10 ); <span style="color: #008000">// Generate a sequence of 10 random numbers</span>

numbers.ForEach( number =&gt;
                 {
                     <span style="color: #008000">// Display the number only if it's even</span>
                     <span style="color: #0000ff">if</span> ( number % 2 == 0 )
                        Console.WriteLine( number );
                 }
               );</pre>
</div>
<p>Something to keep in mind with all the parameterized Action delegates is that the <strong>parameters are passed by value</strong> which means that any modification to anyone of them will only be local to the scope of delegate’s body or the method being invoked by the delegate.&#160; In other words, the collection’s items won’t be modified.&#160; The multiple parameterized Action delegates introduced in .NET 3.5 allow you to use them in case you need to do something with either two, three or four parameters (they can all be of the same type if needed).</p>
<h4>The Comparison&lt;T&gt; delegate</h4>
<p>Introduced in .NET 2.0, the generic Comparison&lt;T&gt; delegate is mostly used for <strong>sorting elements within a collection</strong>.&#160; It is currently used by the Sort methods of both the Array and generic List&lt;T&gt; classes.&#160; This delegate has the following signature:</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, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<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, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">public</span> <span style="color: #0000ff">delegate</span> <span style="color: #0000ff">int</span> Comparison&lt;T&gt;(T x, T y)</pre>
</div>
<p>The nature of the delegate is identical to the IComparer&lt;T&gt;.Compare method in that:</p>
<ul>
<li>if x &gt; y, then a positive value is returned (traditionally that value is 1); </li>
<li>if x &lt; y then a negative value is returned (traditionally that value is -1); </li>
<li>in the case where both x and y are equal, a value of 0 is returned. </li>
</ul>
<p>This shouldn’t be too much of a surprise because internally the Sort method of both the Array and generic List&lt;T&gt; classes use the generic FunctorComparer&lt;T&gt; to wrap the delegate so that it can be used as an IComparer&lt;T&gt; object internally.&#160; When the IComparer&lt;T&gt;.Compare method is invoked by .NET, it is actually the Comparison&lt;T&gt; delegate that is fired.&#160; Pretty neat, uh?&#160; The semantic of using this delegate (or the IComparer interface for that matter) is to define an <strong>alternative order</strong> for sorting elements within a collection.&#160; Getting back to our toys collection, suppose we want to sort them by name (a string).&#160; We could provide the following code to satisfy this requirement:</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, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<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, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">List&lt;Toy&gt; toys = Repository&lt;Toy&gt;.FetchAll();  <span style="color: #008000">// Again it doesn't matter how we get our toys</span>

<span style="color: #008000">// using a lambda expression to define our sorting algorithm</span>
toys.Sort((x, y) =&gt;
           {
               <span style="color: #0000ff">if</span> (x == y) <span style="color: #0000ff">return</span> 0;

               <span style="color: #0000ff">if</span> (x == <span style="color: #0000ff">null</span>) <span style="color: #0000ff">return</span> -1;

               <span style="color: #0000ff">if</span> (y == <span style="color: #0000ff">null</span>) <span style="color: #0000ff">return</span> 1;

               <span style="color: #0000ff">return</span> x.Name.CompareTo(y.Name);

           }
        );</pre>
</div>
<p>This solution is great if you only have one sorting strategy and you foresee that it will not change in the future.&#160; But there’s a better way to use this delegate.&#160; In fact, the power of the Comparison&lt;T&gt; delegate is that…it’s a delegate!&#160; This means that we can do some crazy and complex sorting if we must by combining various strategies!&#160; What if we want to sort our toys first by name, then by price and also by a different criteria?&#160; Using a lambda expression is asking way too much trouble.&#160; Let’s see how we can take advantage of the Comparison&lt;T&gt; delegate in this case.&#160; Let us now sort our toys by name, then by price.</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, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<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, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">private</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">void</span> Main(<span style="color: #0000ff">string</span>[] args)
{
    List&lt;Toy&gt; toys = Repository&lt;Toy&gt;.FetchAll();  <span style="color: #008000">// Again it doesn't matter how we get our toys</span>

    <span style="color: #008000">// Instantiate our Comparison&lt;T&gt; delegate in a way that we want to sort our toys by name (first order), then by price (second order)</span>
    Comparison&lt;Toy&gt; comparison = CompareToysByName;
    comparison += CompareToysByPrice;

    toys.Sort(comparison);
}

<span style="color: #008000">// Compare two toys by name</span>
<span style="color: #0000ff">private</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">int</span> CompareToysByName( Toy x, Toy y )
{
    <span style="color: #0000ff">if</span> (x == y) <span style="color: #0000ff">return</span> 0;

    <span style="color: #0000ff">if</span> (x == <span style="color: #0000ff">null</span>) <span style="color: #0000ff">return</span> -1;

    <span style="color: #0000ff">if</span> (y == <span style="color: #0000ff">null</span>) <span style="color: #0000ff">return</span> 1;

    <span style="color: #0000ff">return</span> x.Name.CompareTo(y.Name);
}

<span style="color: #008000">// Compares two toys by price</span>
<span style="color: #0000ff">private</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">int</span> CompareToysByPrice( Toy x, Toy y )
{
    <span style="color: #0000ff">if</span> (x == y) <span style="color: #0000ff">return</span> 0;

    <span style="color: #0000ff">if</span> (x == <span style="color: #0000ff">null</span>) <span style="color: #0000ff">return</span> -1;

    <span style="color: #0000ff">if</span> (y == <span style="color: #0000ff">null</span>) <span style="color: #0000ff">return</span> 1;

    <span style="color: #0000ff">return</span> x.Price.CompareTo(y.Price);
}</pre>
</div>
<p>This is awesome because we can simply mix our sorting strategies through a simple delegate which will be used as a parameter to the Sort method of both an Array and generic List&lt;T&gt; classes.&#160; Once the Sort method has finished its job, your collection will be sorted by the criteria you have specified.&#160; </p>
<h4>The Converter&lt;TInput, TOutput&gt; delegate</h4>
<p>The next delegate that I would like to be familiar with is the generic Converter&lt;TInput, TOutput&gt; delegate which was introduced in .NET 2.0.&#160; Just like its other counterparts, this delegate is being used by both the Array and generic List&lt;T&gt; classes, more specifically in their ConvertAll&lt;TOutput&gt; methods.&#160; The signature of the Converter&lt;TInput, TOutput&gt; delegate is as follows:</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, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<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, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">public</span> <span style="color: #0000ff">delegate</span> TOutput Converter&lt;TInput, TOutput&gt;(TInput input)</pre>
</div>
<p>This delegate is useful whenever you have to define a strategy to <strong>convert an object from one type to another type</strong>.&#160; For example, you might want to convert an object of type System.Int32 to a type System.String.&#160; Continuing with our toys example, let us consider the following simple requirement: we want to create a list containing only the names of every toy from our toys collection.&#160; </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, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<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, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">List&lt;Toy&gt; toys = Repository&lt;Toy&gt;.FetchAll(); <span style="color: #008000">// Not really important how we get all our toys.</span>

List&lt;<span style="color: #0000ff">string</span>&gt; toysNames = toys.ConvertAll(toy =&gt; toy.Name);</pre>
</div>
<p>It’s that easy!&#160; Our strategy is basically that given a Toy (this is our closed type for TInput), we’ll return a String (this is our closed type for TOutput).&#160; Just like we have done with the Comparison&lt;T&gt; delegate example, you can also mix in some conversion strategies.&#160; Just remember that variance on delegates isn’t supported in C# 3.0.&#160; For more information on this topic, I strongly suggest you to read <a href="http://blogs.msdn.com/ericlippert/archive/tags/Covariance+and+Contravariance/default.aspx">Eric Lippert’s eleven-part posts on covariance and contravariance</a>. </p>
<h4>The Predicate&lt;T&gt; delegate</h4>
<p>Though being used once again by the Array and generic List&lt;T&gt; classes, the generic Predicate&lt;T&gt; delegate is more used by the framework than the three other ones.&#160; This delegate represents a method that <strong>defines a set of criteria and determines whether the specified object meets those criteria</strong>.&#160; You can also see this delegate acting like a filter on a collection. The signature of the Predicate&lt;T&gt; delegate is as follows:</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, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<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, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">public</span> <span style="color: #0000ff">delegate</span> <span style="color: #0000ff">bool</span> Predicate&lt;T&gt;(T obj)</pre>
</div>
<p>Like I said, the .NET framework uses this delegate in both the Array and generic List&lt;T&gt; classes in many of their methods (Exists, Find, FindAll, FindIndex, etc.).&#160; In short, you provide an evaluation context for a parameter where you either return true if the condition for that parameter is met, false otherwise.&#160; Continuing with our toys example, suppose that we want to 1) find out whether we have a toy with a specific name and year, and 2) find all the toys that were made in Canada.&#160; We could simply use the provided methods (Exists and FindAll) and passing them a Predicate&lt;T&gt; delegate that will contain our logic for evaluating whether or not the condition is satisfied.</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, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<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, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">List&lt;Toy&gt; toys = Repository&lt;Toy&gt;.FetchAll(); <span style="color: #008000">// We're not particularly interested in knowing how we got our toys.</span>

<span style="color: #008000">// 1. We're interested in knowing whether we have my favorite Transformer of all: Megatron!  </span>
<span style="color: #008000">// I have a couple of them, but I'm specifically interested in the one my parents bought me in 1985.</span>
<span style="color: #0000ff">bool</span> containsMy1985Megatron = toys.Exists( toy =&gt; toy.Name == <span style="color: #006080">&quot;Megatron&quot;</span> &amp;&amp; toy.Year = 1985 );

<span style="color: #008000">// 2. We're now interested in retrieving all our toys made in Canada.</span>
List&lt;Toy&gt; myDecepticons = toys.FindAll( toy =&gt; toy.Country == <span style="color: #006080">&quot;Canada&quot;</span> );</pre>
</div>
<p>By simply invoking those methods and passing them a Predicate&lt;T&gt; delegate, I can concentrate on what I want in a more declarative way because I don’t have to explicitly iterate/loop over the collection with either a foreach statement, a for loop, a while loop, etc.&#160; I just want to iterate over my toys, and either find out if a match was found or retrieve all my toys that satisfy some condition.&#160; This last statement is also true for any of the other delegates that I presented here. </p>
<h4>Conclusion</h4>
<p>In this post, I wanted to familiarize you with some of the basic delegates that are offered by the .NET framework BCL (outside of ASP.NET, ADO.NET, etc.) that allow you more flexibility in specifying different strategies for various contexts (such as in finding, retrieving, converting or performing an action to an element of a collection).&#160; In other words, these delegates allow me to concentrate more on the business logic rather than, for example, writing the plumbing necessary to iterate over a collection, because they are commonly used as a parameter to a method which already implements the plumbing on my behalf. </p>
<p>Whether I’m consulting with companies or training developers, more often than not I see these kind of delegates redefined in code because the developers were completely ignorant of the existence of these delegates!&#160; That’s too bad, because violating the DRY principle forces you to document, test and maintain more code than you would actually need in your codebase.&#160; Remember that the .NET framework isn’t solely C#.&#160; The .NET framework is a huge toolbox that provides you with many tools (interfaces, classes, events, delegates, etc.) to build various applications.&#160; The more you know about those tools and how to use them properly, the better your code will be and the more valuable you will become to your organization and team.</p>
<p>For more information on delegates, I highly recommend you the following links:</p>
<ul>
<li>Get a copy of <a href="http://www.amazon.com/exec/obidos/ASIN/0321485890/brdicr-20"><strong>More Effective C#: 50 Specific Ways to Improve Your C#</strong></a> by Bill Wagner.&#160; More specifically, take a look at Item 18: Decouple Iterations from Actions, Predicate, and Functions to get a better understanding of Action, Predicate and Func delegates. </li>
<li>Get a copy of <a href="http://www.amazon.com/exec/obidos/ASIN/1933988363/brdicr-20"><strong>C# in Depth</strong></a> by Jon Skeet.&#160; This is one guy who has been very helpful in the .NET community by writing many <a href="http://www.yoda.arachsys.com/csharp/">useful articles</a> and also published, in my opinion, the best practical book on C# 2.0/3.0 to date. </li>
<li>Check out dnrTV’s episode on <a href="http://www.dnrtv.com/default.aspx?showNum=40">events and delegates with Mark Miller</a>. </li>
</ul>
                        <p><br />
My name is Brian Di Croce, a passionate software developer living, coding, blogging and working in Montreal, Canada.  Feel free to visit my <a href="http://www.briandicroce.com">website/blog</a> for more great content related to software development with .NET! &copy;2007-2008<br />
</p>                        <div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=FEoTQ3xUhZ4:pPAfiqX8SmA:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=FEoTQ3xUhZ4:pPAfiqX8SmA:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=FEoTQ3xUhZ4:pPAfiqX8SmA:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=FEoTQ3xUhZ4:pPAfiqX8SmA:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=FEoTQ3xUhZ4:pPAfiqX8SmA:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/BrianDiCroce/~4/FEoTQ3xUhZ4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.briandicroce.com/2009/02/01/getting-familiar-with-your-basic-net-delegates/feed/</wfw:commentRss>
		<feedburner:origLink>http://blog.briandicroce.com/2009/02/01/getting-familiar-with-your-basic-net-delegates/</feedburner:origLink></item>
		<item>
		<title>Rely on your experience and knowledge over some tools’ recommendations</title>
		<link>http://feedproxy.google.com/~r/BrianDiCroce/~3/tE490d69w98/</link>
		<comments>http://blog.briandicroce.com/2008/12/30/rely-on-your-experience-and-knowledge-over-some-tools-recommendations/#comments</comments>
		<pubDate>Tue, 30 Dec 2008 20:49:19 +0000</pubDate>
		<dc:creator>Brian Di Croce</dc:creator>
		
		<category><![CDATA[.NET Programming]]></category>

		<guid isPermaLink="false">http://blog.briandicroce.com/?p=481</guid>
		<description>Whenever .NET developers tell me they know C# really well, I can’t help myself but to wonder whether they mean 1) the programming language itself (its syntax, its grammar and its constructs), 2) the compiler or 3) both. The compiler is the heart of any programming language and if you respect it enough when you [...]</description>
			<content:encoded><![CDATA[<p>Whenever .NET developers tell me they know C# really well, I can’t help myself but to wonder whether they mean 1) the programming language itself (its syntax, its grammar and its constructs), 2) the compiler or 3) both. The compiler is the heart of any programming language and if you respect it enough when you code, you can create some very optimal and productive things with it. On the other hand, if you only focus on the programming language and disregard the inner workings of the compiler, chances are that you risk affecting the health of your software…negatively.</p>
<p>For example, I tend to see a severe chronic problems amongst C# developers towards operations related to <a href="http://msdn.microsoft.com/en-us/library/yz2be5wk.aspx">boxing and unboxing</a>. Reading some newsgroups posts, blog posts’ comments and working with many .NET developers that have never heard these terms before made me aware that this chronic problem was pretty much widespread. This phenomena is even more real for developers that are too keen on using coding/refactoring tools, like <a href="http://www.jetbrains.com/resharper/">ReSharper</a>, because they tend to rely more on the suggestions of those tools instead of relying on deeper knowledge to decide whether or not a change in the code is due. Before building on this idea, I think it’ll be a good idea to refresh our concepts of boxing and unboxing in .NET. For this, I’ll share some notes from the excellent book on .NET programming, <a href="http://www.amazon.com/exec/obidos/ASIN/0735621632/brdicr-20">CLR via C#</a> (second edition), by Jeffrey Richter. </p>
<p>Let us consider what happens when <strong>boxing</strong> occurs:</p>
<blockquote><p>It&#8217;s possible to convert a value type to a reference type by using a mechanism called boxing. Internally, here&#8217;s what happens when an instance of a value type is boxed:</p>
<ol>
<li>Memory is allocated from the managed heap. The amount of memory allocated is the size required by the value type&#8217;s fields plus the two additional overhead members (the type object pointer and the sync block index) required by all objects on the managed heap.</li>
<li>The value type&#8217;s fields are copied to the newly allocated heap memory.</li>
<li>The address of the object is returned. This address is now a reference to an object; the value type is now a reference type.</li>
</ol>
<p>The C# compiler automatically produces the IL code necessary to box a value type instance, <strong><span style="text-decoration: underline;">but you still need to understand what&#8217;s going on internally so that you&#8217;re aware of code size and performance issues</span></strong>.</p></blockquote>
<p>You see that I have put the last sentence in bold. What Jeffrey is saying there is extremely important, because some tools aren’t smart enough to handle every single mechanisms of the compiler, therefore “you still need to understand what’s going on internally so that you’re aware of code size and performance issues”. Let us move on. </p>
<p>Let us now consider what happens during <strong>unboxing</strong>:</p>
<blockquote><p>Unboxing is <em>not</em> the exact opposite of boxing. The unboxing operation is much less costly than boxing. Unboxing is really just the operation of obtaining a pointer to the raw value type (data fields) contained within an object. In effect, the pointer refers to the unboxed portion in the boxed instance. So, unlike boxing, unboxing doesn’t involve the copying of any bytes in memory. Having made this important clarification, it is important to note than an unboxing operation is typically followed by copying the fields. Frequently, however, an unboxing operation is followed immediately by copying its fields. Internally, here’s exactly what happens when a boxed value type instance in unboxed:</p>
<ol>
<li>If the variable containing the reference to the boxed value type is <span style="font-family: courier new;">null</span>, a <span style="font-family: courier new;">NullReferenceException</span> is thrown.</li>
<li>If the reference doesn’t refer to an object that is a boxed instance of the desired value type, an <span style="font-family: courier new;">InvalidCastException</span> is thrown.</li>
</ol>
</blockquote>
<p>Now that we have a general idea of what boxing and unboxing are and how they work, we should consider the following as an important principle:</p>
<blockquote><p>Obviously, boxing and unboxing/copy operations hurt your application’s performance in terms of both speed and memory, <strong>so you should be aware of when the compiler generates code to perform these operations automatically and <span style="text-decoration: underline;">try to write code that minimizes this code generation</span></strong>.</p></blockquote>
<p>In a nutshell you get boxing whenever a conversion from a value type to a reference type occurs. Conceptually, unboxing is the reverse operation where a conversion from a reference type (such as an instance of <span style="font-family: courier new;">Object</span>) to a value type occurs. In .NET, value types are any object that derives from <span style="font-family: courier new;">System.ValueType</span>, such as your familiar primitive types (<span style="font-family: courier new;">Int32</span>, <span style="font-family: courier new;">Boolean</span>, <span style="font-family: courier new;">Char</span>, <span style="font-family: courier new;">Decimal</span>, etc.), structures and enumerations. Reference types are classes, interfaces, events, delegates, exceptions, etc. (basically anything that doesn’t derive from <span style="font-family: courier new;">System.ValueType</span>). The key element to understand is not necessary the mechanisms involved by the compiler, but rather to be conscious that there is a performance hit whenever boxing and unboxing occurs. Since the introduction of generics with .NET 2.0, we don’t have to deal as much with such concepts because generics provide type safety and better performance by avoiding boxing/unboxing operations. But not everything in .NET is generic and it’s extremely important to discover those potential “danger zones” where boxing/unboxing operations can occur within the framework, especially if you’re using development tools like ReSharper.</p>
<p>I’m a big fan of <a href="http://www.jetbrains.com">JetBrains</a> and all their products that help me be more effective as a developer. Their continuous integration tool, <a href="http://www.jetbrains.com/teamcity/">TeamCity</a>, is in my opinion the most innovative and complete software to set up a CI environment. Their <a href="http://www.jetbrains.com/profiler/index.html">dotTrace</a> profiling application is also one of those tools that is installed whenever I set up a fresh development environment. But the one tool that I cannot code without is none other than <a href="http://www.jetbrains.com/resharper/">ReSharper</a>. I believe so much in that tool for making me more productive and effective when I code that I even wrote a post about <a href="http://blog.briandicroce.com/2008/05/12/the-case-for-resharper-in-the-enterprise/">reasons why the enterprise should seriously consider ReSharper for its developers</a>. Unfortunately, ReSharper isn’t perfect. Excellent yes, but not perfect. Which means that developers should still use their knowledge about the programming language and the compiler to really take advantage of the .NET platform. This statement is even more pronounced when potential boxing/unboxing situations can occur. For example, consider the following code:</p>
<pre class="csharp" name="code">private static void Main()
{
  string name = "Brian";
  int age = 27;
  System.Console.WriteLine("Hello, my name is " + name + " and I'm " + age + " years old.");
}</pre>
<p>At first sight, it seems that the above code is right.  I would agree with you at some extend.  I agree that it compiles just fine and that it outputs the correct message on the console.  If you had ReSharper installed, it will also say that the code is well formatted and that you’re good to check it in (the feedback for this is a little green icon on the top right side of the code window in Visual Studio).  The underlying problem with this code is that your application gets a performance hit because a boxing operation has occurred.  In fact, if you view the IL emitted by the compiler you will see a <span style="font-family: Courier New;">box</span> instruction which forces the CLR to perform boxing for the value type.  The reason for this is that implicitly, this overloaded version of <span style="font-family: Courier New;">Console.WriteLine()</span> calls one of the overloaded versions <span style="font-family: Courier New;">String.Concat()</span> which accepts <span style="font-family: Courier New;">Object</span> parameters (a tool like <a href="http://www.red-gate.com/products/reflector/">Reflector</a> or <a href="http://msdn.microsoft.com/en-us/library/f7dy01k1(VS.80).aspx">ILDASM</a> can help you to see this for yourself).</p>
<p>This is the point where knowledge and experience kicks in.  The proper way to write the above code is as following:</p>
<pre class="csharp" name="code">private static void Main()
{
  string name = "Brian";
  int age = 27;
  System.Console.WriteLine("Hello, my name is " + name + " and I'm " + age.ToString() + " years old.");
}</pre>
<p>The reason the code above is superior is that you get all the benefits of the first version without the performance hit because no boxing occurs (again you can check this for yourself by viewing the IL emitted by the compiler).  As a matter of fact, calling a <span style="font-family: Courier New;">ToString()</span> method on a value type will tell the CLR to invoke that method instead on that particular instance instead of boxing the value type as a reference type and then calling <span style="font-family: Courier New;">Object</span>’s <span style="font-family: Courier New;">ToString()</span> on it.  If you call Console.WriteLine( age ) instead, you might be surprised to know that no boxing occurs because one of the overloaded versions of that method actually accepts an Int32 as a parameter.  </p>
<p>This is why I said that knowledge and experience counts because unless you know these nifty facts you could blindly follow your tools’ recommendations which might propose some false positives.  An example of a false positive can be ReSharper graying out the <span style="font-family: Courier New;">ToString()</span> method call on the <span style="font-family: Courier New;">age</span> variable and recommending you to remove it.  Most developers using ReSharper will blindly follow such recommendation and actually remove the invocation of <span style="font-family: Courier New;">ToString()</span> on the value type by either hitting ALT+ENTER on the line and let ReSharper remove the invocation or by reformatting the whole code file by hitting CTRL+ALT+SHIFT+F.  Though the above example seems pretty negligent, you can imagine this kind of operation in a loop or anywhere else a boxing/unboxing operation might occur in a library or within the framework itself.  A simple profiling on the application should detect such a performance bottleneck.  In other words, don’t checkmate yourself by blindly following your tools recommendations!</p>
<p>Even though I only touched on the subject of boxing and unboxing, it’s important to understand that there are many other areas that this post’s ideas apply.  For example, knowing when to explicitly implement an interface, deciding when to favor composition over inheritance, justifying the encapsulation level of a class and its members, etc.  These are strategies that some tools can’t provide a hint for, therefore you should rely on your knowledge and experience on the platform and the programming paradigms (object-oriented, functional, etc.) currently used.  If you have the chance of working in a larger team, I highly recommend your team to conduct code review sessions so that each team member can leverage each other’s knowledge and experience on the platform.  On the other hand, if you don’t have the privilege of participating in code reviews, or even worse if your organization doesn’t encourage such a practice, then you’re pretty much on your own, but you’re not alone!  In that case, I recommend you to read the following books which will no doubt make you a better C#/.NET programmer:</p>
<ul>
<li><a href="http://www.amazon.com/exec/obidos/ASIN/0735621632/brdicr-20"><strong>CLR via C# (Second Edition)</strong></a> by Jeffrey Richter</li>
<li><a href="http://www.amazon.com/exec/obidos/ASIN/1933988363/brdicr-20"><strong>C# in Depth</strong></a> by Jon Skeet</li>
<li><a href="http://www.amazon.com/exec/obidos/ASIN/0321245660/brdicr-20"><strong>Effective C#</strong></a> by Bill Wagner</li>
</ul>
                        <p><br />
My name is Brian Di Croce, a passionate software developer living, coding, blogging and working in Montreal, Canada.  Feel free to visit my <a href="http://www.briandicroce.com">website/blog</a> for more great content related to software development with .NET! &copy;2007-2008<br />
</p>                        <div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=tE490d69w98:8G7grOCvlF4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=tE490d69w98:8G7grOCvlF4:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=tE490d69w98:8G7grOCvlF4:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=tE490d69w98:8G7grOCvlF4:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=tE490d69w98:8G7grOCvlF4:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/BrianDiCroce/~4/tE490d69w98" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.briandicroce.com/2008/12/30/rely-on-your-experience-and-knowledge-over-some-tools-recommendations/feed/</wfw:commentRss>
		<feedburner:origLink>http://blog.briandicroce.com/2008/12/30/rely-on-your-experience-and-knowledge-over-some-tools-recommendations/</feedburner:origLink></item>
		<item>
		<title>Mapping a shortcut to execute unit test in current context with ReSharper</title>
		<link>http://feedproxy.google.com/~r/BrianDiCroce/~3/IRKzIrx6PjA/</link>
		<comments>http://blog.briandicroce.com/2008/11/30/mapping-a-shortcut-to-execute-unit-test-in-current-context-with-resharper/#comments</comments>
		<pubDate>Mon, 01 Dec 2008 02:34:53 +0000</pubDate>
		<dc:creator>Brian Di Croce</dc:creator>
		
		<category><![CDATA[ReSharper]]></category>

		<guid isPermaLink="false">http://blog.briandicroce.com/2008/11/30/mapping-a-shortcut-to-execute-unit-test-in-current-context-with-resharper/</guid>
		<description>It shouldn’t be a surprise to you that I’m a big fan of ReSharper since its early versions.&amp;#160; Its productivity boost and refactoring possibilities should alone convey a reason to learn and master it to be more effective when programming with C#.&amp;#160; 
One thing that I wish came out of the box, but is currently [...]</description>
			<content:encoded><![CDATA[<p>It shouldn’t be a surprise to you that I’m a big fan of <a href="http://www.jetbrains.com/resharper/">ReSharper</a> since its early versions.&#160; Its productivity boost and refactoring possibilities should alone convey a reason to learn and master it to be more effective when programming with C#.&#160; </p>
<p>One thing that I wish came out of the box, but is currently missing, is a shortcut that allows me to run my unit test in the current context (by context I mean where my cursor is currently located.&#160; If my cursor is currently in the body of TestA, then that shortcut will run the TestA unit test).&#160; This will allow me to use the mouse even less, because right now I’m using the mouse to tell ReSharper to execute the current test. It turns out that though this functionality is lacking in ReSharper 4.1, the possibility to do so still exists.&#160; </p>
<p>Here are the steps to follow if you want to map a keyboard shortcut that will run a test in the current context:</p>
<ol>
<li>In Visual Studio, go to <strong>Tools</strong> –&gt; <strong>Options</strong></li>
<li>Expand the <strong>Environment</strong> node, then go to <strong>Keyboard</strong></li>
<li>In the commands list, search for <strong>Resharper.Resharper_UnitTest_ContextRun</strong></li>
<li>Assign a shortcut for that command.&#160; In my case, I have decided to map it with <strong>Alt + X</strong> in the <strong>Global</strong> context.&#160; That shortcut is intuitive (X for &quot;execute”) and easy to trigger.&#160; You can choose whatever mapping you want, just make sure there are no conflicts with other existing shortcuts.</li>
</ol>
<p>Here’s a screenshot of the above steps in action:</p>
<p><img title="image" style="border-right: 0px; border-top: 0px; display: block; float: none; margin: 0px auto 10px; border-left: 0px; border-bottom: 0px" height="386" alt="image" src="http://blog.briandicroce.com/wp-content/uploads/2008/11/image2.png" width="648" border="0" /> </p>
<p>Now you can place your cursor in a test context (test body or test method name) and hit that shortcut (Alt + X in my case) and that test will get executed.&#160; A good tip to follow is to save your Visual Studio keyboard settings (and ReSharper settings too) under a backup repository (such as <a href="http://www.mesh.com">Live Mesh</a> for example) so that you (or your team) can re-use those same settings in your Visual Studio sessions in other machines.</p>
                        <p><br />
My name is Brian Di Croce, a passionate software developer living, coding, blogging and working in Montreal, Canada.  Feel free to visit my <a href="http://www.briandicroce.com">website/blog</a> for more great content related to software development with .NET! &copy;2007-2008<br />
</p>                        <div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=IRKzIrx6PjA:TSYHak5DEfk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=IRKzIrx6PjA:TSYHak5DEfk:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=IRKzIrx6PjA:TSYHak5DEfk:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=IRKzIrx6PjA:TSYHak5DEfk:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=IRKzIrx6PjA:TSYHak5DEfk:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/BrianDiCroce/~4/IRKzIrx6PjA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.briandicroce.com/2008/11/30/mapping-a-shortcut-to-execute-unit-test-in-current-context-with-resharper/feed/</wfw:commentRss>
		<feedburner:origLink>http://blog.briandicroce.com/2008/11/30/mapping-a-shortcut-to-execute-unit-test-in-current-context-with-resharper/</feedburner:origLink></item>
		<item>
		<title>Being professional at work: an interview with Uncle Bob, Michael Feathers and Pete McBreen (JAOO)</title>
		<link>http://feedproxy.google.com/~r/BrianDiCroce/~3/63tlcLAeIEk/</link>
		<comments>http://blog.briandicroce.com/2008/11/18/being-professional-at-work-an-interview-with-uncle-bob-michael-feathers-and-pete-mcbreen-jaoo/#comments</comments>
		<pubDate>Wed, 19 Nov 2008 01:14:05 +0000</pubDate>
		<dc:creator>Brian Di Croce</dc:creator>
		
		<category><![CDATA[Media/Presentations]]></category>

		<guid isPermaLink="false">http://blog.briandicroce.com/2008/11/18/being-professional-at-work-an-interview-with-uncle-bob-michael-feathers-and-pete-mcbreen-jaoo/</guid>
		<description>I just finished watching a special interview with Robert “Uncle Bob” Martin, Michael Feathers and Pete McBreen (author of one of my favorite books “Software Craftsmanship”) that was recorded at last year’s JAOO (check out more JAOO videos here).&amp;#160; The subject is one my dearest and often misunderstood in the industry: being professional at work [...]</description>
			<content:encoded><![CDATA[<p>I just finished watching a special <a href="http://blog.jaoo.dk/2008/06/19/is-it-professional-to-cheat-the-boss/">interview</a> with Robert “Uncle Bob” Martin, Michael Feathers and Pete McBreen (author of one of my favorite books “<a href="http://www.mcbreen.ab.ca/SoftwareCraftsmanship/index.html">Software Craftsmanship</a>”) that was recorded at last year’s JAOO (check <a href="http://jaoo.blip.tv/">out more JAOO videos here</a>).&#160; The subject is one my dearest and often misunderstood in the industry: being professional at work by writing clean code.&#160; I’ve studied software engineering as an undergraduate and one thing that was clearly missing in the curriculum was a class or two about how to write good, solid, simple, clean code that works.&#160; Instead we were taught a lot about software processes and how the processes determines whether or not your project will succeed.&#160; That’s sad because deep inside I know that the process is the to support your project, not drive it.&#160; What drives the project at the end of the line is the code.&#160; Your software is ALL about code, not processes.</p>
<p>A couple of things that made me jump while listening to this interview were when Michael Feathers says that in one company, in which he consulted, none of the developers have heard of the “Design Patterns” book by the GoF.&#160; Even a story that Pete McBreen told us about a developer who didn’t checked in his code after working on it more than four weeks.&#160; This is a very important interview that the JAOO folks have made public and even more important for managers and developers to watch it together.&#160; A special thanks for this discovery goes to <a href="http://redsquirrel.com/dave/">Dave Hoover</a> who started a thread on “apprenticeship” over at the <a href="http://groups.google.com/group/software_craftsmanship/">Software Craftsmanship Google group</a>. </p>
<p>&#160;</p>
<div align="center">
<div class="wlWriterEditableSmartContent" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:82c66866-e1a1-40af-aa2f-165bb2aacd5c" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<div><embed src="http://blip.tv/play/6Va55HGJtgc" type="application/x-shockwave-flash" width="800" height="480" allowscriptaccess="always" allowfullscreen="true"></embed></div>
</div></div>
                        <p><br />
My name is Brian Di Croce, a passionate software developer living, coding, blogging and working in Montreal, Canada.  Feel free to visit my <a href="http://www.briandicroce.com">website/blog</a> for more great content related to software development with .NET! &copy;2007-2008<br />
</p>                        <div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=63tlcLAeIEk:56-R_JWBqts:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=63tlcLAeIEk:56-R_JWBqts:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=63tlcLAeIEk:56-R_JWBqts:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=63tlcLAeIEk:56-R_JWBqts:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=63tlcLAeIEk:56-R_JWBqts:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/BrianDiCroce/~4/63tlcLAeIEk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.briandicroce.com/2008/11/18/being-professional-at-work-an-interview-with-uncle-bob-michael-feathers-and-pete-mcbreen-jaoo/feed/</wfw:commentRss>
		<feedburner:origLink>http://blog.briandicroce.com/2008/11/18/being-professional-at-work-an-interview-with-uncle-bob-michael-feathers-and-pete-mcbreen-jaoo/</feedburner:origLink></item>
		<item>
		<title>Pluralsight’s screencasts on WCF, WF, AtomPub services, Oslo and more!</title>
		<link>http://feedproxy.google.com/~r/BrianDiCroce/~3/gYHmrwz-mhs/</link>
		<comments>http://blog.briandicroce.com/2008/11/08/pluralsights-screencasts-on-wcf-wf-atompub-services-oslo-and-more/#comments</comments>
		<pubDate>Sun, 09 Nov 2008 04:26:32 +0000</pubDate>
		<dc:creator>Brian Di Croce</dc:creator>
		
		<category><![CDATA[Media/Presentations]]></category>

		<guid isPermaLink="false">http://blog.briandicroce.com/2008/11/08/pluralsights-screencasts-on-wcf-wf-atompub-services-oslo-and-more/</guid>
		<description>For your information, Pluralsight (a training firm specialized in Microsoft technologies) recently recorded some pretty useful screencasts about new and important .NET technologies such as WCF, WF, AtomPub services, Oslo and more.&amp;#160; These screencasts are available at no cost and is open to the public.&amp;#160; You can download these screencasts here.
     [...]</description>
			<content:encoded><![CDATA[<p>For your information, <a href="http://www.pluralsight.com">Pluralsight</a> (a training firm specialized in Microsoft technologies) recently recorded some pretty useful screencasts about new and important .NET technologies such as WCF, WF, AtomPub services, Oslo and more.&#160; These screencasts are available at no cost and is open to the public.&#160; You can <a href="http://www.pluralsight.com/main/screencasts/default.aspx"><strong>download these screencasts here</strong></a>.</p>
                        <p><br />
My name is Brian Di Croce, a passionate software developer living, coding, blogging and working in Montreal, Canada.  Feel free to visit my <a href="http://www.briandicroce.com">website/blog</a> for more great content related to software development with .NET! &copy;2007-2008<br />
</p>                        <div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=gYHmrwz-mhs:ka9LQZAhOv0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=gYHmrwz-mhs:ka9LQZAhOv0:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=gYHmrwz-mhs:ka9LQZAhOv0:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=gYHmrwz-mhs:ka9LQZAhOv0:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=gYHmrwz-mhs:ka9LQZAhOv0:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/BrianDiCroce/~4/gYHmrwz-mhs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.briandicroce.com/2008/11/08/pluralsights-screencasts-on-wcf-wf-atompub-services-oslo-and-more/feed/</wfw:commentRss>
		<feedburner:origLink>http://blog.briandicroce.com/2008/11/08/pluralsights-screencasts-on-wcf-wf-atompub-services-oslo-and-more/</feedburner:origLink></item>
		<item>
		<title>Edsger Dijkstra on the “Discipline in Thought”</title>
		<link>http://feedproxy.google.com/~r/BrianDiCroce/~3/WC58jeKnAnk/</link>
		<comments>http://blog.briandicroce.com/2008/11/07/edsger-dijkstra-on-the-discipline-in-thought/#comments</comments>
		<pubDate>Fri, 07 Nov 2008 16:19:00 +0000</pubDate>
		<dc:creator>Brian Di Croce</dc:creator>
		
		<category><![CDATA[Media/Presentations]]></category>

		<guid isPermaLink="false">http://blog.briandicroce.com/2008/11/07/edsger-dijkstra-on-the-discipline-in-thought/</guid>
		<description>I first heard of Professor E.D. Dijkstra in an algorithm course during my undergraduate studies.&amp;#160; I&amp;#8217;ve enjoyed reading his paper The Humble Programmer which he wrote as an acceptance speech for receiving a Turing Award in 1972.&amp;#160; While reading that paper, I couldn’t help myself to notice some key associations between what he suggested was [...]</description>
			<content:encoded><![CDATA[<p>I first heard of Professor <a href="http://en.wikipedia.org/wiki/Edsger_W._Dijkstra">E.D. Dijkstra</a> in an algorithm course during my undergraduate studies.&#160; I&#8217;ve enjoyed reading his paper <em><a href="http://www.cs.utexas.edu/~EWD/transcriptions/EWD03xx/EWD340.html">The Humble Programmer</a></em> which he wrote as an acceptance speech for receiving a Turing Award in 1972.&#160; While reading that paper, I couldn’t help myself to notice some key associations between what he suggested was needed to improve the art and science of software development and what the Agile philosophy was bringing forward.&#160; I don’t want to go too much into the detail of that paper, but I strongly suggest you print a copy for yourself and read it.&#160; Now to the essence of this post…I tend to get carried away sometimes…</p>
<p>A couple of years ago, Edsger Dijkstra was interviewed for sharing his thoughts on the discipline of programming.&#160; For example, he mentions the beauty of code being measured in terms of <strong>quality</strong>, <strong>correctness</strong> and <strong>elegance</strong>.&#160; That’s a key value which I hold tight in my heart when programming:&#160; Always having that struggle with my ego, my mind and my intuition about how to write or change an implementation to make it just right…not perfect, but <em>just right</em>.&#160; But what is <em>just right</em>?&#160; See…that’s the kind of struggle I constantly have.&#160; I love it.</p>
<p>While watching the interview, he seemed pretty sad or disappointed with the current state of computer science in the industry, as well as in the academia.&#160; No doubt that we still have a long way to go to bring beauty in code, but I think that we have also make a strong progress since that first 1968 NATO conference on <a href="http://en.wikipedia.org/wiki/Software_engineering">software engineering</a>.&#160; I believe that we’re living in exciting times in this industry.&#160; I don’t know if Dijkstra would agree with that statement.&#160; What do you think?&#160; </p>
<div class="wlWriterEditableSmartContent" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:3b8f9112-0ec4-43e2-9da6-b28b2f1d9c85" style="padding-right: 0px; display: block; padding-left: 0px; float: none; padding-bottom: 0px; margin-left: auto; width: 400px; margin-right: auto; padding-top: 0px">
<div><embed style="width:400px; height:326px;" wmode="transparent" id="VideoPlayback" type="application/x-shockwave-flash" src="http://video.google.com/googleplayer.swf?docId=-6873628658308030363&amp;hl=en" flashvars=""> </embed></div>
</div>
<p>NOTE:<strong> </strong>I came about this video from the most excellent blog of <a href="http://www.catonmat.net/"><strong>Peteris Krumins</strong></a>.</p>
                        <p><br />
My name is Brian Di Croce, a passionate software developer living, coding, blogging and working in Montreal, Canada.  Feel free to visit my <a href="http://www.briandicroce.com">website/blog</a> for more great content related to software development with .NET! &copy;2007-2008<br />
</p>                        <div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=WC58jeKnAnk:ss-EGkA61mc:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=WC58jeKnAnk:ss-EGkA61mc:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=WC58jeKnAnk:ss-EGkA61mc:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=WC58jeKnAnk:ss-EGkA61mc:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=WC58jeKnAnk:ss-EGkA61mc:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/BrianDiCroce/~4/WC58jeKnAnk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.briandicroce.com/2008/11/07/edsger-dijkstra-on-the-discipline-in-thought/feed/</wfw:commentRss>
		<feedburner:origLink>http://blog.briandicroce.com/2008/11/07/edsger-dijkstra-on-the-discipline-in-thought/</feedburner:origLink></item>
		<item>
		<title>Sessions from PDC2008 now available!</title>
		<link>http://feedproxy.google.com/~r/BrianDiCroce/~3/4u_P4qdaTM8/</link>
		<comments>http://blog.briandicroce.com/2008/11/06/sessions-from-pdc2008-now-available/#comments</comments>
		<pubDate>Fri, 07 Nov 2008 03:17:45 +0000</pubDate>
		<dc:creator>Brian Di Croce</dc:creator>
		
		<category><![CDATA[Media/Presentations]]></category>

		<guid isPermaLink="false">http://blog.briandicroce.com/2008/11/06/sessions-from-pdc2008-now-available/</guid>
		<description>This year’s Microsoft Professional Developer Conference is a thing of the past.&amp;#160; For those unlucky ones (like me) who didn’t attend this event, you can now have full and free access to the sessions and the keynotes.&amp;#160; Suddenly life just got better!
Mike Swanson has prepared for us a simple list of all keynotes and sessions [...]</description>
			<content:encoded><![CDATA[<p>This year’s Microsoft Professional Developer Conference is a thing of the past.&#160; For those unlucky ones (like me) who didn’t attend this event, you can now have full and free access to the sessions and the keynotes.&#160; Suddenly life just got better!</p>
<p><a href="http://blogs.msdn.com/mswanson">Mike Swanson</a> has prepared for us a <a href="http://blogs.msdn.com/mswanson/pages/PDC2008Sessions.aspx"><strong>simple list of all keynotes and sessions by code and title from this year’s PDC</strong></a>.&#160; This is some really cool stuff!</p>
<p>Remember that you can also browse the sessions by tag on the <a href="http://channel9.msdn.com/pdc2008/">Channel 9 PDC 2008 page</a>.</p>
<p>Now, let’s see what <a href="http://www.microsoft-watch.com/content/web_services_browser/azure_windows_becomes_the_web.html?kc=MWRSS02129TX1K0000535">Azure</a> is really all about…</p>
                        <p><br />
My name is Brian Di Croce, a passionate software developer living, coding, blogging and working in Montreal, Canada.  Feel free to visit my <a href="http://www.briandicroce.com">website/blog</a> for more great content related to software development with .NET! &copy;2007-2008<br />
</p>                        <div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=4u_P4qdaTM8:t1wu-eTB8cw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=4u_P4qdaTM8:t1wu-eTB8cw:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=4u_P4qdaTM8:t1wu-eTB8cw:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=4u_P4qdaTM8:t1wu-eTB8cw:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=4u_P4qdaTM8:t1wu-eTB8cw:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/BrianDiCroce/~4/4u_P4qdaTM8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.briandicroce.com/2008/11/06/sessions-from-pdc2008-now-available/feed/</wfw:commentRss>
		<feedburner:origLink>http://blog.briandicroce.com/2008/11/06/sessions-from-pdc2008-now-available/</feedburner:origLink></item>
		<item>
		<title>Evolving your design with the Principle of Least Knowledge</title>
		<link>http://feedproxy.google.com/~r/BrianDiCroce/~3/58ysJvZc_Kk/</link>
		<comments>http://blog.briandicroce.com/2008/11/02/evolving-your-design-with-the-principle-of-least-knowledge/#comments</comments>
		<pubDate>Mon, 03 Nov 2008 03:05:49 +0000</pubDate>
		<dc:creator>Brian Di Croce</dc:creator>
		
		<category><![CDATA[.NET Programming]]></category>

		<guid isPermaLink="false">http://blog.briandicroce.com/?p=405</guid>
		<description>One of the principles of object-oriented development is that you should strive for a design that favors low coupling among objects.&amp;#160; Given that change is constant in a software project, this principle provides many benefits when rightfully applied:

Code is easier to maintain because any change can be isolated to a very limited number of objects [...]</description>
			<content:encoded><![CDATA[<p>One of the principles of object-oriented development is that you should strive for a design that favors low coupling among objects.&#160; Given that change is constant in a software project, this principle provides many benefits when rightfully applied:</p>
<ul>
<li>Code is easier to <strong>maintain</strong> because any change can be isolated to a very limited number of objects (hopefully only one) </li>
<li>Code is easier to <strong>use</strong> and <strong>reuse</strong> because your objects are not tightly related to a web of other objects </li>
<li>Code is easier to <strong>understand</strong> because we can focus on the behavior of a very limited number of objects (hopefully only one) </li>
<li>Code is easier to <strong>test</strong> because of the reasons stated above (it also reduces the use of mock objects in our tests which simplifies writing and maintaining them) </li>
</ul>
<p>The last point is very important.&#160; Code that is easier to test favors the writing of unit tests, which avoids potential bugs infesting the system, and embraces change as we have confidence in refactoring the codebase because our unit tests act as a safety net so that if we should brake something in the system, we’ll be notified in a short time…if the tests were well written of course, but that’s a subject for another post.</p>
<p>The <strong>Principle of Least Knowledge</strong>, also known as the <a href="http://en.wikipedia.org/wiki/Law_of_Demeter">Law of Demeter</a>, is one of those principles which favor low coupling in your codebase.&#160; The most excellent book “<strong><a href="http://blog.briandicroce.com/2008/01/01/book-review-3-head-first-design-patterns/">Head First Design Patterns</a></strong>” defines this principle as the following:</p>
<blockquote><p><em>The Principle of Least Knowledge guides us to reduce the interactions between objects to just a few close “friends”.</em></p>
<p><em>But what does this mean in real terms?&#160; It means when you are designing a system, for any object, be careful of the <strong>number of classes</strong> it interacts with and also how it comes to interact with those classes.</em></p>
<p><em>This principle prevents us from creating designs that have a <strong>large number of classes</strong> coupled together so that changes in one part of the system cascade to other parts.&#160; When you build a lot of dependencies between many classes, you are building a fragile system that will be costly to maintain and complex for others to understand</em>.&#160; &#8212; “<strong>Head First Design Patterns</strong>”, pages 265-266.</p>
</blockquote>
<p>In other words, this principle states that given an object, any of its method should only invoke methods that belong to:</p>
<ul>
<li><strong>The object itself</strong> </li>
<li><strong>Objects passed in as a parameter to the method</strong> </li>
<li><strong>Any object the method creates or instantiates</strong> </li>
<li><strong>Any components of the object</strong> </li>
</ul>
<p>Least but nonetheless important is another pointer which makes the whole difference (like spreading Nutella on whole wheat bread): <strong>methods should avoid invoking methods belonging to objects that were returned from some other call</strong>.</p>
<p>For example, you should avoid writing the following:.</p>
<pre class="csharp" name="code">public void DepositAmount(int accountId, double amount)
{
  Account account = bank.GetAccount( accountId );
  account.Deposit( amount );
}</pre>
<p>
  <br />And instead opt for this: </p>
<p></p>
<pre class="csharp" name="code">public void DepositAmount(int accountId, double amount)
{
  bank.Deposit( accountId, amount );
}</pre>
<p>You should see that the latter implementation is easier to maintain, reuse, understand and test.&#160; We haven’t changed the interface of the method, just its implementation.&#160; This implementation is easier to reuse and test because we don’t have to rely on another external (whether concrete or abstract) object, in this case an Account, to fulfill the service.&#160; We only have one object, the Bank, to deal with.</p>
<p>One of my mentors refers to this principle as the “<strong>Tell, don’t ask</strong>” principle.&#160; It makes a lot of sense.&#160; Alec Sharp, author of <em>Smalltalk by Example</em>, summarizes this principle in other words:</p>
<blockquote>
<p><em>Procedural code gets information then makes decisions.&#160; Object-oriented code <strong>tells</strong> objects to do things. &#8212; <strong>Alec Sharp</strong></em></p>
</blockquote>
<p>That was the theory behind the principle.&#160; Let’s see a concrete and simple example which demonstrates what we should avoid and what we should strive for in our design.</p>
<p>This example doesn’t follow the Principle of Least Knowledge:</p>
<pre class="csharp" name="code">namespace ConsoleApplication1
{
  class Program
  {
    static void Main(string[] args)
    {
      var car = new Car();
      var driver = new Driver( car );

      driver.Car.Engine.Start(); // Not good.
                                 // Changing the signature of Start() will force to change
                                 // the callers too because of the strong coupling.
                                 // It also breaks the encapusalation of CarEngine because
                                 // the Driver knows too much about that class.
    }
  }

  class Driver
  {
    public Driver( Car car )
    {
      Car = car;
    }

    public Car Car { get; private set; }
  }

  class Car
  {
    private readonly CarEngine _engine;

    public Car()
    {
      _engine = new CarEngine();
    }

    public CarEngine Engine
    {
      get
      {
        return _engine;
      }
    }

    public class CarEngine
    {
      public void Start()
      {
        Console.WriteLine( &quot;vroum! vroum!&quot; );
      }
    }
  }
}</pre>
<p>
  <br />Whereas this same example does respect the Principle of Least Knowledge: </p>
<p></p>
<pre class="csharp" name="code">namespace ConsoleApplication1
{
  class Program
  {
    static void Main(string[] args)
    {
      var car = new Car();
      var driver = new Driver( car );

      driver.Car.Start(); /* Much better.&#160; Why?
                             Now, we can also make CarEngine private to the Car class.
                             Even though CarEngine.Start is public doesn't mean we should
                             use it!&#160; Here we decided to remove the Engine property in the Car
                             class.

                             With this approach, the Driver could care less HOW the Car gets
                             started.&#160; Now, CarEngine can evolve on its own without impacting
                             the rest of the system.

                             In other words...just because there's a gun laying on the ground
                             outside Montreal East and it's past 2AM...doesn't mean you should
                             take it!&#160; Not everything that's public is good to take.
                             */
    }
  }

  class Driver
  {
    public Driver( Car car )
    {
      Car = car;
    }

    public Car Car { get; private set; }
  }

  class Car
  {
    private readonly CarEngine _engine;

    public Car()
    {
      _engine = new CarEngine();
    }

    class CarEngine
    {
      public void Start()
      {
        Console.WriteLine( &quot;vroum! vroum!&quot; );
      }
    }

    public void Start()
    {
      _engine.Start();
    }
  }
}</pre>
<p>As you can see from the preceding example, adopting the Principle of Least Knowledge in your design allows you to easily evolve other components in your system since they’re not tightly coupled with other components in other areas of the system.&#160; In this instance, I can easily evolve <strong>CarEngine</strong> without impacting the rest of the system.&#160; For example, I can change the way an engine is started.&#160; Furthermore, I can even make the <strong>CarEngine</strong> class abstract, then have various implementations of it and still avoid rippling changes to my system.&#160; The Principle of Least Knowledge gives me so much ease, flexibility and possibilities to evolve my design and test my system.</p>
<p>Using a tool like <a href="http://www.ndepend.com/">NDepend </a>can help you to pinpoint locations in your code where coupling is strong so that you leverage this principle and step-by-step eliminate the unnecessary coupling among components.</p>
<p>In conclusion, I urge you to not get too personal with objects.&#160; Don&#8217;t be too polite with them neither.&#160; With people yes, but not with objects.&#160; If you need an object to do something for you, tell it to do so.&#160; Another variation of &quot;tell&quot; is &quot;command&quot;.&#160; Don&#8217;t tell the object to ask another object to do some job for you.&#160; If you see that happening, you should remove the intermediate object and have the one that knows more about the underlying operation to execute the job for you.&#160; In his book <em>Applying UML and Patterns</em>, Craig Larman refers to the <a href="http://web.cs.wpi.edu/~gpollice/cs4233-a05/CourseNotes/maps/class4/InformationExpert.html"><strong>Information Expert pattern</strong></a> for this kind of situation.&#160; According to that pattern, you should &quot;<em>assign a responsibility to the information expert - the class that has the information necessary to fulfill the responsibility</em>&quot;.</p>
<p>As you can see, there are many different interpretations for this principle.&#160; Whether you know it as the Principle of Least Knowledge, the Law of Demeter or the Information Expert pattern, what&#8217;s important is that you understand and apply the essence behind it.&#160; It&#8217;s all about doing object-oriented development right.</p>
                        <p><br />
My name is Brian Di Croce, a passionate software developer living, coding, blogging and working in Montreal, Canada.  Feel free to visit my <a href="http://www.briandicroce.com">website/blog</a> for more great content related to software development with .NET! &copy;2007-2008<br />
</p>                        <div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=58ysJvZc_Kk:UZObKzXEeHk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=58ysJvZc_Kk:UZObKzXEeHk:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=58ysJvZc_Kk:UZObKzXEeHk:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=58ysJvZc_Kk:UZObKzXEeHk:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=58ysJvZc_Kk:UZObKzXEeHk:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/BrianDiCroce/~4/58ysJvZc_Kk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.briandicroce.com/2008/11/02/evolving-your-design-with-the-principle-of-least-knowledge/feed/</wfw:commentRss>
		<feedburner:origLink>http://blog.briandicroce.com/2008/11/02/evolving-your-design-with-the-principle-of-least-knowledge/</feedburner:origLink></item>
		<item>
		<title>The road towards MCPD-EAD: I passed exam 70-528, 70-526 and 70-549. Mission Accomplished!</title>
		<link>http://feedproxy.google.com/~r/BrianDiCroce/~3/C05wFOkcS2k/</link>
		<comments>http://blog.briandicroce.com/2008/10/22/the-road-towards-mcpd-ead-i-passed-exam-70-528-70-526-and-70-549-mission-accomplished/#comments</comments>
		<pubDate>Thu, 23 Oct 2008 01:51:00 +0000</pubDate>
		<dc:creator>Brian Di Croce</dc:creator>
		
		<category><![CDATA[Certifications]]></category>

		<guid isPermaLink="false">http://blog.briandicroce.com/2008/10/22/the-road-towards-mcpd-ead-i-passed-exam-70-528-70-526-and-70-549-mission-accomplished/</guid>
		<description>Some readers were asking me about the status of my self-imposed challenge to achieve the MCPD-EAD (Microsoft Certified Professional Developer: Enterprise Application Developer) certification before the end of the year.&amp;#160; Well, it turns out that I’ve completed and passed the last exam of the series this morning.&amp;#160; When I first started out with this insane [...]</description>
			<content:encoded><![CDATA[<p><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; margin: 0px 10px 10px 0px; border-right-width: 0px" height="79" alt="image" src="http://blog.briandicroce.com/wp-content/uploads/2008/10/image9.png" width="328" align="left" border="0" />Some readers were asking me about the status of my self-imposed challenge to achieve the MCPD-EAD (Microsoft Certified Professional Developer: Enterprise Application Developer) certification before the end of the year.&#160; Well, it turns out that I’ve completed and passed the last exam of the series this morning.&#160; When I first started out with this insane challenge of doing one certification every three to four weeks, I had no idea of the amount of time I would have to dedicate to complete it in the initial timeframe.&#160; So just to recap, I passed <a href="http://www.microsoft.com/learning/exams/70-536.mspx">70-536</a> (Fundamentals) back in <strong>June</strong>, <a href="http://www.microsoft.com/learning/en/us/exams/70-529.mspx">70-529</a> (Distributed Applications) in <strong>July</strong>, <a href="http://www.microsoft.com/learning/exams/70-528.mspx">70-528</a> (Web Applications) in <strong>August</strong>, <a href="http://www.microsoft.com/learning/en/us/exams/70-526.mspx">70-526</a> (Windows Applications) in <strong>September</strong> and <a href="http://www.microsoft.com/learning/exams/70-549.mspx">70-549</a> (Design and Development) this morning (<strong>October</strong>).&#160; All of these exams focus on various technologies targeting .NET 2.0.</p>
<p>For each of these exams, I have used the “self-paced” book series (the same series used for 70-536 and 70-529), which are:</p>
<ul>
<li><a href="http://www.microsoft.com/mspress/books/9982.aspx">MCTS Self-Paced Training Kit (Exam 70-528): Microsoft .NET Framework 2.0 Web-Based Client Development</a></li>
<li><a href="http://www.microsoft.com/mspress/books/9983.aspx">MCTS Self-Paced Training Kit (Exam 70-526): Microsoft .NET Framework 2.0 Windows-Based Client Development</a></li>
<li><a href="http://www.microsoft.com/mspress/books/10094.aspx">MCPD Self-Paced Training Kit (Exam 70-549): Designing and Developing Enterprise Applications Using the Microsoft .NET Framework</a></li>
</ul>
<p>Now, I’m going to say it straight and simple: all of these books suck.&#160; The only good thing about them is that the authors have done a pretty good job copy/pasting the right MSDN documentation so that we wouldn’t waste our time doing it ourselves.&#160; The major drawbacks I have against these books are the <em>really</em> poor coding style of the authors towards their examples.&#160; A big portion of the examples contain errors, are sometimes misleading and some of them clearly won’t compile if you copy/paste the code in Visual Studio.&#160;&#160; It’s sad to see so many mistakes like these, especially when each book is written by so many authors, because the credibility of these individuals take a pretty bad hit in the public’s eye.&#160; I’m sure they were pushed by the deadline, but I wished they’ve polished the examples a little bit more.&#160; I know…I know…Nobody’s perfect…I know.&#160; But that’s still no reason to deliver mediocre products.</p>
<p>All right.&#160; So just in case you’re thinking (or already started) to get your MCPD-EAD credentials, I am going to tell you how I’ve managed my time to pass each of these exams in hope that it might help you to pass them successfully.&#160; In average, I dedicated about 40 hours per exam:</p>
<ul>
<ul>
<li>15 hours to read the book (1 hour in the morning and 1 hour in the evening should be enough for you to read the whole book within a week.&#160; You don’t have to read EVERYTHING.&#160; If you’re proficient in C#, then skip all the VB.NET examples.&#160; Same idea goes if you’re more proficient in VB.NET than C#.&#160;&#160; Whenever the authors mentions something in a box with the title “Real-World Scenario” you SKIP it.&#160; It doesn’t matter.&#160; The “real-world scenario” isn’t in the book…it’s in the REAL WORLD.&#160; Don’t waste your time.&#160; Also, don’t do all of the activities at the end of each chapter.&#160; Just get through the book because you don’t want to waste too much of your time.&#160; Here we’re really trying to cram our brain with tons of information.&#160; The exams are roughly 80% based on memorization of the content and 20% on actual thinking.&#160; Feel free to write notes and underline important ideas as you read along.&#160; I used to write “EXAM” in red ink on the margin so that I can review it at a later time.) </li>
<li>20 hours to practice with <a href="http://www.transcender.com/">Transcender</a> or <a href="http://www.measureup.com/">MeasureUp</a> exams.&#160; I have only used Transcenders, so I can’t say much about MeasureUp.&#160; I’ve heard they’re quite good too.&#160; Whichever you decide to do, I strongly suggest you to do all of the questions more than once.&#160; Then when you’re confident enough about the material, take a moment to answer the questions in the “certification” mode to give you a better feel for the exam.&#160; By the way, none of the questions of either Transcenders or MeasureUp were in the exams I’ve taken.&#160; To be honest, the mock exams’ goals are to deepen your knowledge with the various technologies.&#160; That’s it, that’s all.&#160; Don’t put too much confidence in them, because what I’ve concluded at the end of each real exam is that the mock exams only helped me about 20% on the “knowledge” stuff and 80% on the actual “feeling” for the exam.&#160; Take a week or two to practice these.</li>
<li>5 hours to practice some things I didn’t fully understand (proper use of some class, understanding the use behind some interfaces, getting comfortable with the security model, etc.) inside Visual Studio.&#160; I strongly suggest you use <a href="http://www.red-gate.com/products/reflector/">Reflector</a> to assist you in quickly discovering the information behind some objects in the framework.</li>
</ul>
</ul>
<p>I also suggest you to book your exam in advance.&#160; For example, suppose you start studying for an exam today, then you will book an exam date four weeks from now.&#160; This should motivate you to stay on course and respect your schedule.&#160; And if that’s not enough, then mention to your boss and your fellow co-workers that you intend to pass this exam by that date.&#160; Feel free to also share you exam date as a comment on this post! That should put enough pressure to get the job done…wouldn’t it? <img src='http://blog.briandicroce.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>In closing, I found that the 70-526 (Windows Applications) exam was the easiest exam of the bunch.&#160; As for the hardest, I must say that it was the 70-529 (Distributed Applications) exam, mostly because I’ve never done .NET Remoting in the past.&#160; And now that WCF is in the neighborhood, I doubt I’ll even have to touch .NET Remoting in the future!&#160; It all depends on your experience with these technologies.&#160; The more you practice and learn, the greater your chance in passing.</p>
                        <p><br />
My name is Brian Di Croce, a passionate software developer living, coding, blogging and working in Montreal, Canada.  Feel free to visit my <a href="http://www.briandicroce.com">website/blog</a> for more great content related to software development with .NET! &copy;2007-2008<br />
</p>                        <div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=C05wFOkcS2k:RRUmbMQfT3o:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=C05wFOkcS2k:RRUmbMQfT3o:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=C05wFOkcS2k:RRUmbMQfT3o:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=C05wFOkcS2k:RRUmbMQfT3o:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=C05wFOkcS2k:RRUmbMQfT3o:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/BrianDiCroce/~4/C05wFOkcS2k" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.briandicroce.com/2008/10/22/the-road-towards-mcpd-ead-i-passed-exam-70-528-70-526-and-70-549-mission-accomplished/feed/</wfw:commentRss>
		<feedburner:origLink>http://blog.briandicroce.com/2008/10/22/the-road-towards-mcpd-ead-i-passed-exam-70-528-70-526-and-70-549-mission-accomplished/</feedburner:origLink></item>
		<item>
		<title>Lesson 3 of 3 from "The Big Moo": Juggling Is Not What You Think It Is</title>
		<link>http://feedproxy.google.com/~r/BrianDiCroce/~3/5jweCL5P6EQ/</link>
		<comments>http://blog.briandicroce.com/2008/10/15/lesson-3-of-3-from-the-big-moo-juggling-is-not-what-you-think-it-is/#comments</comments>
		<pubDate>Wed, 15 Oct 2008 19:39:46 +0000</pubDate>
		<dc:creator>Brian Di Croce</dc:creator>
		
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.briandicroce.com/?p=388</guid>
		<description>This is the third and last installment of lessons learned from reading &amp;#8220;The Big Moo&amp;#8221;.  The first lesson learned was about compromise and the second one was about being why being extreme is necessary sometimes.  This lesson is about knowing the importance of being proactive rather than reactive in a position of management or leadership.  [...]</description>
			<content:encoded><![CDATA[<p>This is the third and last installment of lessons learned from reading &#8220;The Big Moo&#8221;.  The first lesson learned was about compromise and the second one was about being why being extreme is necessary sometimes.  This lesson is about knowing the importance of being proactive rather than reactive in a position of management or leadership.  It&#8217;s important, in order to be successful, to know how to trust and delegate work to people.  To be great at that, you must treat your co-workers/employees first of all as humans, and also take time to know them on personal/professional level.  What do they like to work on?  What are they passionate about in their job?  What motivates them to spend their energy, intelligence and experience to help your organization achieve its goals and drive its strategy?  Discovering the values behind these variables will make you more remarkable in your organization.  Furthermore, this lesson teaches you to stop being a fireman and instead be an innovator.  You have too much smarts to indulge your time in putting out fire caused by other people.  It&#8217;s important to realize that you simply can&#8217;t handle every single situation at work.  Sometimes when there&#8217;s just too many fires to put out, the best thing to do is build some brick walls to isolate your from them, but also to help you set a path that will guide you to success.  That being said, I present you the last essay for this lesson.  This one is entitled &#8220;Juggling Is Not What You Think&#8221; and (yep, you&#8217;ve guess it) and its author is unknown.</p>
<h3 style="text-align: center;">Juggling Is Not What You Think It Is</h3>
<p>&#8220;Sometimes, I teach juggling classes.  Everyone wants to get the learning process of how to juggle three balls over with as quickly as he can.  The universal approach people take is to devote all their attention and effort at catching the calls.  They just throw &#8216;em up and rush around trying to catch them.  Extraordinary efforts are justified to catch the balls, because after all, if a ball hits the ground, you&#8217;ve failed.  The nascent juggler expects that with enough practice, they&#8217;ll get really good at catching balls.&#8221;</p>
<p>&#8220;Lots of your peers think that they&#8217;re good at juggling.  They rush this way and that, dealing with emergencies, handling multiple priorities, and never letting anything fall through the cracks.&#8221;</p>
<p>&#8220;But that&#8217;s not juggling.  That&#8217;s rushing around like a madman.  Let <em>them</em> be good at that.  There are plenty of people out there who are great at rushing about and handling emergencies, and frankly, they don&#8217;t need your help.&#8221;</p>
<p>&#8220;<strong>It turns out that juggling is about throwing, not catching.</strong> The way to learn how to juggle is not to focus obsessively on not dropping a ball.  No, the way to get good at juggling is to focus on your throw instead.&#8221;</p>
<p>&#8220;If you are good at throwing, the catching will take care of itself.&#8221;</p>
<p>&#8220;Once you&#8217;ve got three or four or five projects in the air at work, no amount of rushing around is going to keep them from crashing to the ground.  No amount of effort can help you catch the misthrown balls.  It&#8217;s physically impossible.&#8221;</p>
<p>&#8220;On the other hand, if your balls are well thrown, the catching is effortless.&#8221;</p>
<p>&#8220;That&#8217;s part of the secret of becoming remarkable.  Don&#8217;t spend any time at all worrying about catching.  Let your co-workers do that.  Instead, become the best thrower there ever was.  If you become good at throwing, you&#8217;ll find that you&#8217;re irreplaceable.  Organizations need really good throwers.&#8221;</p>
                        <p><br />
My name is Brian Di Croce, a passionate software developer living, coding, blogging and working in Montreal, Canada.  Feel free to visit my <a href="http://www.briandicroce.com">website/blog</a> for more great content related to software development with .NET! &copy;2007-2008<br />
</p>                        <div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=5jweCL5P6EQ:VuEu7tdWPSM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=5jweCL5P6EQ:VuEu7tdWPSM:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=5jweCL5P6EQ:VuEu7tdWPSM:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=5jweCL5P6EQ:VuEu7tdWPSM:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=5jweCL5P6EQ:VuEu7tdWPSM:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/BrianDiCroce/~4/5jweCL5P6EQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.briandicroce.com/2008/10/15/lesson-3-of-3-from-the-big-moo-juggling-is-not-what-you-think-it-is/feed/</wfw:commentRss>
		<feedburner:origLink>http://blog.briandicroce.com/2008/10/15/lesson-3-of-3-from-the-big-moo-juggling-is-not-what-you-think-it-is/</feedburner:origLink></item>
		<item>
		<title>Lesson 2 of 3 from "The Big Moo": They Say I’m Extreme</title>
		<link>http://feedproxy.google.com/~r/BrianDiCroce/~3/VSYSKH3aQ3o/</link>
		<comments>http://blog.briandicroce.com/2008/10/14/lesson-2-of-3-from-the-big-moo-they-say-im-extreme/#comments</comments>
		<pubDate>Tue, 14 Oct 2008 17:46:15 +0000</pubDate>
		<dc:creator>Brian Di Croce</dc:creator>
		
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.briandicroce.com/?p=387</guid>
		<description>This is the second installment of lessons learned from reading &amp;#8220;The Big Moo&amp;#8220;.  It goes inline with the first lesson learned about compromises.  This time, we&amp;#8217;re talking about being &amp;#8220;extreme&amp;#8221; in the sense that you shouldn&amp;#8217;t accept status quo if there&amp;#8217;s no value, no growth and no opportunities associated with a given situation that you&amp;#8217;re [...]</description>
			<content:encoded><![CDATA[<p>This is the second installment of lessons learned from reading &#8220;<a href="http://blog.briandicroce.com/2008/10/03/book-review-9-the-big-moo/">The Big Moo</a>&#8220;.  It goes inline with the <a href="http://blog.briandicroce.com/2008/10/10/lesson-1-of-3-from-the-big-moo-the-problem-with-compromise/">first lesson</a> learned about compromises.  This time, we&#8217;re talking about being &#8220;extreme&#8221; in the sense that you shouldn&#8217;t accept status quo if there&#8217;s no value, no growth and no opportunities associated with a given situation that you&#8217;re involved in.  I hope that the following essay taken directly from the book will inspire you to be different, to be realistic, but more importantly to be remarkable in taking sound actions to push the barrier for excellence a bit higher even when the crowd shouts differently.  It&#8217;s important that you realize when &#8220;enough is enough&#8221; and realize that your integrity and credibility is on the line every time you&#8217;re doing something that violates your set of values and principles.  Here is the full text from (once again) an unknown author:</p>
<h3 style="text-align: center;">They Say I&#8217;m Extreme</h3>
<p>They say I&#8217;m extreme.<br />
<strong>I say I&#8217;m a realist.</strong></p>
<p>They say I demand too much.<br />
<strong>I say they accept mediocrity and continuous improvement too readily.</strong></p>
<p>They say, &#8220;We can&#8217;t handle this much change.&#8221;<br />
<strong>I say, &#8220;Your job and career are in jeopardy; what other options do you have?&#8221;</strong></p>
<p>They say, &#8220;What&#8217;s wrong with a &#8216;good product&#8217;?&#8221;<br />
<strong>I say, &#8220;Wal-Mart or China or both are about to eat your lunch.  Why can&#8217;t you provide instead a fabulous experience?&#8221;</strong></p>
<p>They say, &#8220;Take a deep breath.  Be calm.&#8221;<br />
<strong>I say, &#8220;Tell it to Wal-Mart.  Tell it to China.  Tell it to India.  Tell it to Dell.  Tell it to Microsoft.&#8221;</strong></p>
<p>They say the Web is a useful tool.<br />
<strong>I say the Web changes everything.  Now.</strong></p>
<p>They say, &#8220;We need an initiative.&#8221;<br />
<strong>I say, &#8220;We need a dream.  And dreamers.&#8221;</strong></p>
<p>They say great design is &#8220;nice&#8221;.<br />
<strong>I say great design is necessary.</strong></p>
<p>They say, &#8220;Effective governance is important.&#8221;<br />
<strong>I say bold, brash boards that are representative of the market served - more than a token woman or two and an empty seat for the &#8220;forthcoming Hispanic&#8221; - are an imperative.  Now.</strong></p>
<p>They say, &#8220;Plan it.&#8221;<br />
<strong>I say, &#8220;<em>Do</em> it&#8221;.</strong></p>
<p>They say, &#8220;We need more steady, loyal employees.&#8221;<br />
<strong>I say, &#8220;We need more &#8216;freaks&#8217; who routinely tell those in charge to take a flying leap&#8230;before it&#8217;s too late.&#8221;</strong></p>
<p>They say, &#8220;We need Good People.&#8221;<br />
<strong>I say, &#8220;We need Quirky Talent.&#8221;</strong></p>
<p>They say, &#8220;We like people who, with steely determination, say, &#8216;I can make it better&#8217;.&#8221;<br />
<strong>I say, &#8220;I love people who, with a certain maniacal gleam in their eye, perhaps even a giggle, say, &#8216;I can turn the world upside down.  Watch me!&#8217;&#8221;</strong></p>
<p>They say, &#8220;Sure, we need change.&#8221;<br />
<strong>I say we need <em>revolution now</em>.</strong></p>
<p>They say, &#8220;Fast follower.&#8221;<br />
<strong>I say, &#8220;Battered and bruised leader.&#8221;</strong></p>
<p>They say, &#8220;Conglomerate and imitate!&#8221;<br />
<strong>I say, &#8220;Create and innovate!&#8221;</strong></p>
<p>They say, &#8220;Market share.&#8221;<br />
<strong>I say, &#8220;Market creation.&#8221;</strong></p>
<p>They say, &#8220;Improve and maintain.&#8221;<br />
<strong>I say, &#8220;Destroy and reimagine.&#8221;</strong></p>
<p>They say, &#8220;Normal.&#8221;<br />
<strong>I say, &#8220;Weird.&#8221;</strong></p>
<p>They say, &#8220;Happy balance.&#8221;<br />
<strong>I say, &#8220;Creative tension.&#8221;</strong></p>
<p>They say they favor a &#8220;team that works and lives in harmony.&#8221;<br />
<strong>I say, &#8220;Give me a raucous brawl among the most creative people imaginable.&#8221;</strong></p>
<p>They say, &#8220;Peace, brother.&#8221;<br />
<strong>I say, &#8220;Bruise my feelings.  Flatten my ego.  <em>Save my job</em>.&#8221;</strong></p>
<p>They say, &#8220;Basic black.&#8221;<br />
<strong>I say, &#8220;Technicolor rules!&#8221;</strong></p>
<p>They say, &#8220;We need happy customers.&#8221;<br />
<strong>I say, &#8220;Give me pushy, needy, nasty, provocative customers.&#8221;</strong></p>
<p>They say, &#8220;We seek Harvard M.B.A.s.&#8221;<br />
<strong>I say, &#8220;I seek certificate-free &#8216;Ph.D.S&#8217; from the School of Hard Knocks.&#8221;</strong></p>
<p>They say they want recruits with &#8220;spotless records.&#8221;<br />
<strong>I say, &#8220;the spots are what matter most.&#8221;</strong></p>
<p>They say, &#8220;Integrity is important.&#8221;<br />
<strong>I say, &#8220;Tell the unvarnished truth, all the time&#8230;or take a hike.&#8221;</strong></p>
<p>They say diversity is a &#8220;good thing.&#8221;<br />
<strong>I say diversity is breath of fresh, creative air - absolutely necessary for economic salvation in perilous times.</strong></p>
<p>They say it&#8217;s &#8220;daunting.&#8221;<br />
<strong>I say it&#8217;s &#8220;a hoot.&#8221;</strong></p>
<p>They say, &#8220;Zero defects.&#8221;<br />
<strong>I say, &#8220;A day without a screwup or two is a day pissed away.&#8221;</strong></p>
<p>They say, &#8220;Think about it.&#8221;<br />
<strong>I say, &#8220;Try it.&#8221;</strong></p>
<p>They say, &#8220;Plan it.&#8221;<br />
<strong>I say, &#8220;Test it.&#8221;</strong></p>
<p>They say, &#8220;Radical change takes a decade.&#8221;<br />
<strong>I say, &#8220;Radical change takes a minute.&#8221;</strong></p>
<p>They say, &#8220;Times are changing.&#8221;<br />
<strong>I say, &#8220;Everything has already changed.  Tomorrow is the first day of your revolution&#8230;or you&#8217;re toast.&#8221;</strong></p>
<p>They say, &#8220;We can&#8217;t all be revolutionaries.&#8221;<br />
<strong>I say, &#8220;Why not?&#8221;</strong></p>
<p>They say, &#8220;We can&#8217;t all be a brand.&#8221;<br />
<strong>I say, &#8220;Why not?&#8221;</strong></p>
<p>They say this is just a rant.<br />
<strong>I say this is just reality.</strong></p>
                        <p><br />
My name is Brian Di Croce, a passionate software developer living, coding, blogging and working in Montreal, Canada.  Feel free to visit my <a href="http://www.briandicroce.com">website/blog</a> for more great content related to software development with .NET! &copy;2007-2008<br />
</p>                        <div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=VSYSKH3aQ3o:K548s2MB5SI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=VSYSKH3aQ3o:K548s2MB5SI:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=VSYSKH3aQ3o:K548s2MB5SI:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=VSYSKH3aQ3o:K548s2MB5SI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=VSYSKH3aQ3o:K548s2MB5SI:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/BrianDiCroce/~4/VSYSKH3aQ3o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.briandicroce.com/2008/10/14/lesson-2-of-3-from-the-big-moo-they-say-im-extreme/feed/</wfw:commentRss>
		<feedburner:origLink>http://blog.briandicroce.com/2008/10/14/lesson-2-of-3-from-the-big-moo-they-say-im-extreme/</feedburner:origLink></item>
		<item>
		<title>How I spent an easy earned $250</title>
		<link>http://feedproxy.google.com/~r/BrianDiCroce/~3/IhRc4cj5yUs/</link>
		<comments>http://blog.briandicroce.com/2008/10/11/how-i-spent-an-easy-earned-250/#comments</comments>
		<pubDate>Sat, 11 Oct 2008 22:58:00 +0000</pubDate>
		<dc:creator>Brian Di Croce</dc:creator>
		
		<category><![CDATA[Books]]></category>

		<guid isPermaLink="false">http://blog.briandicroce.com/2008/10/11/how-i-spent-an-easy-earned-250/</guid>
		<description>A couple of weeks ago, some guys from work invited me to participate in a video contest for our region.  Little did I know was a $1000 cash prize to be won&amp;#8230;which we did won, ladies and gentlemen!  So the four of us equally divided the prize which allowed us to earn $250 each for [...]</description>
			<content:encoded><![CDATA[<p>A couple of weeks ago, some guys from <a href="http://www.avanade.ca">work</a> invited me to participate in a video contest for our region.  Little did I know was a $1000 cash prize to be won&#8230;which we did won, ladies and gentlemen!  So the four of us equally divided the prize which allowed us to earn $250 each for a half an hour activity.  Not bad!  I was wondering what I could do with that easy earned money.  Invest it in a retirement funds? Nah.  Give half to my wife? Nah. Since I&#8217;m an avid reader of books, I thought that it would be nice to get a hold of some good books on software development.  Even though I&#8217;ve got over thirty books on software development and engineering, I wanted to get some dealing with patterns and principles in software design because those kind of books transcend time and technology.</p>
<p>Here are the books I bought with the easiest and fastest $250 earned in my life:</p>
<ul>
<li><a href="http://www.amazon.com/exec/obidos/ASIN/0131857258/brdicr-20"><strong>Agile Principles, Patterns, and Practices in C#</strong></a> by Robert C. Martin</li>
<li><a href="http://www.amazon.com/exec/obidos/ASIN/0131177052/brdicr-20"><strong>Working Effectively with Legacy Code</strong></a> by Michael Feathers</li>
<li><a href="http://www.amazon.com/exec/obidos/ASIN/0321213351/brdicr-20"><strong>Refactoring to Patterns</strong></a> by Joshua Kerievsky</li>
<li><a href="http://www.amazon.com/exec/obidos/ASIN/0131495054/brdicr-20"><strong>xUnit Test Patterns</strong></a> by Gerarld Meszaros</li>
<li><a href="http://www.amazon.com/exec/obidos/ASIN/0735619654/brdicr-20"><strong>Object Thinking</strong></a> by David West</li>
</ul>
<p>I&#8217;ve actually started reading one of them, &#8220;<strong>Object Thinking</strong>&#8220;, and I have to tell you that it&#8217;s by far one of the best book I&#8217;ve read on object design.  What books would you have bought had you be given a similar amount of easy money?</p>
<p><img style="border-top-width: 0px; display: block; border-left-width: 0px; float: none; border-bottom-width: 0px; margin: 0px auto 10px; border-right-width: 0px" src="http://blog.briandicroce.com/wp-content/uploads/2008/10/image3.png" border="0" alt="" width="570" height="433" /></p>
                        <p><br />
My name is Brian Di Croce, a passionate software developer living, coding, blogging and working in Montreal, Canada.  Feel free to visit my <a href="http://www.briandicroce.com">website/blog</a> for more great content related to software development with .NET! &copy;2007-2008<br />
</p>                        <div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=IhRc4cj5yUs:AsbRkAZwsGA:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=IhRc4cj5yUs:AsbRkAZwsGA:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=IhRc4cj5yUs:AsbRkAZwsGA:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=IhRc4cj5yUs:AsbRkAZwsGA:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=IhRc4cj5yUs:AsbRkAZwsGA:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/BrianDiCroce/~4/IhRc4cj5yUs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.briandicroce.com/2008/10/11/how-i-spent-an-easy-earned-250/feed/</wfw:commentRss>
		<feedburner:origLink>http://blog.briandicroce.com/2008/10/11/how-i-spent-an-easy-earned-250/</feedburner:origLink></item>
		<item>
		<title>Lesson 1 of 3 from "The Big Moo": The Problem With Compromise</title>
		<link>http://feedproxy.google.com/~r/BrianDiCroce/~3/zwNiO5LyaKA/</link>
		<comments>http://blog.briandicroce.com/2008/10/10/lesson-1-of-3-from-the-big-moo-the-problem-with-compromise/#comments</comments>
		<pubDate>Sat, 11 Oct 2008 03:47:41 +0000</pubDate>
		<dc:creator>Brian Di Croce</dc:creator>
		
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.briandicroce.com/2008/10/10/lesson-1-of-3-from-the-big-moo-the-problem-with-compromise/</guid>
		<description>As promised in my review of The Big Moo, I will share with you three different lessons learned from reading the book.  The first lesson deals with compromise.  The field of software development is full of stories about products being bloated with unwanted or unnecessary features, costs overrun, late delivery dates, etc.  One reason that [...]</description>
			<content:encoded><![CDATA[<p>As promised in <a href="http://blog.briandicroce.com/2008/10/03/book-review-9-the-big-moo/">my review of The Big Moo</a>, I will share with you three different lessons learned from reading the book.  The first lesson deals with compromise.  The field of software development is full of stories about products being bloated with unwanted or unnecessary features, costs overrun, late delivery dates, etc.  One reason that explains the cause of this is the lack of courage (that&#8217;s right, the same <em>courage</em> that Kent Beck preaches in Extreme Programming) from developers, analysts, managers or any serious project stakeholder to say &#8220;Hey, wait a minute!  I seriously we should think about this before we go on!&#8221; for example.  Lacking courage in such situations can make place for compromise to settle in and take more space than it should be allowed.  Once compromise is leading the project, the product will suffer, your team will suffer, your organization will suffer, your customer(s) will suffer, and this profession will suffer.  So why should you keep an eagle eye on compromise?  How can you avoid it?  Why should you avoid it?  This first lesson is well told in the essay title &#8220;<strong>The Problem With Compromise</strong>&#8220;.</p>
<p>Here&#8217;s the full text of this essay (author unknown):</p>
<p style="text-align: center">
<h3 style="text-align: center;">The Problem With Compromise</h3>
<p>&#8220;<strong>Any organization with more than one person in it is a place of compromise</strong>.  If you want to get something done, a project okayed, a budget approved, a product sold, you&#8217;re going to have to compromise.&#8221;</p>
<p>&#8220;Most of the time, it seems as though half is better than none.  If you refuse to compromise, nothing happens.  And this desire to make it happen explains why so many things are mediocre.  It tells us why it&#8217;s so hard to make something remarkable, and why the remarkable succeeds so easily.  Because everything is a compromise, everything is sort of mediocre, isn&#8217;t it?&#8221;</p>
<p>&#8220;The wireless Internet access at the Denver airport has compromise written all over it.  I&#8217;m sure that when it was first designed (probably by a lone engineer in a cubicle), it was simple and fast and easy to use.  Today, however, it takes at least a dozen clicks to get started.  You need to enter a username and ID not once, but twice.  And your ID must be at least eight characters long and include numbers <em>and</em> a special character like $, %, or #.  So, something like &#8220;$3eVh!&#8221; is not secure enough because it&#8217;s too short.  Huh?  This isn&#8217;t your credit rating you&#8217;re protecting&#8230;it&#8217;s just the right to spend nine dollars and go online.&#8221;</p>
<p>&#8220;At every step along the way, each compromise to the sign-on system seemed reasonable.  At each step, the evolution of the design was simple: Either the project manager had to go along with the needs of this or that person (and the boss) or risk having the project canceled.  What would you do?  <strong>All those compromises may have made each person happy, but the final product was something that absolutely no one liked</strong>.&#8221;</p>
<p>&#8220;<strong>The first step to fighting back is understanding how compromise corrupts the things you&#8217;re so busy building.  More often than not, half is actually <em>worse</em> than none.  More often than not, you&#8217;re better off doing nothing than shipping something that is just average</strong>.  The project manager in Denver should have just stopped the project and let the chorus of complaints from passengers sink in to make the case for doing things the right way from the start.&#8221;</p>
<p>&#8220;Twenty years ago, Japanese car companies solved their quality control problem using a technique called <a href="http://en.wikipedia.org/wiki/Kanban">Kanban</a>.  Instead of following the American technique of having plenty of spare parts on the assembly line (workers were told to just discard a screw if it didn&#8217;t fit right), the Japanese adopted a fundamentally different strategy.  They kept only <em>one</em> necessary part at a time on the assembly line.  If the part wasn&#8217;t perfect, the entire assembly line stopped until a new part arrived.&#8221;</p>
<p>&#8220;The Americans said that this was insane.  Everyone knew that keeping the assembly line moving was the only way to make a car efficiently.  If a finished car wasn&#8217;t good enough, then you fixed it after it was assembled.&#8221;</p>
<p>&#8220;What Toyota and Honda understood was that the act of stopping the assembly line would send a powerful signal to every worker and to every supplier.  Sure enough, the line didn&#8217;t have to stop very often.  Every part improved in quality, because no one wanted to be responsible for shutting the operation down.  As a result, better parts improved every car as well.  With Kanban, very few cars left the assembly line in need of later reworking.  It <strong>turned out to be cheaper and faster to build cars right the first time than it was to fix them later</strong>.&#8221;</p>
<p>&#8220;You might try the same thing in your organization.  <strong>Refuse to compromise</strong>.  See what happens.  For a while, the assembly line will slow down or even stop.  Things won&#8217;t ship, products will get stuck in development.  And then a funny thing will happen: People will begin to understand that compromising the product just to keep the system working is stupid.  <strong>The only reason the system exists is so that you can make the things you make, right?  So </strong><em><strong>if the system is demeaning your work, change the system</strong>.&#8221;</em></p>
<p>What do you think?  Are you currently in such a situation where compromise has settled in your project team?  What did you do to get out of the situation and prevent it from repeating itself?  Your comments are encouraged for this first lesson learned.</p>
                        <p><br />
My name is Brian Di Croce, a passionate software developer living, coding, blogging and working in Montreal, Canada.  Feel free to visit my <a href="http://www.briandicroce.com">website/blog</a> for more great content related to software development with .NET! &copy;2007-2008<br />
</p>                        <div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=zwNiO5LyaKA:PfLEPKF1CwU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=zwNiO5LyaKA:PfLEPKF1CwU:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=zwNiO5LyaKA:PfLEPKF1CwU:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=zwNiO5LyaKA:PfLEPKF1CwU:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=zwNiO5LyaKA:PfLEPKF1CwU:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/BrianDiCroce/~4/zwNiO5LyaKA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.briandicroce.com/2008/10/10/lesson-1-of-3-from-the-big-moo-the-problem-with-compromise/feed/</wfw:commentRss>
		<feedburner:origLink>http://blog.briandicroce.com/2008/10/10/lesson-1-of-3-from-the-big-moo-the-problem-with-compromise/</feedburner:origLink></item>
		<item>
		<title>Book Review #9: "The Big Moo"</title>
		<link>http://feedproxy.google.com/~r/BrianDiCroce/~3/eD9-SQceh5w/</link>
		<comments>http://blog.briandicroce.com/2008/10/03/book-review-9-the-big-moo/#comments</comments>
		<pubDate>Sat, 04 Oct 2008 03:21:39 +0000</pubDate>
		<dc:creator>Brian Di Croce</dc:creator>
		
		<category><![CDATA[Books]]></category>

		<guid isPermaLink="false">http://blog.briandicroce.com/2008/10/03/book-review-9-the-big-moo/</guid>
		<description>After reading The Dip: A Little Book That Teaches You When to Quit (and When to Stick) from best-seller author, marketing guru and prolific blogger Seth Godin, I couldn&amp;#8217;t wait but to read another one of his writings.&amp;#160; This time I settled for The Big Moo, a collection of over thirty essays focused on [...]</description>
			<content:encoded><![CDATA[<p><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin: 0px 0px 10px 10px; border-right-width: 0px" height="258" alt="image" src="http://blog.briandicroce.com/wp-content/uploads/2008/10/image.png" width="184" align="right" border="0" /> After reading <a href="http://blog.briandicroce.com/2008/03/18/book-review-7-the-dip-a-little-book-that-teaches-you-when-to-quit-and-when-to-stick/">The Dip: A Little Book That Teaches You When to Quit (and When to Stick)</a> from best-seller author, marketing guru and prolific blogger <a href="http://sethgodin.typepad.com/">Seth Godin</a>, I couldn&#8217;t wait but to read another one of his writings.&#160; This time I settled for <a href="www.thebigmoo.com"><strong>The Big Moo</strong></a>, a collection of over thirty essays focused on showing you <em>how</em> and <em>why</em> you and your organization should thrive to be remarkable.&#160; In Seth Godin&#8217;s words: &quot;<strong>Stop trying to be perfect and start being remarkable</strong>&quot;.&#160; At first, I was hit by the book&#8217;s title, but after reading a few pages, it all made sense.&#160; Here&#8217;s what the front cover has to say about what the big moo is all about:</p>
<blockquote><p>As Seth Godin said in his widely quoted best-seller <em>Purple Cow</em>, first you need to stop being a brown cow - in a field of hundreds of other brown cows - and dare to be <em>purple</em>.&#160; But after a while, that&#8217;s not enough.&#160; You need a big moo, an extreme purple cow, <strong>an innovation that completely changes the game</strong>.</p>
</blockquote>
<p>With the collaboration of &quot;33 of the world&#8217;s smartest business thinkers&quot;, including Malcolm Gladwell, Tom Peters, Guy Kawasaki, Marc Benioff, etc., this book is truly a collection of 21st-century wisdom for any organization that&#8217;s looking for a way or a purpose to reach a higher plateau in the way business is done with people.&#160; As stated in the back cover:</p>
<blockquote><p><em>The Big Moo</em> tells their stories.&#160; Stories that will stick to your ribs, light your fire, and give you flashes of inspiration.&#160; Stories about memorable customer service, amazing dedication, daring design standards, and legendary leadership.&#160; <em>The Big Moo</em> will help you drive growth and change in your organization, from the mail room to the boardroom to the front lines.</p>
</blockquote>
<p>No doubt that being remarkable (in the eye of the customer) will give you an edge over your competition that&#8217;s simply doing <em>business</em>.&#160; But The Big Moo is not just for growing and differentiating organizations.&#160; It&#8217;s also a valuable asset to help YOU grow both on a personal and professional level too!&#160; In case you haven&#8217;t noticed, you are also in competition with other people when it comes to signing a contract for a job, a music record, a part in the school&#8217;s play, etc.&#160; </p>
<p>I don&#8217;t want to say too much about this 177-pages book because I rather let you discover its fruits on your own.&#160; While reading it daily on my way to work and back home, I realized that each single essay had something inspiring and concrete that could easily apply to my personal and professional life.&#160; Speaking of essays, you never know which collaborator wrote an essay because each one of them is anonymous&#8230;neat, huh?&#160; Also, we are recommended to share some of these essays publicly without any legal constraints.&#160; Therefore, I will share with you three essays that struck me profoundly in further posts so that you can get a better taste of what the book has to offer.&#160; So stay tuned!&#160; </p>
<p>Meanwhile, I highly recommend anyone in your organization that has a role of leadership to get a copy of The Big Moo and share the stories with the rest of the organization.&#160; Even better&#8230;Get some people in your organization to participate in writing their own remarkable stories and publish them either on your intranet or on the Web.&#160; <strong>Let the &quot;purple cow&quot; in you run free from any boundary!</strong></p>
                        <p><br />
My name is Brian Di Croce, a passionate software developer living, coding, blogging and working in Montreal, Canada.  Feel free to visit my <a href="http://www.briandicroce.com">website/blog</a> for more great content related to software development with .NET! &copy;2007-2008<br />
</p>                        <div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=eD9-SQceh5w:HKeGlm0a18g:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=eD9-SQceh5w:HKeGlm0a18g:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=eD9-SQceh5w:HKeGlm0a18g:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=eD9-SQceh5w:HKeGlm0a18g:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=eD9-SQceh5w:HKeGlm0a18g:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/BrianDiCroce/~4/eD9-SQceh5w" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.briandicroce.com/2008/10/03/book-review-9-the-big-moo/feed/</wfw:commentRss>
		<feedburner:origLink>http://blog.briandicroce.com/2008/10/03/book-review-9-the-big-moo/</feedburner:origLink></item>
		<item>
		<title>Inserting and Retrieving An Image In SQL Server 2005</title>
		<link>http://feedproxy.google.com/~r/BrianDiCroce/~3/DZAZpz7mQbw/</link>
		<comments>http://blog.briandicroce.com/2008/10/01/inserting-and-retrieving-an-image-in-sql-server-2005/#comments</comments>
		<pubDate>Wed, 01 Oct 2008 19:17:30 +0000</pubDate>
		<dc:creator>Brian Di Croce</dc:creator>
		
		<category><![CDATA[.NET Programming]]></category>

		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://blog.briandicroce.com/?p=313</guid>
		<description>If you&amp;#8217;re looking for a solution to store and retrieve a picture from a table in a SQL Server 2005 database, I hope that these two functions (StoreImageInDatabase at line 4 and RetrieveImageFromDatabase at line 72) will satisfy your requirement.  I had to implement such functionality in a project and decided to keep it [...]</description>
			<content:encoded><![CDATA[<p>If you&#8217;re looking for a solution to store and retrieve a picture from a table in a SQL Server 2005 database, I hope that these two functions (<strong>StoreImageInDatabase</strong> at line <strong>4</strong> and <strong>RetrieveImageFromDatabase</strong> at line <strong>72</strong>) will satisfy your requirement.  I had to implement such functionality in a project and decided to keep it here for further reference.  It&#8217;s heavily commented for those developers that are taking their first steps with ADO.NET.  Feel free to share your own implementation too.  There are so many ways to do this.<br />
</p>
<pre name="code" class="csharp">
/// <summary>
/// Stores an image to the database
/// </summary>
private static void StoreImageInDatabase( string imageFilename, ImageFormat imageFormat )
{
    // Make sure the image file exists prior to proceeding with the storage.
    // Note: The File.Exists method will return false whether the imageFilename parameter is null or empty.
    if ( !File.Exists( imageFilename ) ) throw new FileNotFoundException( "The image file was not found", imageFilename );

    // Load the image from the filename received as a parameter.
    Image image = Image.FromFile( imageFilename );

    // Holds the byte representation of the image.
    Byte[] content;

    // Use a MemoryStream to store the image representation as stream of bytes.
    using ( var stream = new MemoryStream() )
    {
        image.Save( stream, imageFormat );

        // Convert the stream into an array of bytes because that's the value we'll pass to our SQL parameter.
        content = stream.ToArray();
    }

    // Our connection string (put it in your configuration file if needed)
    const string connectionString = "INSERT YOUR DATABASE'S CONNECTION STRING HERE";

    // Create an SQL connection based on a connection string pre-defined (the using statement will close/dispose the connection on our behalf even if an exception should occur).
    using ( var connection = new SqlConnection( connectionString ) )
    {
        // The SQL statement/stored procedure used to store our image.
        // Just make sure that you have a parameter named '@PICTURE' of type Image as well as a column named 'PICTURE' of type Image too in the table.
        const string sqlStatement = "UPDATE SOME_TABLE SET PICTURE = @PICTURE WHERE SOME_CONDITION";

        // Create an SQL command based on our stored procedure and SQL connection.
        using ( var command = new SqlCommand( sqlStatement, connection ) )
        {
            // Explicitly state that we'll be using a SQL statement or a stored procedure (CommandType.StoredProcedure).
            command.CommandType = CommandType.Text;

            // Define the SQL parameter which will hold our image to store.
            var parameter = new SqlParameter( "@PICTURE", SqlDbType.Image )
                            {
                                    Value = content
                            };
            command.Parameters.Add( parameter );

            try
            {
                // Open the connection.
                connection.Open();

                // Execute the stored procedure to store our image in the database.
                command.ExecuteNonQuery();

                MessageBox.Show( "Image stored successfully", "Image storage", MessageBoxButtons.OK,
                                 MessageBoxIcon.Information );
            }

            catch ( SqlException ex )
            {
                MessageBox.Show( ex.Message, "SQLException", MessageBoxButtons.OK, MessageBoxIcon.Error );
                // Other error handling, logging, etc.
            }
        }
    }
}

/// <summary>
/// Retrieves an image from the database
/// </summary>
private static Image RetrieveImageFromDatabase()
{
    // The image that will be retrieved
    Image image = null;

    // Our connection string (put it in your configuration file if needed)
    const string connectionString = "INSERT YOUR DATABASE'S CONNECTION STRING HERE";

    // Create an SQL connection based on a connection string pre-defined (the using statement will close/dispose the connection on our behalf even if an exception should occur).
    using ( var connection = new SqlConnection( connectionString ) )
    {
        // The SQL statement/stored procedure used to retrieve our image.
        // Just make sure that you have a column named 'PICTURE' of type Image.
        const string sqlStatement = "SELECT PICTURE FROM SOME_TABLE WHERE SOME_CONDITION";

        // Create an SQL command based on our stored procedure and SQL connection.
        using ( var command = new SqlCommand( sqlStatement, connection ) )
        {
            try
            {
                // Explicitly state that we'll be using a SQL statement or a stored procedure (CommandType.StoredProcedure).
                command.CommandType = CommandType.Text;

                // Open the connection.
                connection.Open();

                // Execute the query and build a DataReader with the results.
                var reader = command.ExecuteReader();

                Debug.Assert( reader != null );

                // Since we only have one image stored in the table (this is an example after all...), we'll only have one image to retrieve from our table.
                // If you have to retrieve one specific image (or more) from a collection of images in the table, then you can precise which one to retrieve via a parameter.
                reader.Read();

                // Since the only column of our table is used to store/retrieve an image, its column index is zero.
                // We simply cast that column into an array of bytes.
                var content = (byte[])reader[0];

                // Create a stream based on the entire content of our buffer.
                using ( Stream stream = new MemoryStream( content, 0, content.Length ) )
                {
                    // Write the content (array of bytes) to our stream.
                    stream.Write( content, 0, content.Length );

                    // Create an image object based on the stream.
                    image = Image.FromStream( stream );
                }
            }

            catch ( SqlException ex )
            {
                MessageBox.Show( ex.Message, "SQLException", MessageBoxButtons.OK, MessageBoxIcon.Error );
                // Other error handling, logging, etc.
            }
        }
    }

    return image;
}
</pre>
                        <p><br />
My name is Brian Di Croce, a passionate software developer living, coding, blogging and working in Montreal, Canada.  Feel free to visit my <a href="http://www.briandicroce.com">website/blog</a> for more great content related to software development with .NET! &copy;2007-2008<br />
</p>                        <div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=DZAZpz7mQbw:KVdJpl2VCGY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=DZAZpz7mQbw:KVdJpl2VCGY:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=DZAZpz7mQbw:KVdJpl2VCGY:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=DZAZpz7mQbw:KVdJpl2VCGY:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=DZAZpz7mQbw:KVdJpl2VCGY:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/BrianDiCroce/~4/DZAZpz7mQbw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.briandicroce.com/2008/10/01/inserting-and-retrieving-an-image-in-sql-server-2005/feed/</wfw:commentRss>
		<feedburner:origLink>http://blog.briandicroce.com/2008/10/01/inserting-and-retrieving-an-image-in-sql-server-2005/</feedburner:origLink></item>
		<item>
		<title>Grady Booch’s thoughts on software development @ Yahoo!</title>
		<link>http://feedproxy.google.com/~r/BrianDiCroce/~3/qIc4JKjfFNQ/</link>
		<comments>http://blog.briandicroce.com/2008/09/10/grady-boochs-thoughts-on-software-development-yahoo/#comments</comments>
		<pubDate>Thu, 11 Sep 2008 00:33:50 +0000</pubDate>
		<dc:creator>Brian Di Croce</dc:creator>
		
		<category><![CDATA[Media/Presentations]]></category>

		<guid isPermaLink="false">http://blog.briandicroce.com/2008/09/10/grady-boochs-thoughts-on-software-development-yahoo/</guid>
		<description>Last year, Grady Booch was invited to give a talk at Yahoo! on the present state and the future of software development.&amp;#160; Entitled &amp;#34;The Promise, The Limits, The Beauty of Software&amp;#34;, he clearly shares some remarks and insights about his experience as a software craftsman throughout his career and the industry.&amp;#160; The video is [...]</description>
			<content:encoded><![CDATA[<p><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin: 0px 0px 10px 10px; border-right-width: 0px" height="187" alt="image" src="http://blog.briandicroce.com/wp-content/uploads/2008/09/image1.png" width="270" align="right" border="0" /> Last year, <a href="http://en.wikipedia.org/wiki/Grady_Booch">Grady Booch</a> was invited to give a talk at Yahoo! on the present state and the future of software development.&#160; Entitled &quot;<a href="http://video.yahoo.com/watch/577305/2839970"><strong>The Promise, The Limits, The Beauty of Software</strong></a>&quot;, he clearly shares some remarks and insights about his experience as a software craftsman throughout his career and the industry.&#160; The video is about an hour long, but very insightful.&#160; If you&#8217;re not accustomed to reading books about software development in general, I think you will gain a lot by watching this one.</p>
                        <p><br />
My name is Brian Di Croce, a passionate software developer living, coding, blogging and working in Montreal, Canada.  Feel free to visit my <a href="http://www.briandicroce.com">website/blog</a> for more great content related to software development with .NET! &copy;2007-2008<br />
</p>                        <div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=qIc4JKjfFNQ:x3gEXpKKkJk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=qIc4JKjfFNQ:x3gEXpKKkJk:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=qIc4JKjfFNQ:x3gEXpKKkJk:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=qIc4JKjfFNQ:x3gEXpKKkJk:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=qIc4JKjfFNQ:x3gEXpKKkJk:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/BrianDiCroce/~4/qIc4JKjfFNQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.briandicroce.com/2008/09/10/grady-boochs-thoughts-on-software-development-yahoo/feed/</wfw:commentRss>
		<feedburner:origLink>http://blog.briandicroce.com/2008/09/10/grady-boochs-thoughts-on-software-development-yahoo/</feedburner:origLink></item>
		<item>
		<title>How do you construct your objects?</title>
		<link>http://feedproxy.google.com/~r/BrianDiCroce/~3/tqpboWTSYWQ/</link>
		<comments>http://blog.briandicroce.com/2008/09/09/how-do-you-construct-your-objects/#comments</comments>
		<pubDate>Tue, 09 Sep 2008 15:21:33 +0000</pubDate>
		<dc:creator>Brian Di Croce</dc:creator>
		
		<category><![CDATA[.NET Programming]]></category>

		<guid isPermaLink="false">http://blog.briandicroce.com/?p=379</guid>
		<description>I love it when an object is designed in a way that allows me to use it without forcing me to ask or wonder how it should be initialized.  Good enough?  Ok, let’s go further…
Let’s start with a simple example of a Person class.  One way I could write the class is like this:

class Person
{
    [...]</description>
			<content:encoded><![CDATA[<p>I love it when an object is designed in a way that allows me to use it without forcing me to ask or wonder how it should be initialized.  Good enough?  Ok, let’s go further…</p>
<p>Let’s start with a simple example of a <strong>Person</strong> class.  One way I could write the class is like this:</p>
<pre name="code" class="csharp">
class Person
{
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public int Age { get; set; }

    // No constructors defined means the compiler will create a default (parameterless) constructor for us.
}
</pre>
<p>All right, so if I want to use this class, I need to know or figure out which properties of my newly instantiated Person object to set before actually using it.  This is an important step, because if the object participates in some method that requests a valid value from one of its properties, and that property isn’t in a valid, coherent state, then we might not get the expected result and debugging the problem might be cumbersome.  In our case, since a Person object is fairly straightforward and common, we pretty much know that its FirstName and LastName properties should be set prior to use it.  But what about its Age?  Let’s suppose that the Age is as important as the FirstName and the LastName.  Let’s also suppose that there are a bunch of other properties that defines a Person, such as Weight, Height, EyesColor, HairColor, Cavities, Faith, etc.  How can we possibly know that we must set the Age property when IntelliSense gives us a myriad of other properties belonging to this object?  Frankly, we can’t, unless the author of the class tells us or it’s documented somewhere (but then again who documents code, right?).</p>
<p>I believe that if the author of the Person class had use an intention-revealing technique to design the class, such as Test-Driven Development, she probably would’ve thought about how to properly initialize the class.  But then again, even that depends on the developer’s <strong>experience</strong>, <strong>philosophy</strong> and <strong>imagination</strong> on designing object-oriented software.</p>
<p>When designing objects, it’s important to ask ourselves a few questions prior to coding.  For example, should we provide a parameterless constructor (which will force the clients of the object to properly initialize its members)?  Should we provide constructors which accept parameters to properly initialize the object so that it’s ready to be used?  Even that question forces us to ask whether or not we should fully or partially initialize the object. </p>
<p>Whenever I instantiate an object, I like to know the information it needs to be properly initialized (<a href="http://www.jetbrains.com/resharper" target="_blank">ReSharper</a> is pretty helpful in such a scenario).  In other words, I want to know the “what” NOW…not later.  Furthermore, I don’t want the clients using my object to think too much about these concerns either.  I just want them to instantiate the object and be ready to start using it.  Am I asking for too much here?  I don’t consider myself a good programmer if I remove the developer out of the “<a href="http://en.wikipedia.org/wiki/Flow_(psychology)" target="_blank">zone</a>” whenever she uses my objects.  It’s like constantly turning on and off a lighting switch&#8230;it gets annoying…<em>very</em> annoying.  That being said, if I take our previous little example, I would design the Person class as the following:</p>
<pre name="code" class="csharp">
class Person
{
    public Person (string firstName, string lastName, int age)
    {
        // Implementation…
    }

    // No more constructors…not even a default (parameterless) constructor.
}
</pre>
<p>This constructor implementation would be valid if I want this object to be initialized with a FirstName, LastName and Age upon instantiation.  How can I know whether or not this is a “good” practice?  In most cases, you can probably find the answer directly in the requirements document, but again I strongly believe that it depends on one’s own experience, philosophy and imagination with object-oriented design and programming.  Nevertheless, with the now refactored Person class, I can easily communicate to the client of that class what she needs to provide to the object for it to be properly instantiated and ready to use.  <strong>I don’t make her think…I don’t push her out of the “<a href="http://en.wikipedia.org/wiki/Flow_(psychology)" target="_blank">zone</a>”.</strong></p>
<p>Another way to think about it is that when you go to the bank to open a new account, the bank teller doesn’t just hand you over a new “empty” account.  First, she asks you a few questions and gets some information from you, such as your name, your address, your credit history, etc.  Does it make sense for her to ask those things?  Absolutely, because it makes sense in the process of creating a bank account.  Going back to our Person class, does it make sense for that object to ask you to provide a FirstName, LastName and Age information prior to creating one?  Well, it also depends on the process of creating a Person object in your business domain.  (Software development is a field where there’s a lot of those “<em>well, it depends!</em>” moments).</p>
<p>Let me wrap up this idea by giving you two more examples from the .NET Framework.  If you search for the “MailMessage” class with Reflector, you will see that there are two MailMessage classes in the search results (see the picture below).  One of these belongs to the <strong>System.Net.Mail</strong> namespace and another one belongs to the <strong>System.Web.Mail</strong> namespace.  They both provide the same functionality, but the one from System.Web.Mail is actually <strong>obsolete</strong>.  In fact, it’ll ask you to use the one from the System.Net.Mail namespace instead. <br />
<center><br />
<strong>Figure 1.</strong> Search results for “Mail Message” in <a href="http://www.red-gate.com/products/reflector/">Reflector</a><br />
<img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" title="image" src="http://blog.briandicroce.com/wp-content/uploads/2008/09/image.png" border="0" alt="image" width="430" height="156" /><br />
</center><br />
If we look at MailMessage from <strong>System.Net.Mail</strong>, we’ll see the following four constructors:</p>
<ul>
<li>A public parameterless constructor which initializes an empty instance of it.</li>
<li>Another public constructor which accepts two MailAddress objects as parameters (one is the source MailAddress and another the destination MailAddress)</li>
<li>Another public constructor which accepts two string parameters (the source email address and the destination email address)</li>
<li>Another public constructor which accepts four string parameters (the source email address, the destination email address, the subject and the message body)</li>
</ul>
<p>I can understand that providing multiple ways to instantiate such an object is required in this context, because this MailMessage object belongs to a framework and not a custom application.  As <a href="http://en.wikipedia.org/wiki/Kent_Beck" target="_blank">Kent Beck</a> righteously points out in his latest book, “<a href="http://www.infoq.com/interviews/beck-implementation-patterns" target="_blank">Implementation Patterns</a>”, <strong>there is a big difference in the way objects are designed and built in a framework versus a custom application</strong>.  As you can see, these constructors are telling me what specific information I should provide them in order to instantiate a fully working object.</p>
<p>Now take a look at the obsolete MailMessage class from <strong>System.Web.Mail</strong>.  You might expect the same number of constructors as the one from System.Net.Mail.  Instead, this one only provides one constructor: the default parameterless one.  Oh boy!  Now, the client of this class must know which properties (Attachments, Bcc, Body, BodyEncoding, From, CC, etc.) to set before actually using the object.  She is getting out of her “<a href="http://en.wikipedia.org/wiki/Flow_(psychology)" target="_blank">zone</a>”…the light bulb is flashing…it’s annoying.  Good thing this one is now obsolete.</p>
<p>I still see much code in custom application that doesn’t offer the developer the guidance to properly instantiate an object prior to using it.  This forces us to ask ourselves “Ok, now that I have instantiated this object, what <em>exactly</em> do I need to provide it with for it to work properly?”.  I hate asking myself these questions.  I just want to use the object.  I want to think about more important things that knowing which properties to set.  If you’re at this crossroad and need to know what kind of information should an object request in its constructor, writing a unit test for it prior to coding might reveal a powerful weapon to counter the never-ending battle in our minds when designing good objects.</p>
<p>What other tricks or ways do you know about writing good object constructors?</p>
                        <p><br />
My name is Brian Di Croce, a passionate software developer living, coding, blogging and working in Montreal, Canada.  Feel free to visit my <a href="http://www.briandicroce.com">website/blog</a> for more great content related to software development with .NET! &copy;2007-2008<br />
</p>                        <div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=tqpboWTSYWQ:Z2j1WGz3gEg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=tqpboWTSYWQ:Z2j1WGz3gEg:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=tqpboWTSYWQ:Z2j1WGz3gEg:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/BrianDiCroce?a=tqpboWTSYWQ:Z2j1WGz3gEg:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/BrianDiCroce?i=tqpboWTSYWQ:Z2j1WGz3gEg:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/BrianDiCroce/~4/tqpboWTSYWQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.briandicroce.com/2008/09/09/how-do-you-construct-your-objects/feed/</wfw:commentRss>
		<feedburner:origLink>http://blog.briandicroce.com/2008/09/09/how-do-you-construct-your-objects/</feedburner:origLink></item>
	</channel>
</rss>
