<?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, 04 Feb 2010 20:27:11 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<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>Taking A Week Off</title>
		<link>http://feedproxy.google.com/~r/davybrion/~3/nR094C9VPeM/</link>
		<comments>http://davybrion.com/blog/2010/02/taking-a-week-off/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 20:27:11 +0000</pubDate>
		<dc:creator>Davy Brion</dc:creator>
				<category><![CDATA[About The Blog]]></category>

		<guid isPermaLink="false">http://davybrion.com/blog/?p=2244</guid>
		<description><![CDATA[Well, i&#8217;m off for a week&#8230; i&#8217;ll be doing the tourist thing (you know, hanging out, having fun, laughing our asses off, taking pictures and generally annoying the hell out of the locals) in New York City and i won&#8217;t be back until February 14th.  I will be avoiding all kinds of electronic communication [...]]]></description>
			<content:encoded><![CDATA[<p>Well, i&#8217;m off for a week&#8230; i&#8217;ll be doing the tourist thing (you know, hanging out, having fun, laughing our asses off, taking pictures and generally annoying the hell out of the locals) in New York City and i won&#8217;t be back until February 14th.  I will be avoiding all kinds of electronic communication and the internet in general, so if you&#8217;re wondering why i&#8217;m not responding to email, now you know why <img src='http://davybrion.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><a href="http://davybrion.com/blog/wp-content/uploads/2010/02/NewYork.jpg"><img src="http://davybrion.com/blog/wp-content/uploads/2010/02/NewYork.jpg" alt="" title="NewYork" width="600" height="424" class="aligncenter size-full wp-image-2245" /></a></p>
<p>I&#8217;m not leaving until Saturday morning, so if you have some &#8216;must-see&#8217; or &#8216;must-do&#8217; tips about New York, bring em on! <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/T_QSqf6mxRdIf7_bAM7huZUmq7w/0/da"><img src="http://feedads.g.doubleclick.net/~a/T_QSqf6mxRdIf7_bAM7huZUmq7w/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/T_QSqf6mxRdIf7_bAM7huZUmq7w/1/da"><img src="http://feedads.g.doubleclick.net/~a/T_QSqf6mxRdIf7_bAM7huZUmq7w/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/davybrion?a=nR094C9VPeM:VpQjJLUZDMQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/davybrion?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/davybrion?a=nR094C9VPeM:VpQjJLUZDMQ:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/davybrion?i=nR094C9VPeM:VpQjJLUZDMQ:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/davybrion/~4/nR094C9VPeM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://davybrion.com/blog/2010/02/taking-a-week-off/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://davybrion.com/blog/2010/02/taking-a-week-off/</feedburner:origLink></item>
		<item>
		<title>Browser Usage</title>
		<link>http://feedproxy.google.com/~r/davybrion/~3/K1T06dDkm0A/</link>
		<comments>http://davybrion.com/blog/2010/02/browser-usage/#comments</comments>
		<pubDate>Tue, 02 Feb 2010 21:06:23 +0000</pubDate>
		<dc:creator>Davy Brion</dc:creator>
				<category><![CDATA[About The Blog]]></category>

		<guid isPermaLink="false">http://davybrion.com/blog/2010/02/browser-usage/</guid>
		<description><![CDATA[I read an article today about how Chrome has increased a lot in market share in the past year, mostly at the expense of Firefox.&#160; I wanted to see how Chrome usage on this blog has progressed in the past year so i got some stats from Google Analytics and created this little graph:
 
(note: [...]]]></description>
			<content:encoded><![CDATA[<p>I read an article today about how Chrome has increased a lot in market share in the past year, mostly at the expense of Firefox.&#160; I wanted to see how Chrome usage on this blog has progressed in the past year so i got some stats from Google Analytics and created this little graph:</p>
<p><a href="http://davybrion.com/pictures/BrowserUsage_12EC1/image.png" target="_blank"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://davybrion.com/pictures/BrowserUsage_12EC1/image_thumb.png" width="704" height="285" /></a> </p>
<p>(note: these numbers are obviously only from visits to this blog and are thus not representative of the entire internet (<em>yet</em>) etc…)</p>
<p>I started at the month before the first Chrome users were reported to give you an idea of Firefox’s score at that time.&#160; Naturally, the people that come to this blog are into technology so it’s no wonder that Firefox is the dominant browser instead of IE.&#160; Before Chrome entered the picture, nearly 70% of all visits to this blog in August 2008 were from Firefox users.&#160; In its first month, Chrome immediately got about 8%, which i thought was pretty impressive.&#160; Firefox’s numbers dropped below 50% for the first time less than a year later.&#160; That’s a pretty big impact in a relatively short time.&#160;&#160; And as you can see, Chrome usage has been growing a lot in the past 6 months ago, at the expense of both Firefox and IE.&#160; I wouldn’t be surprised if Chrome catches up to Firefox in another 6 months.</p>
<p>I’m not fanatic about any browser (as long as i don’t have to use IE, right?)… i use Firefox for OS X at home, but i use Chrome at work.&#160; I’m not really into the whole plugin/extension thing (except for Adblock obviously) so i’m not really ‘tied’ to a specific browser.&#160; Now, some people <em>are</em> pretty fanatic about their browser so what i’m wondering is: what would it take for you to switch to another browser (no matter which one you use now)?&#160; Are you hooked on extensions that you can’t go without in another browser?&#160; What was the reason you picked your current browser and why are you sticking with it? Or is it all pretty much the same for you?&#160; Do you frequently use multiple browsers?</p>
<p>In some weird way, i find that kinda stuff interesting so please do share <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/7Z5HFVWoN5YbxVPwJy0MWcc7DZU/0/da"><img src="http://feedads.g.doubleclick.net/~a/7Z5HFVWoN5YbxVPwJy0MWcc7DZU/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/7Z5HFVWoN5YbxVPwJy0MWcc7DZU/1/da"><img src="http://feedads.g.doubleclick.net/~a/7Z5HFVWoN5YbxVPwJy0MWcc7DZU/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/davybrion?a=K1T06dDkm0A:2d6CpPo3vAg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/davybrion?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/davybrion?a=K1T06dDkm0A:2d6CpPo3vAg:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/davybrion?i=K1T06dDkm0A:2d6CpPo3vAg:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/davybrion/~4/K1T06dDkm0A" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://davybrion.com/blog/2010/02/browser-usage/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		<feedburner:origLink>http://davybrion.com/blog/2010/02/browser-usage/</feedburner:origLink></item>
		<item>
		<title>Good Team Dynamics Are Essential For High Technical Quality</title>
		<link>http://feedproxy.google.com/~r/davybrion/~3/q_pqNX5qDTE/</link>
		<comments>http://davybrion.com/blog/2010/01/good-team-dynamics-are-essential-for-high-technical-quality/#comments</comments>
		<pubDate>Sun, 31 Jan 2010 20:42:16 +0000</pubDate>
		<dc:creator>Davy Brion</dc:creator>
				<category><![CDATA[Opinions]]></category>

		<guid isPermaLink="false">http://davybrion.com/blog/2010/01/good-team-dynamics-are-essential-for-high-technical-quality/</guid>
		<description><![CDATA[Just read an interesting post from David Tchepak about the lessons he learned from his long-term agile project.&#160; The post itself is interesting but there was one point in particular on the momentum of his team that caught my attention:
This probably sounds a bit touchy-feely, but I think dismissing it on those grounds is ignoring [...]]]></description>
			<content:encoded><![CDATA[<p>Just read an interesting post from David Tchepak about the <a href="http://www.davesquared.net/2010/01/lessons-learned-from-my-current-project.html" target="_blank">lessons he learned from his long-term agile project</a>.&#160; The post itself is interesting but there was one point in particular on the momentum of his team that caught my attention:</p>
<blockquote><p>This probably sounds a bit touchy-feely, but I think dismissing it on those grounds is ignoring a fairly fundamental part of human nature. If every day, every task is a thankless struggle, the intertia will pull down your team&#8217;s morale, motivation, concentration, and reduce their creativity and ability to innovate. On the flip side, once the team gets up a bit of steam and starts churning through stories, seeing visible progress as they move across the task board and into the Done column, the team&#8217;s enthusiasm and creativity soars. They start kicking around new ideas on how to remove some duplication from the code and reduce some overhead for future stories.</p>
</blockquote>
<p>David is right, but i’d go even further than that.&#160; I’d assert that good team dynamics are essential for achieving high technical quality that is sustainable in the long term.&#160; I think we can all agree that people work better together if they actually like working with each other.&#160; And i’m pretty sure that many of us have experienced first hand how a negative relationship within a team can have a pretty negative impact on the technical quality of a project.&#160; </p>
<p>Have you ever been on a project where you were looking at a piece of code thinking “wow, this really ought to be cleaned up… but i’m not touching it since John is gonna get all pissed over somebody touching his code”.&#160; Or worse, “wow, he really made a mess of this but i’m not touching it… let him live with the pain”.&#160;&#160; I certainly wouldn’t be surprised if many of us have at one point (or more) in our career had this exact thought about a certain piece of code written by a teammate at the time.&#160; That is a perfect example of how negative team dynamics can have a pretty serious impact on the technical quality and thus, i’d argue, the long-term viability of the project.&#160;&#160; See, the thing is that it won’t end what that certain piece of code.&#160; Sure, code rot has been introduced.&#160; But even worse, team rot is being introduced by this behavior as well, even if you are just trying to preserve the peace by trying to avoid a possible confrontation.</p>
<p>This kind of team rot will not end there.&#160; If you don’t actively try to get rid of it ASAP, it’ll eventually spread throughout the team, as more and more people gradually get into the same mentality.&#160; Eventually, even the strongest, most positive personalities can fall victim to it.&#160; When new people join the team, they’ll quickly pick up on it as well and there are very few people who are willing to stand up to such a situation when joining an existing team.&#160; As i’m sure you can imagine, nobody really likes working in such a team.&#160; A lot of people in that situation will get into a “i’m just gonna look out for myself and to hell with anyone else” mentality.&#160;&#160; They will try to do their job in a way that they will not be blamed for anything.&#160; Communication will drop to a ‘nothing-more-than-necessary’-level.&#160; A lot of issues will be ignored until they are actually found by end-users.&#160; A lot of time and effort is going to be wasted in general.&#160; And you’ll probably end up with a pretty high turnover rate of team members.&#160; Believe it or not, these kind of teams truly do exist.</p>
<p>On the other hand, if everybody on the team gets along everything seems to go much more smoothly.&#160; People won’t be afraid to make changes in other people’s code if everyone understands that it’s for the best of the project and if they know that it’s not gonna lead to a bitchfest from a difficult team member.&#160; Discussions will be about actual facts and merits, not about not-wanting-to-give-in-to-someone-you-no-longer-like.&#160; People will alert their team members when they notice something that could cause problems later on.&#160; People will be much more likely to maintain their technical discipline when there is positive peer pressure to maintain high standards.&#160;&#160; People will help each other when they can.&#160; Essentially, those people will form a true team instead of being a collection of coworkers who are unfortunately working on the same project together.</p>
<p>As much as many of us strive to improve our technical abilities and skills on a continuous basis, we also need to ask ourselves the following questions regularly: </p>
<ul>
<li>Am i a good team member? </li>
<li>Would i like to work with someone like me? </li>
<li>What can i do to make people enjoy working with me more than they might do now? </li>
</ul>
<p>That doesn’t mean you have to become Mr Popular.&#160; It doesn’t mean you have to crack the best jokes.&#160; You can be almost entirely yourself, as long as you realize that:</p>
<ul>
<li>communication is extremely important </li>
<li>treating others with respect is crucial </li>
<li><a href="http://davybrion.com/blog/2009/12/dont-be-a-whiny-developer/" target="_blank">nobody likes working with whiney developers</a> </li>
<li>you can’t expect others to work on their flaws if you’re not willing to work on yours… it’s a two-way street </li>
</ul>

<p><a href="http://feedads.g.doubleclick.net/~a/2RTcgXNXU_1_ArEUrC78NchpyBo/0/da"><img src="http://feedads.g.doubleclick.net/~a/2RTcgXNXU_1_ArEUrC78NchpyBo/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/2RTcgXNXU_1_ArEUrC78NchpyBo/1/da"><img src="http://feedads.g.doubleclick.net/~a/2RTcgXNXU_1_ArEUrC78NchpyBo/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/davybrion?a=q_pqNX5qDTE:4vAbVMp8asA:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/davybrion?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/davybrion?a=q_pqNX5qDTE:4vAbVMp8asA:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/davybrion?i=q_pqNX5qDTE:4vAbVMp8asA:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/davybrion/~4/q_pqNX5qDTE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://davybrion.com/blog/2010/01/good-team-dynamics-are-essential-for-high-technical-quality/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://davybrion.com/blog/2010/01/good-team-dynamics-are-essential-for-high-technical-quality/</feedburner:origLink></item>
		<item>
		<title>NDepend 3 Preview</title>
		<link>http://feedproxy.google.com/~r/davybrion/~3/5SYjU6IszFY/</link>
		<comments>http://davybrion.com/blog/2010/01/ndepend-3-preview/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 09:45:30 +0000</pubDate>
		<dc:creator>Davy Brion</dc:creator>
				<category><![CDATA[IDE]]></category>
		<category><![CDATA[NDepend]]></category>

		<guid isPermaLink="false">http://davybrion.com/blog/2010/01/ndepend-3-preview/</guid>
		<description><![CDATA[I was just playing around with an NDepend 3 beta version to experiment with the new Visual Studio integration that the NDepend team has developed.&#160; 
Once you install the Visual Studio addin through the VisualNDepend.exe tool, you’ll notice the following menu has been added in Visual Studio:
 
If you select the first item, you can [...]]]></description>
			<content:encoded><![CDATA[<p>I was just playing around with an NDepend 3 beta version to experiment with the new Visual Studio integration that the NDepend team has developed.&#160; </p>
<p>Once you install the Visual Studio addin through the VisualNDepend.exe tool, you’ll notice the following menu has been added in Visual Studio:</p>
<p><a href="http://davybrion.com/pictures/NDepend3Preview_1277D/01.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="01" border="0" alt="01" src="http://davybrion.com/pictures/NDepend3Preview_1277D/01_thumb.png" width="377" height="242" /></a> </p>
<p>If you select the first item, you can easily create a new NDepend project for your current solution:</p>
<p><a href="http://davybrion.com/pictures/NDepend3Preview_1277D/02.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="02" border="0" alt="02" src="http://davybrion.com/pictures/NDepend3Preview_1277D/02_thumb.png" width="644" height="400" /></a></p>
<p>You’ll also notice an NDepend icon in the bottom-right corner of Visual Studio.&#160; Clicking on it shows you an immediate overview of NDepend’s CQL query results for your solution:</p>
<p>&#160;<a href="http://davybrion.com/pictures/NDepend3Preview_1277D/03.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="03" border="0" alt="03" src="http://davybrion.com/pictures/NDepend3Preview_1277D/03_thumb.png" width="224" height="403" /></a> </p>
<p>Clicking on the Show SQL Explorer immediately brings you to this view, which many NDepend users will recognize:</p>
<p><a href="http://davybrion.com/pictures/NDepend3Preview_1277D/04.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="04" border="0" alt="04" src="http://davybrion.com/pictures/NDepend3Preview_1277D/04_thumb.png" width="644" height="333" /></a> </p>
<p>You can also right-click on a type (or a method) and you’ll see the following NDepend context-menu:</p>
<p><a href="http://davybrion.com/pictures/NDepend3Preview_1277D/05.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="05" border="0" alt="05" src="http://davybrion.com/pictures/NDepend3Preview_1277D/05_thumb.png" width="624" height="484" /></a> </p>
<p>Which in turn allows you to open many of the familiar NDepend views:</p>
<p><a href="http://davybrion.com/pictures/NDepend3Preview_1277D/06.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="06" border="0" alt="06" src="http://davybrion.com/pictures/NDepend3Preview_1277D/06_thumb.png" width="644" height="364" /></a></p>
<p>This particular view is something that i find extremely useful.&#160; Notice how you get an immediate overview of relevant metrics when you click on one of the items in the graph.&#160; Or you can look at the metrics view:</p>
<p>&#160;<a href="http://davybrion.com/pictures/NDepend3Preview_1277D/07.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="07" border="0" alt="07" src="http://davybrion.com/pictures/NDepend3Preview_1277D/07_thumb.png" width="644" height="479" /></a> </p>
<p>I’ve never understood how to interpret this view, but NDepend users who do will be glad to know they can now access it extremely easily <img src='http://davybrion.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>One thing that i can see myself make extensive usage of are the following features:</p>
<p><a href="http://davybrion.com/pictures/NDepend3Preview_1277D/08.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="08" border="0" alt="08" src="http://davybrion.com/pictures/NDepend3Preview_1277D/08_thumb.png" width="681" height="489" /></a> </p>
<p>I’ve only played around with it for about 15 minutes now, but i’m impressed.&#160; I never really liked NDepend 2 because i always got completely lost in the VisualNDepend UI.&#160; Now that i have all of this integrated in Visual Studio, it just seems much easier to get to the information i really want.&#160; And if you have to review a lot of code (like me), then this new NDepend version is sure to save you <em>a lot</em> of time.&#160;&#160; It’s pretty much everything you’ve always wanted or already loved from NDepend, but much more easily accessible.</p>
<p>I did notice some small visual glitches (which might be related to running this in a VMWare virtual machine on OS X) and at one time even a Visual Studio crash, but i’m sure those issues will be fixed before the final release.</p>
<p>Oh, and i’m also very happy to note that <a href="http://davybrion.com/blog/2009/12/ndepend-and-lack-of-cohesion-of-methods-not-to-be-trusted/" target="_blank">this particular issue</a> has also been resolved <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/Gfhy0ToxI0V4witUJ31hQ8UFmOA/0/da"><img src="http://feedads.g.doubleclick.net/~a/Gfhy0ToxI0V4witUJ31hQ8UFmOA/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/Gfhy0ToxI0V4witUJ31hQ8UFmOA/1/da"><img src="http://feedads.g.doubleclick.net/~a/Gfhy0ToxI0V4witUJ31hQ8UFmOA/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/davybrion?a=5SYjU6IszFY:hdN0AOcmO4I:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/davybrion?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/davybrion?a=5SYjU6IszFY:hdN0AOcmO4I:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/davybrion?i=5SYjU6IszFY:hdN0AOcmO4I:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/davybrion/~4/5SYjU6IszFY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://davybrion.com/blog/2010/01/ndepend-3-preview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://davybrion.com/blog/2010/01/ndepend-3-preview/</feedburner:origLink></item>
		<item>
		<title>Securing Your Agatha Service Layer</title>
		<link>http://feedproxy.google.com/~r/davybrion/~3/9YQkRV6Nlo8/</link>
		<comments>http://davybrion.com/blog/2010/01/securing-your-agatha-service-layer/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 20:05:11 +0000</pubDate>
		<dc:creator>Davy Brion</dc:creator>
				<category><![CDATA[agatha]]></category>

		<guid isPermaLink="false">http://davybrion.com/blog/2010/01/securing-your-agatha-service-layer/</guid>
		<description><![CDATA[The question of how to implement security for an Agatha Service Layer is one that comes up frequently.&#160; First of all, you need to remember that if you’re using Agatha with WCF you can use any of the WCF features that you’d normally use to secure your WCF service.&#160; There’s already plenty of information available [...]]]></description>
			<content:encoded><![CDATA[<p>The question of how to implement security for an Agatha Service Layer is one that comes up frequently.&#160; First of all, you need to remember that if you’re using Agatha with WCF you can use any of the WCF features that you’d normally use to secure your WCF service.&#160; There’s already plenty of information available online or in books on implementing security for WCF services so i’m not going to spend time on covering those options.&#160; What i am going to cover is the approach that we typically use for our Agatha service layers.</p>
<p>I don’t like to tie myself to WCF-specific features, so i always plug in custom authentication into either a custom Request Processor, or a base Request Handler class that all other Request Handlers must inherit from.&#160;&#160; But first, how do we get the authentication-related data from the client to the service?</p>
<p>In each project i use Agatha in, i always have a MyProjectRequest and MyProjectResponse base class:</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">class</span> <span style="color: #2b91af">MyProjectRequest</span> : <span style="color: #2b91af">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: blue">string</span> UserName { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: blue">byte</span>[] PasswordHash { <span style="color: blue">get</span>; <span style="color: blue">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">class</span> <span style="color: #2b91af">MyProjectResponse</span> : <span style="color: #2b91af">Response</span> {}</p>
</p></div>
<p>&#160;</p>
<p>Each request in the project inherits from this base request, and each response inherits from the base response.&#160; The base response class is often empty, though this does make it very easy if you ever need to send something back with every response.</p>
<p>Now obviously, if every single request that is sent to your service layer needs values for the UserName and PasswordHash properties you want this to be done in only one place.&#160; I do this by using a custom request dispatcher:</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">class</span> <span style="color: #2b91af">MyProjectAsyncRequestDispatcher</span> : <span style="color: #2b91af">AsyncRequestDispatcher</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">readonly</span> <span style="color: #2b91af">IUserContext</span> userContext;</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">public</span> MyProjectAsyncRequestDispatcher(<span style="color: #2b91af">IAsyncRequestProcessor</span> requestProcessor, <span style="color: #2b91af">IUserContext</span> userContext) : <span style="color: blue">base</span>(requestProcessor)</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">this</span>.userContext = userContext;</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">override</span> <span style="color: blue">void</span> BeforeSendingRequests(<span style="color: #2b91af">IEnumerable</span>&lt;<span style="color: #2b91af">Request</span>&gt; requestsToProcess)</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">base</span>.BeforeSendingRequests(requestsToProcess);</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">foreach</span> (<span style="color: blue">var</span> myProjectRequest <span style="color: blue">in</span> requestsToProcess.OfType&lt;<span style="color: #2b91af">MyProjectRequest</span>&gt;())</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; myProjectRequest.UserName = userContext.UserName;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; myProjectRequest.PasswordHash = userContext.PasswordHash;</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; }</p>
<p style="margin: 0px">&#160;&#160;&#160; }</p>
</p></div>
<p>&#160;</p>
<p>The IUserContext dependency is just a component that is registered in my IOC container and will be injected automatically whenever you get an instance of IAsyncRequestDispatcher.&#160;&#160; Now, in this example you can see that i add the authentication data to <em>every request </em>in a batch, even though the batch will be sent in one roundtrip.&#160; If you want, you can add the authentication data only to the first request and then only use the first request to do the authentication within your service layer.&#160; I prefer to add the authentication data to each request and then authenticate every single request (even subsequent requests in a batch) within the service layer.&#160; I’ll get back to this point later on.</p>
<p>Now, the only thing we need to do to make sure that your requests will always have the authentication data contained within them is to instruct Agatha to always use instances of your MyProjectAsyncRequestDispatcher class whenever an IAsyncRequestDispatcher is needed.&#160; This is easily done during Agatha’s client-side configuration:</p>
<div style="font-family: consolas; background: white; color: black; font-size: 10pt">
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">new</span> <span style="color: #2b91af">ClientConfiguration</span>(<span style="color: blue">typeof</span>(<span style="color: #2b91af">MyProjectRequest</span>).Assembly, <span style="color: blue">new</span> Agatha.Castle.<span style="color: #2b91af">Container</span>(myContainerWrapper))</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#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;&#160;&#160;&#160;&#160; AsyncRequestDispatcherImplementation = <span style="color: blue">typeof</span>(<span style="color: #2b91af">MyProjectAsyncRequestDispatcher</span>)</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#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; .Initialize();</p>
</p></div>
<p>&#160;</p>
<p>Keep in mind that you still have to register your IUserContext with the container on your own though.&#160; </p>
<p>With that in place, we are sure that each request that comes from <em>our clients</em> always contains the proper authentication data.&#160; Now we need to make sure that we actually authenticate these requests within the service layer.&#160; You basically have 2 options: either implement your own Request Processor which adds authentication checks, or create a base Request Handler that your other Request Handlers inherit from.</p>
<p>We’ll first cover the option of using a custom Request Processor.&#160;&#160; You could create one 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">class</span> <span style="color: #2b91af">MyProjectRequestProcessor</span> : <span style="color: #2b91af">RequestProcessor</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">readonly</span> <span style="color: #2b91af">IAuthenticator</span> authenticator;</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">public</span> MyProjectRequestProcessor(<span style="color: #2b91af">IAuthenticator</span> authenticator, <span style="color: #2b91af">ServiceLayerConfiguration</span> serviceLayerConfiguration, <span style="color: #2b91af">ICacheManager</span> cacheManager) </p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; : <span style="color: blue">base</span>(serviceLayerConfiguration, cacheManager)</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">this</span>.authenticator = authenticator;</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">override</span> <span style="color: blue">void</span> BeforeHandle(<span style="color: #2b91af">Request</span> request)</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> myProjectRequest = request <span style="color: blue">as</span> <span style="color: #2b91af">MyProjectRequest</span>;</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">if</span> (myProjectRequest != <span style="color: blue">null</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">if</span> (!authenticator.AreValidCredentials(myProjectRequest.UserName, myProjectRequest.PasswordHash))</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#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;&#160;&#160;&#160;&#160; <span style="color: blue">throw</span> <span style="color: blue">new</span> <span style="color: #2b91af">MySecurityException</span>();</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#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; }</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;&#160;&#160; }</p>
</p></div>
<p>&#160;</p>
<p>The BeforeHandle virtual method is called right before the request is passed to its Request Handler to be handled.&#160; Note that this Request Processor would authenticate <em>every </em>request.&#160; If you want a Request Processor that only authenticates the first request, you could do so 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">class</span> <span style="color: #2b91af">MyProjectRequestProcessor</span> : <span style="color: #2b91af">RequestProcessor</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">readonly</span> <span style="color: #2b91af">IAuthenticator</span> authenticator;</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">public</span> MyProjectRequestProcessor(<span style="color: #2b91af">IAuthenticator</span> authenticator, <span style="color: #2b91af">ServiceLayerConfiguration</span> serviceLayerConfiguration, <span style="color: #2b91af">ICacheManager</span> cacheManager) </p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; : <span style="color: blue">base</span>(serviceLayerConfiguration, cacheManager)</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">this</span>.authenticator = authenticator;</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">override</span> <span style="color: blue">void</span> BeforeProcessing(<span style="color: #2b91af">IEnumerable</span>&lt;<span style="color: #2b91af">Request</span>&gt; requests)</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> myProjectRequest = (<span style="color: #2b91af">MyProjectRequest</span>)requests.ElementAt(0);</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">if</span> (!authenticator.AreValidCredentials(myProjectRequest.UserName, myProjectRequest.PasswordHash))</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">throw</span> <span style="color: blue">new</span> <span style="color: #2b91af">MySecurityException</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; }</p>
<p style="margin: 0px">&#160;&#160;&#160; }</p>
</p></div>
<p>&#160;</p>
<p>The BeforeProcessing virtual method is called before any of the requests are handled, so you could authenticate only the first request in a batch and then proceed with regular processing if the first one is authenticated.&#160; Now, the big problem that i have with this approach is that you aren’t really in control of what is sent to your service layer.&#160; Yes, you can guarantee that each request coming from <em>your clients</em> contains the proper authentication data.&#160; What you simply can’t guarantee however is what other people or custom clients can send to your service layer.&#160; If they send you a batch of 2 requests, the first containing valid credentials of a normal user for a benign request, it will pass the authentication just fine.&#160; If the second request in that batch contains invalid credentials (to trick your authorization into believing it’s from a user with higher privileges for instance) for a request that could cause some damage (deleting important information or triggering certain tasks or whatever), then you can’t really do anything to prevent that.&#160; Unless of course, you reject this approach and authenticate every single request.</p>
<p>As for the MySecurityException type, that’s up to you as well.&#160; When you configure your Agatha service layer, you can set the SecurityExceptionType property to the type of exception that should be considered as a security exception.&#160; When the Request Processor catches an exception of that type, it will set the ExceptionType property of the response to ExceptionType.Security so you can check for that specific situation in your client.</p>
<p>To configure Agatha to use your custom Request Processor, your configuration code would look 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;&#160;&#160;&#160;&#160; <span style="color: blue">new</span> <span style="color: #2b91af">ServiceLayerConfiguration</span>(<span style="color: #2b91af">Assembly</span>.GetExecutingAssembly(), <span style="color: blue">typeof</span>(<span style="color: #2b91af">MyProjectRequest</span>).Assembly,</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">new</span> Agatha.Castle.<span style="color: #2b91af">Container</span>(containerWrapper))</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#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;&#160;&#160;&#160;&#160; RequestProcessorImplementation = <span style="color: blue">typeof</span>(<span style="color: #2b91af">MyProjectRequestProcessor</span>),</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; SecurityExceptionType = <span style="color: blue">typeof</span>(<span style="color: #2b91af">MySecurityException</span>)</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#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; .Initialize();</p>
</p></div>
<p>&#160;</p>
<p>Another alternative is to create a base Request Handler for your project and to have each Request Handler inherit from it.&#160; Something like this, for instance:</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: #2b91af">MyProjectRequestHandler</span>&lt;TRequest, TResponse&gt; : <span style="color: #2b91af">RequestHandler</span>&lt;TRequest, TResponse&gt; </p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">where</span> TRequest : <span style="color: #2b91af">MyProjectRequest</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: #2b91af">IAuthenticator</span> Authenticator { <span style="color: blue">get</span>; <span style="color: blue">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">override</span> <span style="color: blue">void</span> BeforeHandle(TRequest request)</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">base</span>.BeforeHandle(request);</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">if</span> (!Authenticator.AreValidCredentials(request.UserName, request.PasswordHash))</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">throw</span> <span style="color: blue">new</span> <span style="color: #2b91af">MySecurityException</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; Authorize(request);</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">virtual</span> <span style="color: blue">void</span> Authorize(TRequest request) {}</p>
<p style="margin: 0px">&#160;&#160;&#160; }</p>
</p></div>
<p>&#160;</p>
<p>In case you’re wondering why i’m using Setter-injection here instead of Constructor-injection, read <a href="http://davybrion.com/blog/2009/11/constructor-injection-vs-sette-injection/" target="_blank">this</a>.</p>
<p>I typically prefer the custom Request Handler approach for authentication.&#160; In most applications that we write, authentication is not enough and we need custom authorization checks for many requests.&#160; So i’m going to need a base Request Handler which introduces the virtual Authorize method anyway.&#160; So i might as well do my authentication check right before it. </p>
<p>With the custom Request Handler approach, you probably still want to configure Agatha to use your custom security exception type:</p>
<div style="font-family: consolas; background: white; color: black; font-size: 10pt">
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">new</span> <span style="color: #2b91af">ServiceLayerConfiguration</span>(<span style="color: #2b91af">Assembly</span>.GetExecutingAssembly(), <span style="color: blue">typeof</span>(<span style="color: #2b91af">MyProjectRequest</span>).Assembly,</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">new</span> Agatha.Castle.<span style="color: #2b91af">Container</span>(containerWrapper))</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#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;&#160;&#160;&#160;&#160; SecurityExceptionType = <span style="color: blue">typeof</span>(<span style="color: #2b91af">MySecurityException</span>)</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#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; .Initialize();</p>
</p></div>
<p>&#160;</p>
<p>And then you just need to let your own Request Handlers inherit from your MyProjectRequestHandler.&#160; Authentication will be performed for each request by default, and you can easily add specific authorization logic for every request.&#160; </p>
<p>And those are pretty much the options you have to secure your Agatha Service Layer.&#160;&#160; Oh, and be sure to only expose your Service Layer through SSL <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/TF8ESSb_kNz9F7Mo_yQr6IKpMR8/0/da"><img src="http://feedads.g.doubleclick.net/~a/TF8ESSb_kNz9F7Mo_yQr6IKpMR8/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/TF8ESSb_kNz9F7Mo_yQr6IKpMR8/1/da"><img src="http://feedads.g.doubleclick.net/~a/TF8ESSb_kNz9F7Mo_yQr6IKpMR8/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/davybrion?a=9YQkRV6Nlo8:eToPo9ImIAM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/davybrion?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/davybrion?a=9YQkRV6Nlo8:eToPo9ImIAM:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/davybrion?i=9YQkRV6Nlo8:eToPo9ImIAM:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/davybrion/~4/9YQkRV6Nlo8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://davybrion.com/blog/2010/01/securing-your-agatha-service-layer/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://davybrion.com/blog/2010/01/securing-your-agatha-service-layer/</feedburner:origLink></item>
		<item>
		<title>Agatha Vs NServiceBus?</title>
		<link>http://feedproxy.google.com/~r/davybrion/~3/IloL4pASAKI/</link>
		<comments>http://davybrion.com/blog/2010/01/agatha-vs-nservicebus/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 20:50:51 +0000</pubDate>
		<dc:creator>Davy Brion</dc:creator>
				<category><![CDATA[agatha]]></category>
		<category><![CDATA[nservicebus]]></category>

		<guid isPermaLink="false">http://davybrion.com/blog/2010/01/agatha-vs-nservicebus/</guid>
		<description><![CDATA[Ever since i open sourced Agatha, i’ve gotten questions from people who are wondering whether they should use Agatha or NServiceBus.&#160; I’ve also gotten questions about things that people wanted to do with Agatha but that aren’t really supported.&#160; And i’ve also noticed that people were coming to my site with search keywords like “agatha [...]]]></description>
			<content:encoded><![CDATA[<p>Ever since i open sourced <a href="http://code.google.com/p/agatha-rrsl/" target="_blank">Agatha</a>, i’ve gotten questions from people who are wondering whether they should use Agatha or <a href="http://nservicebus.com/" target="_blank">NServiceBus</a>.&#160; I’ve also gotten questions about things that people wanted to do with Agatha but that aren’t really supported.&#160; And i’ve also noticed that people were coming to my site with search keywords like “agatha vs nservicebus”.&#160; The thing is, they are hardly comparable.</p>
<p>Agatha is a Request/Response Service Layer framework.&#160; It basically supports synchronous and asynchronous Request/Response style communication and tries to make it as easy as possible to write a service layer for that type of communication.&#160; Apart from being easy to use, it also encourages a clean implementation of your service layer and a way to minimize the repetitiveness of cross-cutting concerns.&#160; It also enables you to get better performance than with typical Remote Procedure Call or Remote Method Invocation style service layers because it will try to minimize roundtrips by batching requests and responses together.&#160; In the next release, it will also offer a caching layer so certain requests (depending on how you set it up) don’t need to be processed and cached responses can simply be returned.&#160; There’s also support for one-way requests (or fire-and-forget requests) but it has the same downsides as one-way requests with typical WCF services have. That’s pretty much all it does.&#160; That’s probably all it’ll ever do.&#160; In short, it’s just an upgrade over your typical WCF services.</p>
<p>NServiceBus on the other hand also does Request/Response, but that’s just one of the things it can do.&#160; Again, Agatha is essentially an RPC or RMI framework whereas NServiceBus is built on top of one-way messaging technology.&#160; This allows for much more possibilities when it comes to communicating between different applications or different parts or processes within the same application boundary.&#160; A great overview of those possibilities can be found <a href="http://nservicebus.com/ArchitecturalPrinciples.aspx" target="_blank">here</a>.&#160; Because it is based on messaging, there are a lot of benefits that you can get from NServiceBus that you’ll probably never get from Agatha.&#160; For one, the ‘Store &amp; Forward’ messaging model from NServiceBus might seem similar to Agatha’s one-way requests on first sight, but there are some very important differences.&#160; If you send a fire-and-forget request with Agatha, and the service is currently down, then that request is essentially lost.&#160; With NServiceBus, the message is stored in a message queue and it will be processed when the target of the fire-and-forget message comes up again.&#160; From a reliability point of view, that’s obviously a tremendous improvement over what Agatha can offer you.&#160; Another area where NServiceBus truly shines (IMO) is in its <a href="http://en.wikipedia.org/wiki/Publish_subscribe" target="_blank">Publish/Subscribe</a> implementation.&#160; Some people have asked me if i’ll ever provide something like that in Agatha and the answer has always been ‘no’.&#160;&#160; For one, it doesn’t fit into what Agatha tries to do and i don’t see the point in implementing it if a better implementation is available already in another project.&#160;&#160; There’s plenty more interesting things in NServiceBus to deal with more advanced scenarios, which you’ll have to find out about on your own <img src='http://davybrion.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>So which one is more suitable for you or your applications? As with every technology choice, it depends.&#160; Agatha is great for most typical business applications.&#160; If you need to communicate between one or more different clients (with different i don’t mean multiple instances but different types of clients like a web app, a silverlight client and/or a WPF client) and<em> one </em>service (you can obviously use it with more than one service as well if you want to) on an application server which encapsulates your business layer then it is a very attractive solution, as long as you don’t need the superior reliability that NServiceBus can offer you.&#160; With superior reliability i particularly mean the ability to still process received messages once the service layer comes back up after having been unavailable.&#160; In my experience, most business applications don’t really need that, since most of those applications are entirely unusable if the service they depend on is down.&#160; In short, if all the possible downsides of using a WCF service layer are not an issue for your project, then Agatha will be a great fit.</p>
<p>If however, you need to maximize reliability, performance and general robustness of a critical enterprise application, then NServiceBus will definitely be a much better choice.&#160; If you’re dealing with many distributed parts, NServiceBus will also make things much easier for you than Agatha (or any other WCF service layer for that matter) will.&#160;&#160; And obviously, if you want to integrate multiple applications while reducing coupling between applications as much as possible, NServiceBus will also be a much better fit than Agatha.&#160; With NServiceBus, you’d only need to share an assembly containing the types of the messages.&#160; With Agatha, you either need to share an assembly with shared request/response types or use proxies for them <em>and</em> you would also have to <em>know</em> about the other applications since you’d need to access their services directly.&#160; This can get quite ugly pretty fast.</p>
<p>And in some cases, you can just use both of them at the same time.&#160; At work we have two projects that use Agatha for all of their internal communication within their own application boundary, yet they use NServiceBus to notify each other of certain events.&#160; Neither of the applications knows about the existence of the other… the only thing they share is one assembly with some shared message types.&#160; We’ve also started working on a new platform where each application in the platform will use Agatha for all of the communication within their own application boundary (since they’re all typical silverlight clients backed by a WCF service style applications) but they will use NServiceBus for every kind of communication that goes outside of the application boundary.</p>
<p>As with many things, it’s just a matter of choosing the right tool for the right job.&#160; Hopefully, this post will help some of you make that decision should you need to make it in the future <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/Mre5wx7_5znYbE6FSsBFuSbgp5Y/0/da"><img src="http://feedads.g.doubleclick.net/~a/Mre5wx7_5znYbE6FSsBFuSbgp5Y/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/Mre5wx7_5znYbE6FSsBFuSbgp5Y/1/da"><img src="http://feedads.g.doubleclick.net/~a/Mre5wx7_5znYbE6FSsBFuSbgp5Y/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/davybrion?a=IloL4pASAKI:IYHmSLbJyxk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/davybrion?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/davybrion?a=IloL4pASAKI:IYHmSLbJyxk:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/davybrion?i=IloL4pASAKI:IYHmSLbJyxk:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/davybrion/~4/IloL4pASAKI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://davybrion.com/blog/2010/01/agatha-vs-nservicebus/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://davybrion.com/blog/2010/01/agatha-vs-nservicebus/</feedburner:origLink></item>
		<item>
		<title>Highly Recommended Book: Debug It!</title>
		<link>http://feedproxy.google.com/~r/davybrion/~3/FdCQMrmZfTU/</link>
		<comments>http://davybrion.com/blog/2010/01/highly-recommended-book-debug-it/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 06:03:57 +0000</pubDate>
		<dc:creator>Davy Brion</dc:creator>
				<category><![CDATA[Books]]></category>

		<guid isPermaLink="false">http://davybrion.com/blog/?p=2223</guid>
		<description><![CDATA[I’m not the best debugger out there, but i usually manage to get to the bottom of things and sometimes i even enjoy chasing down a weird bug.&#160; And while i actively try to avoid bugs as much as possible, i’m also always looking to learn more techniques or practices to efficiently find and fix [...]]]></description>
			<content:encoded><![CDATA[<p>I’m not the best debugger out there, but i usually manage to get to the bottom of things and sometimes i even enjoy chasing down a weird bug.&#160; And while i actively try to avoid bugs as much as possible, i’m also always looking to learn more techniques or practices to efficiently find and fix bugs when they do occur.&#160; So when i first heard about Paul Butcher’s <a href="http://www.amazon.com/Debug-Repair-Prevent-Pragmatic-Programmers/dp/193435628X/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1264250644&amp;sr=8-1" target="_blank">Debug It</a>, i immediately preordered it.&#160; And now that i’ve read it, i’m very glad i did.</p>
<p>The book is divided in 3 parts.&#160; The chapters of the first part explain in depth what kind of debugging strategy you’ll need.&#160; Discussed topics include:</p>
<ul>
<li>figuring out what you’re really looking for </li>
<li>tips and tricks to come up with a reliable reproduction of the bug and the value of having that reproduction </li>
<li>diagnosing the <em>actual</em> problem </li>
<li>coming up with a <em>true</em> fix </li>
<li>reflecting on why the bug ever got into the software</li>
<li>making sure that the bug can’t come back and that we learn from the mistake</li>
</ul>
<p>For some of you, most of this stuff will just be common sense.&#160; For a lot of developers though, this part alone should be considered required reading.&#160; It’s a complete process of how to deal with bugs efficiently in less than 80 pages!&#160; Think about that for a second: 80 pages that <em>will</em> improve your efficiency at your job and will reduce the amount of time you spend doing something you probably don’t like doing.&#160; How could you resist?</p>
<p>The second part is pretty short (only 2 chapters) but pretty interesting as well.&#160; It mostly deals with organizational patterns and practices that a development shop should take into account.&#160; It covers things such as:</p>
<ul>
<li>
<div align="left">the importance of bug tracking</div>
</li>
<li>
<div align="left">what makes a good bug report</div>
</li>
<li>
<div align="left">effective communication with users and support staff</div>
</li>
<li>
<div align="left">giving priority to bugs as soon as they’re discovered</div>
</li>
<li>
<div align="left">the importance of pragmatic zero-tolerance for bugs</div>
</li>
<li>
<div align="left">ways to get out of a Quality Hole</div>
</li>
</ul>
<p align="left">Not all developers will like the second part, but it definitely contains some valuable information for technical managers, or for developers who need to convince their technical managers <img src='http://davybrion.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p align="left">The third part of the book deals with a lot of various strategies for a variety of specific situations.&#160; While not everyone will get something out of every topic discussed in this part, odds are that quite a few of them will indeed be interesting for you.&#160; You’ll find specific advice for quite a few special cases (performance, concurrency, backwards compatibility, third-party bugs, etc…).&#160; You’ll also find the obligatory chapter on creating an ideal debugging environment with automated tests, a build system and continuous integration.&#160; If you’re reading this blog, you’re hopefully already convinced of the values of such things so you might want to skip this chapter.&#160; The final 2 chapters are again very interesting… They’ll show you how you can write software that will debug itself.&#160; While not everyone will actually go out and do this, some ideas of that chapter should definitely be kept in mind by most of us.&#160; The final chapter deals with some common (mostly organizational) anti-patterns for dealing with bugs.</p>
<p align="left">All in all, there is just a lot of tremendously valuable information in this book.&#160; And it’s only about 190 pages so it definitely won’t take you a long time to read it.&#160; I’ve frequently been amazed at the inability of developers to efficiently debug issues when they occur.&#160; And i’m not just talking about bad developers.&#160; I’ve seen plenty of good or even great developers having trouble with debugging efficiently.&#160; This book would definitely get them on the right track, with just a little bit effort.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/irwr0HY-6bzUxftykGNkDhtdRRQ/0/da"><img src="http://feedads.g.doubleclick.net/~a/irwr0HY-6bzUxftykGNkDhtdRRQ/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/irwr0HY-6bzUxftykGNkDhtdRRQ/1/da"><img src="http://feedads.g.doubleclick.net/~a/irwr0HY-6bzUxftykGNkDhtdRRQ/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/davybrion?a=FdCQMrmZfTU:B13UA2Pa4Eo:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/davybrion?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/davybrion?a=FdCQMrmZfTU:B13UA2Pa4Eo:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/davybrion?i=FdCQMrmZfTU:B13UA2Pa4Eo:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/davybrion/~4/FdCQMrmZfTU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://davybrion.com/blog/2010/01/highly-recommended-book-debug-it/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://davybrion.com/blog/2010/01/highly-recommended-book-debug-it/</feedburner:origLink></item>
		<item>
		<title>I Still Have Low Expectations For Visual Studio 2010</title>
		<link>http://feedproxy.google.com/~r/davybrion/~3/ybKWMSeCM1w/</link>
		<comments>http://davybrion.com/blog/2010/01/i-still-have-low-expectations-for-visual-studio-2010/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 11:46:39 +0000</pubDate>
		<dc:creator>Davy Brion</dc:creator>
				<category><![CDATA[IDE]]></category>

		<guid isPermaLink="false">http://davybrion.com/blog/2010/01/i-still-have-low-expectations-for-visual-studio-2010/</guid>
		<description><![CDATA[Last month i told you i had very low expectations for Visual Studio 2010 from a performance point of view.&#160; Luckily, i was not alone as many people complained about it.&#160; Microsoft has been working hard on the performance of VS2010 ever since.&#160; Today i read a new post from Brian Harry about the results [...]]]></description>
			<content:encoded><![CDATA[<p>Last month i told you i had <a href="http://davybrion.com/blog/2009/12/very-low-expectations-for-visual-studio-2010/" target="_blank">very low expectations for Visual Studio 2010</a> from a performance point of view.&#160; Luckily, i was not alone as many people complained about it.&#160; Microsoft has been working hard on the performance of VS2010 ever since.&#160; Today i read a <a href="http://blogs.msdn.com/bharry/archive/2010/01/24/state-of-vs-2010-performance.aspx" target="_blank">new post</a> from Brian Harry about the results of their performance improvements.</p>
<p>Some quotes that make me cringe:</p>
<blockquote><p>The performance is acceptable now and I would consider the product generally shippable…</p>
</blockquote>
<p>Acceptable? One of the originally stated goals for Visual Studio 2010 was better performance over 2008.&#160; At this point, it should be more than acceptable IMO!</p>
<blockquote><p>I&#8217;ve been running the SLCTP3 for about 3.5 hours today and its been amazing. Previously I would have crashed at least 2 times and had insane perf issues.</p>
</blockquote>
<p>I can only hope that it runs without crashing and insane performance issues for those of us who are using it 8 hours (or more) a day…</p>
<blockquote><p>I&#8217;d say the performance is about equal or maybe slightly better in some scenarios than VS2008.</p>
</blockquote>
<p>I find this very disappointing… again, it was supposed to be faster than VS2008</p>
<blockquote><p>VS2008 still feels snappier when compared side-by-side on the same VM, but the performance doesn&#8217;t bother me in this build of VS2010.</p>
</blockquote>
<p>I’m glad it doesn’t bother Brian, but i sure as hell would prefer that the new version is at least faster and snappier than the previous version</p>
<blockquote><p>Build time is 10-15% longer for the same solution compared to 2008</p>
</blockquote>
<p>Excuse me? Build time in 2008 is already ridiculously slow for large solutions… the fact that it has gotten slower <em>on the same hardware</em> is simply unacceptable</p>
<blockquote><p>Compilation of WPF project is &gt;500% slower on VS 2010 SLCTP 3</p>
</blockquote>
<p>Wow… just wow</p>
<blockquote><p>Intellisense pop-ups are slow to pop up</p>
</blockquote>
<p>It’s not like we need those to be fast, right?</p>
<p>For those of you who think i’m making a big deal out of this, you might be right.&#160; But i’m often working with large solutions and i frequently have multiple instances of VS running at the same time.&#160; The performance of VS2008 is at times embarrassingly bad and to think that VS2010 is not going to improve this, and likely even make the situation worse is something that i can’t really be happy about.&#160; </p>
<p>Can’t we just get a Visual Studio 2008 Service Pack with support for .NET 4.0 instead?</p>

<p><a href="http://feedads.g.doubleclick.net/~a/2xemgRWGmhkV19TxrN0S5TeLODo/0/da"><img src="http://feedads.g.doubleclick.net/~a/2xemgRWGmhkV19TxrN0S5TeLODo/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/2xemgRWGmhkV19TxrN0S5TeLODo/1/da"><img src="http://feedads.g.doubleclick.net/~a/2xemgRWGmhkV19TxrN0S5TeLODo/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/davybrion?a=ybKWMSeCM1w:qnuKIINRyaw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/davybrion?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/davybrion?a=ybKWMSeCM1w:qnuKIINRyaw:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/davybrion?i=ybKWMSeCM1w:qnuKIINRyaw:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/davybrion/~4/ybKWMSeCM1w" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://davybrion.com/blog/2010/01/i-still-have-low-expectations-for-visual-studio-2010/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		<feedburner:origLink>http://davybrion.com/blog/2010/01/i-still-have-low-expectations-for-visual-studio-2010/</feedburner:origLink></item>
		<item>
		<title>As A Movement, ALT.NET Has Been Dead For A While</title>
		<link>http://feedproxy.google.com/~r/davybrion/~3/zDhumdeC8xc/</link>
		<comments>http://davybrion.com/blog/2010/01/as-a-movement-alt-net-has-been-dead-for-a-while/#comments</comments>
		<pubDate>Sun, 24 Jan 2010 15:06:58 +0000</pubDate>
		<dc:creator>Davy Brion</dc:creator>
				<category><![CDATA[ALT.NET]]></category>
		<category><![CDATA[Opinions]]></category>

		<guid isPermaLink="false">http://davybrion.com/blog/2010/01/as-a-movement-alt-net-has-been-dead-for-a-while/</guid>
		<description><![CDATA[Quite a few posts have been written lately on the state of the ALT.NET community, or movement or whatever else you want to consider or call it.&#160; I’ve always thought of ALT.NET in 3 ways.

it is a mindset 
it is a community 
there is a movement 

The ALT.NET mindset was originally described perfectly by Dave [...]]]></description>
			<content:encoded><![CDATA[<p>Quite a few posts have been written lately on the state of the ALT.NET community, or movement or whatever else you want to consider or call it.&#160; I’ve always thought of ALT.NET in 3 ways.</p>
<ol>
<li>it is a mindset </li>
<li>it is a community </li>
<li>there is a movement </li>
</ol>
<p>The ALT.NET mindset was originally described perfectly by <a href="http://laribee.com/blog/2007/04/10/altnet/" target="_blank">Dave Laribee</a>:</p>
<blockquote><ol>
<li>You’re the type of developer who uses what works while keeping an eye out for a better way. </li>
<li>You reach outside the mainstream to adopt the best of any community: Open Source, Agile, Java, Ruby, etc. </li>
<li>You’re not content with the status quo. Things can always be better expressed, more elegant and simple, more mutable, higher quality, etc. </li>
<li>You know tools are great, but they only take you so far. It’s the principles and knowledge that really matter. The best tools are those that embed the knowledge and encourage the principles (e.g. Resharper.) </li>
</ol>
</blockquote>
<p>This mindset still lives on, and will always stay alive. There will always be .NET developers that are continuously looking for better ways to create software.&#160; We might not think there are enough of them, but they are still growing gradually.&#160; Typical ALT.NET topics, practices and principles have become much more popular and more and more people are definitely still looking to learn about them.&#160; I can’t think of a single reason why this would ever cease to happen.</p>
<p>As a community, ALT.NET hasn’t done a good job (IMO) of being accessible to new-comers.&#160; I’ve complained about this <a href="http://davybrion.com/blog/2008/08/why-the-altnet-community-needs-to-change-their-ways/" target="_blank">in August 2008</a>.&#160; Nothing changed after that post, and nothing will change after this post either.&#160; A lot of the people in the ALT.NET community are still too negative in expressing their views, or have even stopped trying altogether.&#160; Some of them just attacked everyone who disagreed with them.&#160; Things like that will obviously never, ever lead to adoption of your thoughts and ideas.&#160; And after that, they’d complain that nobody was listening anyway and that they were tired of trying to discuss these things with people who didn’t believe in it yet. It also doesn’t help that quite a few people got involved purely for the sake of bettering themselves.&#160; After all, the ALT.NET name was hot and being associated with it and getting involved with it was an easy way to improve your reputation, status and for some even their finances.</p>
<p>As a movement, we’ve failed as well.&#160; Essentially, the ALT.NET movement is about education.&#160; Teaching people the things we believe in.&#160; Showing them that there are better ways to develop software than that what is more accepted in the Microsoft world.&#160; In the early stages of the movement, there was a tremendous amount of interesting blog posts being written with exactly that purpose in mind.&#160; Teaching people.&#160; Showing them the benefits.&#160; Explaining things to them.&#160;&#160; After a while though, some of those bloggers didn’t quite put the same effort into it anymore.&#160; A lot of them resorted to one-liners about why approach A is better than approach B and they weren’t really taking the time anymore to try to educate people.&#160; The rise of Twitter certainly didn’t help either since you simply can’t teach this stuff to people through 140-character tweets.&#160; You can’t really show them the benefit of whatever it is that you think is a good thing to do.&#160; And since a lot of those bloggers are spending more of their time on Twitter than on working on their blogs nowadays, a lot of valuable knowledge and experience isn’t being spread as much anymore as it used to.&#160; Now obviously, we can’t tell people how to spend their time so if those people prefer to spend time on Twitter instead of writing good posts that could help more people, that is their personal choice and nobody can blame them for that.&#160;&#160; At the same time, they can’t really complain about the current state of ALT.NET as a movement and a community either.</p>
<p>But hey, the mindset still lives and will continue on living.&#160; The best thing you can do is to share your knowledge and experience with as many people that want to hear it.&#160; And trust me, there are quite a few people who want to hear it.&#160; </p>

<p><a href="http://feedads.g.doubleclick.net/~a/3hwA4FHXHPmdg_Q1HGsi_Uz8Ixk/0/da"><img src="http://feedads.g.doubleclick.net/~a/3hwA4FHXHPmdg_Q1HGsi_Uz8Ixk/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/3hwA4FHXHPmdg_Q1HGsi_Uz8Ixk/1/da"><img src="http://feedads.g.doubleclick.net/~a/3hwA4FHXHPmdg_Q1HGsi_Uz8Ixk/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/davybrion?a=zDhumdeC8xc:YOF1OIVkrVk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/davybrion?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/davybrion?a=zDhumdeC8xc:YOF1OIVkrVk:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/davybrion?i=zDhumdeC8xc:YOF1OIVkrVk:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/davybrion/~4/zDhumdeC8xc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://davybrion.com/blog/2010/01/as-a-movement-alt-net-has-been-dead-for-a-while/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://davybrion.com/blog/2010/01/as-a-movement-alt-net-has-been-dead-for-a-while/</feedburner:origLink></item>
		<item>
		<title>Inversion Of Control Containers And Factories Aren’t Mutually Exclusive</title>
		<link>http://feedproxy.google.com/~r/davybrion/~3/ra-JpWLOUL0/</link>
		<comments>http://davybrion.com/blog/2010/01/inversion-of-control-containers-and-factories-arent-mutually-exclusive/#comments</comments>
		<pubDate>Sat, 23 Jan 2010 15:14:45 +0000</pubDate>
		<dc:creator>Davy Brion</dc:creator>
				<category><![CDATA[Dependency Injection]]></category>
		<category><![CDATA[Inversion Of Control]]></category>

		<guid isPermaLink="false">http://davybrion.com/blog/?p=2224</guid>
		<description><![CDATA[Julian Birch recently posted a reaction to my reaction to Uncle Bob’s IOC lunacy post.&#160; Julian mistakenly thinks that i have a problem with using factories.&#160; I definitely don’t have a problem with using factories.&#160; I just have a problem with using them in the manner that Uncle Bob suggested in his post.&#160; Jeffrey Palermo [...]]]></description>
			<content:encoded><![CDATA[<p>Julian Birch recently posted a <a href="http://www.colourcoding.net/Blog/archive/2010/01/19/dependency-reversi.aspx" target="_blank">reaction</a> to <a href="http://davybrion.com/blog/2010/01/dependency-injection-inversion-rejection/" target="_blank">my reaction to Uncle Bob’s IOC lunacy post</a>.&#160; Julian mistakenly thinks that i have a problem with using factories.&#160; I definitely don’t have a problem with using factories.&#160; I just have a problem with using them in the manner that Uncle Bob suggested in his post.&#160; Jeffrey Palermo also recently posted <a href="http://jeffreypalermo.com/blog/constructor-over-injection-anti-pattern/" target="_blank">an example</a> of where he thinks using a factory is better than injecting dependencies.&#160; I wanted to react to both those posts with a real-world example of where i prefer to use a factory and how i use an IOC container to do so.</p>
<p>As you probably know by now, i’m a big proponent of using IOC containers.&#160; I’ve never stated that they should be used in every single application, but using one certainly pays off in most applications, especially as complexity increases gradually.&#160; When you use an IOC container, you’ll have much less need for factories.&#160;&#160; There are however two situations where i certainly prefer to use a factory.&#160; And that is when:</p>
<ol>
<li>a certain dependency might not always be used by a class <em>and</em> that dependency is expensive to create </li>
<li>i might need multiple instances of a dependency during the lifetime of a class </li>
</ol>
<p>A good example of both those situations is when using <a href="http://code.google.com/p/agatha-rrsl/" target="_blank">Agatha</a>’s AsyncRequestDispatcher class from a Silverlight user control.&#160; Creating an AsyncRequestDispatcher is expensive because it in turn requires an instance of the AsyncRequestProcessorProxy class.&#160; The AsyncRequestProcessorProxy class inherits from WCF’s ClientBase class, and those types are relatively expensive to create.&#160;&#160; And due to the asynchronous nature of those service calls, you can never deterministically dispose of a AsyncRequestDispatcher instance with absolute certainty that it won’t be disposed <em>before</em> the response of the service call is returned from the service.&#160; Because of that, the AsyncRequestDispatcher class was designed to dispose of itself automatically once the response is returned.&#160; This effectively means that you’ll need a new instance of AsyncRequestDispatcher whenever you need to make an asynchronous call to an Agatha service.&#160; </p>
<p>For most user controls, it obviously doesn’t make sense to inject one instance of the AsyncRequestDispatcher into the user control because you often need to make multiple service calls depending on user interactions or other events.&#160;&#160; A good way to deal with this is obviously to ask a factory to create the AsyncRequestDispatcher whenever you need one.&#160;&#160; Which is why Agatha offers the AsyncRequestDispatcherFactory class, which looks 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">interface</span> <span style="color: #2b91af">IAsyncRequestDispatcherFactory</span></p>
<p style="margin: 0px">&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #2b91af">IAsyncRequestDispatcher</span> CreateAsyncRequestDispatcher();</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: #2b91af">AsyncRequestDispatcherFactory</span> : <span style="color: #2b91af">IAsyncRequestDispatcherFactory</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: #2b91af">IAsyncRequestDispatcher</span> CreateAsyncRequestDispatcher()</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: #2b91af">IoC</span>.Container.Resolve&lt;<span style="color: #2b91af">IAsyncRequestDispatcher</span>&gt;();</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;&#160;&#160; }</p>
</p></div>
<p>&#160;</p>
<p>Now, some of you are probably thinking: what is the difference between this and Uncle Bob’s example?&#160; Well, unlike Uncle Bob’s example this factory is not responsible for registering the required components to create an AsyncRequestDispatcher with the container.&#160; It merely resolves an instance and returns it.&#160; And yes, it uses the container to do so.&#160;&#160; I could actually just new up an AsyncRequestDispatcher myself but then the factory would also have to <em>know</em> about its dependencies and make sure it’d be able to create them.&#160; If those dependencies have dependencies of their own, i’m back to dealing with dependencies manually which is exactly what i’m trying to avoid throughout my codebase.</p>
<p>I can’t come up with a single reason why this would be wrong, but some of you probably will so feel free to point out those reasons <img src='http://davybrion.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The benefit of this factory is that it enables me to delay the instantiation of an expensive dependency, and it also enables me to get more than one instance if i need to during the lifetime of a single object.&#160; At the same time, it doesn’t have <em>any</em> of the downsides of Uncle Bob’s approach.&#160; Also, this approach is something that you won’t need to resort to throughout your codebase, it’s more for edge-cases.</p>
<p>Now, how do we use this factory?&#160; Instead of new’ing the factory manually like Jeffrey does in his example, the factory is registered with the IOC container and i simply inject the factory into the class that needs to use it.&#160; This still enables me to change implementations of both the factory as well as the instances the factory needs to create.&#160; And it also makes it easy to stub or mock the factory during tests.&#160; I get all of the benefits from using Dependency Injection and an IOC container, and i have yet to notice any downsides to this approach.&#160; But again, i only use this approach in the 2 situations i mentioned in the beginning of this post.&#160; In most cases, you really don’t need factories anymore.&#160; And when you do, just leverage your IOC container to make the factory as simple and dumb as possible.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/Kd1hwbpejbPsIb21IkkMFsFD624/0/da"><img src="http://feedads.g.doubleclick.net/~a/Kd1hwbpejbPsIb21IkkMFsFD624/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/Kd1hwbpejbPsIb21IkkMFsFD624/1/da"><img src="http://feedads.g.doubleclick.net/~a/Kd1hwbpejbPsIb21IkkMFsFD624/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/davybrion?a=ra-JpWLOUL0:ZLpJ-AaEeT8:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/davybrion?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/davybrion?a=ra-JpWLOUL0:ZLpJ-AaEeT8:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/davybrion?i=ra-JpWLOUL0:ZLpJ-AaEeT8:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/davybrion/~4/ra-JpWLOUL0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://davybrion.com/blog/2010/01/inversion-of-control-containers-and-factories-arent-mutually-exclusive/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		<feedburner:origLink>http://davybrion.com/blog/2010/01/inversion-of-control-containers-and-factories-arent-mutually-exclusive/</feedburner:origLink></item>
		<item>
		<title>Do You Know What’s Really Going On?</title>
		<link>http://feedproxy.google.com/~r/davybrion/~3/tS8x6CaI3sQ/</link>
		<comments>http://davybrion.com/blog/2010/01/do-you-know-whats-really-going-on/#comments</comments>
		<pubDate>Wed, 20 Jan 2010 07:52:00 +0000</pubDate>
		<dc:creator>Davy Brion</dc:creator>
				<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://davybrion.com/blog/?p=2202</guid>
		<description><![CDATA[I recently showed the following picture and asked you what it showed:

Matt Hidinger pretty much nailed it in the comments:
Well it appears to have something to do with Efferent Coupling at the Type Level (http://www.ndepend.com/Metrics.aspx#TypeCe) — simply meaning the number of types that a class directly depends on.
So it appears that you’re aiming for less [...]]]></description>
			<content:encoded><![CDATA[<p>I recently showed the following picture and asked you what it showed:</p>
<p><a href="http://davybrion.com/pictures/DoYouKnowWhatsReallyGoingOn_F8AE/Capture.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Capture" border="0" alt="Capture" src="http://davybrion.com/pictures/DoYouKnowWhatsReallyGoingOn_F8AE/Capture_thumb.png" width="644" height="409" /></a></p>
<p><a href="http://www.matthidinger.com/" target="_blank">Matt Hidinger</a> pretty much nailed it in the comments:</p>
<blockquote><p>Well it appears to have something to do with Efferent Coupling at the Type Level (<a href="http://www.ndepend.com/Metrics.aspx#TypeCe">http://www.ndepend.com/Metrics.aspx#TypeCe</a>) — simply meaning the number of types that a class directly depends on.</p>
<p>So it appears that you’re aiming for less than 20 direct type dependencies and highlighting classes with more than 35 deps.</p>
<p>I imagine this is a view of a particular namespace, but I’m not sure on that.</p>
</blockquote>
<p>I mentioned in the comments that i’d write more about it soon, so here it is.&#160; That screenshot comes from a product (called <a href="http://www.itemsolutions.com/products/glance" target="_blank">Glance</a>) that <a href="http://www.itemsolutions.com" target="_blank">we</a> initially developed for internal use, because a lot of the people at our company are well, addicted to data.&#160; I guess we got tired of looking at numbers at some point so we decided to spruce things up a little.&#160; Let’s walk through an example, shall we?</p>
<p>In my case, i’m interested in code metrics.&#160; Well, some of them at least.&#160; The following picture shows a high level view on the status (or health) of some code metrics for a particular project:</p>
<p><a href="http://davybrion.com/pictures/DoYouKnowWhatsReallyGoingOn_F8AE/01.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="01" border="0" alt="01" src="http://davybrion.com/pictures/DoYouKnowWhatsReallyGoingOn_F8AE/01_thumb.png" width="509" height="172" /></a></p>
<p>Their names aren’t being shown correctly yet, but the metrics that are shown are the following: Association Between Classes, Cyclomatic Complexity, Depth Of Inheritance, Effererent Coupling and Number Of Lines Of Code.&#160; Notice their colors.&#160; They can range from green (which is good) to red (which is bad).&#160; Again, i’m looking at these metrics on a project level so the colors that are shown here represent the average status of each specific metric for the entire project. In this particular image, you can see that the Cyclomatic Complexity color is starting to turn a bit yellowish.&#160; When you hover over the metric, you get to see the following:</p>
<p>&#160;<a href="http://davybrion.com/pictures/DoYouKnowWhatsReallyGoingOn_F8AE/02.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="02" border="0" alt="02" src="http://davybrion.com/pictures/DoYouKnowWhatsReallyGoingOn_F8AE/02_thumb.png" width="475" height="484" /></a></p>
<p>As the description of this particular metric says, the goal is to get a value of 0.2 which would result in a status of +1.&#160; 0.4 would be neutral so that’s 0 and anything greater than 0.6 would be –1.&#160; The color ranges from red to green based on the status (-1 = red, +1 = green). For this particular project, the <em>average</em> <em>value</em> of all types is 0.5649<em>.&#160; </em>This is sort of confusing, because you’d think that it should be close to red but the <em>average status</em> is 0.3587 and that is what the color is based on.&#160; Now, if the average value is close to red yet the average status is green, it means that there are probably some classes that have a very high score (for this metric, that’s obviously very bad) and they have a heavy influence on the average.&#160; The average status however, is not impacted in this case.&#160; At this point, we’re still not quite sure whether the color should be based on the average status, or the average value but that’s a minor detail which isn’t important for this post <img src='http://davybrion.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Anyway, when i click on the metric i get the following screen:</p>
<p><a href="http://davybrion.com/pictures/DoYouKnowWhatsReallyGoingOn_F8AE/03.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="03" border="0" alt="03" src="http://davybrion.com/pictures/DoYouKnowWhatsReallyGoingOn_F8AE/03_thumb.png" width="644" height="350" /></a></p>
<p>This shows a circle for each top-level namespace in the project.&#160; Each circle is colored based on the average status of the types within that namespace.&#160; As you can see, some of them are green, and some are yellow.&#160; What you don’t see in this screenshot is that those circles are all floating around the center circle (which represents the parent level of this view) in a 3D view.&#160; I rotated the view to make it as clear as possible where the circles are located.&#160; When you hover over one of the circles, you’ll again see the value and the status of the namespace that is represented by that circle.</p>
<p><a href="http://davybrion.com/pictures/DoYouKnowWhatsReallyGoingOn_F8AE/04.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="04" border="0" alt="04" src="http://davybrion.com/pictures/DoYouKnowWhatsReallyGoingOn_F8AE/04_thumb.png" width="644" height="353" /></a></p>
<p>Obviously, you can do this with each circle in the view:</p>
<p>&#160;<a href="http://davybrion.com/pictures/DoYouKnowWhatsReallyGoingOn_F8AE/05.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="05" border="0" alt="05" src="http://davybrion.com/pictures/DoYouKnowWhatsReallyGoingOn_F8AE/05_thumb.png" width="363" height="386" /></a></p>
<p>This namespace isn’t even close to green, so we really ought to check out what’s going on.&#160; When i click on it, i drill-down into the data again, and i get to see the namespaces and classes that are in the EMS.Silverlight.Common namespace.</p>
<p><a href="http://davybrion.com/pictures/DoYouKnowWhatsReallyGoingOn_F8AE/06.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="06" border="0" alt="06" src="http://davybrion.com/pictures/DoYouKnowWhatsReallyGoingOn_F8AE/06_thumb.png" width="644" height="282" /></a></p>
<p>The EMS.Silverlight.Common.Controls.Tooltip namespace seems to be in the worst shape, so i click on it again.</p>
<p>&#160;<a href="http://davybrion.com/pictures/DoYouKnowWhatsReallyGoingOn_F8AE/07.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="07" border="0" alt="07" src="http://davybrion.com/pictures/DoYouKnowWhatsReallyGoingOn_F8AE/07_thumb.png" width="644" height="337" /></a></p>
<p>Oops.&#160; We have two classes that are pretty red.&#160; I guess we’ve identified a good candidate for refactoring <img src='http://davybrion.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>&#160;<a href="http://davybrion.com/pictures/DoYouKnowWhatsReallyGoingOn_F8AE/08.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="08" border="0" alt="08" src="http://davybrion.com/pictures/DoYouKnowWhatsReallyGoingOn_F8AE/08_thumb.png" width="349" height="383" /></a></p>
<p>To wrap up the screenshot bonanza i’ve got going on here, here’s a picture of the Lines Of Code metric in a large web application.&#160; It clearly shows that there are 4 parts that we really need to look at for large classes, while the rest of it doesn’t really warrant any attention at this time.</p>
<p><a href="http://davybrion.com/pictures/DoYouKnowWhatsReallyGoingOn_F8AE/09.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="09" border="0" alt="09" src="http://davybrion.com/pictures/DoYouKnowWhatsReallyGoingOn_F8AE/09_thumb.png" width="509" height="484" /></a></p>
<p>Now, as cool as those screenshots are (at least, i certainly think so) they aren’t really the coolest part of all this.&#160; First of all, you might be wondering “who on earth goes to all this trouble to develop a tool to look at code metrics like this?”.&#160; Well, as a company we are kinda “out there” but we’re definitely not <em>that far</em> “out there”.&#160; It would be ridiculous to develop something like this purely to look at code metrics.</p>
<p>Instead, we can use this for pretty much any kind of data.&#160; The tool doesn’t even know it’s showing code metrics.&#160; It is just showing data from a data warehouse where we’ve defined dimensions and hierarchies, like Assembly -&gt; Namespace -&gt; Type in the above example, to define the context for some <a href="http://en.wikipedia.org/wiki/Performance_indicator" target="_blank">Key Performance Indicators</a> (KPI’s).&#160; The actual code metrics come from nightly NDepend builds that we run for each of our projects.&#160; The data is imported in our warehouse and then we can look at it with this tool due to the KPI’s that we’ve defined.</p>
<p>So basically, pretty much everything is possible as long as you can get the data in your warehouse and define some KPI’s for that data.&#160; I only showed you code metrics in this post, but we use it for a lot more than that.&#160;&#160; Some examples include Holiday Acceptance (which manager is the fastest or slowest in approving holidays), Aging Invoices (which customers are always late with payments), Project Revenue (which projects do we make the most money on), Issues (who fixes bugs the fastest? who creates the most or the fewest bugs?), etc…</p>
<p>And you really can get all of that data from everywhere… in our case, we get a lot of data from our <a href="http://www.itemsolutions.com/products/productsems" target="_blank">EMS</a> system and obviously from <a href="http://davybrion.com/blog/2008/11/genesis-bridging-the-gap-between-requirement-and-code/" target="_blank">Genesis</a> as well.&#160; We also get data from NDepend (as you’ve seen in this post), from TeamCity (anything build-related), Subversion, whatever you want basically.&#160; Obviously, you’re not limited to looking at the data in the ‘circle view’.&#160; You can get traditional graphs as well.&#160; For instance:</p>
<p><a href="http://davybrion.com/pictures/DoYouKnowWhatsReallyGoingOn_F8AE/image.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://davybrion.com/pictures/DoYouKnowWhatsReallyGoingOn_F8AE/image_thumb.png" width="632" height="367" /></a> </p>
<p>This is global view of all requested changes for all of our projects (both commercial projects for customers as our internal applications).</p>
<p>The following picture shows the average lead time for issues that we had in 2009 based on the type of issue:</p>
<p><a href="http://davybrion.com/pictures/DoYouKnowWhatsReallyGoingOn_F8AE/image_3.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://davybrion.com/pictures/DoYouKnowWhatsReallyGoingOn_F8AE/image_thumb_3.png" width="632" height="343" /></a> </p>
<p>Finally, an overview of the time we spend on global task types:</p>
<p><a href="http://davybrion.com/pictures/DoYouKnowWhatsReallyGoingOn_F8AE/image_4.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://davybrion.com/pictures/DoYouKnowWhatsReallyGoingOn_F8AE/image_thumb_4.png" width="632" height="373" /></a> </p>
<p>Note that we do very little up-front design, and our continuous/evolutionary design is obviously a part of our regular Development tasks.&#160; And i’m sure you can understand that this kind of data is very helpful when we need to make estimations for new projects.&#160; We have a very good view on the amount of overhead that we typically have for project management, for instance.</p>
<p>One of the biggest benefits (IMO anyway) is that with the way the data is visualized (especially with the circle view), everyone can easily look at the data and see where more attention is required.&#160; I don’t know a lot about finances but i know that red circles are bad.&#160; My boss doesn’t know anything about good code, but even he now has a pretty good view on the quality of our code and he actually likes coming up to some of our guys to say “wow, class X in your project really could use some attention huh?”.</p>
<p>And today i heard that one of our customers who’s already using this is apparently learning quite a lot about their business because of this tool.&#160; They also put <em>a lot</em> of data in their warehouse and they are learning in advance where they need to improve their business processes before those things really become a problem because of what <a href="http://www.itemsolutions.com/products/glance" target="_blank">Glance</a> is showing them.&#160; The process is actually pretty simple. If it’s green, you don’t really need to spend time on it.&#160; If it’s turning yellow or red, you probably want to investigate things and try to improve the situation before it really starts causing problems.&#160; In the future, we’re also going to add automated notifications to it.&#160; So once things start going bad, you’ll be notified of them automagically. </p>
<p>In short, you can find out what’s really going on in your organization and focus your efforts on where it truly makes sense to do so.&#160; And that, my friends, is what it’s all about.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/eWPWcb-xGql-PHWyn6CPg2lWA0g/0/da"><img src="http://feedads.g.doubleclick.net/~a/eWPWcb-xGql-PHWyn6CPg2lWA0g/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/eWPWcb-xGql-PHWyn6CPg2lWA0g/1/da"><img src="http://feedads.g.doubleclick.net/~a/eWPWcb-xGql-PHWyn6CPg2lWA0g/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/davybrion?a=tS8x6CaI3sQ:j5HTRVhBhcw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/davybrion?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/davybrion?a=tS8x6CaI3sQ:j5HTRVhBhcw:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/davybrion?i=tS8x6CaI3sQ:j5HTRVhBhcw:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/davybrion/~4/tS8x6CaI3sQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://davybrion.com/blog/2010/01/do-you-know-whats-really-going-on/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		<feedburner:origLink>http://davybrion.com/blog/2010/01/do-you-know-whats-really-going-on/</feedburner:origLink></item>
		<item>
		<title>Dependency Injection Inversion Rejection</title>
		<link>http://feedproxy.google.com/~r/davybrion/~3/u-QbGpJ3eEA/</link>
		<comments>http://davybrion.com/blog/2010/01/dependency-injection-inversion-rejection/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 08:19:38 +0000</pubDate>
		<dc:creator>Davy Brion</dc:creator>
				<category><![CDATA[Dependency Injection]]></category>
		<category><![CDATA[Inversion Of Control]]></category>

		<guid isPermaLink="false">http://davybrion.com/blog/2010/01/dependency-injection-inversion-rejection/</guid>
		<description><![CDATA[Uncle Bob has done it again.&#160; In his latest post, he actually advises people to go back to manual dependency injection instead of relying on a framework (our beloved IOC containers) to do it for us.&#160; You really ought to check out the post and his examples in particular.&#160; Done with that? Ok.
There are two [...]]]></description>
			<content:encoded><![CDATA[<p>Uncle Bob has done it again.&#160; In <a href="http://blog.objectmentor.com/articles/2010/01/17/dependency-injection-inversion" target="_blank">his latest post</a>, he actually advises people to go back to manual dependency injection instead of relying on a framework (our beloved IOC containers) to do it for us.&#160; You really ought to check out the post and his examples in particular.&#160; Done with that? Ok.</p>
<p>There are two major problems that i have with his post.&#160; The first is this one:</p>
<blockquote><p>I like this because now all the Guice is in one well understood place. I don’t have Guice all over my application. Rather, I’ve got factories that contain the Guice. Guicey factories that keep the Guice from being smeared all through my application. </p>
<p>What’s more, if I wanted to replace Guice with some other DI framework, I know exactly what classes would need to change, and how to change them. So I’ve kept Guice uncoupled from my application.</p>
</blockquote>
<p>For those of you who don’t know, Guice is an IOC container from Google.&#160; Uncle Bob doesn’t want references of an IOC container spread out throughout his application, but he doesn’t seem to mind coupling his factories with his IOC container for some reason.&#160; He seems to think that he can actually switch to a different container more easily because of this, because he would only have to modify his factories.</p>
<p>Here’s the deal.&#160; If you have more than a handful of references to your IOC container in your code (apart from the registration obviously), then you really don’t know what using an IOC container is all about.&#160; Yes, i know Uncle Bob is supposed to be a legend.&#160; Yes, i realize that i’m saying that a legend in the OO world doesn’t seem to grasp some of the most important concepts of using an IOC container.&#160; Can you really disagree with that after reading his post? </p>
<p>His whole idea of making it easier to switch to another container with his approach is ludicrous.&#160; He would have to modify every single factory that he uses, and in his trivial non-real world examples that wouldn’t be a lot to do but out here in the real world, we’d end up with a boatload of those factories and they would all have to be modified.&#160; Conversely, if you’re using an IOC container in the way it is meant to be used, you’d only have to change your registration code and the <em>one or two</em> places where you resolve something manually through the container.&#160; And that’s it.&#160; Yes, you typically only need one or two places where you use the container directly.&#160; Well, unless you’re Uncle Bob of course.</p>
<p>My other problem with his post is with the sample that he uses.&#160; It really is a very simplistic example and the approach he outlines simply does not scale when you’re dealing with large, real-world codebases.&#160; His approach might work for the size of the examples in his books, or for the code of <a href="http://fitnesse.org/" target="_blank">Fitnesse</a>, but if i were to apply his recommended approach for some of the systems that we’re working on, it would lead to a terrible mess very quickly.&#160; Not exactly what i’d have in mind when thinking of <a href="http://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1263888825&amp;sr=8-1" target="_blank">Clean Code</a>.</p>
<p>The one thing i do like about this post? Well, there are quite a few people who follow Uncle Bob blindly and can’t say a single bad thing about his thoughts/ideas/approaches.&#160; I know quite a few of them make extensive use of IOC containers and some of them are even involved in the development of these containers.&#160; Hopefully, Uncle Bob’s post will finally convince these people that blindly following <em>anyone</em> is simply never a good idea and that you have to keep a critical mindset for everything that you read, no matter who wrote it.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/KthPFrQtVFRBVLJ0qFEen0acOvs/0/da"><img src="http://feedads.g.doubleclick.net/~a/KthPFrQtVFRBVLJ0qFEen0acOvs/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/KthPFrQtVFRBVLJ0qFEen0acOvs/1/da"><img src="http://feedads.g.doubleclick.net/~a/KthPFrQtVFRBVLJ0qFEen0acOvs/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/davybrion?a=u-QbGpJ3eEA:b43sBFLscdU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/davybrion?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/davybrion?a=u-QbGpJ3eEA:b43sBFLscdU:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/davybrion?i=u-QbGpJ3eEA:b43sBFLscdU:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/davybrion/~4/u-QbGpJ3eEA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://davybrion.com/blog/2010/01/dependency-injection-inversion-rejection/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		<feedburner:origLink>http://davybrion.com/blog/2010/01/dependency-injection-inversion-rejection/</feedburner:origLink></item>
		<item>
		<title>Hey Microsoft, Our Databases Aren’t Services!</title>
		<link>http://feedproxy.google.com/~r/davybrion/~3/dlC4lRaMHlw/</link>
		<comments>http://davybrion.com/blog/2010/01/hey-microsoft-our-databases-arent-services/#comments</comments>
		<pubDate>Sun, 17 Jan 2010 17:46:11 +0000</pubDate>
		<dc:creator>Davy Brion</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Opinions]]></category>
		<category><![CDATA[WCF]]></category>

		<guid isPermaLink="false">http://davybrion.com/blog/2010/01/hey-microsoft-our-databases-arent-services/</guid>
		<description><![CDATA[Something that frequently bothers me is when people/companies create services that are basically thin layers on top of their database.&#160; The service contracts expose the typical CRUD operations for each table, and add some additional methods for specific queries etc.&#160; These kind of services will sometimes pretend to contain a bit of ‘business logic’ but [...]]]></description>
			<content:encoded><![CDATA[<p>Something that frequently bothers me is when people/companies create services that are basically thin layers on top of their database.&#160; The service contracts expose the typical CRUD operations for each table, and add some additional methods for specific queries etc.&#160; These kind of services will sometimes pretend to contain a bit of ‘business logic’ but they are essentially just a remote interface into your database with maybe a bit of extra security on top of it.&#160; They effectively turn your database into a remote service.&#160; Now if you’re anything like me, you’re probably thinking “why on earth would people do that?”</p>
<p>There are probably a few answers to that question, but one reason that can’t really be disputed is that a lot of the tooling that Microsoft offers to developers simply encourage this kind of stuff.&#160; Let’s go over a little example.</p>
<p>I wanted to see what some of Microsoft’s recommended tools would create for me if i wanted to create a Silverlight application which uses a database.&#160; Obviously, a Silverlight application can’t use a database directly so the application will need to communicate with a service.&#160; The service obviously does have access to the database.&#160; RIA Services is a solution that Microsoft seems to be pushing a lot for this specific scenario so i figured i’d give this a shot.</p>
<p>I created a RIA Services Class Library project in my solution and tried to add a ‘Domain Service Class’ (as the RIA Services templates call it) to the project.&#160; If you already have a DataContext or an ObjectContext defined within the same assembly, you can immediately select the database tables that you want to expose.&#160;&#160; So i canceled the dialog and quickly added an ADO.NET Entity Data Model to the solution for which i selected my <a href="http://www.codeplex.com/ChinookDatabase" target="_blank">Chinook</a> database.&#160; I tried to create a ‘Domain Service Class’ again and got the following window:</p>
<p><a href="http://davybrion.com/pictures/YourDatabaseIsNotAService_E97E/create_service.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="create_service" border="0" alt="create_service" src="http://davybrion.com/pictures/YourDatabaseIsNotAService_E97E/create_service_thumb.png" width="454" height="554" /></a> </p>
<p>Well, now that sure is easy isn’t it? I can immediately select all my ‘Entities’ and i can even check whether i want to be able to edit them through the service, and apparently i can also generate associated classes for metadata (which would be useful for validation according to the tooltip).&#160; I checked the Album table, and left the ‘Enable editing’ option unchecked.&#160; This created a service with the following code:</p>
<div style="font-family: consolas; background: white; color: black; font-size: 10pt">
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: green">// Implements application logic using the ChinookEntities context.</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: green">// TODO: Add your application logic to these methods or in additional methods.</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: green">// TODO: Wire up authentication (Windows/ASP.NET Forms) and uncomment the following to disable anonymous access</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: green">// Also consider adding roles to restrict access as appropriate.</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: green">// [RequiresAuthentication]</span></p>
<p style="margin: 0px">&#160;&#160;&#160; [<span style="color: #2b91af">EnableClientAccess</span>()]</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: blue">class</span> <span style="color: #2b91af">AlbumService</span> : <span style="color: #2b91af">LinqToEntitiesDomainService</span>&lt;<span style="color: #2b91af">ChinookEntities</span>&gt;</p>
<p style="margin: 0px">&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: green">// TODO: Consider</span></p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: green">// 1. Adding parameters to this method and constraining returned results, and/or</span></p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: green">// 2. Adding query methods taking different parameters.</span></p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: #2b91af">IQueryable</span>&lt;<span style="color: #2b91af">Album</span>&gt; GetAlbum()</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: blue">this</span>.ObjectContext.Album;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;&#160;&#160; }</p>
</p></div>
<p>&#160;</p>
<p>I don’t know about you, but i love those TODO statements.&#160; After all, you really do might want to <em>consider</em> constraining the resultset that could be returned by the GetAlbum method.&#160;&#160; Who knows, perhaps you have certain use cases where you don’t want <em>all</em> of the ‘entities’ in the Album <em>table</em> to be returned by your ‘domain service’<em>.</em>&#160; Hopefully, this service will be used by developers who are smart enough to realize that they should modify this method, instead of using client-side LINQ statements to filter the returned Album ‘entities’ as i’m sure we’ve all seen in too many Microsoft demo’s already.</p>
<p>It gets better if you recreate the service and check the ‘Enable editing’ option.&#160; Now you’re ‘domain service’ will also contain the following methods:</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> InsertAlbum(<span style="color: #2b91af">Album</span> album)</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">this</span>.ObjectContext.AddToAlbum(album);</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> UpdateAlbum(<span style="color: #2b91af">Album</span> currentAlbum)</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> ((currentAlbum.EntityState == <span style="color: #2b91af">EntityState</span>.Detached))</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">this</span>.ObjectContext.AttachAsModified(currentAlbum, <span style="color: blue">this</span>.ChangeSet.GetOriginal(currentAlbum));</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; }</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> DeleteAlbum(<span style="color: #2b91af">Album</span> album)</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> ((album.EntityState == <span style="color: #2b91af">EntityState</span>.Detached))</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">this</span>.ObjectContext.Attach(album);</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; <span style="color: blue">this</span>.ObjectContext.DeleteObject(album);</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
</p></div>
<p>&#160;</p>
<p>Man, this sure is easy, isn’t it? I now have a service that offers me full CRUD access to the Album table in my database.&#160; If i wanted to, i could now start implementing a screen in my Silverlight application which allows my users to list the albums, edit them, delete them, create new ones, etc… and i wouldn’t even have to change anything in my ‘service layer’.&#160;&#160; The problem is that too many developers actually will do exactly that.&#160;&#160; After all, why should they doubt any code that was generated by a tool which comes from Microsoft?&#160; If the tool can generate this, then certainly some people actually want you to use it like this, no?&#160; If not, why would it even generate code like this?</p>
<p>I’m sure this kind of stuff gets a lot of ooh’s and aah’s during the product demo’s at Microsoft events, but other than that, what good does this really bring?&#160; Is this really the way you want people to develop their services?&#160; Do you really want developers to pretty much expose the database as-is to remote clients?&#160; And those TODO statements simply won’t cut it, you know that all too well.&#160; I simply don’t think there’s any good reason to generate code like this because a lot of people will simply take it as is and use it like that directly from their client code.&#160; Oh sure, most of them will hook up the authentication but i’m willing to bet that very few people will actually put real business logic in there.&#160; Why would they?&#160; The message that a lot of people will get from the resulting code is that a service is merely a way to provide CRUD for your database tables.&#160; What’s business logic to these people?&#160; Right, the stuff they’ll implement in their presentation layer because this service doesn’t really encourage people to consider implementing it there.</p>
<p>The <em>only </em>benefit that i can see from using RIA services is that you don’t really have to deal with your service contracts, and your operation contracts or any of that stuff.&#160;&#160; No, we won’t be doing any of that.&#160; We simply use a [EnableClientAccess] attribute and we’re done!&#160; I don’t really consider that a benefit, though i can certainly understand why people would not want to deal with <a href="http://davybrion.com/blog/2009/07/why-i-dislike-classic-or-typical-wcf-usage/" target="_blank">the pain of classic WCF services</a>.&#160; RIA Services is simply a solution to the <em>wrong</em> problem.</p>
<p>I haven’t looked at ADO.NET Data Services (which will be renamed to WCF Data Services in .NET 4.0) yet, but i suppose it’ll be more of the same: something that makes it incredibly easy to create services directly on top of your database data. </p>
<p>Seriously though: who on earth actually <em>wants </em>that? </p>
<p>I have no doubt that there are some people out there that are using RIA Services in a responsible manner and are sticking by responsible architectural guidelines.&#160; I also have no doubt that those people are ignoring most of the tooling that is offered by Microsoft around it.&#160; So really, why not get rid of this kind of tooling, and spend the effort that normally goes into those tools (or anything else which encourages bad practices for that matter) on providing actual guidance to the developers of your platform?&#160; The last thing we need are more developers who think that this is ‘ok’, or projects that have been delivered based on this kind of ‘architecture’, or customers that are turned off by .NET projects because “they all have maintenance problems”.&#160; </p>

<p><a href="http://feedads.g.doubleclick.net/~a/IrJS8Lemp7j5BFFT-8MklhRbJC4/0/da"><img src="http://feedads.g.doubleclick.net/~a/IrJS8Lemp7j5BFFT-8MklhRbJC4/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/IrJS8Lemp7j5BFFT-8MklhRbJC4/1/da"><img src="http://feedads.g.doubleclick.net/~a/IrJS8Lemp7j5BFFT-8MklhRbJC4/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/davybrion?a=dlC4lRaMHlw:wFRO7aAtCLg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/davybrion?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/davybrion?a=dlC4lRaMHlw:wFRO7aAtCLg:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/davybrion?i=dlC4lRaMHlw:wFRO7aAtCLg:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/davybrion/~4/dlC4lRaMHlw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://davybrion.com/blog/2010/01/hey-microsoft-our-databases-arent-services/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		<feedburner:origLink>http://davybrion.com/blog/2010/01/hey-microsoft-our-databases-arent-services/</feedburner:origLink></item>
		<item>
		<title>Is There A Good Reason To Hide Inherited Members?</title>
		<link>http://feedproxy.google.com/~r/davybrion/~3/Rr_pDa-MrDM/</link>
		<comments>http://davybrion.com/blog/2010/01/is-there-a-good-reason-to-hide-inherited-members/#comments</comments>
		<pubDate>Sun, 17 Jan 2010 15:25:00 +0000</pubDate>
		<dc:creator>Davy Brion</dc:creator>
				<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://davybrion.com/blog/?p=2181</guid>
		<description><![CDATA[A mistake that i used to see a lot, and sometimes still do, is that developers hide inherited members in derived types.&#160; For those of you who don’t know what that means, check out the following class:

&#160;&#160;&#160; public class MyClass
&#160;&#160;&#160; {
&#160;&#160;&#160;&#160;&#160;&#160;&#160; public void DoSomething()
&#160;&#160;&#160;&#160;&#160;&#160;&#160; {
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Console.WriteLine(&#34;i&#8217;m doing something important&#34;);
&#160;&#160;&#160;&#160;&#160;&#160;&#160; }
&#160;&#160;&#160; }

&#160;
As you can see, the [...]]]></description>
			<content:encoded><![CDATA[<p>A mistake that i used to see a lot, and sometimes still do, is that developers hide inherited members in derived types.&#160; For those of you who don’t know what that means, check out the following class:</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">class</span> <span style="color: #2b91af">MyClass</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: blue">void</span> DoSomething()</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: #2b91af">Console</span>.WriteLine(<span style="color: #a31515">&quot;i&#8217;m doing something important&quot;</span>);</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;&#160;&#160; }</p>
</p></div>
<p>&#160;</p>
<p>As you can see, the DoSomething method does something important, so you as a developer should consider its behavior important as well.&#160;&#160; In some cases, you might want to add something extra to this behavior in a derived class.&#160; Some developers would do that 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">class</span> <span style="color: #2b91af">MyDerivedClass</span> : <span style="color: #2b91af">MyClass</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: blue">void</span> DoSomething()</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">base</span>.DoSomething();</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #2b91af">Console</span>.WriteLine(<span style="color: #a31515">&quot;(i&#8217;m just better at it)&quot;</span>);</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;&#160;&#160; }</p>
</p></div>
<p>&#160;</p>
<p>When they compile this, they’ll get the following warning:</p>
<p>warning CS0108: &#8216;HidingMethods.MyDerivedClass.DoSomething()&#8217; hides inherited member &#8216;HidingMethods.MyClass.DoSomething()&#8217;. Use the new keyword if hiding was intended.</p>
<p>When this occurs, either one of 4 things can happen:</p>
<ol>
<li>The developer doesn’t bother to read compiler warnings (an offense worthy of a bitchslap) and is not aware of a possible problem </li>
<li>The developer sees the warning and just adds the ‘new’ keyword to the method. </li>
<li>The developer reads the documentation to figure what this really means, and hopefully realizes his mistake.&#160; If he does, he combines this option with option 4.&#160; If he doesn’t, he goes the option 2 route. </li>
<li>The developer realizes his mistake and either makes the base method virtual and adds the override keyword to the method in the derived class, or when that’s not possible, either renames the method or thinks of a different approach. </li>
</ol>
<p>If you’re unlucky, you either end up with no modification or the method will now look 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">new</span> <span style="color: blue">public</span> <span style="color: blue">void</span> DoSomething()</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">base</span>.DoSomething();</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #2b91af">Console</span>.WriteLine(<span style="color: #a31515">&quot;(i&#8217;m just better at it)&quot;</span>);</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
</p></div>
<p>&#160;</p>
<p>Great, no more compiler warning! All is well in the world now, right?</p>
<p>Err… not really.</p>
<p>The DoSomething method of MyDerivedClass actually <em>hides</em> the original DoSomething method.&#160; </p>
<p>The following code will always produce the expected behavior:</p>
<div style="font-family: consolas; background: white; color: black; font-size: 10pt">
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">new</span> <span style="color: #2b91af">MyClass</span>().DoSomething();</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">new</span> <span style="color: #2b91af">MyDerivedClass</span>().DoSomething();</p>
</p></div>
<p>&#160;</p>
<p>That is, when the DoSomething method of an instance of MyClass is called, it will obviously execute the original DoSomething method.&#160; And if the DoSomething method of an instance of MyDerivedClass class is called <em>through a reference of MyDerivedClass</em> then it will call the ‘new’ DoSomething method.</p>
<p>The following code however, would not produce the expected behavior:</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">static</span> <span style="color: blue">void</span> DoIt(<span style="color: #2b91af">MyClass</span> subject)</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; subject.DoSomething();</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">static</span> <span style="color: blue">void</span> Main(<span style="color: blue">string</span>[] args)</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; DoIt(<span style="color: blue">new</span> <span style="color: #2b91af">MyClass</span>());&#160;&#160;&#160; </p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; DoIt(<span style="color: blue">new</span> <span style="color: #2b91af">MyDerivedClass</span>());</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: #2b91af">Console</span>.ReadLine();</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
</p></div>
<p>&#160;</p>
<p>In this example, the DoSomething method is always called through a reference of MyClass.&#160; When the DoIt method receives an instance of MyClass, the original DoSomething method will obviously be executed.&#160; What some (many?) people unfortunately aren’t aware of is that when an instance of MyDerivedClass is passed into the DoIt method, the ‘new’ DoSomething method will not be executed but only the original one will be executed.&#160; The reason is because methods that hide inherited members can only be called through references of the type, or derived types of that, that hides the inherited method.&#160; Doesn’t really sound like a fun situation to debug, right?</p>
<p>So anyways, back to my original question: is there any valid reason why you would want to do this? Or better yet, can you share a situation where you had to resort to hiding an inherited member and if so, are you happy with the solution or did you consider it a hack?&#160; And are you aware that it is essentially a bug waiting to happen?</p>
<p>So far, i have never actually <em>seen</em> a valid reason for doing this.&#160; The only reason i’ve seen so far for occurrences of hidden members was because the developers that used it simply didn’t know any better.&#160; In some cases, either me or someone else wasted debugging time on this when a piece of code that used a reference of a base class suddenly didn’t do what was expected when it was passed an instance of a derived class which hid the original method.&#160;&#160; </p>
<p>I have <em>read</em> of only one valid reason to do this, and that is if a (either virtual or non-virtual) method with the same signature is introduced outside of your control in a base class that you can’t modify (like say, a class in the .NET framework or some other 3rd party assembly that you depend on) and you want to get rid of the compiler error that you got when recompiling against the newer version of the assembly.&#160; In that case, it does make sense though i’d still say it’s going to be a future source of confusion sooner or later, and quite likely lead to a future bug as well.&#160; In that situation, i’d much rather rename the member in my class.&#160; Even if it means that consumers of my code will be forced to deal with the breaking change.&#160; After all, a simple rename will always be less work than having to debug an issue because of a hidden member.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/bEbvPnQuWP3pSw8QiAUwlutOb0I/0/da"><img src="http://feedads.g.doubleclick.net/~a/bEbvPnQuWP3pSw8QiAUwlutOb0I/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/bEbvPnQuWP3pSw8QiAUwlutOb0I/1/da"><img src="http://feedads.g.doubleclick.net/~a/bEbvPnQuWP3pSw8QiAUwlutOb0I/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/davybrion?a=Rr_pDa-MrDM:xqpPULgyjoI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/davybrion?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/davybrion?a=Rr_pDa-MrDM:xqpPULgyjoI:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/davybrion?i=Rr_pDa-MrDM:xqpPULgyjoI:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/davybrion/~4/Rr_pDa-MrDM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://davybrion.com/blog/2010/01/is-there-a-good-reason-to-hide-inherited-members/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		<feedburner:origLink>http://davybrion.com/blog/2010/01/is-there-a-good-reason-to-hide-inherited-members/</feedburner:origLink></item>
		<item>
		<title>This Is Just Not Cool</title>
		<link>http://feedproxy.google.com/~r/davybrion/~3/_RmDGzq78fQ/</link>
		<comments>http://davybrion.com/blog/2010/01/this-is-just-not-cool/#comments</comments>
		<pubDate>Fri, 15 Jan 2010 15:12:21 +0000</pubDate>
		<dc:creator>Davy Brion</dc:creator>
				<category><![CDATA[Rants]]></category>

		<guid isPermaLink="false">http://davybrion.com/blog/?p=2199</guid>
		<description><![CDATA[ 
That’s what happened when i ran the RunMeFirst.bat file that comes with the NServiceBus download.&#160; 
What if i actually need msmq_ADIntegrated?
]]></description>
			<content:encoded><![CDATA[<p><a href="http://davybrion.com/pictures/ThisIsJustNotCool_E146/not_cool.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="not_cool" border="0" alt="not_cool" src="http://davybrion.com/pictures/ThisIsJustNotCool_E146/not_cool_thumb.png" width="889" height="364" /></a> </p>
<p>That’s what happened when i ran the RunMeFirst.bat file that comes with the NServiceBus download.&#160; </p>
<p>What if i actually <em>need</em> msmq_ADIntegrated?</p>

<p><a href="http://feedads.g.doubleclick.net/~a/umPaHOdXQh5iQFz3jeGWT7KJe9o/0/da"><img src="http://feedads.g.doubleclick.net/~a/umPaHOdXQh5iQFz3jeGWT7KJe9o/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/umPaHOdXQh5iQFz3jeGWT7KJe9o/1/da"><img src="http://feedads.g.doubleclick.net/~a/umPaHOdXQh5iQFz3jeGWT7KJe9o/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/davybrion?a=_RmDGzq78fQ:yPmovBvS8pw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/davybrion?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/davybrion?a=_RmDGzq78fQ:yPmovBvS8pw:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/davybrion?i=_RmDGzq78fQ:yPmovBvS8pw:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/davybrion/~4/_RmDGzq78fQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://davybrion.com/blog/2010/01/this-is-just-not-cool/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://davybrion.com/blog/2010/01/this-is-just-not-cool/</feedburner:origLink></item>
		<item>
		<title>Career Advice For Young Developers, Part 2</title>
		<link>http://feedproxy.google.com/~r/davybrion/~3/P2juAygmgzo/</link>
		<comments>http://davybrion.com/blog/2010/01/career-advice-for-young-developers-part-2/#comments</comments>
		<pubDate>Wed, 13 Jan 2010 20:37:35 +0000</pubDate>
		<dc:creator>Davy Brion</dc:creator>
				<category><![CDATA[Opinions]]></category>

		<guid isPermaLink="false">http://davybrion.com/blog/?p=2183</guid>
		<description><![CDATA[Little over a year ago, i wrote a post which had some career advice for young software developers.  That post was mostly based on things that worked for me, but obviously also on mistakes that i had seen other people make.   Now, a large percentage of posts in my &#8216;Opinions&#8217; category are [...]]]></description>
			<content:encoded><![CDATA[<p>Little over a year ago, i wrote a post which had some <a href="http://davybrion.com/blog/2008/10/career-advice-for-young-developers/">career advice for young software developers</a>.  That post was mostly based on things that worked for me, but obviously also on mistakes that i had seen other people make.   Now, a large percentage of posts in my &#8216;Opinions&#8217; category are directed at people that i know personally, and this one is no exception.  I typically don&#8217;t mention names or actual situations in those posts, but in this post i am going to talk about a certain situation, though i won&#8217;t name names.  I am going to contact the person in question so he knows full well that this post is directed to him.  If he doesn&#8217;t like that, that&#8217;s his problem.  Hopefully, he&#8217;ll appreciate the advice though.</p>
<p>Every year we work with interns from the school that i and many of my coworkers come from.  We&#8217;ve been extremely lucky with the interns we&#8217;ve gotten from that school so far, and many of our best developers actually come from that school.  We basically expect to get really good people from them and when they do good during their internship, they usually get offered a job and most of them accept it.  Last year, we had 5 interns from that school.  Two of them are now working for us.  There was another guy who i would&#8217;ve loved to have on our staff.   This kid was 21 (maybe 22, not sure) years old, and i quickly noticed that he was exceptionally talented.  I don&#8217;t know about you guys, but i rarely get to talk with anyone who really makes a great impression on me (on a technical level) who i&#8217;m not already working with or who i&#8217;ve haven&#8217;t worked with in the past.  I was <em>very</em> impressed with this kid even before i saw his code.  He knew a lot of stuff that most of us only learn after a while, and he seemed to be a very all-round talent.</p>
<p>I was very curious to see how he would complete his internship and i was already hoping that he would be working for us once he graduated.  He took on a leadership role of his team (which admittedly, consisted only of interns) but he really managed them pretty well.   He took care of most of the technical challenges, and he made sure the others were productive in their tasks.  If he wasn&#8217;t sure of certain technical issues, he didn&#8217;t mind asking for advice or help.  The skills and the approaches he demonstrated at his age were truly exceptional in my opinion.  No matter how good you think you are right now, think back about how you were when you were 21, 22 years old.  I thought i was pretty good back then, but i didn&#8217;t even know a fraction of what i know right now.  And i don&#8217;t just mean on a technical level, but more about how businesses work, how you need to deal with people and situations, stuff like that.  Most people simply don&#8217;t have a clue about how to deal with that at that age.</p>
<p>This kid knew, though.  Not everything obviously, but at least a lot more than most people would at that age.  He&#8217;s smart, he&#8217;s talented and he knows how to apply his skills.   The one thing he doesn&#8217;t know yet, is how to deal with previous mistakes.   And that is something you only learn once you&#8217;ve been working in a professional environment for a year or two, and if you&#8217;re lucky enough that people will challenge you and confront you with your mistakes.  He may not have liked it, but i once caught him breaking the build and i told him he needed to fix it.  He said it was a problem with subversion and that something must&#8217;ve gone wrong with the commit in question.  I showed him that it was impossible that it could&#8217;ve been due to a problem with subversion and that he simply made a mistake in his commit.  And while he probably still won&#8217;t admit it, he knew that i was right and that he was wrong.  Now, there&#8217;s nothing wrong with a situation like that per se, but it was clear that he wasn&#8217;t used to a situation like that.</p>
<p>Think about it.  You&#8217;re gifted.  You&#8217;ve got a lot of talent.  You&#8217;re pretty much better than anyone you&#8217;ve ever had to deal with at school.  But the thing is, true improvement comes from learning from your mistakes, and you need to be in a situation where people aren&#8217;t afraid or too intimidated by your skills to be able to tell you when you&#8217;re wrong.  If you don&#8217;t get confronted with your own mistakes, you are going to miss out on a lot of opportunities to improve yourself.  </p>
<p>This guy made it very clear from the beginning that he wanted to pursue another degree after he graduated.  And he&#8217;s currently doing that.  The thing is, with the skills that he has, and the ability to convince other people of his skills, combined with the extra degree that i have no doubt he&#8217;ll earn this year, it&#8217;s very likely that he is going to end up with some large company in a very comfortable position.  The thing that worries me though, is that a lot of people in those kind of companies aren&#8217;t very honest with their employees.  Especially the ones they consider to be &#8216;high-potentials&#8217;.  I doubt that he&#8217;s going to be around the kind of people who are going to be honest with him when he makes mistakes (and he surely will make them, as everyone does).  And no matter how good you are, no matter how well you learn from your own mistakes, a very large part of self-improvement comes from being confronted with your mistakes by others.</p>
<p>So finally, we get to the &#8216;advice&#8217; part of the post.  To him specifically, and anyone else who recognizes himself (or herself) in a story like this i would advise the following:</p>
<ul>
<li>Do not automatically assume that a fancy position at a large company is the best situation for you.  For most of these companies, you&#8217;re only valuable as long as you&#8217;re willing to play along with <em>their</em> game.  It&#8217;s their game, their rules.  You either play along, or you fold after a while, and believe me when i tell you that it is going to end up bothering the hell out of you.</li>
<li>Learn to appreciate criticism.  If you handle it right, you&#8217;re only going to end up better from it and you will truly learn from it.</li>
<li>Status or position doesn&#8217;t mean anything if you suddenly realize you&#8217;re surrounded by idiots.</li>
<li>If you don&#8217;t really need the extra money you can make while working for people who truly couldn&#8217;t care less about you personally, you certainly don&#8217;t need to subject yourself to all of the crap that <em>will</em> come with it.</li>
</ul>

<p><a href="http://feedads.g.doubleclick.net/~a/gRTdTGp4-mmarsdTRkc-57CJbOY/0/da"><img src="http://feedads.g.doubleclick.net/~a/gRTdTGp4-mmarsdTRkc-57CJbOY/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/gRTdTGp4-mmarsdTRkc-57CJbOY/1/da"><img src="http://feedads.g.doubleclick.net/~a/gRTdTGp4-mmarsdTRkc-57CJbOY/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/davybrion?a=P2juAygmgzo:HdKHKNVjefY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/davybrion?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/davybrion?a=P2juAygmgzo:HdKHKNVjefY:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/davybrion?i=P2juAygmgzo:HdKHKNVjefY:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/davybrion/~4/P2juAygmgzo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://davybrion.com/blog/2010/01/career-advice-for-young-developers-part-2/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://davybrion.com/blog/2010/01/career-advice-for-young-developers-part-2/</feedburner:origLink></item>
		<item>
		<title>OMG! Someone Stole My Code</title>
		<link>http://feedproxy.google.com/~r/davybrion/~3/ZZsn2-KlUtM/</link>
		<comments>http://davybrion.com/blog/2010/01/omg-someone-stole-my-code/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 21:06:53 +0000</pubDate>
		<dc:creator>Davy Brion</dc:creator>
				<category><![CDATA[Opinions]]></category>

		<guid isPermaLink="false">http://davybrion.com/blog/?p=2170</guid>
		<description><![CDATA[I received an email from someone who wanted to let me know that she noticed that a coworker of her used all of the code from my Build Your Own Data Access Layer Series in their project without any notice of where it actually came from.  The code in that series was posted using [...]]]></description>
			<content:encoded><![CDATA[<p>I received an email from someone who wanted to let me know that she noticed that a coworker of her used all of the code from my <a href="http://davybrion.com/blog/2009/08/build-your-own-data-access-layer-series/">Build Your Own Data Access Layer Series</a> in their project without any notice of where it actually came from.  The code in that series was posted using the <a href="http://creativecommons.org/licenses/by/2.0/">Creative Commons Attribution license</a> which only states one simple condition:</p>
<blockquote><p>You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work).</p></blockquote>
<p>First of all, i don&#8217;t really get what this person was trying to achieve by notifying me of this.  What am i going to do about it?  Ask them to add a notice?  Should i even care about it?  I don&#8217;t, actually.  If anything, i&#8217;m glad they&#8217;re using it and i just hope that it works for them and that they don&#8217;t run into any issues with it.  If i didn&#8217;t want people using it, i shouldn&#8217;t have posted it.  And as for adding a notice&#8230; that would be nice, but it&#8217;s not going to make any difference for me whether they do or don&#8217;t.  </p>
<p>I think it&#8217;s different when you release code as an open source project.  Then i obviously do want people to respect the license, but for blog code i don&#8217;t really care what people do with it.  I did mention a license in the original post, but that&#8217;s pretty much only because some people don&#8217;t want to use it if there is no license mentioned.  Which is correct, theoretically.  But the vast majority of code that i list on this blog never has a mention of a specific license.  It&#8217;s just too much of a bother IMO, and there isn&#8217;t anything that i can realistically do about it if people use it without respecting the license anyway.</p>
<p>So for future reference: feel free to do whatever you want with any code that i post on this blog, unless of course that code comes from an open source project.  Would it be legal? No. Am i going to do something about it? No.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/U2L_jMCZZ1OJiNwJvr1v6-ADjDQ/0/da"><img src="http://feedads.g.doubleclick.net/~a/U2L_jMCZZ1OJiNwJvr1v6-ADjDQ/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/U2L_jMCZZ1OJiNwJvr1v6-ADjDQ/1/da"><img src="http://feedads.g.doubleclick.net/~a/U2L_jMCZZ1OJiNwJvr1v6-ADjDQ/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/davybrion?a=ZZsn2-KlUtM:5FeOzXQUyHg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/davybrion?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/davybrion?a=ZZsn2-KlUtM:5FeOzXQUyHg:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/davybrion?i=ZZsn2-KlUtM:5FeOzXQUyHg:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/davybrion/~4/ZZsn2-KlUtM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://davybrion.com/blog/2010/01/omg-someone-stole-my-code/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://davybrion.com/blog/2010/01/omg-someone-stole-my-code/</feedburner:origLink></item>
		<item>
		<title>Checking Whether A Method Is Overridden</title>
		<link>http://feedproxy.google.com/~r/davybrion/~3/NnsFE_HdiEg/</link>
		<comments>http://davybrion.com/blog/2010/01/checking-whether-a-method-is-overridden/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 20:05:04 +0000</pubDate>
		<dc:creator>Davy Brion</dc:creator>
				<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://davybrion.com/blog/2010/01/checking-whether-a-method-is-overridden/</guid>
		<description><![CDATA[One of the requirements for using Agatha’s Caching Layer is that your request types must override the Equals and the GetHashCode methods.&#160; In order to limit the number of questions i’m going to receive about the caching layer not working correctly the amount of time people will waste on debugging when they don’t override these [...]]]></description>
			<content:encoded><![CDATA[<p>One of the requirements for using <a href="http://davybrion.com/blog/2009/12/agathas-caching-layer-implementation-first-draft/" target="_blank">Agatha’s Caching Layer</a> is that your request types must override the Equals and the GetHashCode methods.&#160; In order to limit <strike>the number of questions i’m going to receive about the caching layer not working correctly</strike> the amount of time people will waste on debugging when they don’t override these methods, i wanted to add a check to the initialization of Agatha which makes sure that each cacheable request type indeed overrides Equals and GetHashCode.</p>
<p>I actually had to think about how i could do this, but it turned out to be very simple.&#160; The trick is basically to retrieve the MethodInfo of the method you&#8217;re interested in, and then check the declaring type of that method.&#160; If the method has been overridden, the declaring type will equal the type of the class you&#8217;re checking.&#160; If it hasn’t been overridden, the declaring type will be that of one of the base classes:</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">private</span> <span style="color: blue">static</span> <span style="color: blue">bool</span> CheckIfOverrideExists(<span style="color: #2b91af">Type</span> type, <span style="color: blue">string</span> methodName)</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> methodInfo = type.GetMethod(methodName, <span style="color: #2b91af">BindingFlags</span>.Instance | <span style="color: #2b91af">BindingFlags</span>.Public);</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">if</span> (methodInfo == <span style="color: blue">null</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">false</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> methodInfo.DeclaringType == type;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
</p></div>
<p>&#160;</p>
<p>Not sure if there’s a better way to do this (if so, please share) but for now, this is good enough for me.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/qmWzYmmVq8qu6AN3U1lieWpUUhY/0/da"><img src="http://feedads.g.doubleclick.net/~a/qmWzYmmVq8qu6AN3U1lieWpUUhY/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/qmWzYmmVq8qu6AN3U1lieWpUUhY/1/da"><img src="http://feedads.g.doubleclick.net/~a/qmWzYmmVq8qu6AN3U1lieWpUUhY/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/davybrion?a=NnsFE_HdiEg:7_lNnx66rx4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/davybrion?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/davybrion?a=NnsFE_HdiEg:7_lNnx66rx4:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/davybrion?i=NnsFE_HdiEg:7_lNnx66rx4:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/davybrion/~4/NnsFE_HdiEg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://davybrion.com/blog/2010/01/checking-whether-a-method-is-overridden/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		<feedburner:origLink>http://davybrion.com/blog/2010/01/checking-whether-a-method-is-overridden/</feedburner:origLink></item>
		<item>
		<title>Virtual Method Performance Penalty</title>
		<link>http://feedproxy.google.com/~r/davybrion/~3/tDvVbYxCulU/</link>
		<comments>http://davybrion.com/blog/2010/01/virtual-method-performance-penalty/#comments</comments>
		<pubDate>Sun, 10 Jan 2010 16:14:51 +0000</pubDate>
		<dc:creator>Davy Brion</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://davybrion.com/blog/2010/01/virtual-method-performance-penalty/</guid>
		<description><![CDATA[You often hear/read that one of the reasons why C# methods aren’t virtual by default is because of performance.&#160; Calling a virtual method is more expensive than calling a regular instance method, because the CLR has to determine the correct override to call at runtime, instead of being able to simply call the instance method [...]]]></description>
			<content:encoded><![CDATA[<p>You often hear/read that one of the reasons why C# methods aren’t virtual by default is because of performance.&#160; Calling a virtual method is more expensive than calling a regular instance method, because the CLR has to determine the correct override to call at runtime, instead of being able to simply call the instance method directly.&#160; Another reason why virtual methods are more expensive to call is because they can never be inlined.</p>
<p>Is it really that much more expensive though? I ran a little experiment and i’d like to share the results with you.</p>
<p>Suppose you have the following 2 classes:</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">class</span> <span style="color: #2b91af">MyClass</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">protected</span> <span style="color: blue">long</span> someLong;</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> IncreaseLong()</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; someLong++;</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">virtual</span> <span style="color: blue">void</span> VirtualIncreaseLong()</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; someLong++;</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: #2b91af">MyDerivedClass</span> : <span style="color: #2b91af">MyClass</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: blue">override</span> <span style="color: blue">void</span> VirtualIncreaseLong()</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; someLong += 2;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;&#160;&#160; }</p>
</p></div>
<p>&#160;</p>
<p>As you can see, there is no difference between the IncreaseLong and VirtualIncreaseLong methods, except that the latter is virtual and the former is a regular instance method.&#160; According to many people, calling VirtualIncreaseLong instead of IncreaseLong will be more expensive.&#160; I also have a derived class which overrides the VirtualIncreaseLong method with a slightly different implementation.</p>
<p>If we call these methods a bunch of times (like 1000000000 times), we should notice quite a difference according to many people.</p>
<p>I wrote the following test code which calls these methods a bunch of times, times it, and outputs the results.</p>
<div style="font-family: consolas; background: white; color: black; font-size: 10pt">
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">class</span> <span style="color: #2b91af">Program</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">const</span> <span style="color: blue">int</span> numberOfTimes = 1000000000;</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">static</span> <span style="color: blue">void</span> Main(<span style="color: blue">string</span>[] args)</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> myObject = <span style="color: blue">new</span> <span style="color: #2b91af">MyClass</span>();</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">var</span> myDerivedObject = <span style="color: blue">new</span> <span style="color: #2b91af">MyDerivedClass</span>();</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: green">// we do this so there&#8217;s no first-time performance cost while timing</span></p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; EnsureThatEverythingHasBeenJitted(myObject);</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; EnsureThatEverythingHasBeenJitted(myDerivedObject);</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; TestNormalIncreaseMethod(myObject);</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; TestVirtualIncreaseMethod(myObject);</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; TestNormalIncreaseMethod(myDerivedObject);</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; TestVirtualIncreaseMethod(myDerivedObject);</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: #2b91af">Console</span>.ReadLine();</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">static</span> <span style="color: blue">void</span> EnsureThatEverythingHasBeenJitted(<span style="color: #2b91af">MyClass</span> theObject)</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; theObject.IncreaseLong();</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; theObject.VirtualIncreaseLong();</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">static</span> <span style="color: blue">void</span> TestNormalIncreaseMethod(<span style="color: #2b91af">MyClass</span> theObject)</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: #2b91af">Console</span>.WriteLine(<span style="color: blue">string</span>.Format(<span style="color: #a31515">&quot;calling the IncreaseLong method of type {0} {1} times&quot;</span>, theObject.GetType().Name, numberOfTimes));</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">var</span> stopwatch = <span style="color: #2b91af">Stopwatch</span>.StartNew();</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">for</span> (<span style="color: blue">var</span> i = 0; i &lt; numberOfTimes; i++)</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; theObject.IncreaseLong();</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; stopwatch.Stop();</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: #2b91af">Console</span>.WriteLine(<span style="color: #a31515">&quot;Elapsed milliseconds: &quot;</span> + stopwatch.ElapsedMilliseconds);</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">static</span> <span style="color: blue">void</span> TestVirtualIncreaseMethod(<span style="color: #2b91af">MyClass</span> theObject)</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: #2b91af">Console</span>.WriteLine(<span style="color: blue">string</span>.Format(<span style="color: #a31515">&quot;calling the VirtualIncreaseLong method of type {0} {1} times&quot;</span>, theObject.GetType().Name, numberOfTimes));</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">var</span> stopwatch = <span style="color: #2b91af">Stopwatch</span>.StartNew();</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">for</span> (<span style="color: blue">var</span> i = 0; i &lt; numberOfTimes; i++)</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; theObject.VirtualIncreaseLong();</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; stopwatch.Stop();</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: #2b91af">Console</span>.WriteLine(<span style="color: #a31515">&quot;Elapsed milliseconds: &quot;</span> + stopwatch.ElapsedMilliseconds);</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;&#160;&#160; }</p>
</p></div>
<p>&#160;</p>
<p>The output of running this code might surprise you.&#160; On my machine, i got the following results when the code was compiled in debug mode:</p>
<p><a href="http://davybrion.com/blog/wp-content/uploads/2010/01/manual_compile_debug.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="manual_compile_debug" border="0" alt="manual_compile_debug" src="http://davybrion.com/blog/wp-content/uploads/2010/01/manual_compile_debug_thumb.png" width="753" height="161" /></a> </p>
<p>The difference between calling the regular instance method and the virtual method is quite small.&#160; I’d even say it’s negligible.</p>
<p>When compiling in release mode, i got the following output:</p>
<p><a href="http://davybrion.com/blog/wp-content/uploads/2010/01/manual_compile_optimized.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="manual_compile_optimized" border="0" alt="manual_compile_optimized" src="http://davybrion.com/blog/wp-content/uploads/2010/01/manual_compile_optimized_thumb.png" width="757" height="171" /></a> </p>
<p>I ran the test a bunch of times, and there was no consistent observable performance penalty when calling the virtual methods.&#160; In fact, the virtual methods often performed faster than the regular instance methods and in most cases were equally fast.&#160; I’m not claiming that virtual methods are faster than regular instance methods, but if there really was an extra <em>real-world </em>performance cost associated with virtual methods, it surely should be observable with this test code, no?</p>
<p>Obviously, this test isn’t scientific in any way.&#160; But still, i think it does show that the so called performance cost associated with virtual methods is highly overrated.&#160; There definitely will be cases where virtual methods are more expensive than regular instance methods, but i’m willing to bet that those cases are rare and that the vast majority of .NET developers will never be negatively impacted by it.&#160; </p>
<p>Side note: have you ever noticed that most people who recommend to avoid virtual methods due to their performance cost never put the same emphasis on avoiding the cost of say, frequent remote operations?&#160; Which is odd, since i wouldn’t be surprised if that would be the most common reason for performance problems with .NET applications.&#160; Then again, that’s what you get when the biggest company pushing a platform advocates meaningless performance improvements while at the same time pushing bad architectural decisions/guidelines on the world because the resulting code is supposedly easier to write, use and maintain.</p>
<p>You can download the example code <a href="http://davybrion.com/VirtualMethodsPerformance.zip" target="_blank">here</a> so you can run the test yourself.&#160; </p>

<p><a href="http://feedads.g.doubleclick.net/~a/2nym4decppC3cVxZUVRplbHzbgY/0/da"><img src="http://feedads.g.doubleclick.net/~a/2nym4decppC3cVxZUVRplbHzbgY/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/2nym4decppC3cVxZUVRplbHzbgY/1/da"><img src="http://feedads.g.doubleclick.net/~a/2nym4decppC3cVxZUVRplbHzbgY/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/davybrion?a=tDvVbYxCulU:wR91-EfZqCg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/davybrion?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/davybrion?a=tDvVbYxCulU:wR91-EfZqCg:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/davybrion?i=tDvVbYxCulU:wR91-EfZqCg:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/davybrion/~4/tDvVbYxCulU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://davybrion.com/blog/2010/01/virtual-method-performance-penalty/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		<feedburner:origLink>http://davybrion.com/blog/2010/01/virtual-method-performance-penalty/</feedburner:origLink></item>
		<item>
		<title>There’s Nothing Courageous About Being Honest About Mistakes</title>
		<link>http://feedproxy.google.com/~r/davybrion/~3/eNTgIa7DG2Q/</link>
		<comments>http://davybrion.com/blog/2010/01/theres-nothing-courageous-about-being-honest-about-mistakes/#comments</comments>
		<pubDate>Sat, 09 Jan 2010 18:46:07 +0000</pubDate>
		<dc:creator>Davy Brion</dc:creator>
				<category><![CDATA[Opinions]]></category>

		<guid isPermaLink="false">http://davybrion.com/blog/?p=2163</guid>
		<description><![CDATA[Michel Grootjans recently left the following comment on a post where i discussed a really stupid mistake i made:
Been there, done that, but never had the courage to post it.

That got me thinking.&#160; What exactly is courageous about being honest about a mistake you made?&#160; I mean, everybody makes mistakes and nobody is an exception [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://geekswithblogs.net/alternativedotnet/Default.aspx" target="_blank">Michel Grootjans</a> recently left the following comment on a <a href="http://davybrion.com/blog/2010/01/never-underestimate-your-own-stupidity" target="_blank">post</a> where i discussed a really stupid mistake i made:</p>
<blockquote><p>Been there, done that, but never had the courage to post it.</p>
</blockquote>
<p>That got me thinking.&#160; What exactly is courageous about being honest about a mistake you made?&#160; I mean, everybody makes mistakes and nobody is an exception to that.&#160; Why do so many people try to hide this fact?</p>
<p>I used to work at a large financial institution where a lot of the people weren’t very honest about mistakes they made.&#160; When things went wrong, a lot of them came up with excuses or denied outright that they had made a mistake and blamed it one someone else or on some other event.&#160; That’s one of the worst things you can do if you ask me.&#160; For one, it reduces your credibility and people will be less likely to trust whatever it is you say once they realize that you’re not entirely honest about such things.</p>
<p>One of the biggest mistakes that i made there led to learning one of my most cherished lessons.&#160; I once accidentally truncated 4 large tables in a production database.&#160; It was very early in the morning and parts of my brain must’ve still been sleeping.&#160; I knew that the database operations guys were going to spend a lot of time on trying to fix things, and that it would be a very unpleasant situation for me.&#160; When i called them, i just told them outright that i had made a really stupid mistake and that i needed their help.&#160; It was pretty obvious that they weren’t used to someone actually telling them that and to my surprise, they were very cool about it.&#160; They restored the 4 tables rather quickly and the whole situation was resolved without too many problems.&#160; I told my superior about what had happened and that it was my own stupid fault that the application was down for a few hours.&#160; He too took that rather well.&#160; From that point on, i’ve made it a habit to just be entirely honest about every mistake or screw up that i’d make.&#160; </p>
<p>For one, why on earth should i worry about what people will think of me because i made a stupid mistake?&#160; Like i said, everyone makes mistakes and as long as you don’t make too many of them too frequently, there is nothing wrong with it.&#160; And anyone who will think differently of you because of it is really just a hypocrite.&#160; In fact, most people will respect you more if you are just honest and open about it.</p>
<p>As for writing posts about them… there are a few reasons why i do that.&#160; First of all, by writing about them you are more likely to remember the mistake and you’ll hopefully won’t make it again.&#160; Secondly, it’s typically an interesting opportunity for others to learn from as well.&#160; Last but not least, by posting honestly about them i can hopefully show people that there really isn’t anything wrong with being honest about it and who knows, maybe even encourage them to do the same in the future when it happens to them.</p>
<p>But is it courageous? I don’t think so… If a certain action doesn’t justify any fear, then there’s no reason to consider doing so courageous either.</p>
<p>Oh, and if you want to read up on more of my mistakes, check out the following posts:</p>
<ul>
<li><a title="http://davybrion.com/blog/2009/01/my-2-most-cherished-mistakes/" href="http://davybrion.com/blog/2009/01/my-2-most-cherished-mistakes/" target="_blank">My 2 most cherished mistakes</a></li>
<li><a title="http://davybrion.com/blog/2008/05/how-a-simple-foreach-statement-can-waste-an-afternoon/" href="http://davybrion.com/blog/2008/05/how-a-simple-foreach-statement-can-waste-an-afternoon/" target="_blank">How a simple foreach statement can waste an afternoon</a></li>
<li><a title="http://davybrion.com/blog/2008/10/do-not-dispose-in-the-prerender-event/" href="http://davybrion.com/blog/2008/10/do-not-dispose-in-the-prerender-event/" target="_blank">Do not dispose in the prerender event</a></li>
<li><a title="http://davybrion.com/blog/2008/12/the-importance-of-releasing-your-components-through-windsor/" href="http://davybrion.com/blog/2008/12/the-importance-of-releasing-your-components-through-windsor/" target="_blank">The importance of releasing your components through Windsor</a></li>
</ul>
<p>Come to think of it, there should be plenty more of those… guess i gotta start posting about them more often <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/9aGzbD-dwhCSF-nQMhsIsdOLTek/0/da"><img src="http://feedads.g.doubleclick.net/~a/9aGzbD-dwhCSF-nQMhsIsdOLTek/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/9aGzbD-dwhCSF-nQMhsIsdOLTek/1/da"><img src="http://feedads.g.doubleclick.net/~a/9aGzbD-dwhCSF-nQMhsIsdOLTek/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/davybrion?a=eNTgIa7DG2Q:JtSg1tn1HBg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/davybrion?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/davybrion?a=eNTgIa7DG2Q:JtSg1tn1HBg:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/davybrion?i=eNTgIa7DG2Q:JtSg1tn1HBg:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/davybrion/~4/eNTgIa7DG2Q" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://davybrion.com/blog/2010/01/theres-nothing-courageous-about-being-honest-about-mistakes/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://davybrion.com/blog/2010/01/theres-nothing-courageous-about-being-honest-about-mistakes/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 0.916 seconds. --><!-- Cached page generated by WP-Super-Cache on 2010-02-04 21:27:36 -->
