<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>The Inquisitive Coder - Davy Brion's Blog</title>
	
	<link>http://davybrion.com/blog</link>
	<description>Trying to walk that thin line between intelligence and ignorance</description>
	<lastBuildDate>Thu, 29 Jul 2010 20:51:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/davybrion" /><feedburner:info uri="davybrion" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Hey, It Is MY Personal Time After All</title>
		<link>http://feedproxy.google.com/~r/davybrion/~3/SrcG29VIU00/</link>
		<comments>http://davybrion.com/blog/2010/07/hey-it-is-my-personal-time-after-all/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 20:11:35 +0000</pubDate>
		<dc:creator>Davy Brion</dc:creator>
				<category><![CDATA[About The Blog]]></category>

		<guid isPermaLink="false">http://davybrion.com/blog/?p=2409</guid>
		<description><![CDATA[I just got the following comment on my post about MVVM being overrated: Sorry, but you’re just talking. Where’s the code ? I mean you seem to have all the time in the world to just say things on your blog , but no time to put together a simple sample up. I seriously doubt [...]]]></description>
			<content:encoded><![CDATA[<p>I just got the following <a href="http://davybrion.com/blog/2010/07/the-mvvm-pattern-is-highly-overrated/#comment-50017">comment</a> on my post about MVVM being overrated:</p>
<blockquote><p>
Sorry, but you’re just talking.</p>
<p>Where’s the code ?</p>
<p>I mean you seem to have all the time in the world to just say things on your blog , but no time to put together a simple sample up.</p>
<p>I seriously doubt you understand what you talk about.
</p></blockquote>
<p>As you can probably tell from my <a href="http://davybrion.com/blog/2010/07/the-mvvm-pattern-is-highly-overrated/#comment-50019">reaction</a>, i got pretty pissed off.  Normally, i don&#8217;t let comments like that get to me.  But in this case, i have been spending quite a bit of my personal time working on a sample and preparing the blog posts.  I&#8217;m actually planning to spend quite a bit of my weekend on this (as i did last weekend), not to mention that i&#8217;m also gonna spend a couple of hours working on it during my day off tomorrow.</p>
<p>I&#8217;m not getting paid for any of this.  In fact, i&#8217;m only getting shit for doing this.  The handful of people who are looking at this because they&#8217;re tired of the MSDN-way of developing things will appreciate it, but the vast majority of people who&#8217;re gonna read it are going to complain because &#8220;it&#8217;s too complicated!&#8221; or &#8220;i have to think too much!&#8221;.  Well, you know what?  You&#8217;re not the kind of developer i&#8217;m targeting anyway.  If you stumble upon a post of mine about Silverlight or anything else that&#8217;s hot in MSDN-land, you probably got here through a link-blog or a link on twitter.  And in those cases, odds are pretty high that the way i think about software development and the way you think about it don&#8217;t exactly match.  And that&#8217;s ok.  I&#8217;ll do what i wanna do in the way i feel it&#8217;s right to do so, and i suggest you do the same.  But pressuring me into backing up the stuff i say with code is not really gonna get you anything sooner.  I&#8217;m still gonna do whatever it is that i&#8217;m gonna do in a time frame that suits <em>me, not you</em>.</p>
<p>And to top it all off, i just got the following reply from the same guy:</p>
<p>&#8220;I’ll just say this.</p>
<p>When you make a public statement , you better have some code ready to prove it.&#8221;</p>
<p>Priceless, ain&#8217;t it?</p>

<p><a href="http://feedads.g.doubleclick.net/~a/amaxFZMl4kT7JfEpvpMVvv0yem4/0/da"><img src="http://feedads.g.doubleclick.net/~a/amaxFZMl4kT7JfEpvpMVvv0yem4/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/amaxFZMl4kT7JfEpvpMVvv0yem4/1/da"><img src="http://feedads.g.doubleclick.net/~a/amaxFZMl4kT7JfEpvpMVvv0yem4/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/davybrion?a=SrcG29VIU00:Izi0bYYdwNc:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/davybrion?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/davybrion?a=SrcG29VIU00:Izi0bYYdwNc:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/davybrion?i=SrcG29VIU00:Izi0bYYdwNc:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/davybrion/~4/SrcG29VIU00" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://davybrion.com/blog/2010/07/hey-it-is-my-personal-time-after-all/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://davybrion.com/blog/2010/07/hey-it-is-my-personal-time-after-all/</feedburner:origLink></item>
		<item>
		<title>Estimates Are A Double-Edged Sword</title>
		<link>http://feedproxy.google.com/~r/davybrion/~3/GS0FZofB7kk/</link>
		<comments>http://davybrion.com/blog/2010/07/estimates-are-a-double-edged-sword/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 19:45:52 +0000</pubDate>
		<dc:creator>Davy Brion</dc:creator>
				<category><![CDATA[Opinions]]></category>

		<guid isPermaLink="false">http://davybrion.com/blog/?p=2404</guid>
		<description><![CDATA[Most people in the software development industry will (hopefully) agree that estimates are important. You need estimates to predict the cost of development and how long it&#8217;s going to take. Without them, there is no way you could promise a delivery date to a customer or come up with a total cost estimate. Both of [...]]]></description>
			<content:encoded><![CDATA[<p>Most people in the software development industry will (hopefully) agree that estimates are important. You need estimates to predict the cost of development and how long it&#8217;s going to take.  Without them, there is no way you could promise a delivery date to a customer or come up with a total cost estimate.  Both of which are tremendously important when your core business is based on delivering software to clients.  It is therefore very important to make sure your estimates are as good as they can be, and that you review your estimates with the final actual figures so you can figure out where you need to start improving (either your development process, or your estimation practices).</p>
<p>But there are some things you need to watch out for in any organization which takes estimates seriously.  Most development shops have estimates at the task-level.  These task-level estimates are often used during the planning of the next iteration, but were most likely also used in the initial total estimate of the project.  I certainly don&#8217;t doubt the importance of those task-level estimates, but i do think they should be used cautiously.  </p>
<p>If too much importance is placed on staying below the estimates, or at least not going over them, you run the risk of growing a culture where developers let the estimates have too much influence on the quality of the work they&#8217;re doing.  Some developers will strive hard to routinely stay below the estimates.  Some developers will work in fear of going over the estimate.  In both cases, it leads to technical shortcuts that will be taken.  Those shortcuts will consist of skipping some tests here and there, skipping a bunch of tests altogether, decreasing willingness to refactor code that could use it and worst of all, no longer keeping a clean design in mind.  Granted, i&#8217;m painting a very bleak picture here but it <em>does</em> happen with some people and the negative results can not be underestimated.</p>
<p>Let&#8217;s consider the overall effect of these shortcuts.  A shortcut here or there is not abnormal in some circumstances, but it should be exceptional.  It should not become routine, it should be frowned upon and i&#8217;d even go as far as recommending a &#8220;no shortcuts allowed unless the team approves of it&#8221; policy.  A shortcut here or there doesn&#8217;t take a lot of effort to fix and because of this, it can often be done as soon as the original reason of the existence of the shortcut (typically: a deadline) is no longer an issue.  An accumulation of shortcuts however leads to not only an obviously bigger workload to fix all of the shortcuts, but it also impacts <em>a lot of other code</em> that shouldn&#8217;t have been impacted in the first place.  Once this happens, you&#8217;ve got yourself an <a href="http://davybrion.com/blog/2008/09/code-health/">unhealthy code base</a> and it&#8217;s only going to get worse until it eventually dies at a younger age than it could have reached.</p>
<p>Now, imagine a culture where estimates are given as much importance as quality.  If you&#8217;re approaching the estimate and you&#8217;ve still got a lot of work left to fully complete the task (and with fully completed, i really don&#8217;t mean watching it work on your machine as you manually test it), then you consult with the rest of your team members.  Estimate how much time it would take to fully complete the task, and see if the increased time over the original estimate is doable.  If you&#8217;re already behind your overall schedule, it&#8217;s probably not doable unless there are many subsequent tasks that are dependent on this particular task.  But if you&#8217;re ahead of schedule, you&#8217;re probably better off accepting the fact that you&#8217;re going to go over this task&#8217;s original estimate in order to <em>do it right</em>.  If you do so, the extra hours you spent on this task should (in most cases at least) not lead to extra hours on <em>future</em> tasks.  Conversely, if you&#8217;ve finished a task well below the estimate, it might actually be a good <em>investment</em> to refactor some &#8216;bad&#8217; code that you&#8217;ve come across while working on your task.  Or to add some missing tests here or there.  That certainly doesn&#8217;t mean that you need to spend all the available remaining time you have but you shouldn&#8217;t run to start on a new task as soon as humanly possible either.  Follow the <a href="http://programmer.97things.oreilly.com/wiki/index.php/The_Boy_Scout_Rule">boy scout rule</a> here&#8230; you won&#8217;t spend that much extra time on it, but overall quality can improve greatly from this.</p>
<p>In fact, i&#8217;d even bet that the time it takes to <em>do it right</em> will in a large majority of cases still be less than the sum of the original time that was spent on a task hastily done and the time that will be spent on bugs that resulted from that hastily done task, not to mention the impact it could have on the development of future tasks simply because of the suboptimal implementation of the hastily done task.</p>
<p>Finally, it&#8217;s also important to think about why there was a need to go over an estimate.  There can be a variety of reasons for this, and one of them is that the task was simply badly estimated.  If that indeed turns out to be the case, make sure that you <em>learn</em> from it to prevent this from happening in the future.  When we find bugs in our code, we try to prevent those bugs from ever occurring again.  We should have a similar attitude to our estimating practices as well.  If an estimate was simply too low, make sure that a similar task in the future won&#8217;t be estimated too low again or you will again introduce a possible problem in your (future) project.</p>
<p>And that, in my opinion, is also a good reason to decide to go over the estimate if you can.  If you go over the estimate and all people involved learn from the bad estimate, then everyone basically benefits from it.  Future estimates should become more accurate, and no code was harmed in the process.  You might have lost some money on it, but at least you only lost it <em>once</em> instead of losing it over and over again in similar future circumstances. </p>

<p><a href="http://feedads.g.doubleclick.net/~a/tNkRamIMEhXVw4qUQHbyQZJDZK4/0/da"><img src="http://feedads.g.doubleclick.net/~a/tNkRamIMEhXVw4qUQHbyQZJDZK4/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/tNkRamIMEhXVw4qUQHbyQZJDZK4/1/da"><img src="http://feedads.g.doubleclick.net/~a/tNkRamIMEhXVw4qUQHbyQZJDZK4/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/davybrion?a=GS0FZofB7kk:VqIBWT3QEME:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/davybrion?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/davybrion?a=GS0FZofB7kk:VqIBWT3QEME:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/davybrion?i=GS0FZofB7kk:VqIBWT3QEME:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/davybrion/~4/GS0FZofB7kk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://davybrion.com/blog/2010/07/estimates-are-a-double-edged-sword/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<feedburner:origLink>http://davybrion.com/blog/2010/07/estimates-are-a-double-edged-sword/</feedburner:origLink></item>
		<item>
		<title>Is That How You Talk To People?</title>
		<link>http://feedproxy.google.com/~r/davybrion/~3/L0MNFphNjoY/</link>
		<comments>http://davybrion.com/blog/2010/07/is-that-how-you-talk-to-people/#comments</comments>
		<pubDate>Mon, 26 Jul 2010 12:29:05 +0000</pubDate>
		<dc:creator>Davy Brion</dc:creator>
				<category><![CDATA[Code Quality]]></category>

		<guid isPermaLink="false">http://davybrion.com/blog/2010/07/is-that-how-you-talk-to-people/</guid>
		<description><![CDATA[I just spotted the following 2 methods in a piece of code: &#160;&#160;&#160;&#160;&#160;&#160;&#160; public void ShowPanelWindow(bool isVisible) &#160;&#160;&#160;&#160;&#160;&#160;&#160; { &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Visibility = isVisible ? Visibility.Visible : Visibility.Collapsed; &#160;&#160;&#160;&#160;&#160;&#160;&#160; } &#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160; public void ShowBusy(bool isBusy) &#160;&#160;&#160;&#160;&#160;&#160;&#160; { &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; BusyIndicator.ShowIsBusy = isBusy; &#160;&#160;&#160;&#160;&#160;&#160;&#160; } &#160; And i cringed. Personally, i think it’s weird to read lines [...]]]></description>
			<content:encoded><![CDATA[<p>I just spotted the following 2 methods in a piece of code:</p>
<div style="font-family: consolas; background: white; color: black; font-size: 10pt">
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: blue">void</span> <span style="color: #008b8b">ShowPanelWindow</span>(<span style="color: blue">bool</span> isVisible)</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: purple">Visibility</span> = isVisible ? <span style="color: #00008b">Visibility</span>.<span style="color: purple; font-weight: bold">Visible</span> : <span style="color: #00008b">Visibility</span>.<span style="color: purple; font-weight: bold">Collapsed</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: blue">void</span> <span style="color: #008b8b">ShowBusy</span>(<span style="color: blue">bool</span> isBusy)</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: purple">BusyIndicator</span>.<span style="color: purple">ShowIsBusy</span> = isBusy;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;</p>
</p></div>
<p>And i cringed. Personally, i think it’s weird to read lines of code that say view.ShowPanelWindow(false) or view.ShowBusy(false).&#160; Instead, i’d go for something like this:</p>
<div style="font-family: consolas; background: white; color: black; font-size: 10pt">
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: blue">void</span> <span style="color: #008b8b">HidePanelWindow</span>()</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: purple">Visibility</span> = <span style="color: #00008b">Visibility</span>.<span style="color: purple; font-weight: bold">Collapsed</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: blue">void</span> <span style="color: #008b8b">ShowPanelWindow</span>()</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: purple">Visibility</span> = <span style="color: #00008b">Visibility</span>.<span style="color: purple; font-weight: bold">Visible</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: blue">void</span> <span style="color: #008b8b">LookBusy</span>()</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: purple">BusyIndicator</span>.<span style="color: purple">ShowIsBusy</span> = <span style="color: blue">true</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: blue">void</span> <span style="color: #008b8b">StopLookingBusy</span>()</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: purple">BusyIndicator</span>.<span style="color: purple">ShowIsBusy</span> = <span style="color: blue">false</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;</p>
</p></div>
<p>Sure, i’m not gonna win the fewest-lines-of-code contest but then again, we’re not participating in that contest anyway.&#160; And while my version is a little bit longer, it doesn’t take more than a few extra seconds to write that extra code, and the improved readability of the consuming code is more than worth it.&#160; After all, you do prefer reading view.HidePanelWindow() over view.ShowPanelWindow(false), no?</p>
<p>I’ve always liked the following approach to avoid (or at least, mimimize) bad method names.&#160; Just pretend that the classes are people and that the method names are messages between them.&#160; There is after all a reason why we referred to it as “sending a message to an object” originally in OO-terms.&#160; Give it a shot, and you’ll notice that your code will become more readable with hardly any extra effort.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/oaDHKuwo8v3CjmIuDcbo7XOrYiA/0/da"><img src="http://feedads.g.doubleclick.net/~a/oaDHKuwo8v3CjmIuDcbo7XOrYiA/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/oaDHKuwo8v3CjmIuDcbo7XOrYiA/1/da"><img src="http://feedads.g.doubleclick.net/~a/oaDHKuwo8v3CjmIuDcbo7XOrYiA/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/davybrion?a=L0MNFphNjoY:Hq5iKD1iRV4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/davybrion?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/davybrion?a=L0MNFphNjoY:Hq5iKD1iRV4:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/davybrion?i=L0MNFphNjoY:Hq5iKD1iRV4:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/davybrion/~4/L0MNFphNjoY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://davybrion.com/blog/2010/07/is-that-how-you-talk-to-people/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		<feedburner:origLink>http://davybrion.com/blog/2010/07/is-that-how-you-talk-to-people/</feedburner:origLink></item>
		<item>
		<title>The MVVM Pattern Is Highly Overrated</title>
		<link>http://feedproxy.google.com/~r/davybrion/~3/LNZqmGrxXYo/</link>
		<comments>http://davybrion.com/blog/2010/07/the-mvvm-pattern-is-highly-overrated/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 14:23:58 +0000</pubDate>
		<dc:creator>Davy Brion</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Code Quality]]></category>
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://davybrion.com/blog/?p=2392</guid>
		<description><![CDATA[If you&#8217;re doing Silverlight or WPF, you&#8217;ve no doubt come across the MVVM (Model-View-ViewModel) pattern. It seems to be the most popular client-side architecture pattern used among Silverlight/WPF developers. I find the pattern to be highly overrated, and actually have some big issues with the whole thing. First, let&#8217;s briefly cover what MVVM is about [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re doing Silverlight or WPF, you&#8217;ve no doubt come across the MVVM (Model-View-ViewModel) pattern.  It seems to be the most popular client-side architecture pattern used among Silverlight/WPF developers.  I find the pattern to be highly overrated, and actually have some big issues with the whole thing. </p>
<p>First, let&#8217;s briefly cover what MVVM is about for those of you who don&#8217;t know yet.  MVVM virtually eliminates all of the code that would typically be placed in the code-behind file of your View (a user control, a screen, whatever) by putting all of that logic in the ViewModel.  The ViewModel itself is never tightly coupled to the View. If it does have a reference to it, it&#8217;s typically through an interface that the View implements instead of a reference of the actual type of the View.  This increases, or better yet, introduces testability to a large part of your UI code that you normally wouldn&#8217;t be able to cover with unit tests if you&#8217;d go with the traditional &#8220;put it all in the code-behind&#8221;-approach.</p>
<p>The ViewModel typically contains properties for the data that is to be shown in the View, and also raises notification events when the data in those properties changes.  The View uses the powerful data-binding capabilities of Silverlight/WPF to bind the properties of the ViewModel to other user controls that the View is composed of.  User-events that are captured by the View are sent to the ViewModel through Commands.  Typically, these commands execute a method in the ViewModel which contains some kind of logic&#8230; usually to either send the updated data in the ViewModel&#8217;s properties to the Model (usually a Service Layer in Silverlight, in WPF it could be either a true Domain Model or also a Service Layer), to perform some business logic in the Model, or to retrieve data from the Model so it can be placed in the ViewModel&#8217;s properties so the View can bind to it.</p>
<p>That is, in a nutshell, how the MVVM pattern works.  So why do i have issues with this? You can develop and test most of the application&#8217;s logic without being dependent on a physical View and that is typically a Good Thing, no? It sure is!  However, my problem with this approach is that  too many responsibilities are concentrated within the ViewModel.  Its main responsibilities are to facilitate databinding <em>and</em> to interact with the Model.  And that, in my opinion, isn&#8217;t very clean.  In some ways, you could actually think of the ViewModel as a glorified code-behind, with the only difference being that it&#8217;s not tightly coupled to the (physical) View.</p>
<p>In most (if not all) MVVM implementations, a ViewModel has many possible reasons to be changed.  It might need to be changed because of different data-binding requirements.  Then again, it might also require changes when a part of the Model is modified.  Now, i&#8217;m sure many of you can agree with me when i say that two of the most important principles in software development are <a href="http://en.wikipedia.org/wiki/Separation_of_concerns">Seperation of Concerns (SoC)</a> and the <a href="http://en.wikipedia.org/wiki/Single_responsibility_principle">Single Responsibility Principle (SRP)</a>.  Obviously, the ViewModel doesn&#8217;t fare well when it comes to both of these principles. </p>
<p>Lets forget about MVVM for a second and focus on the concerns and responsibilities that a user control can have&#8230; say, a user control that shows customer information and allows the user to edit that data so it can be persisted:</p>
<ul>
<li>visualization of the actual control (its own layout as well drawing other user controls that it is composed of)</li>
<li>communication/interaction with the Model</li>
<li>making data (from the Model) available so it can be displayed</li>
<li>outputting data in the correct user controls (for instance: various textboxes)</li>
<li>(simple validation) of modified/inputted data (for instance: no string values for numeric fields, etc&#8230;)</li>
</ul>
<p>Without MVVM, all of these would be taken care of in the View.  Obviously, not a good idea right?  After all, if it were a good idea, we&#8217;d never have had a reason to start using MVVM in the first place.</p>
<p>Now, with MVVM, a lot of people would divide these concerns and responsibilities like this:</p>
<p>View:</p>
<ul>
<li>visualization of the actual control (its own layout as well drawing other user controls that it is composed of)</li>
<li>outputting data in the correct user controls (for instance: various textboxes)</li>
<li>(simple validation) of modified/inputted data (for instance: no string values for numeric fields, etc&#8230;)</li>
</ul>
<p>ViewModel:</p>
<ul>
<li>communication/interaction with the Model</li>
<li>making data (from the Model) available so it can be displayed</li>
</ul>
<p>In this case, the View still has 3 responsibilities which is still too much according to &#8216;the guidelines&#8217;, but it&#8217;s not that big of a deal (though plenty of people would argue that the simple validation would be better placed in the ViewModel).  You&#8217;re highly unlikely to actually want to write automated tests for pure visualization anyway and the SRP is not something that you absolutely need to follow to the extreme in every single place.  For the View, this is really not a problem and very much acceptable.</p>
<p>The ViewModel however has 2 important responsibilities in this case, and i&#8217;d argue that these 2 things should not be done in the same place.  Making data available is done through data-binding.  To do this, you need a set of properties and you need to raise the necessary events.  In most cases, raising those events is very straightforward, but in more complex controls you might need a bit of additional logic to determine which event should be raised at what point.  The other important responsibility is the communication/interaction with the Model.  In most Silverlight applications, the Model will be a Service Layer.  To communicate with this Service Layer, you need Service Proxies.  That means that your ViewModel is essentially responsible for communicating with the Service Layer, dealing with business exceptions that might be thrown by some service calls, and dealing with technical exceptions that can occur simply because of network-related problems.  Group all of those together and i don&#8217;t think i&#8217;m going out on a limb here by saying that that is a lot of logic to put in <em>one</em> class, no?</p>
<p>(Sidenote: what i don&#8217;t really understand is that many people who vigorously advocate adherence to SRP and SoC in their domain and business code don&#8217;t seem to hold their UI code to the same standards. I do.)</p>
<p>At work, we do <em>a lot</em> of Silverlight development.  We typically have around 5 Silverlight projects in active development at the same time.  And it&#8217;s been that way for over a year now.  That equals a lot of Silverlight code that we&#8217;ve written and experience and knowledge that we&#8217;ve built up.  And we haven&#8217;t used MVVM for any of it.  All this time, we&#8217;ve been using the MVP pattern (Supervising Controller variant) with a slight twist.  That twist being a slimmed down version of a <a href="http://www.martinfowler.com/eaaDev/PresentationModel.html">Presentation Model</a>.  Our Presentation Model&#8217;s sole responsibility is to facilitate data-binding, and in some cases, a touch of validation is added as well.</p>
<p>If we go back to our previous example of the customer screen, the responsibilities and concerns would be divided like this in our MVP-PMlight approach:</p>
<p>View:</p>
<ul>
<li>visualization of the actual control (its own layout as well drawing other user controls that it is composed of)</li>
<li>outputting data in the correct user controls (for instance: various textboxes)</li>
<li>(simple validation) of modified/inputted data (for instance: no string values for numeric fields, etc&#8230;)</li>
</ul>
<p>Presenter:</p>
<ul>
<li>communication/interaction with the Model based on the contents of the Presentation Model</li>
</ul>
<p>Presentation Model: </p>
<ul>
<li>making data (from the Model) available so it can be displayed</li>
</ul>
<p>Which leads to classes which are more focused on their task instead of trying to focus on too many things at the same time.  In my opinion, this approach is much better/cleaner than MVVM.  Not only is there a noticeable benefit in code quality (classes are more focused), there is also increased potential to reuse our &#8216;light Presentation Models&#8217; in multiple controls.  Testability is increased over MVVM as well since it&#8217;s always easier to test classes which are focused versus testing classes which have too many responsibilities.  All in all, a couple of important benefits and we still haven&#8217;t thought of a real drawback compared to MVVM.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/SVfovLR-n5gKoQclmDtNo4BDoVI/0/da"><img src="http://feedads.g.doubleclick.net/~a/SVfovLR-n5gKoQclmDtNo4BDoVI/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/SVfovLR-n5gKoQclmDtNo4BDoVI/1/da"><img src="http://feedads.g.doubleclick.net/~a/SVfovLR-n5gKoQclmDtNo4BDoVI/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/davybrion?a=LNZqmGrxXYo:0zlEu1DvIQU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/davybrion?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/davybrion?a=LNZqmGrxXYo:0zlEu1DvIQU:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/davybrion?i=LNZqmGrxXYo:0zlEu1DvIQU:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/davybrion/~4/LNZqmGrxXYo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://davybrion.com/blog/2010/07/the-mvvm-pattern-is-highly-overrated/feed/</wfw:commentRss>
		<slash:comments>56</slash:comments>
		<feedburner:origLink>http://davybrion.com/blog/2010/07/the-mvvm-pattern-is-highly-overrated/</feedburner:origLink></item>
		<item>
		<title>Which Language Do You Code In?</title>
		<link>http://feedproxy.google.com/~r/davybrion/~3/IFCzHHrHsvg/</link>
		<comments>http://davybrion.com/blog/2010/07/which-language-do-you-code-in/#comments</comments>
		<pubDate>Sun, 18 Jul 2010 12:21:13 +0000</pubDate>
		<dc:creator>Davy Brion</dc:creator>
				<category><![CDATA[Code Quality]]></category>

		<guid isPermaLink="false">http://davybrion.com/blog/?p=2384</guid>
		<description><![CDATA[I got into an interesting discussion on twitter today on what language you use when coding. We weren&#8217;t talking about programming languages, but the actual real world language that is used for class names, method names, variable names, comments, etc&#8230; My take on the matter is to just always do it in English. And for [...]]]></description>
			<content:encoded><![CDATA[<p>I got into an interesting discussion on twitter today on what language you use when coding.  We weren&#8217;t talking about programming languages, but the actual real world language that is used for class names, method names, variable names, comments, etc&#8230;  My take on the matter is to just always do it in English.  And for the record, i&#8217;m a native Dutch speaker and i work in Belgium.  Our official languages are Dutch and French, not English.</p>
<p>A few years ago, i worked at a large financial institution in Belgium where we developed software for internal use in the main offices.  The UI was pretty much always done in Dutch, but most of the time we wrote all of our code in English.  There were a few projects where the developers had used Dutch in their code though.  At first, this wasn&#8217;t an issue and seemed to be more of a personal preference thing (though mixing within a project is just horrible).  After a while, the company got involved in the outsourcing game and suddenly, they were sending a lot of the projects that were in maintenance to a group of Indian developers.  It&#8217;s hard enough to get developers who use a different language and are part of a different culture on the same page when working on software, but it&#8217;s obviously even harder if the code they are supposed to read, maintain and extend is in a language <em>they don&#8217;t even know</em>.</p>
<p>At my current job, we also have a branch in Hungary.  We often mix teams so naturally, we all write our code in English.  We not only write our code in English, but we also use English as our language in any kind of documentation.  Now, we do have one customer who insists that the functional designs are all done in Dutch.  Maintaining 2 sets of documents is something that we won&#8217;t do, and since <a href="http://davybrion.com/blog/2008/11/genesis-bridging-the-gap-between-requirement-and-code/">our development process requires developers to link our code to our functional designs</a>, we&#8217;ll never be able to use our Hungarian developers on the projects that we do for this customer.  To me, that is a huge downside to having to write the documents in Dutch.  And it&#8217;s the exact same problem we&#8217;d have if we would write our code in Dutch.</p>
<p>Both those examples should tell you why i&#8217;m so much in favor of just writing code in English all the time.  Generally speaking, if you pick a non-English language to code in, you are limiting the pool of possible future developers to those developers who know the language you&#8217;ve chosen.  It&#8217;s that simple.  The more people who know the language, the bigger the pool of future developers.  And when it comes to languages that aren&#8217;t used by a lot of people&#8230; well, that&#8217;s a pretty big restriction on your future options.</p>
<p>Another downside to using non-English in your code, is that you&#8217;re effectively already mixing multiple languages in the code base.  Your programming language <em>already is in English</em>, and using non-English in your code leads to something that just sounds (or reads, i guess) wrong.  </p>
<p>The biggest problem that people bring up with always using English, is that you obviously need to translate business concepts.  Especially for people who are doing DDD and who want to leverage the Ubiquitous Language, this isn&#8217;t always an easy decision to make.  For one, your domain experts might not be willing to take on the translation burden.  If they are unwilling to do so, you can still use a translated version of the Ubiquitous Language but then the entire team (except for the domain experts) has to deal with that burden on a daily basis.</p>
<p>Now, i&#8217;m not sure if that&#8217;s really that big of a problem.  For starters, English terms are becoming more pervasive in &#8216;business language&#8217; every day.  I&#8217;m not saying that everyone is already using English for their business concepts/terms, but i would argue that it is increasing, that it&#8217;s only going to increase more and more and most importantly, that more and more business people don&#8217;t really have a problem with using English terms anymore.  </p>
<p>And lets not forget that the percentage of teams that is truly doing DDD and leveraging the Ubiquitous Language is probably still small.  After all, most true DDD experts will say that DDD is only a good idea for 10% of all projects <img src='http://davybrion.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> , so i can&#8217;t help but wonder how big of an issue the translation burden <em>really</em> is.</p>
<p>Thoughts?</p>

<p><a href="http://feedads.g.doubleclick.net/~a/nysBRgq1PrFtSxrjDtJCLfF0YPw/0/da"><img src="http://feedads.g.doubleclick.net/~a/nysBRgq1PrFtSxrjDtJCLfF0YPw/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/nysBRgq1PrFtSxrjDtJCLfF0YPw/1/da"><img src="http://feedads.g.doubleclick.net/~a/nysBRgq1PrFtSxrjDtJCLfF0YPw/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/davybrion?a=IFCzHHrHsvg:TG6gLnY9tFs:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/davybrion?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/davybrion?a=IFCzHHrHsvg:TG6gLnY9tFs:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/davybrion?i=IFCzHHrHsvg:TG6gLnY9tFs:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/davybrion/~4/IFCzHHrHsvg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://davybrion.com/blog/2010/07/which-language-do-you-code-in/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		<feedburner:origLink>http://davybrion.com/blog/2010/07/which-language-do-you-code-in/</feedburner:origLink></item>
		<item>
		<title>Using The Dynamic Keyword To Avoid Difficulties With Generics</title>
		<link>http://feedproxy.google.com/~r/davybrion/~3/543NsurfweA/</link>
		<comments>http://davybrion.com/blog/2010/07/using-the-dynamic-keyword-to-avoid-difficulties-with-generics/#comments</comments>
		<pubDate>Fri, 16 Jul 2010 14:15:41 +0000</pubDate>
		<dc:creator>Davy Brion</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Code Quality]]></category>

		<guid isPermaLink="false">http://davybrion.com/blog/2010/07/using-the-dynamic-keyword-to-avoid-difficulties-with-generics/</guid>
		<description><![CDATA[A coworker was working on some kind of base EntityBuilder class to use in his tests.&#160; One of the requirements of the EntityBuilder class was that it would need to automatically set the ID of an entity to a ‘real’ value (as in: not the default value of the type).&#160; The EntityBuilder would use some [...]]]></description>
			<content:encoded><![CDATA[<p>A coworker was working on some kind of base EntityBuilder class to use in his tests.&#160; One of the requirements of the EntityBuilder class was that it would need to automatically set the ID of an entity to a ‘real’ value (as in: not the default value of the type).&#160; The EntityBuilder would use some kind of IdGenerator based on the type of the ID of the entity.&#160;&#160; First of all, the example i’m gonna show is highly simplified and might not look like it makes much sense, but it’s only to illustrate some C# stuff with regards to generics and the dynamic keyword.&#160; So bear with me, and just focus on the language details <img src='http://davybrion.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Suppose you’ve got something like this:</p>
<div style="font-family: consolas; background: white; color: black; font-size: 10pt">
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: blue">abstract</span> <span style="color: blue">class</span> <span style="color: #00008b">Entity</span>&lt;<span style="color: #00008b">TId</span>&gt;</p>
<p style="margin: 0px">&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: blue">virtual</span> <span style="color: #00008b">TId</span> <span style="color: purple">Id</span> { <span style="color: #008b8b">get</span>; <span style="color: #008b8b">set</span>; }</p>
<p style="margin: 0px">&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: blue">interface</span> <span style="color: #00008b">IIdGenerator</span>&lt;<span style="color: #00008b">TId</span>&gt;</p>
<p style="margin: 0px">&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #00008b">TId</span> <span style="color: #008b8b">GenerateId</span>();</p>
<p style="margin: 0px">&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: blue">class</span> <span style="color: #00008b">IntIdGenerator</span> : <span style="color: #00008b">IIdGenerator</span>&lt;<span style="color: blue">int</span>&gt;</p>
<p style="margin: 0px">&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">private</span> <span style="color: blue">static</span> <span style="color: blue">int</span> <span style="color: purple">lastIssuedId</span>;</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: blue">int</span> <span style="color: #008b8b">GenerateId</span>()</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">return</span> ++<span style="color: purple">lastIssuedId</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: blue">class</span> <span style="color: #00008b">GuidIdGenerator</span> : <span style="color: #00008b">IIdGenerator</span>&lt;<span style="color: #00008b">Guid</span>&gt;</p>
<p style="margin: 0px">&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: #00008b">Guid</span> <span style="color: #008b8b">GenerateId</span>()</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">return</span> <span style="color: #00008b">Guid</span>.<span style="color: #008b8b">NewGuid</span>();</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;</p>
</p></div>
<p>The idea was to write the EntityBuilder somewhat along these lines:</p>
<div style="font-family: consolas; background: white; color: black; font-size: 10pt">
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: blue">abstract</span> <span style="color: blue">class</span> <span style="color: #00008b">TestEntityBuilder</span>&lt;<span style="color: #00008b">TEntity</span>, <span style="color: #00008b">TId</span>&gt; <span style="color: blue">where</span> <span style="color: #00008b">TEntity</span> : <span style="color: #00008b">Entity</span>&lt;<span style="color: #00008b">TId</span>&gt;</p>
<p style="margin: 0px">&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: #00008b">TEntity</span> <span style="color: #008b8b">Build</span>()</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">var</span> entity = <span style="color: #008b8b">CreateEntityWithDefaultProperties</span>();</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; entity.<span style="color: purple">Id</span> = <span style="color: #008b8b">GetIdGeneratorFor</span>(<span style="color: blue">typeof</span>(<span style="color: #00008b">TId</span>)).<span style="color: #008b8b">GenerateId</span>();</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">return</span> entity;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">protected</span> <span style="color: blue">abstract</span> <span style="color: #00008b">TEntity</span> <span style="color: #008b8b">CreateEntityWithDefaultProperties</span>();</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">private</span> <span style="color: #00008b">IIdGenerator</span>&lt;<span style="color: #00008b">TId</span>&gt; <span style="color: #008b8b">GetIdGeneratorFor</span>(<span style="color: #00008b">Type</span> type)</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">if</span> (type <span style="color: #008b8b">==</span> <span style="color: blue">typeof</span>(<span style="color: blue">int</span>))</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">return</span> <span style="color: blue">new</span> <span style="color: #00008b">IntIdGenerator</span>();</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">return</span> <span style="color: blue">new</span> <span style="color: #00008b">GuidIdGenerator</span>();</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;</p>
</p></div>
<p>Of course, that doesn’t even compile… you’ll get the following compiler errors:</p>
<p>error CS0266: Cannot implicitly convert type &#8216;MyProject.IntIdGenerator&#8217; to &#8216;MyProject.IIdGenerator&lt;TId&gt;&#8217;. An explicit conversion exists (are you missing a cast?)    <br />error CS0266: Cannot implicitly convert type &#8216;MyProject.GuidIdGenerator&#8217; to &#8216;MyProject.IIdGenerator&lt;TId&gt;&#8217;. An explicit conversion exists (are you missing a cast?)</p>
<p>So, how exactly do you get this working with generics? That’s when he asked for my help, and i didn’t know the answer either… i’ve struggled with this exact problem in a few previous situations and i never really got a clean solution either.&#160; But then i thought “wait, can’t we just avoid the problems with generics through the dynamic keyword?”</p>
<p>We changed the code to look like this:</p>
<div style="font-family: consolas; background: white; color: black; font-size: 10pt">
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: blue">abstract</span> <span style="color: blue">class</span> <span style="color: #00008b">TestEntityBuilder</span>&lt;<span style="color: #00008b">TEntity</span>, <span style="color: #00008b">TId</span>&gt; <span style="color: blue">where</span> <span style="color: #00008b">TEntity</span> : <span style="color: #00008b">Entity</span>&lt;<span style="color: #00008b">TId</span>&gt;</p>
<p style="margin: 0px">&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: #00008b">TEntity</span> <span style="color: #008b8b">Build</span>()</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">var</span> entity = <span style="color: #008b8b">CreateEntityWithDefaultProperties</span>();</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; entity.<span style="color: purple">Id</span> = <span style="color: #008b8b">GetIdGeneratorFor</span>(<span style="color: blue">typeof</span>(<span style="color: #00008b">TId</span>)).<span style="color: #00008b">GenerateId</span>();</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">return</span> entity;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">protected</span> <span style="color: blue">abstract</span> <span style="color: #00008b">TEntity</span> <span style="color: #008b8b">CreateEntityWithDefaultProperties</span>();</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">private</span> <span style="color: blue">dynamic</span> <span style="color: #008b8b">GetIdGeneratorFor</span>(<span style="color: #00008b">Type</span> type)</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">if</span> (type <span style="color: #008b8b">==</span> <span style="color: blue">typeof</span>(<span style="color: blue">int</span>))</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">return</span> <span style="color: blue">new</span> <span style="color: #00008b">IntIdGenerator</span>();</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">return</span> <span style="color: blue">new</span> <span style="color: #00008b">GuidIdGenerator</span>();</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;</p>
</p></div>
<p>We just changed the return type of the GetIdGeneratorFor method to ‘dynamic’, and the call to the GenerateId method is now a dynamic call instead of a normal method call.&#160; And it works.&#160; No messing around with generics voodoo, no (direct) usage of reflection either.&#160; Just clean code.</p>
<p>I’ll probably use this trick a lot more times in the future when i run into the limitations of generics <img src='http://davybrion.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<p><a href="http://feedads.g.doubleclick.net/~a/ZkSLI2KUn4HEqGwT4UFIQW1NI6Q/0/da"><img src="http://feedads.g.doubleclick.net/~a/ZkSLI2KUn4HEqGwT4UFIQW1NI6Q/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/ZkSLI2KUn4HEqGwT4UFIQW1NI6Q/1/da"><img src="http://feedads.g.doubleclick.net/~a/ZkSLI2KUn4HEqGwT4UFIQW1NI6Q/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/davybrion?a=543NsurfweA:GwdPjfI2zeQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/davybrion?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/davybrion?a=543NsurfweA:GwdPjfI2zeQ:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/davybrion?i=543NsurfweA:GwdPjfI2zeQ:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/davybrion/~4/543NsurfweA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://davybrion.com/blog/2010/07/using-the-dynamic-keyword-to-avoid-difficulties-with-generics/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		<feedburner:origLink>http://davybrion.com/blog/2010/07/using-the-dynamic-keyword-to-avoid-difficulties-with-generics/</feedburner:origLink></item>
		<item>
		<title>I Finally Caved: I’m On Twitter</title>
		<link>http://feedproxy.google.com/~r/davybrion/~3/B3nW2jWadYQ/</link>
		<comments>http://davybrion.com/blog/2010/07/i-finally-caved-im-on-twitter/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 21:14:52 +0000</pubDate>
		<dc:creator>Davy Brion</dc:creator>
				<category><![CDATA[About The Blog]]></category>

		<guid isPermaLink="false">http://davybrion.com/blog/?p=2378</guid>
		<description><![CDATA[Ok&#8230; i know what i said before. And i don&#8217;t know yet whether i was right or wrong. But it is starting to feel like i&#8217;m missing out on some good conversations due to not being on twitter so i figured &#8220;what the hell, i&#8217;m gonna give it a shot&#8221;. So i&#8217;ve created an account [...]]]></description>
			<content:encoded><![CDATA[<p>Ok&#8230; i know what i said <a href="http://davybrion.com/blog/2009/11/why-i-dont-use-twitter/">before</a>.  And i don&#8217;t know yet whether i was right or wrong.  But it is starting to feel like i&#8217;m missing out on some good conversations due to not being on twitter so i figured &#8220;what the hell, i&#8217;m gonna give it a shot&#8221;.  So i&#8217;ve created an account (@davybrion) and i&#8217;m just gonna see how it goes.  If i like it, i&#8217;ll keep using it and i&#8217;ll gladly state that i was wrong about the whole thing.  If i don&#8217;t like it, i&#8217;ll get rid of the account and i&#8217;ll let you know why <img src='http://davybrion.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .  But however it&#8217;s gonna turn out to be, at least this time it&#8217;ll be an <em>informed</em> decision.</p>
<p>So&#8230; any tips from you twitter addicts on how to keep the signal-to-noise ratio down and how to make the whole experience as valuable as possible?</p>

<p><a href="http://feedads.g.doubleclick.net/~a/WBUWo3trYhWNkCcfnu-h56L4eLI/0/da"><img src="http://feedads.g.doubleclick.net/~a/WBUWo3trYhWNkCcfnu-h56L4eLI/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/WBUWo3trYhWNkCcfnu-h56L4eLI/1/da"><img src="http://feedads.g.doubleclick.net/~a/WBUWo3trYhWNkCcfnu-h56L4eLI/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/davybrion?a=B3nW2jWadYQ:iIoEQj3E_5Y:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/davybrion?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/davybrion?a=B3nW2jWadYQ:iIoEQj3E_5Y:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/davybrion?i=B3nW2jWadYQ:iIoEQj3E_5Y:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/davybrion/~4/B3nW2jWadYQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://davybrion.com/blog/2010/07/i-finally-caved-im-on-twitter/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://davybrion.com/blog/2010/07/i-finally-caved-im-on-twitter/</feedburner:origLink></item>
		<item>
		<title>What’s Wrong With This Picture?</title>
		<link>http://feedproxy.google.com/~r/davybrion/~3/F6dg4h6TsUA/</link>
		<comments>http://davybrion.com/blog/2010/07/whats-wrong-with-this-picture-4/#comments</comments>
		<pubDate>Wed, 14 Jul 2010 14:53:01 +0000</pubDate>
		<dc:creator>Davy Brion</dc:creator>
				<category><![CDATA[What's Wrong With This Picture]]></category>

		<guid isPermaLink="false">http://davybrion.com/blog/2010/07/whats-wrong-with-this-picture-4/</guid>
		<description><![CDATA[Actually, this time it’s pictures instead of just one… 2 of my coworkers pointed me to a piece of code that they thought was pretty ugly.&#160; Much to my amusement, i spotted something that i think is worth a post]]></description>
			<content:encoded><![CDATA[<p>Actually, this time it’s picture<strong>s</strong> instead of just one… 2 of my coworkers pointed me to a piece of code that they thought was pretty ugly.&#160; Much to my amusement, i spotted something that i think is worth a post <img src='http://davybrion.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><a href="http://davybrion.com/pictures/WhatsWrongWithThisPicture_ED7C/wr1.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="wr1" border="0" alt="wr1" src="http://davybrion.com/pictures/WhatsWrongWithThisPicture_ED7C/wr1_thumb.png" width="282" height="79" /></a> </p>
<p><a href="http://davybrion.com/pictures/WhatsWrongWithThisPicture_ED7C/wr2.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="wr2" border="0" alt="wr2" src="http://davybrion.com/pictures/WhatsWrongWithThisPicture_ED7C/wr2_thumb.png" width="241" height="142" /></a></p>

<p><a href="http://feedads.g.doubleclick.net/~a/qAs_rwpxG7QxkR1emxwMRGSKAzw/0/da"><img src="http://feedads.g.doubleclick.net/~a/qAs_rwpxG7QxkR1emxwMRGSKAzw/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/qAs_rwpxG7QxkR1emxwMRGSKAzw/1/da"><img src="http://feedads.g.doubleclick.net/~a/qAs_rwpxG7QxkR1emxwMRGSKAzw/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/davybrion?a=F6dg4h6TsUA:0YdACBsAtts:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/davybrion?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/davybrion?a=F6dg4h6TsUA:0YdACBsAtts:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/davybrion?i=F6dg4h6TsUA:0YdACBsAtts:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/davybrion/~4/F6dg4h6TsUA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://davybrion.com/blog/2010/07/whats-wrong-with-this-picture-4/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://davybrion.com/blog/2010/07/whats-wrong-with-this-picture-4/</feedburner:origLink></item>
		<item>
		<title>500 Posts</title>
		<link>http://feedproxy.google.com/~r/davybrion/~3/kGcPZ5o8ouI/</link>
		<comments>http://davybrion.com/blog/2010/07/500-posts/#comments</comments>
		<pubDate>Tue, 13 Jul 2010 19:00:18 +0000</pubDate>
		<dc:creator>Davy Brion</dc:creator>
				<category><![CDATA[About The Blog]]></category>

		<guid isPermaLink="false">http://davybrion.com/blog/2010/07/500-posts/</guid>
		<description><![CDATA[So this is my 500th post on this blog.&#160; I know i said that i would end the tradition of posting the most popular recent (as in: within the last 100 posts) posts when i hit 400 but since 500 is such a nice number, i think it’s alright if i hit you guys with [...]]]></description>
			<content:encoded><![CDATA[<p>So this is my 500th post on this blog.&#160; I know i said that i would end the tradition of posting the most popular recent (as in: within the last 100 posts) posts when i hit <a href="http://davybrion.com/blog/2009/11/400-posts/" target="_blank">400</a> but since 500 is such a nice number, i think it’s alright if i hit you guys with another link bonanza.&#160; So i’m gonna post the links to the top 10 most popular posts of all time, as well as the top 10 most popular posts of the last 100.</p>
<p>Top 10 All Time:</p>
<ol>
<li><a href="http://davybrion.com/blog/2008/10/career-advice-for-young-developers/" target="_blank">Career Advice For Young Developers</a> </li>
<li><a href="http://davybrion.com/blog/2009/04/at-this-point-id-prefer-java-developers-over-net-developers/" target="_blank">At This Point, I’d Prefer Java Developers Over .NET Developers</a></li>
<li><a href="http://davybrion.com/blog/2007/07/nhibernate-mapping-examples/" target="_blank">NHibernate Mapping Examples</a> (pretty outdated by now though)</li>
<li><a href="http://davybrion.com/blog/2009/08/build-your-own-data-access-layer-series/" target="_blank">Build Your Own Data Access Layer Series</a></li>
<li><a href="http://davybrion.com/blog/2009/03/upgrading-to-nhibernate-21/" target="_blank">Upgrading To NHibernate 2.1</a> (this is what happens when people are too lazy to read exception messages)</li>
<li><a href="http://davybrion.com/blog/2009/11/a-reading-guide-to-becoming-a-better-developer/" target="_blank">A Reading Guide To Becoming A Better Developer</a></li>
<li><a href="http://davybrion.com/blog/2008/06/data-access-with-nhibernate/" target="_blank">Data Access Layer With NHibernate</a></li>
<li><a href="http://davybrion.com/blog/2008/06/managing-your-nhibernate-sessions/" target="_blank">Managing Your NHibernate Sessions</a></li>
<li><a href="http://davybrion.com/blog/2008/01/sending-nhibernate-entities-over-the-wcf-wire/" target="_blank">Sending NHibernate Entities Over The WCF Wire</a> (i wish i never wrote this)</li>
<li><a href="http://davybrion.com/blog/2009/11/requestresponse-service-layer-series/" target="_blank">Request Response Service Layer Series</a></li>
</ol>
<p>Top 10 Of The Last 100:</p>
<ol>
<li><a href="http://davybrion.com/blog/2010/05/why-you-shouldnt-expose-your-entities-through-your-services/" target="_blank">Why You Shouldn&#8217;t Expose Your Entities Through Your Services</a></li>
<li><a href="http://davybrion.com/blog/2009/12/using-nhibernate-in-your-service-layer/" target="_blank">Using NHibernate In Your Service Layer</a></li>
<li><a href="http://davybrion.com/blog/2010/01/hey-microsoft-our-databases-arent-services/" target="_blank">Hey Microsoft, Our Databases Aren&#8217;t Services!</a></li>
<li><a href="http://davybrion.com/blog/2009/12/unit-testing-an-nhibernate-application/" target="_blank">Unit Testing An NHibernate Application</a></li>
<li><a href="http://davybrion.com/blog/2010/05/avoiding-leaking-connections-with-nhibernate-and-transactionscope/" target="_blank">Avoiding Leaking Connections With NHibernate And TransactionScope</a></li>
<li><a href="http://davybrion.com/blog/2010/01/agatha-vs-nservicebus/" target="_blank">Agatha Vs NServiceBus</a></li>
<li><a href="http://davybrion.com/blog/2010/01/do-you-know-whats-really-going-on/" target="_blank">Do You Know What&#8217;s Really Going On?</a></li>
<li><a href="http://davybrion.com/blog/2010/01/dependency-injection-inversion-rejection/" target="_blank">Dependency Injection Inversion Rejection</a></li>
<li><a href="http://davybrion.com/blog/2009/12/real-world-benefits-from-loose-coupling-inversion-of-control-and-dependency-injection/" target="_blank">Real World Benefits From Loose Coupling, Inversion Of Control And Dependency Injection</a></li>
<li>&#160;<a href="http://davybrion.com/blog/2010/01/virtual-method-performance-penalty/" target="_blank">Virtual Method Performance Penalty</a></li>
</ol>
<p>So… on to the next 100 i guess <img src='http://davybrion.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<p><a href="http://feedads.g.doubleclick.net/~a/DX0ano3OgZS--HPBwv0Eb6_s4sc/0/da"><img src="http://feedads.g.doubleclick.net/~a/DX0ano3OgZS--HPBwv0Eb6_s4sc/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/DX0ano3OgZS--HPBwv0Eb6_s4sc/1/da"><img src="http://feedads.g.doubleclick.net/~a/DX0ano3OgZS--HPBwv0Eb6_s4sc/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/davybrion?a=kGcPZ5o8ouI:zT8KjGfYWrw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/davybrion?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/davybrion?a=kGcPZ5o8ouI:zT8KjGfYWrw:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/davybrion?i=kGcPZ5o8ouI:zT8KjGfYWrw:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/davybrion/~4/kGcPZ5o8ouI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://davybrion.com/blog/2010/07/500-posts/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://davybrion.com/blog/2010/07/500-posts/</feedburner:origLink></item>
		<item>
		<title>Resharper 5.1’s Test Runner Is Broken</title>
		<link>http://feedproxy.google.com/~r/davybrion/~3/HY9gxNXEDEk/</link>
		<comments>http://davybrion.com/blog/2010/07/resharper-5-1s-test-runner-is-broken/#comments</comments>
		<pubDate>Tue, 13 Jul 2010 07:59:43 +0000</pubDate>
		<dc:creator>Davy Brion</dc:creator>
				<category><![CDATA[resharper]]></category>

		<guid isPermaLink="false">http://davybrion.com/blog/2010/07/resharper-5-1s-test-runner-is-broken/</guid>
		<description><![CDATA[I used to be very happy with pretty much everything JetBrains released, but lately they seem to be having some serious quality issues with their Resharper product.&#160; The 5.0 release was pretty much unusable for us due to a stupid bug in their Silverlight support.&#160; It was fixed in the 5.1 EAP builds, but the [...]]]></description>
			<content:encoded><![CDATA[<p>I used to be very happy with pretty much everything JetBrains released, but lately they seem to be having some serious quality issues with their Resharper product.&#160; The 5.0 release was pretty much unusable for us due to <a href="http://davybrion.com/blog/2010/05/silverlight-4-and-resharper-5-pain/" target="_blank">a stupid bug</a> in their Silverlight support.&#160; It was fixed in the 5.1 EAP builds, but the newly released 5.1 version has another major (IMO) problem when it comes to running tests:</p>
<p><a href="http://davybrion.com/pictures/Resharper5.1sTestRunnerIsBroken_8C9D/resharper_fail.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="resharper_fail" border="0" alt="resharper_fail" src="http://davybrion.com/pictures/Resharper5.1sTestRunnerIsBroken_8C9D/resharper_fail_thumb.png" width="835" height="123" /></a> </p>
<p>It no longer runs inherited tests.&#160; Which is especially annoying to us because we use inherited tests to make sure that our <a href="http://davybrion.com/blog/2009/12/testing-crud-operations-with-nhibernate/" target="_blank">NHibernate CRUD operations work</a>.&#160; We also use the inherited tests pattern for some other things, but that means we’re pretty much screwed now.</p>
<p>The bug has already been <a href="http://youtrack.jetbrains.net/issue/RSRP-186146" target="_blank">reported</a> but since they closed the Early Access Program due to the release of 5.1, i guess we’re gonna have to wait quite a while before we can get our hands on a version that has a usable test runner.</p>
<p>If anyone from the Resharper team reads this: please tell me how on earth something like this could break in a <em>bugfix</em> release?&#160; You <em>sell </em>software for continuous integration, for code coverage, for running tests.&#160; If you’d actually use these things and wrote <em>correct</em> tests then this wouldn’t have happened… </p>

<p><a href="http://feedads.g.doubleclick.net/~a/cQJMtT2cCppyvhpWj86Bi7Ahf68/0/da"><img src="http://feedads.g.doubleclick.net/~a/cQJMtT2cCppyvhpWj86Bi7Ahf68/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/cQJMtT2cCppyvhpWj86Bi7Ahf68/1/da"><img src="http://feedads.g.doubleclick.net/~a/cQJMtT2cCppyvhpWj86Bi7Ahf68/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/davybrion?a=HY9gxNXEDEk:B80MBSWazsY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/davybrion?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/davybrion?a=HY9gxNXEDEk:B80MBSWazsY:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/davybrion?i=HY9gxNXEDEk:B80MBSWazsY:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/davybrion/~4/HY9gxNXEDEk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://davybrion.com/blog/2010/07/resharper-5-1s-test-runner-is-broken/feed/</wfw:commentRss>
		<slash:comments>43</slash:comments>
		<feedburner:origLink>http://davybrion.com/blog/2010/07/resharper-5-1s-test-runner-is-broken/</feedburner:origLink></item>
		<item>
		<title>Off For A Week</title>
		<link>http://feedproxy.google.com/~r/davybrion/~3/mk0xac01Rak/</link>
		<comments>http://davybrion.com/blog/2010/07/off-for-a-week/#comments</comments>
		<pubDate>Sat, 03 Jul 2010 17:01:41 +0000</pubDate>
		<dc:creator>Davy Brion</dc:creator>
				<category><![CDATA[About The Blog]]></category>

		<guid isPermaLink="false">http://davybrion.com/blog/?p=2365</guid>
		<description><![CDATA[Well, time for another short vacation. I&#8217;ll be chilling and hanging out at the Côte d&#8217;Azur next week. I will have internet access but i&#8217;ll probably make very little use of it. So, emails probably won&#8217;t be replied to until July 13th and obviously, there won&#8217;t be any posts either See you in a week!]]></description>
			<content:encoded><![CDATA[<p><a href="http://davybrion.com/blog/wp-content/uploads/2010/07/golf_juan.jpg"><img src="http://davybrion.com/blog/wp-content/uploads/2010/07/435466_1255382111509.jpg" alt="" title="Golf Juan" width="400" height="300" class="aligncenter size-full wp-image-2366" /></a></p>
<p>Well, time for another short vacation.  I&#8217;ll be chilling and hanging out at the Côte d&#8217;Azur next week.  I will have internet access but i&#8217;ll probably make very little use of it.  So, emails probably won&#8217;t be replied to until July 13th and obviously, there won&#8217;t be any posts either <img src='http://davybrion.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>See you in a week!</p>

<p><a href="http://feedads.g.doubleclick.net/~a/zEig85PdKTPatonU1tS9saaVv2Q/0/da"><img src="http://feedads.g.doubleclick.net/~a/zEig85PdKTPatonU1tS9saaVv2Q/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/zEig85PdKTPatonU1tS9saaVv2Q/1/da"><img src="http://feedads.g.doubleclick.net/~a/zEig85PdKTPatonU1tS9saaVv2Q/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/davybrion?a=mk0xac01Rak:nUZ8X4hqTSM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/davybrion?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/davybrion?a=mk0xac01Rak:nUZ8X4hqTSM:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/davybrion?i=mk0xac01Rak:nUZ8X4hqTSM:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/davybrion/~4/mk0xac01Rak" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://davybrion.com/blog/2010/07/off-for-a-week/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://davybrion.com/blog/2010/07/off-for-a-week/</feedburner:origLink></item>
		<item>
		<title>Check Out QuickGenerate</title>
		<link>http://feedproxy.google.com/~r/davybrion/~3/sY0H0W53oVY/</link>
		<comments>http://davybrion.com/blog/2010/06/check-out-quickgenerate/#comments</comments>
		<pubDate>Wed, 30 Jun 2010 07:05:38 +0000</pubDate>
		<dc:creator>Davy Brion</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Code Quality]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Test Driven Development]]></category>

		<guid isPermaLink="false">http://davybrion.com/blog/2010/06/check-out-quickgenerate/</guid>
		<description><![CDATA[One of several interesting things in Mark Meyers’ QuickNet project is the whole input generation thing that you need for property-based testing.&#160; It turns out that those input generators are very usable for far more purposes than just property-based testing, so it’s evolved into its own library.&#160; It can generate object instances of almost any [...]]]></description>
			<content:encoded><![CDATA[<p>One of several interesting things in Mark Meyers’ <a href="http://code.google.com/p/quicknet/" target="_blank">QuickNet</a> project is the whole input generation thing that you need for property-based testing.&#160; It turns out that those input generators are very usable for far more purposes than just property-based testing, so it’s evolved into its own library.&#160; It can generate object instances of almost any kind, while you can still have fine-grained control over the generation if you want to.&#160; You can use it for simple types, complex objects or even entire object graphs. I wish i had time to write a more in-depth post about this, but for now i’m just gonna point you guys in the right direction, and i hope that you’ll see the value in this <img src='http://davybrion.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The announcement of the first release can be found <a href="http://kilfour.wordpress.com/2010/06/29/quickgenerate-0-1-released/" target="_blank">here</a>, and an example can be found <a href="http://kilfour.wordpress.com/2010/06/29/quickgenerate-example/" target="_blank">here</a>.&#160; Here’s a little glimpse at the code of one the examples:</p>
<p><a href="http://davybrion.com/pictures/CheckOutQuickGenerate_7FE6/quickgenerate.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="quickgenerate" border="0" alt="quickgenerate" src="http://davybrion.com/pictures/CheckOutQuickGenerate_7FE6/quickgenerate_thumb.png" width="653" height="500" /></a> </p>
<p>I think that piece of code is a nice illustration of how powerful and flexible this is <img src='http://davybrion.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<p><a href="http://feedads.g.doubleclick.net/~a/rldoI_ESBKOb7XLaEYmnhxdWAuk/0/da"><img src="http://feedads.g.doubleclick.net/~a/rldoI_ESBKOb7XLaEYmnhxdWAuk/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/rldoI_ESBKOb7XLaEYmnhxdWAuk/1/da"><img src="http://feedads.g.doubleclick.net/~a/rldoI_ESBKOb7XLaEYmnhxdWAuk/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/davybrion?a=sY0H0W53oVY:Zb7YufjQdMg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/davybrion?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/davybrion?a=sY0H0W53oVY:Zb7YufjQdMg:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/davybrion?i=sY0H0W53oVY:Zb7YufjQdMg:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/davybrion/~4/sY0H0W53oVY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://davybrion.com/blog/2010/06/check-out-quickgenerate/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://davybrion.com/blog/2010/06/check-out-quickgenerate/</feedburner:origLink></item>
		<item>
		<title>Working Overtime: What It Really Means</title>
		<link>http://feedproxy.google.com/~r/davybrion/~3/tpUo4MyeAsw/</link>
		<comments>http://davybrion.com/blog/2010/06/working-overtime-what-it-really-means/#comments</comments>
		<pubDate>Thu, 24 Jun 2010 20:42:28 +0000</pubDate>
		<dc:creator>Davy Brion</dc:creator>
				<category><![CDATA[Opinions]]></category>

		<guid isPermaLink="false">http://davybrion.com/blog/?p=2357</guid>
		<description><![CDATA[One of the things that pretty much every developer has had to face at least once in his career is the issue of working overtime (typically, to meet a deadline). If you&#8217;re lucky (or smart), this is a rare occasion. For some however, this is either a habit, or happens frequently. There are actually quite [...]]]></description>
			<content:encoded><![CDATA[<p>One of the things that pretty much every developer has had to face at least once in his career is the issue of working overtime (typically, to meet a deadline).  If you&#8217;re lucky (or smart), this is a rare occasion.  For some however, this is either a habit, or happens frequently.  There are actually quite a few developers who are proud of being able to do 60-80 hours a week.  And they could not be more wrong.</p>
<p>There&#8217;s nothing wrong with putting in a few extra hours occasionally.  Sometimes, it just needs to be done.  But, as soon as it is required more than occasionally (and with occasionally, i mean every couple of months), something is wrong.  First of all, you&#8217;re not gonna produce anything good if you&#8217;re doing a lot of overtime.  At first, it starts with a couple of late nights.  The first couple of nights, the work you do is still &#8216;good enough&#8217;.  It&#8217;s not gonna be great, but hey, it&#8217;ll do.  After a couple of nights though, if you&#8217;re still doing a lot of extra hours, there&#8217;s gonna be a noticeable negative effect on the work you&#8217;re doing.  And you know what the worst part is?  You, of all people, won&#8217;t notice it.  You&#8217;re working hard, you&#8217;re trying to catch up with the schedule, and you&#8217;re doing the best you can.  Or at least, you think you are.</p>
<p>In reality, you are hurting yourself, the project and your teammates more than you could imagine at that time.  Here&#8217;s the deal: there&#8217;s a reason why most people are working 8 hours a day on average.  If you routinely work more than 8 hours a day, your work is going to suffer from it (it depends on the job obviously, but for software developers, i&#8217;d argue that this is definitely the case).  If you do a bit of overtime occasionally, then you, nor the project will suffer from it.  It&#8217;ll just take a little bit more out of you than what you&#8217;re used to.  But once it becomes a routine, you, as a human being, will start performing worse and worse as time goes on.  Inevitably, that deterioration will become very noticeable in your work.  And here&#8217;s the sad thing: you&#8217;re putting in the extra effort to catch up with the schedule.  But by doing so, you&#8217;re actually performing worse and you&#8217;re hurting the schedule.  Here&#8217;s what happens: you spend a few late nights at the office.  At first, things go ok.  You&#8217;re getting things done and it appears to be working.  You keep spending late nights at the office.  After a few days (really, it happens that fast), the quality of your work starts deteriorating.  And you won&#8217;t notice it until you get back <em>the next day</em>.  So then what happens?  You start cleaning up the mess you made the night before.  Which only means you&#8217;re getting even more behind schedule.  So then you&#8217;ll need even more time to catch up with the schedule.  But you&#8217;re already spending this much extra time at work, and the problem only seems to get worse!  Well, yeah&#8230; that&#8217;s the whole point that i&#8217;m trying to make here.  You know what&#8217;s the best thing you could possibly do in those situations?  Go home at 3 or 4 in the afternoon, go have some fun, relax, and get a good night&#8217;s sleep.  You won&#8217;t believe how much more productive you&#8217;ll be the next day. </p>
<p>But where is this need to do overtime coming from?  I&#8217;d argue that, in the large majority of cases, this is due to management mistakes.  Either the wrong things were promised to the customer, or your management doesn&#8217;t have a clue of what is really going on.  So, if you find yourself in a position where you routinely need to do overtime, you really need to start asking yourself whether or not you&#8217;re working for the right company.  If you routinely need to do overtime to reach a deadline, that tells you that the project management (and highly likely, every kind of management beyond that) is pretty messed up.  I don&#8217;t know about you, but i really don&#8217;t want to work for people who don&#8217;t know what they&#8217;re doing.  If you&#8217;re doing a lot of overtime, your management is either clueless or stupid.  Probably a combination of both. </p>
<p>As for the developers who are proud of their 60-80 hour work weeks&#8230; what does that tell you about them?  There truly are very few people who can keep on producing great results beyond the regular 40 hours a week.  Something tells me that very few of those developers who brag about their extra hours really fit into that category.  If they really did fit into that category, they&#8217;d let their results speak for themselves instead of needing to brag about the amount of effort they&#8217;re putting in.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/z8MoDRvXQAOPlTdmeHJjAe6oCJ0/0/da"><img src="http://feedads.g.doubleclick.net/~a/z8MoDRvXQAOPlTdmeHJjAe6oCJ0/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/z8MoDRvXQAOPlTdmeHJjAe6oCJ0/1/da"><img src="http://feedads.g.doubleclick.net/~a/z8MoDRvXQAOPlTdmeHJjAe6oCJ0/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/davybrion?a=tpUo4MyeAsw:fRCoRHeqxa8:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/davybrion?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/davybrion?a=tpUo4MyeAsw:fRCoRHeqxa8:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/davybrion?i=tpUo4MyeAsw:fRCoRHeqxa8:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/davybrion/~4/tpUo4MyeAsw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://davybrion.com/blog/2010/06/working-overtime-what-it-really-means/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		<feedburner:origLink>http://davybrion.com/blog/2010/06/working-overtime-what-it-really-means/</feedburner:origLink></item>
		<item>
		<title>More On System.Tuple And Serialization/Deserialization</title>
		<link>http://feedproxy.google.com/~r/davybrion/~3/0qoDidjwqKI/</link>
		<comments>http://davybrion.com/blog/2010/06/more-on-system-tuple-and-serializationdeserialization/#comments</comments>
		<pubDate>Wed, 23 Jun 2010 19:19:07 +0000</pubDate>
		<dc:creator>Davy Brion</dc:creator>
				<category><![CDATA[.NET bugs]]></category>

		<guid isPermaLink="false">http://davybrion.com/blog/2010/06/more-on-system-tuple-and-serializationdeserialization/</guid>
		<description><![CDATA[As i mentioned in my last post, i ran into a serialization problem with a Tuple reference when returning it from a WCF call.&#160; It failed with the typical exception you get when a type can not be deserialized. Unfortunately, the message of the exception that i got is the same as it is when [...]]]></description>
			<content:encoded><![CDATA[<p>As i mentioned in my <a href="http://davybrion.com/blog/2010/06/my-first-request-for-the-next-net-version/" target="_blank">last post</a>, i ran into a serialization problem with a Tuple reference when returning it from a WCF call.&#160; It failed with the typical exception you get when a type can not be deserialized. Unfortunately, the message of the exception that i got is the same as it is when a type can not be serialized, though both situations are actually quite different.&#160; One of my readers left a comment saying that he didn’t have problems serializing/deserializing a Tuple (by the way: am i the only one who has major problems with typing the word ‘tuple’? whenever i wanna use it, i always end up with ‘type’ before i realize my mistake) through WCF.&#160; </p>
<p>So why did it work for him, yet failed in my situation? The answer turns out to be quite simple.&#160; If you look at the Tuple type of .NET 4 in Reflector, you’ll see this:</p>
<p><a href="http://davybrion.com/pictures/Mor.TupleAndSerializationDeserialization_124CB/tuple_dotnet.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="tuple_dotnet" border="0" alt="tuple_dotnet" src="http://davybrion.com/pictures/Mor.TupleAndSerializationDeserialization_124CB/tuple_dotnet_thumb.png" width="493" height="40" /></a> </p>
<p>So it actually is serializable.&#160; The thing is, my client is not a .NET project, it’s Silverlight.&#160; And the Tuple type in Silverlight looks like this:</p>
<p><a href="http://davybrion.com/pictures/Mor.TupleAndSerializationDeserialization_124CB/tuple_silverlight.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="tuple_silverlight" border="0" alt="tuple_silverlight" src="http://davybrion.com/pictures/Mor.TupleAndSerializationDeserialization_124CB/tuple_silverlight_thumb.png" width="497" height="33" /></a> </p>
</p>
<p>Silverlight still doesn’t support the Serializable attribute and the Tuple types don’t have a parameterless constructor, so that’s why it can’t deserialize a Tuple instance when it’s returned from a WCF call.&#160; I can’t believe i didn’t think of this earlier since i’ve been bitten by this problem a few more times (not with the Tuple type, but with other Serializable classes) in the past, but then again, i can’t believe something like this still doesn’t work when using .NET <strong>4</strong>, Silverlight <strong>4</strong> and WCF<strong> 4 </strong>together. </p>

<p><a href="http://feedads.g.doubleclick.net/~a/oSGbbe53kv9q5ZRx4qYjshMoD2c/0/da"><img src="http://feedads.g.doubleclick.net/~a/oSGbbe53kv9q5ZRx4qYjshMoD2c/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/oSGbbe53kv9q5ZRx4qYjshMoD2c/1/da"><img src="http://feedads.g.doubleclick.net/~a/oSGbbe53kv9q5ZRx4qYjshMoD2c/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/davybrion?a=0qoDidjwqKI:6qc81CRjVZg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/davybrion?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/davybrion?a=0qoDidjwqKI:6qc81CRjVZg:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/davybrion?i=0qoDidjwqKI:6qc81CRjVZg:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/davybrion/~4/0qoDidjwqKI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://davybrion.com/blog/2010/06/more-on-system-tuple-and-serializationdeserialization/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://davybrion.com/blog/2010/06/more-on-system-tuple-and-serializationdeserialization/</feedburner:origLink></item>
		<item>
		<title>My First Request For The Next .NET Version</title>
		<link>http://feedproxy.google.com/~r/davybrion/~3/OgCYkta_7-s/</link>
		<comments>http://davybrion.com/blog/2010/06/my-first-request-for-the-next-net-version/#comments</comments>
		<pubDate>Wed, 23 Jun 2010 11:38:37 +0000</pubDate>
		<dc:creator>Davy Brion</dc:creator>
				<category><![CDATA[.NET bugs]]></category>

		<guid isPermaLink="false">http://davybrion.com/blog/2010/06/my-first-request-for-the-next-net-version/</guid>
		<description><![CDATA[Please, pretty please, make the Tuple class serializable… i just got this exception: Type &#8216;System.Tuple`2[System.Guid,System.Nullable`1[System.Guid]]&#8217; cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute. Alternatively, you can ensure that the type is public and has a parameterless constructor &#8211; all public [...]]]></description>
			<content:encoded><![CDATA[<p>Please, pretty please, make the Tuple class serializable… i just got this exception:</p>
<p>Type &#8216;System.Tuple`2[System.Guid,System.Nullable`1[System.Guid]]&#8217; cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute. Alternatively, you can ensure that the type is public <strong>and has a parameterless constructor</strong> &#8211; all public members of the type will then be serialized, and no attributes will be required.</p>
<p>That’s all… now if you’ll excuse me, i gotta go include a useless DTO in my project.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/JjR2WgZLJXtPJdmv2NhSRkYX01E/0/da"><img src="http://feedads.g.doubleclick.net/~a/JjR2WgZLJXtPJdmv2NhSRkYX01E/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/JjR2WgZLJXtPJdmv2NhSRkYX01E/1/da"><img src="http://feedads.g.doubleclick.net/~a/JjR2WgZLJXtPJdmv2NhSRkYX01E/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/davybrion?a=OgCYkta_7-s:iLceMkvvO_4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/davybrion?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/davybrion?a=OgCYkta_7-s:iLceMkvvO_4:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/davybrion?i=OgCYkta_7-s:iLceMkvvO_4:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/davybrion/~4/OgCYkta_7-s" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://davybrion.com/blog/2010/06/my-first-request-for-the-next-net-version/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://davybrion.com/blog/2010/06/my-first-request-for-the-next-net-version/</feedburner:origLink></item>
		<item>
		<title>MSDTC And Microsoft Security Essentials: A Killer Combo!</title>
		<link>http://feedproxy.google.com/~r/davybrion/~3/B9JSviZDTk0/</link>
		<comments>http://davybrion.com/blog/2010/06/msdtc-and-microsoft-security-essentials-a-killer-combo/#comments</comments>
		<pubDate>Mon, 21 Jun 2010 12:19:36 +0000</pubDate>
		<dc:creator>Davy Brion</dc:creator>
				<category><![CDATA[MSDTC]]></category>

		<guid isPermaLink="false">http://davybrion.com/blog/?p=2348</guid>
		<description><![CDATA[Just when i thought i had experienced more than a lifetime&#8217;s worth of MSDTC issues, i ran into another one. All of a sudden, my MSDTC transactions started causing problems on my system again. Now, this happens occasionaly for reasons that i&#8217;ve been unable to figure out. I&#8217;ve learned to just accept it, reboot my [...]]]></description>
			<content:encoded><![CDATA[<p>Just when i thought i had experienced more than a lifetime&#8217;s worth of MSDTC issues, i ran into another one. All of a sudden, my MSDTC transactions started causing problems on my system again. Now, this happens occasionaly for reasons that i&#8217;ve been unable to figure out. I&#8217;ve learned to just accept it, reboot my system when it happens, and once it&#8217;s back up it all just works again. So this time, i rebooted my system, waited for it come back up, tried running the same code that failed before and much to my surprise i got the same exception as i had gotten before:</p>
<p>System.Transactions.TransactionManagerCommunicationException: Communication with the underlying transaction manager has failed. &#8212;&gt; System.Runtime.InteropServices.COMException: The MSDTC transaction manager was unable to push the transaction to the destination transaction manager due to communication problems. Possible causes are: a firewall is present and it doesn&#8217;t have an exception for the MSDTC process, the two machines cannot find each other by their NetBIOS names, or the support for network transactions is not enabled for one of the two transaction managers.</p>
<p>I checked my MSDTC security settings to make sure that everything was still configured correctly, and it was. I then checked to see if Windows Firewall is still disabled, and it was. Then i remembered that i&#8217;ve had problems with MSDTC transactions failing after Microsoft Security Essentials (MSE) had installed updates. Again, when that happens i typically just reboot and everything works again.  Just for the hell of it, i turned off MSE&#8217;s real-time protection and tried again.  And it worked without problems. I turned the real-time protection back on to see if it would fail again but it kept working. I have no idea what the problem is, but at least i&#8217;m now armed with yet another thing to try when MSDTC stops working on my machine.  Gotta love options!</p>
<p>Seriously though, with all the problems i (and others) have run into with using MSDTC, i&#8217;m starting to wonder if Microsoft has some kind of covert Make-MSDTC-Usage-As-Painful-As-Possible mission going on somewhere&#8230;  Then again, maybe their QA is just getting even worse than it already was.  Oh well&#8230;</p>

<p><a href="http://feedads.g.doubleclick.net/~a/SAv5y8FtsN3ltqKMJhnDW6KH7P0/0/da"><img src="http://feedads.g.doubleclick.net/~a/SAv5y8FtsN3ltqKMJhnDW6KH7P0/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/SAv5y8FtsN3ltqKMJhnDW6KH7P0/1/da"><img src="http://feedads.g.doubleclick.net/~a/SAv5y8FtsN3ltqKMJhnDW6KH7P0/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/davybrion?a=B9JSviZDTk0:OfuNSuvTseY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/davybrion?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/davybrion?a=B9JSviZDTk0:OfuNSuvTseY:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/davybrion?i=B9JSviZDTk0:OfuNSuvTseY:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/davybrion/~4/B9JSviZDTk0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://davybrion.com/blog/2010/06/msdtc-and-microsoft-security-essentials-a-killer-combo/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://davybrion.com/blog/2010/06/msdtc-and-microsoft-security-essentials-a-killer-combo/</feedburner:origLink></item>
		<item>
		<title>Using Agatha’s Server-Side Caching</title>
		<link>http://feedproxy.google.com/~r/davybrion/~3/ZCQspPt5LDA/</link>
		<comments>http://davybrion.com/blog/2010/06/using-agathas-server-side-caching/#comments</comments>
		<pubDate>Sun, 20 Jun 2010 16:00:46 +0000</pubDate>
		<dc:creator>Davy Brion</dc:creator>
				<category><![CDATA[agatha]]></category>

		<guid isPermaLink="false">http://davybrion.com/blog/2010/06/using-agathas-server-side-caching/</guid>
		<description><![CDATA[One of the most important new additions in the Agatha 1.1 release is the ability to have the service layer cache responses for requests that are eligible for caching.&#160; Obviously, this doesn’t happen automatically and you need to configure this yourself.&#160; Unfortunately, i’ve never really written a post to describe how to do this and [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most important new additions in the <a href="http://code.google.com/p/agatha-rrsl/" target="_blank">Agatha</a> 1.1 release is the ability to have the service layer cache responses for requests that are eligible for caching.&#160; Obviously, this doesn’t happen automatically and you need to configure this yourself.&#160; Unfortunately, i’ve never really written a post to describe how to do this and what you need to keep in mind.&#160; Hopefully, all of this will be clear after this post.</p>
<p>There are only two things you need to do to use Agatha’s server-side caching feature:</p>
<p><strong>1. Use the EnableResponseCaching attribute</strong></p>
<p>If you want certain Request-derived types to be eligible for caching, you need to put the EnableResponseCaching attribute on top of them.&#160; This attribute enables you to set the logical region (more on that later) where the Response for this Request needs to stored in the cache, and it requires you to set an expiration.&#160; Here’s a simple example:</p>
<div style="font-family: consolas; background: white; color: black; font-size: 10pt">
<p style="margin: 0px">&#160;&#160;&#160; [<span style="color: #00008b">EnableResponseCaching</span>(<span style="color: purple">Minutes</span> = 10, <span style="color: purple">Region</span> = <span style="color: #a31515">&quot;Issues&quot;</span>)]</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: blue">class</span> <span style="color: #00008b">GetUnassignedIssuesForProjectRequest</span> : <span style="color: #00008b">Request</span></p>
<p style="margin: 0px">&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: #00008b">Guid</span> <span style="color: purple">ProjectId</span> { <span style="color: #008b8b">get</span>; <span style="color: #008b8b">set</span>; }</p>
<p style="margin: 0px">&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;</p>
</p></div>
<p>For this particular request type, responses should be cached for a maximum duration of 10 minutes, and the cached responses will be stored in the Issues region.&#160; A region is pretty much just a section within the cache.&#160; If you don’t specify a region, each response will be placed in the default region.&#160; If you do specify one, each cached response for that region is placed within that section.&#160; This gives you the ability to clear an entire region (and thus, all the cached responses that are stored in that region) without impacting any of the other regions (including the default one).</p>
<p>The expiration can be configured by providing a number of hours, minutes or seconds (or a combination of those three) to the attribute.</p>
<p>Now obviously, Agatha needs a way to differentiate between multiple instances of the GetUnassignedIssuesForProjectRequest class.&#160; More specifically, Agatha needs to know when a request can be considered equal to a previous request for which a response has already been cached.&#160; So that brings us to the next thing you need to do:</p>
<p><strong>2. Override the Equals and GetHashCode methods</strong></p>
<p>The response for a GetUnassignedIssuesForProjectRequest instance with ProjectId set to e35c60f7-c35e-43db-9988-0dab3f39c61b will obviously contain a different set of unassigned issues than one for a GetUnassignedIssuesForProjectRequest with ProjectId set to 5d47161a-f334-4cce-9cc4-9606a9d294a6.&#160; To make sure that Agatha knows which response can be returned for a given request, your request needs to override the Equals and GetHashCode methods so you can tell Agatha when an instance of a certain request can be considered equal to one for which a cached response already exists.&#160; In the case of our example, requests of type GetUnassignedIssuesForProjectRequest can be considered equal if they both return the same value through their ProjectId property.&#160; So in this case, our request class needs to look like this:</p>
<div style="font-family: consolas; background: white; color: black; font-size: 10pt">
<p style="margin: 0px">&#160;&#160;&#160; [<span style="color: #00008b">EnableResponseCaching</span>(<span style="color: purple">Minutes</span> = 10, <span style="color: purple">Region</span> = <span style="color: #a31515">&quot;Issues&quot;</span>)]</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: blue">class</span> <span style="color: #00008b">GetUnassignedIssuesForProjectRequest</span> : <span style="color: #00008b">Request</span></p>
<p style="margin: 0px">&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: #00008b">Guid</span> <span style="color: purple">ProjectId</span> { <span style="color: #008b8b">get</span>; <span style="color: #008b8b">set</span>; }</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: blue">bool</span> <span style="color: #008b8b">Equals</span>(<span style="color: #00008b">GetUnassignedIssuesForProjectRequest</span> other)</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">if</span> (<span style="color: #008b8b">ReferenceEquals</span>(<span style="color: blue">null</span>, other)) <span style="color: blue">return</span> <span style="color: blue">false</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">if</span> (<span style="color: #008b8b">ReferenceEquals</span>(<span style="color: blue">this</span>, other)) <span style="color: blue">return</span> <span style="color: blue">true</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">return</span> other.<span style="color: purple">ProjectId</span>.<span style="color: #008b8b">Equals</span>(<span style="color: purple">ProjectId</span>);</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: blue">override</span> <span style="color: blue">bool</span> <span style="color: #008b8b">Equals</span>(<span style="color: blue">object</span> obj)</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">if</span> (<span style="color: #008b8b">ReferenceEquals</span>(<span style="color: blue">null</span>, obj)) <span style="color: blue">return</span> <span style="color: blue">false</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">if</span> (<span style="color: #008b8b">ReferenceEquals</span>(<span style="color: blue">this</span>, obj)) <span style="color: blue">return</span> <span style="color: blue">true</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">if</span> (obj.<span style="color: #008b8b">GetType</span>() <span style="color: #008b8b">!=</span> <span style="color: blue">typeof</span>(<span style="color: #00008b">GetUnassignedIssuesForProjectRequest</span>)) <span style="color: blue">return</span> <span style="color: blue">false</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">return</span> <span style="color: #008b8b">Equals</span>((<span style="color: #00008b">GetUnassignedIssuesForProjectRequest</span>)obj);</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: blue">override</span> <span style="color: blue">int</span> <span style="color: #008b8b">GetHashCode</span>()</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">return</span> <span style="color: purple">ProjectId</span>.<span style="color: #008b8b">GetHashCode</span>();</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;</p>
</p></div>
<p>Now that we have an Equals and a GetHashCode method which only looks at the value of the ProjectId property, Agatha can differentiate between different requests on a value basis instead of a reference basis.&#160; Note that this doesn’t mean that your request types need to be value objects in the truest sense of the term.&#160; They just need to be able to perform an equality check based on the values that make the difference between actually handling the request, or returning the response that has previously been cached for the <em>set of values</em> that you’re using to determine equality.&#160; Simply overriding the Equals method is not enough, since Agatha will use these instances of requests as keys in a dictionary so you need to provide a proper GetHashCode implementation as well (which is recommended anyway if you’re overriding the Equals method).</p>
<p>It’s very important to really consider which properties you want to include in the equality check and the hashcode calculation.&#160; If your request type inherits from some base request (typically one that contains user credentials and stuff like that), then you typically <em>don’t </em>want to include those inherited property values in your equality check, unless you really want to cache different responses based on one of those inherited properties.&#160; I’d recommend writing enough tests to verify that your equality checks and hashcode calculations indeed behave the way you <em>want</em> them to because if they don’t, you will either get suboptimal results from Agatha’s caching or even incorrect ones which would lead to bugs that will be very hard to debug. </p>
<p>A question that came up recently in the <a href="http://groups.google.com/group/agatha-rrsl" target="_blank">Agatha discussion group</a> was how to implement the Equals and GetHashCode method for request types for which each instance should really be considered equal.&#160; For instance, a request type like this:</p>
<div style="font-family: consolas; background: white; color: black; font-size: 10pt">
<p style="margin: 0px">&#160;&#160;&#160; [<span style="color: #00008b">EnableResponseCaching</span>(<span style="color: purple">Hours</span> = 2, <span style="color: purple">Region</span> = <span style="color: #a31515">&quot;ReferenceData&quot;</span>)]</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: blue">class</span> <span style="color: #00008b">GetAllCountriesRequest</span> : <span style="color: #00008b">Request</span> {}</p>
<p style="margin: 0px">&#160;</p>
</p></div>
<p>In this case, the default Equals and GetHashCode implementations will be reference-based and not value based.&#160; But as you can see, there are no values to differentiate between requests.&#160; In this case, there is only one way to retrieve the known Countries in this system, so how do we implement the Equals and GetHashCode methods so this request type can be used correctly with Agatha’s caching layer?&#160; Well, the solution isn’t very nice but it is pretty simple.&#160; You can just introduce a dummy field with a fixed value:</p>
<div style="font-family: consolas; background: white; color: black; font-size: 10pt">
<p style="margin: 0px">&#160;&#160;&#160; [<span style="color: #00008b">EnableResponseCaching</span>(<span style="color: purple">Hours</span> = 2, <span style="color: purple">Region</span> = <span style="color: #a31515">&quot;ReferenceData&quot;</span>)]</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: blue">class</span> <span style="color: #00008b">GetAllCountriesRequest</span> : <span style="color: #00008b">Request</span></p>
<p style="margin: 0px">&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">private</span> <span style="color: blue">string</span> <span style="color: purple">dummyValue</span> = <span style="color: blue">typeof</span>(<span style="color: #00008b">GetAllCountriesRequest</span>).<span style="color: purple">FullName</span>;</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: blue">bool</span> <span style="color: #008b8b">Equals</span>(<span style="color: #00008b">GetAllCountriesRequest</span> other)</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">if</span> (<span style="color: #008b8b">ReferenceEquals</span>(<span style="color: blue">null</span>, other)) <span style="color: blue">return</span> <span style="color: blue">false</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">if</span> (<span style="color: #008b8b">ReferenceEquals</span>(<span style="color: blue">this</span>, other)) <span style="color: blue">return</span> <span style="color: blue">true</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">return</span> <span style="color: #008b8b">Equals</span>(other.<span style="color: purple">dummyValue</span>, <span style="color: purple">dummyValue</span>);</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: blue">override</span> <span style="color: blue">bool</span> <span style="color: #008b8b">Equals</span>(<span style="color: blue">object</span> obj)</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">if</span> (<span style="color: #008b8b">ReferenceEquals</span>(<span style="color: blue">null</span>, obj)) <span style="color: blue">return</span> <span style="color: blue">false</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">if</span> (<span style="color: #008b8b">ReferenceEquals</span>(<span style="color: blue">this</span>, obj)) <span style="color: blue">return</span> <span style="color: blue">true</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">if</span> (obj.<span style="color: #008b8b">GetType</span>() <span style="color: #008b8b">!=</span> <span style="color: blue">typeof</span>(<span style="color: #00008b">GetAllCountriesRequest</span>)) <span style="color: blue">return</span> <span style="color: blue">false</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">return</span> <span style="color: #008b8b">Equals</span>((<span style="color: #00008b">GetAllCountriesRequest</span>)obj);</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: blue">override</span> <span style="color: blue">int</span> <span style="color: #008b8b">GetHashCode</span>()</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">return</span> <span style="color: purple">dummyValue</span>.<span style="color: #008b8b">GetHashCode</span>();</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;</p>
</p></div>
<p>Now, every instance of the GetAllCountriesRequest will be considered equal to each other and they’ll all return the same hashcode as well.&#160; So every incoming instance of this request will return the same cached response (once it’s been cached that is).</p>
<p>That’s pretty much it.&#160; In itself, the caching layer of Agatha is very easy to use, but you definitely need to make sure that your Equals and GetHashCode implementations are correct.&#160; That’s pretty much the only tricky part (and downside) to how Agatha’s caching works, but i was unfortunately unable to come up with something that was easier to use. </p>
<p>One final word on the usage of regions.&#160; If you’re caching responses, then you typically want a way to remove stale responses from the cache.&#160; If some of the data that you’re caching is changed before the cached responses expire, you can clear the region in which those cached responses are being stored.&#160; Just add an ICacheManager constructor parameter to your handler (or any other class for that matter) and call the Clear method which takes a region name as a parameter.</p>
<p>As always with caching: be careful in how you use it, and make sure you think it through <img src='http://davybrion.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<p><a href="http://feedads.g.doubleclick.net/~a/0jqRBCNHhA2mZ2498TfdkO7clzU/0/da"><img src="http://feedads.g.doubleclick.net/~a/0jqRBCNHhA2mZ2498TfdkO7clzU/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/0jqRBCNHhA2mZ2498TfdkO7clzU/1/da"><img src="http://feedads.g.doubleclick.net/~a/0jqRBCNHhA2mZ2498TfdkO7clzU/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/davybrion?a=ZCQspPt5LDA:Q4JbgNZfmOQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/davybrion?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/davybrion?a=ZCQspPt5LDA:Q4JbgNZfmOQ:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/davybrion?i=ZCQspPt5LDA:Q4JbgNZfmOQ:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/davybrion/~4/ZCQspPt5LDA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://davybrion.com/blog/2010/06/using-agathas-server-side-caching/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://davybrion.com/blog/2010/06/using-agathas-server-side-caching/</feedburner:origLink></item>
		<item>
		<title>Why Do We Recycle Our Application Pools?</title>
		<link>http://feedproxy.google.com/~r/davybrion/~3/YO_pfjEM1QE/</link>
		<comments>http://davybrion.com/blog/2010/06/why-do-we-recycle-our-application-pools/#comments</comments>
		<pubDate>Sat, 12 Jun 2010 13:14:16 +0000</pubDate>
		<dc:creator>Davy Brion</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Opinions]]></category>

		<guid isPermaLink="false">http://davybrion.com/blog/2010/06/why-do-we-recycle-our-application-pools/</guid>
		<description><![CDATA[I’ve never understood why IIS by default configures newly created application pools to recycle every 1740 minutes.&#160; That means that by default, our ASP.NET applications are restarted every 29 hours.&#160; And for what?&#160; Are we, the .NET community, so bad that we really can’t write code that can keep running without problems for more than [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve never understood why IIS by default configures newly created application pools to recycle every 1740 minutes.&#160; That means that by default, our ASP.NET applications are restarted every 29 hours.&#160; And for what?&#160; Are we, the .NET community, so bad that we really can’t write code that can keep running without problems for more than 29 hours?&#160; Well, considering the overall lack of knowledge regarding memory management in .NET, i actually wouldn’t be surprised if that turned out to be the case for a very large portion of .NET development teams.</p>
<p>And indeed, if you browse the web to find the reason why application pools are configured to recycle automatically periodically, you’ll be hard pressed to find a reasonable answer that doesn’t pertain to memory issues.&#160; It’s like the community in general has pretty much accepted the fact that our web applications (or service layers hosted in IIS) will need to be recycled to avoid memory problems.&#160; To make things worse, i’ve frequently seen people discuss workarounds on how to keep things working properly after an application pool recycle in mailinglists for various projects.&#160; And again i ask myself: why?</p>
<p>I’ve always been of the opinion that if your code requires periodic restarts to keep working correctly, then something is <em>clearly wrong</em>.&#160; There is a bug in your code somewhere and you need to fix <em>that</em>, instead of restarting the process occasionally to make the problem ‘go away’.&#160; Guess what, it’s not going away, and if the load on your application increases, the problem will only pop up more frequently.&#160; So what are you going to do about that? Make the application pool recycle even more frequently?&#160; Put in another server to share the load?&#160; Perhaps we should focus more on fixing the actual code.&#160; You’re leaking resources somewhere, and <em>that</em> is what you need to fix.</p>
<p>In my company, it’s just standard procedure to disable application pool recycling on all application pools.&#160; Our applications simply <em>have</em> to keep working without application pool recycles.&#160; It’s that simple.&#160; If we run into a memory leak that causes problems, we focus on the actual problem and we fix it.&#160; We’ve ran into plenty of memory leaks (though it hasn’t really happened a lot in the past year, guess why?) and we’ve fixed each and every single one of them that we’ve ran into.&#160; Side note: i’m talking about .NET code that is running on the server.&#160; While i’m pretty sure that we do better at memory management in our Silverlight clients than most other Silverlight-using-shops do, you just never know for sure with Silverlight, partly because there are so many memory leaks in Silveright <em>itself</em>.&#160; But for .NET code running on a server, a memory leak is simply inexcusable in my opinion.&#160; I mean, it can happen to the best of us (i’m pretty much responsible for most of ours to be honest), but it’s not about who introduced the memory leak.&#160; It’s all about how you <em>deal with it</em>.&#160; And recycling the application pool periodically is <em>not</em> dealing with it, it’s living in denial. </p>
<p>The only viable reason to recycle application pools that i can think of is in the situation of a shared hosting provider.&#160; If you’re offering shared hosting, it only makes sense to recycle application pools occasionally since it’s quite realistic to assume that most of those application pools will not be in use constantly.&#160; If a pool is recycled, it will not consume any resources until the next request for an application in that pool is received.&#160; In the context of shared hosting, that actually makes sense.&#160; In the context of real applications, that makes little sense unless you’re hosting a lot of them and plenty of them are hardly being used.&#160; Still, is that really a good enough reason to enabling application pool recycling by default?&#160; I obviously don’t think so.</p>
<p>In my opinion, we, as a community, really need to start focusing more on <a href="http://davybrion.com/blog/2008/08/net-memory-management/" target="_blank">memory management in .NET</a> and on making sure that our applications can <em>keep running without problems.</em></p>

<p><a href="http://feedads.g.doubleclick.net/~a/GwiFVi-J4CUqzSwJIQ6Rlx7JIeE/0/da"><img src="http://feedads.g.doubleclick.net/~a/GwiFVi-J4CUqzSwJIQ6Rlx7JIeE/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/GwiFVi-J4CUqzSwJIQ6Rlx7JIeE/1/da"><img src="http://feedads.g.doubleclick.net/~a/GwiFVi-J4CUqzSwJIQ6Rlx7JIeE/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/davybrion?a=YO_pfjEM1QE:SBXUz2m_5P0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/davybrion?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/davybrion?a=YO_pfjEM1QE:SBXUz2m_5P0:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/davybrion?i=YO_pfjEM1QE:SBXUz2m_5P0:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/davybrion/~4/YO_pfjEM1QE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://davybrion.com/blog/2010/06/why-do-we-recycle-our-application-pools/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		<feedburner:origLink>http://davybrion.com/blog/2010/06/why-do-we-recycle-our-application-pools/</feedburner:origLink></item>
		<item>
		<title>If You Can’t Say Something Bad About It, You Don’t Know It Well Enough</title>
		<link>http://feedproxy.google.com/~r/davybrion/~3/9Fxs2NBx5gs/</link>
		<comments>http://davybrion.com/blog/2010/06/if-you-cant-say-something-bad-about-it-you-dont-know-it-well-enough/#comments</comments>
		<pubDate>Mon, 07 Jun 2010 20:00:57 +0000</pubDate>
		<dc:creator>Davy Brion</dc:creator>
				<category><![CDATA[Opinions]]></category>

		<guid isPermaLink="false">http://davybrion.com/blog/?p=2329</guid>
		<description><![CDATA[One thing that frequently bothers me when reading technical blogs or when talking to people about software development in general is that people often get extremely enthusiastic about some new kind of technology, library, framework or tool that they recently started using or heard other people talking about.&#160; In essence, there is nothing wrong with [...]]]></description>
			<content:encoded><![CDATA[<p>One thing that frequently bothers me when reading technical blogs or when talking to people about software development in general is that people often get extremely enthusiastic about some new kind of technology, library, framework or tool that they recently started using or heard other people talking about.&#160; In essence, there is nothing wrong with that.&#160; We are after all geeks, and the people who like to write or read technical blogs or talk about software development with others are typically passionate geeks and it’s only normal that we’re enthusiastic about tools, frameworks, libraries or pieces of technology in general.&#160; The thing is… we really ought to be a bit more careful in the way some things are often hyped in an uninformed manner.</p>
<p>I have a very simple rule when it comes to avoiding hype: if you can’t say something bad about it, you don’t know it well enough (yet).&#160; And until you are able to say something bad about a library, framework, approach, technology, tool or whatever, i simply can’t believe all of the good things you’re saying about it without some form of skepticism.&#160; In life, nothing is perfect.&#160; In software development even less so.&#160; Every single piece of technology or approach has its drawbacks, issues and problems.&#160; And quite often, those things only become noticeable after having truly used it on a real project for a while.&#160; I think most of us will be able to agree on that.&#160; So really, what does that tell you about someone when that person is extremely positive about something, without being able to mention <em>any</em> downside?&#160; That either tells me that you don’t know what you’re talking about or that you’re not even using whatever it is that you’re hyping on something <em>real</em> (hobby projects don’t really count).&#160; So does it really make sense for one to listen to it?&#160; Conversely, if you are very positive about something <em>but</em> are also able to mention the negative points that you’ve encountered (they don’t have to be huge, and can in fact even be minor) then i’m immediately much more inclined to believe what you’re saying.&#160; </p>
<p>Granted, my approach frequently prevents me from being an early adopter.&#160; But if/when i do become an adopter, i <em>will</em> be a pretty informed one.&#160; In many cases i’ll know about the negatives before they bite me, and will either guard myself against them, work around them if i have no other alternative or simply choose to ignore the technology altogether if the positives don’t outweigh the negatives.&#160; The only downside that i’ve experienced so far from this approach is that i’ll never be one of the cool kids on the internet and among the hype-hungry developers.&#160; Then again, that’s probably more of an upside than a downside, come to think of it <img src='http://davybrion.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Looking back over the past 5 years or so, i can say that i was late in adopting unit testing, agile development, Inversion Of Control, Dependency Injection, ORM, and probably a bunch of other things that i can’t really think of right now.&#160; But i’m pretty sure that i know all of those things <em>pretty</em> well by now.&#160; A large reason for that (i think) is because i took my time and made sure that i made informed decisions before adopting something.&#160; I experimented, thought about drawbacks, tried it in real projects, learned from mistakes that i made, worked around problems that were inherent with the piece of technology or approach in question and only <em>then</em> did i consider myself able to make informed statements about it.&#160; That doesn’t mean you can’t talk about something that you don’t know fully yet.&#160; A lot of very valuable blog posts are written by a lot of people who are learning things or are just experimenting with things.&#160; The smart ones among them though, will be very honest about how much they know about it, how much they <em>don’t</em> know about it, and how far they are in the learning progress. </p>
<p>So, as Public Enemy said: don’t believe the hype!</p>
<p>Get informed instead.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/jJIDz2UE7sfy2PeZcZ955pSA05U/0/da"><img src="http://feedads.g.doubleclick.net/~a/jJIDz2UE7sfy2PeZcZ955pSA05U/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/jJIDz2UE7sfy2PeZcZ955pSA05U/1/da"><img src="http://feedads.g.doubleclick.net/~a/jJIDz2UE7sfy2PeZcZ955pSA05U/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/davybrion?a=9Fxs2NBx5gs:AbeN7xD1EX4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/davybrion?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/davybrion?a=9Fxs2NBx5gs:AbeN7xD1EX4:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/davybrion?i=9Fxs2NBx5gs:AbeN7xD1EX4:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/davybrion/~4/9Fxs2NBx5gs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://davybrion.com/blog/2010/06/if-you-cant-say-something-bad-about-it-you-dont-know-it-well-enough/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://davybrion.com/blog/2010/06/if-you-cant-say-something-bad-about-it-you-dont-know-it-well-enough/</feedburner:origLink></item>
		<item>
		<title>Isolation At Work: Good Or Bad?</title>
		<link>http://feedproxy.google.com/~r/davybrion/~3/JELZRlZOaLE/</link>
		<comments>http://davybrion.com/blog/2010/06/isolation-at-work-good-or-bad/#comments</comments>
		<pubDate>Sat, 05 Jun 2010 14:09:02 +0000</pubDate>
		<dc:creator>Davy Brion</dc:creator>
				<category><![CDATA[Opinions]]></category>

		<guid isPermaLink="false">http://davybrion.com/blog/2010/06/isolation-at-work-good-or-bad/</guid>
		<description><![CDATA[A lot of people are of the opinion that isolating yourself at work, as a developer, is a bad thing to do.&#160; Communication with your teammates is highly important, and thus, isolating yourself from your surroundings by sitting in a different or separate office or listening to your iPod is often spoken of as an [...]]]></description>
			<content:encoded><![CDATA[<p>A lot of people are of the opinion that isolating yourself at work, as a developer, is a bad thing to do.&#160; Communication with your teammates is highly important, and thus, isolating yourself from your surroundings by sitting in a different or separate office or listening to your iPod is often spoken of as an inherently bad thing to do. But is it really?&#160; The way i see it, this can be a good thing, and this can be a bad thing.&#160; It pretty much depends on the type of person you are, what kind of people you work with, or what kind of environment you’re working in.</p>
<p>I can only speak from my own experience, but i frequently isolate myself from my coworkers and my surroundings by turning on my iPod and listening to some music while i work.&#160; I don’t do it all the time, and it definitely depends on what i’m working on, or who i’m working with.&#160; Obviously, if you’re doing pair programming then listening to your iPod is pretty much out of the question.&#160; But if you’re all sitting together, do we really need to avoid any kind of isolation?&#160; When i’m working on something complex, and i don’t really need to communicate with my teammates at that time, then there really isn’t anything wrong with listening to some music and getting some work done.&#160; In fact, it often helps me focus on my work without getting easily distracted, helps me get into a good zone, and it would certainly surprise me if i were the only one who thought that way.&#160; If you or some of your teammembers actually produce better results while they tune into their music, then this can’t really be an inherently bad thing, no?</p>
<p>But obviously, there will be many situations where you actually want to avoid listening to music.&#160; Sometimes you might be working on something that requires you to consult with teammates frequently, whether it is about design decisions or to ask some feedback on implications of certain implementation details.&#160; In those cases, you can end up pausing and resuming your iPod way too frequently so it might just be better to refrain from turning it on altogether.&#160; Or when you notice that teammates are discussing something and it’s taking them a bit too long.&#160; It’s hard to tell when a discussion is too long if you’re not hearing what they’re saying but when i notice 2 developers talking for more then a couple of minutes, i’ll often pause the iPod to check out what they’re talking about.&#160; Maybe you can help by offering a different perspective or maybe you know an immediate answer to the question that they’re discussing.&#160; If you can’t help, go ahead and press Play again.</p>
<p>The thing is… even if you do tune into some music at work, it’s important not to tune out of your coworkers completely.&#160; Go ahead and listen to your music, but keep looking around occasionally.&#160; Turn it off when you notice your teammates are talking and follow the discussion to see if it’s interesting to you or if you can help them.&#160; Conversely, if you’re participating in a discussion and you notice that one or more of your teammates is listening to music while they should probably be involved or at least hear what the conclusion or decision was, go ahead and notify them of what’s been discussed/decided/concluded.&#160; Also don’t be afraid to involve people who weren’t involved yet if you think that it <em>might</em> be important to them.&#160; If it turns out that it wasn’t important to them, then all you’ve lost is a few minutes.&#160; But if it was important to them, you might have saved a lot more than a few minutes by pulling them into the discussion.</p>
<p>As for sitting in a separate office… i’m not a fan of that.&#160; I’ve always noticed the best results are achieved when all of the developers are sitting together in the same office.&#160; In some organizations, senior developers, lead developers or ‘architects’ might be sitting in different offices from the people they’re supposed to be working with.&#160; I don’t know about you, but i’ve never actually seen that work properly.&#160; The typical on-the-floor communication that is so vital to successful teamwork is just reduced a lot of if some people are sitting in a different office.&#160; Obviously, when working with remote coworkers, this problem only increases but that’s something i haven’t really found an efficient solution for either.&#160; In some cases, communication through IM works great.&#160; And sometimes it doesn’t.&#160; It depends on how effectively you can communicate through IM, and how effectively the others can.&#160; </p>
<p>But anyway, when you hear people talk about how developers that isolate themselves at work is a bad thing, don’t necessarily buy into it.&#160; Like i said, it can be good or it can be bad.&#160; As with anything in our business, it all depends.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/Q67pMIbmpZFWk7ErEj2bT6gl2CY/0/da"><img src="http://feedads.g.doubleclick.net/~a/Q67pMIbmpZFWk7ErEj2bT6gl2CY/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/Q67pMIbmpZFWk7ErEj2bT6gl2CY/1/da"><img src="http://feedads.g.doubleclick.net/~a/Q67pMIbmpZFWk7ErEj2bT6gl2CY/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/davybrion?a=JELZRlZOaLE:WcKm1sX0ydY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/davybrion?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/davybrion?a=JELZRlZOaLE:WcKm1sX0ydY:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/davybrion?i=JELZRlZOaLE:WcKm1sX0ydY:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/davybrion/~4/JELZRlZOaLE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://davybrion.com/blog/2010/06/isolation-at-work-good-or-bad/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://davybrion.com/blog/2010/06/isolation-at-work-good-or-bad/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 0.696 seconds. --><!-- Cached page generated by WP-Super-Cache on 2010-07-29 22:51:19 -->
