<?xml version="1.0" encoding="iso-8859-1"?><!-- generator="b2evolution/4.0.3" -->
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:admin="http://webns.net/mvcb/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Architecture, Design &#38; Strategy</title>
		<link>http://blogs.lessthandot.com/index.php/Architect/</link>
		<atom:link rel="self" type="application/rss+xml" href="http://blogs.lessthandot.com/index.php/Architect/?tempskin=_rss2" />
		<description></description>
		<language>en-GB</language>
		<docs>http://blogs.law.harvard.edu/tech/rss</docs>
		<admin:generatorAgent rdf:resource="http://b2evolution.net/?v=4.0.3"/>
		<ttl>60</ttl>
				<item>
			<title>Scalability is Easy! (To Get Wrong)</title>
			<link>http://blogs.lessthandot.com/index.php/Architect/DesigningSoftware/scalability-is-easy-to-get</link>
			<pubDate>Wed, 05 Dec 2012 12:50:00 +0000</pubDate>			<dc:creator>Eli Weinstock-Herman (tarwn)</dc:creator>
			<category domain="main">Designing Software</category>			<guid isPermaLink="false">1923@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;Scalability is easy, provided you don&#039;t need it to work.&lt;/p&gt;

&lt;p&gt;Probably the number one failure of system scaling is when people dive right in and start building. No baselines, limited measurements, no analysis, just a hypothesis and a whole lot of late nights tweaking the system. With extra complexity comes extra costs, from the initial development through more expensive maintenance. Scale poorly and not only do we take on those extra complexity costs, but also the more obvious additional costs of the actual implementation (new servers, more resources, etc).&lt;/p&gt;

&lt;h2&gt;The Somewhat Contrived Example&lt;/h2&gt;

&lt;p&gt;Recently I&#039;ve been working on a system to simulate parallelizing workloads, specifically workloads that depend on external resources with rate or load thresholds. Let&#039;s use it to look at a somewhat contrived example.&lt;/p&gt;

&lt;div style=&quot;background-color: #eeeeee; padding: 1em; margin: 1em;&quot;&gt;
Note: For this post, the simulated &quot;service&quot; has a 100 request/minute limit and throttles individual clients for 15 second windows. Individual operations consist of 50ms of local processing and a single service request that has 50ms of latency and 100 ms for processing and response time. Similar results can be achieved with more realistic batch sizes and rates, the smaller values just allow me to more quickly produce samples for the blog post.
&lt;/div&gt;

&lt;p&gt;So the backstory is that I have a batch process that is running more and more slowly as we take on larger and more frequent workloads. &lt;/p&gt;

&lt;p&gt;I start by testing the batch process locally so I can see how slow it is before I make changes.&lt;/p&gt;

&lt;div style=&quot;text-align: center; font-size: .8em; color: #666666&quot;&gt;
	&lt;img src=&quot;http://tiernok.com/LTDBlog/Scalability/Graph_01.png&quot; alt=&quot;Graph - 1 Client, 60 Requests, 100rpm Limit&quot; /&gt;&lt;br /&gt;
	1 Client, 60 Requests, 100rpm
&lt;/div&gt;

&lt;p&gt;Locally it runs pretty quickly, but I&#039;m betting that parallelizing the process will give me a significant increase in speed.&lt;/p&gt;

&lt;div style=&quot;text-align: center; font-size: .8em; color: #666666&quot;&gt;
	&lt;img src=&quot;http://tiernok.com/LTDBlog/Scalability/Graph_02.png&quot; alt=&quot;Graph - 1 Client vs 30 Clients, 60 Requests, 100rpm Limit&quot; /&gt;&lt;br /&gt;
	1 Client vs 30 Clients, 60 Requests, 100rpm
&lt;/div&gt;

&lt;p&gt;Look how well that performance improved, I achieved better than a 6x improvement in performance. My job here is done. &lt;/p&gt;

&lt;p&gt;Except when I try to push this to production, I start getting a lot of errors. &lt;/p&gt;

&lt;div style=&quot;text-align: center; font-size: .8em; color: #666666&quot;&gt;
	&lt;img src=&quot;http://tiernok.com/LTDBlog/Scalability/Graph_03.png&quot; alt=&quot;Graph - 30 Clients, 300 Requests, 100rpm - 67% Failure Rate&quot; /&gt;&lt;br /&gt;
	30 Clients, 300 Requests, 100rpm - 67% Failure Rate
&lt;/div&gt;

&lt;p&gt;As it turns out, the external API my process saves the data to has a rate limit. When I exceed the allowable rate, I&#039;m throttled for a short period of time. Any requests I make during that throttle period are returned with errors indicating I&#039;m throttled.&lt;/p&gt;

&lt;p&gt;Hmm. Luckily there are a number of common patterns available to retry these types of failures. I&#039;ll add an exponential back-off retry pattern so that when I get throttled my service will retry failed requests at slower rates until the service un-throttles me. While I&#039;ve found plenty of code examples online, none of them seem to have recommendations, so I&#039;ll just use one of the sample settings they provide.&lt;/p&gt;

&lt;div style=&quot;text-align: center; font-size: .8em; color: #666666&quot;&gt;
	&lt;img src=&quot;http://tiernok.com/LTDBlog/Scalability/Graph_04.png&quot; alt=&quot;Graph - 30 Clients, 300 Requests, 100rpm, Retry Policy #1 - 7% Failure Rate&quot; /&gt;&lt;br /&gt;
	30 Clients, 300 Requests, 100rpm, Retry Policy #1 - 7% Failure Rate
&lt;/div&gt;

&lt;p&gt;Hmm, better. My failure rate has gone way down. What if I tweak the values?&lt;/p&gt;

&lt;div style=&quot;text-align: center; font-size: .8em; color: #666666&quot;&gt;
	&lt;img src=&quot;http://tiernok.com/LTDBlog/Scalability/Graph_05.png&quot; alt=&quot;Graph - 30 Clients, 300 Requests, 100rpm, Retry Policy #2 - 29% Failure Rate&quot; /&gt;&lt;br /&gt;
	30 Clients, 300 Requests, 100rpm, Retry Policy #2 - 29% Failure Rate
&lt;/div&gt;

&lt;p&gt;Oh, that was bad, I obviously was on the right track before. What if I just extend the retry amount a bit to try and knock out the last bit of errors. &lt;/p&gt;

&lt;div style=&quot;text-align: center; font-size: .8em; color: #666666&quot;&gt;
	&lt;img src=&quot;http://tiernok.com/LTDBlog/Scalability/Graph_06.png&quot; alt=&quot;Graph - 30 Clients, 300 Requests, 100rpm, Retry Policy #1B - 0% Failure Rate&quot; /&gt;&lt;br /&gt;
	30 Clients, 300 Requests, 100rpm, Retry Policy #1B - 0% Failure Rate
&lt;/div&gt;

&lt;p&gt;Ok, perfect. Now I have a system that is more than 6 times faster than the original, can be easily extended by throwing more workers at it, and is actually in a better position to handle occasional slow downs from my 3rd-party service. &lt;/p&gt;

&lt;p&gt;Success!&lt;/p&gt;

&lt;h2&gt;Where I Went Wrong&lt;/h2&gt;
&lt;p&gt;Ok, so maybe not. Over the course of my little story I went wrong in a number of places. Even though this was a contrived example, I&#039;ve watched very similar scenarios play out in a number of different organizations with real systems.&lt;/p&gt;

&lt;h3&gt;The Bottleneck&lt;/h3&gt;
&lt;p&gt;The first and most critical problem was that I didn&#039;t actually locate the bottleneck in my process, I simply tried to do more of the same. The &lt;a href=&quot;http://en.wikipedia.org/wiki/Theory_of_constraints&quot; title=&quot;Theory of Constraints at Wikipedia&quot;&gt;Theory of Constraints&lt;/a&gt; tells us that we can improve the rate of a process by identifying and exploiting the constraints. &lt;/p&gt;

&lt;p&gt;In this system, the constraint looked like it was the sequential execution of the tasks, but in reality the constraint was the time it took to call the 3rd-party API. Had we identified that bottleneck before starting, we could have approached the problem differently.&lt;/p&gt;

&lt;div style=&quot;text-align: center; font-size: .8em; color: #666666&quot;&gt;
	&lt;img src=&quot;http://tiernok.com/LTDBlog/Scalability/ProcessChange.png&quot; alt=&quot;Process - Alternative Design&quot; /&gt;&lt;br /&gt;
	Process - Alternative Design
&lt;/div&gt;

&lt;p&gt;Rather than the parallel complexity, we can modify how the tasks are executed to try and take advantage of knowing where our bottleneck is. If the API allowed us to submit several requests in a batch, this redesign would net us several orders of magnitude improvement. Another option would be to run the results of the local processing into a queue and submit requests from there at a slow trickle, using only a percentage of our API limit so as not to disrupt any other real-time operations or batch processing the system supports. Another option we could take advantage of is not starting any of our expensive 3rd-party communications until we know that the entire job can actually be processed successfully through our local process.&lt;/p&gt;

&lt;p&gt;Identifying the constraint unlocks the ability to turn the problem on it&#039;s head and achieve higher improvements, typically by orders of magnitude.&lt;/p&gt;

&lt;h3&gt;The Math Error&lt;/h3&gt;
&lt;p&gt;I concluded the scenario above by assuming I had found a good solution that also had a lot of headroom. Unfortunately what I actually did was find the ceiling. I have tuned the retry policy to 30 parallel systems, increasing that number could easily destabilize it further and cause more errors or delays. The headroom is, in fact, an illusion.&lt;/p&gt;

&lt;h3&gt;The Evolving Assumption&lt;/h3&gt;
&lt;p&gt;Somewhere along the way I found 30 clients to be a great improvement and didn&#039;t test other options. Then I made some assumptions about a retry policy. Then I tweaked that retry policy until the error rate disappeared. My assumptions made sense at the time, so I never questioned where they were leading me.&lt;/p&gt;

&lt;p&gt;When I found a winning combination for my retry rate, I didn&#039;t realize I was missing other, better options:&lt;/p&gt;

&lt;div style=&quot;text-align: center; font-size: .8em; color: #666666&quot;&gt;
	&lt;img src=&quot;http://tiernok.com/LTDBlog/Scalability/Graph_07.png&quot; alt=&quot;Graph - 30 Clients, 300 Requests, 100rpm, Retry Policy #1B vs 4A-C&quot; /&gt;&lt;br /&gt;
	30 Clients, 300 Requests, 100rpm, Retry Policy #1B vs 4A-C
&lt;/div&gt;

&lt;p&gt;What&#039;s worse, is that trail of assumptions along the way was never re-validated. I concluded with a 6.5x improvement, but is that still accurate?&lt;/p&gt;

&lt;div style=&quot;text-align: center; font-size: .8em; color: #666666&quot;&gt;
	&lt;img src=&quot;http://tiernok.com/LTDBlog/Scalability/Graph_08.png&quot; alt=&quot;Graph - 1-50 Clients, 300 Requests, 100rpm, Retry Policy #1B&quot; /&gt;&lt;br /&gt;
	1-50 Clients, 300 Requests, 100rpm, Retry Policy #1B
&lt;/div&gt;

&lt;p&gt;When I run the same settings on a range of 1 to 50 clients, we can see that I lost that original 6x improvement along the way. All I have managed to do is add complexity and some very explicit costs for those additional systems.&lt;/p&gt;

&lt;p&gt;&lt;i&gt;Note: What happened to retry policy #3? Well originally 1B was actually named 3, then I decided to update the name halfway through the post but was too lazy to update all of the completed images. Oh well.&lt;/i&gt;&lt;/p&gt;

&lt;h2&gt;Scaling the Wrong Thing&lt;/h2&gt;
&lt;p&gt;This post used fairly small numbers, had I applied a larger workload, higher throughput rates, different throttling windows, the whole problem would have turned out differently. &lt;/p&gt;

&lt;p&gt;When we set out to make a system scale, we need to identify the real scenarios we are trying to scale for and the bottlenecks that stand in our way. Blindly performance tuning can look like an improvement, but is really just a poor short term investment that often entrenches the current performance problems even more deeply. There are a lot of questions that should be asked about the intended result, responsiveness fo the system, other operations it has to support while under load, potential overlap of that load, the type of load, etc. The patterns for one system may have relevance for another, but could just as easily be completely incorrect.&lt;/p&gt;

&lt;p&gt;How hard it is to scale a system is going to depend on a lot of factors. Getting it wrong just happens to be the easiest option.&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/Architect/DesigningSoftware/scalability-is-easy-to-get&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>Scalability is easy, provided you don't need it to work.</p>

<p>Probably the number one failure of system scaling is when people dive right in and start building. No baselines, limited measurements, no analysis, just a hypothesis and a whole lot of late nights tweaking the system. With extra complexity comes extra costs, from the initial development through more expensive maintenance. Scale poorly and not only do we take on those extra complexity costs, but also the more obvious additional costs of the actual implementation (new servers, more resources, etc).</p>

<h2>The Somewhat Contrived Example</h2>

<p>Recently I've been working on a system to simulate parallelizing workloads, specifically workloads that depend on external resources with rate or load thresholds. Let's use it to look at a somewhat contrived example.</p>

<div style="background-color: #eeeeee; padding: 1em; margin: 1em;">
Note: For this post, the simulated "service" has a 100 request/minute limit and throttles individual clients for 15 second windows. Individual operations consist of 50ms of local processing and a single service request that has 50ms of latency and 100 ms for processing and response time. Similar results can be achieved with more realistic batch sizes and rates, the smaller values just allow me to more quickly produce samples for the blog post.
</div>

<p>So the backstory is that I have a batch process that is running more and more slowly as we take on larger and more frequent workloads. </p>

<p>I start by testing the batch process locally so I can see how slow it is before I make changes.</p>

<div style="text-align: center; font-size: .8em; color: #666666">
	<img src="http://tiernok.com/LTDBlog/Scalability/Graph_01.png" alt="Graph - 1 Client, 60 Requests, 100rpm Limit" /><br />
	1 Client, 60 Requests, 100rpm
</div>

<p>Locally it runs pretty quickly, but I'm betting that parallelizing the process will give me a significant increase in speed.</p>

<div style="text-align: center; font-size: .8em; color: #666666">
	<img src="http://tiernok.com/LTDBlog/Scalability/Graph_02.png" alt="Graph - 1 Client vs 30 Clients, 60 Requests, 100rpm Limit" /><br />
	1 Client vs 30 Clients, 60 Requests, 100rpm
</div>

<p>Look how well that performance improved, I achieved better than a 6x improvement in performance. My job here is done. </p>

<p>Except when I try to push this to production, I start getting a lot of errors. </p>

<div style="text-align: center; font-size: .8em; color: #666666">
	<img src="http://tiernok.com/LTDBlog/Scalability/Graph_03.png" alt="Graph - 30 Clients, 300 Requests, 100rpm - 67% Failure Rate" /><br />
	30 Clients, 300 Requests, 100rpm - 67% Failure Rate
</div>

<p>As it turns out, the external API my process saves the data to has a rate limit. When I exceed the allowable rate, I'm throttled for a short period of time. Any requests I make during that throttle period are returned with errors indicating I'm throttled.</p>

<p>Hmm. Luckily there are a number of common patterns available to retry these types of failures. I'll add an exponential back-off retry pattern so that when I get throttled my service will retry failed requests at slower rates until the service un-throttles me. While I've found plenty of code examples online, none of them seem to have recommendations, so I'll just use one of the sample settings they provide.</p>

<div style="text-align: center; font-size: .8em; color: #666666">
	<img src="http://tiernok.com/LTDBlog/Scalability/Graph_04.png" alt="Graph - 30 Clients, 300 Requests, 100rpm, Retry Policy #1 - 7% Failure Rate" /><br />
	30 Clients, 300 Requests, 100rpm, Retry Policy #1 - 7% Failure Rate
</div>

<p>Hmm, better. My failure rate has gone way down. What if I tweak the values?</p>

<div style="text-align: center; font-size: .8em; color: #666666">
	<img src="http://tiernok.com/LTDBlog/Scalability/Graph_05.png" alt="Graph - 30 Clients, 300 Requests, 100rpm, Retry Policy #2 - 29% Failure Rate" /><br />
	30 Clients, 300 Requests, 100rpm, Retry Policy #2 - 29% Failure Rate
</div>

<p>Oh, that was bad, I obviously was on the right track before. What if I just extend the retry amount a bit to try and knock out the last bit of errors. </p>

<div style="text-align: center; font-size: .8em; color: #666666">
	<img src="http://tiernok.com/LTDBlog/Scalability/Graph_06.png" alt="Graph - 30 Clients, 300 Requests, 100rpm, Retry Policy #1B - 0% Failure Rate" /><br />
	30 Clients, 300 Requests, 100rpm, Retry Policy #1B - 0% Failure Rate
</div>

<p>Ok, perfect. Now I have a system that is more than 6 times faster than the original, can be easily extended by throwing more workers at it, and is actually in a better position to handle occasional slow downs from my 3rd-party service. </p>

<p>Success!</p>

<h2>Where I Went Wrong</h2>
<p>Ok, so maybe not. Over the course of my little story I went wrong in a number of places. Even though this was a contrived example, I've watched very similar scenarios play out in a number of different organizations with real systems.</p>

<h3>The Bottleneck</h3>
<p>The first and most critical problem was that I didn't actually locate the bottleneck in my process, I simply tried to do more of the same. The <a href="http://en.wikipedia.org/wiki/Theory_of_constraints" title="Theory of Constraints at Wikipedia">Theory of Constraints</a> tells us that we can improve the rate of a process by identifying and exploiting the constraints. </p>

<p>In this system, the constraint looked like it was the sequential execution of the tasks, but in reality the constraint was the time it took to call the 3rd-party API. Had we identified that bottleneck before starting, we could have approached the problem differently.</p>

<div style="text-align: center; font-size: .8em; color: #666666">
	<img src="http://tiernok.com/LTDBlog/Scalability/ProcessChange.png" alt="Process - Alternative Design" /><br />
	Process - Alternative Design
</div>

<p>Rather than the parallel complexity, we can modify how the tasks are executed to try and take advantage of knowing where our bottleneck is. If the API allowed us to submit several requests in a batch, this redesign would net us several orders of magnitude improvement. Another option would be to run the results of the local processing into a queue and submit requests from there at a slow trickle, using only a percentage of our API limit so as not to disrupt any other real-time operations or batch processing the system supports. Another option we could take advantage of is not starting any of our expensive 3rd-party communications until we know that the entire job can actually be processed successfully through our local process.</p>

<p>Identifying the constraint unlocks the ability to turn the problem on it's head and achieve higher improvements, typically by orders of magnitude.</p>

<h3>The Math Error</h3>
<p>I concluded the scenario above by assuming I had found a good solution that also had a lot of headroom. Unfortunately what I actually did was find the ceiling. I have tuned the retry policy to 30 parallel systems, increasing that number could easily destabilize it further and cause more errors or delays. The headroom is, in fact, an illusion.</p>

<h3>The Evolving Assumption</h3>
<p>Somewhere along the way I found 30 clients to be a great improvement and didn't test other options. Then I made some assumptions about a retry policy. Then I tweaked that retry policy until the error rate disappeared. My assumptions made sense at the time, so I never questioned where they were leading me.</p>

<p>When I found a winning combination for my retry rate, I didn't realize I was missing other, better options:</p>

<div style="text-align: center; font-size: .8em; color: #666666">
	<img src="http://tiernok.com/LTDBlog/Scalability/Graph_07.png" alt="Graph - 30 Clients, 300 Requests, 100rpm, Retry Policy #1B vs 4A-C" /><br />
	30 Clients, 300 Requests, 100rpm, Retry Policy #1B vs 4A-C
</div>

<p>What's worse, is that trail of assumptions along the way was never re-validated. I concluded with a 6.5x improvement, but is that still accurate?</p>

<div style="text-align: center; font-size: .8em; color: #666666">
	<img src="http://tiernok.com/LTDBlog/Scalability/Graph_08.png" alt="Graph - 1-50 Clients, 300 Requests, 100rpm, Retry Policy #1B" /><br />
	1-50 Clients, 300 Requests, 100rpm, Retry Policy #1B
</div>

<p>When I run the same settings on a range of 1 to 50 clients, we can see that I lost that original 6x improvement along the way. All I have managed to do is add complexity and some very explicit costs for those additional systems.</p>

<p><i>Note: What happened to retry policy #3? Well originally 1B was actually named 3, then I decided to update the name halfway through the post but was too lazy to update all of the completed images. Oh well.</i></p>

<h2>Scaling the Wrong Thing</h2>
<p>This post used fairly small numbers, had I applied a larger workload, higher throughput rates, different throttling windows, the whole problem would have turned out differently. </p>

<p>When we set out to make a system scale, we need to identify the real scenarios we are trying to scale for and the bottlenecks that stand in our way. Blindly performance tuning can look like an improvement, but is really just a poor short term investment that often entrenches the current performance problems even more deeply. There are a lot of questions that should be asked about the intended result, responsiveness fo the system, other operations it has to support while under load, potential overlap of that load, the type of load, etc. The patterns for one system may have relevance for another, but could just as easily be completely incorrect.</p>

<p>How hard it is to scale a system is going to depend on a lot of factors. Getting it wrong just happens to be the easiest option.</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/Architect/DesigningSoftware/scalability-is-easy-to-get">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/Architect/DesigningSoftware/scalability-is-easy-to-get#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/Architect/?tempskin=_rss2&#38;disp=comments&#38;p=1923</wfw:commentRss>
		</item>
				<item>
			<title>Getting Flexible With NDepend 4 and CQLinq</title>
			<link>http://blogs.lessthandot.com/index.php/Architect/DesigningSoftware/getting-flexible-with-ndepend-4-and-cqlinq</link>
			<pubDate>Mon, 04 Jun 2012 10:45:00 +0000</pubDate>			<dc:creator>Alex Ullrich</dc:creator>
			<category domain="main">Designing Software</category>			<guid isPermaLink="false">1746@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;At my last job we had a non-functional attribute that another team used to decorate service methods that they consumed.  The other team was working on an alternative client to our WCF services, and they weren&#039;t on the same release schedule they needed to be able to target multiple versions of our services within a single version of their application.  Because of this requirement, they maintained a wrapper around our services that handled some of the differences   between versions.  The main use for this attribute was to foster communication between the teams, so that if we changed a decorated method we would let them know.  As I&#039;m sure anyone on this other team would tell you, we weren&#039;t always that good about communicating these changes.&lt;/p&gt;

&lt;p&gt;In an effort to make communication between teams easier we used a CQL query like this to report changes to these methods as part of our automated builds:&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;sql&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;sql&quot; id=&quot;cb18717&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;SELECT&lt;/span&gt; METHODS &lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;FROM&lt;/span&gt; NAMESPACES &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Services&amp;quot;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;WHERE&lt;/span&gt; HasAttribute &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;OPTIONAL:Services.KnownExternalClientsAttribute&amp;quot;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;AND&lt;/span&gt; CodeWasChanged&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb3015&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This was nice, but it only got us part of the way there.  This would alert us to signature changes or changes to the content of the method, but not necessarily changes to the message contracts passed in to the method.  In Pseudo-CQL the query I had in mind looks something like this:&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;sql&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;sql&quot; id=&quot;cb84695&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;SELECT&lt;/span&gt; TYPES &lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;FROM&lt;/span&gt; NAMESPACES &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Services&amp;quot;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;WHERE&lt;/span&gt; CodeWasChanged&lt;br /&gt;&lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;AND&lt;/span&gt; IsUsedBy &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;SELECT&lt;/span&gt; METHODS &lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;FROM&lt;/span&gt; NAMESPACES &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Services&amp;quot;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;WHERE&lt;/span&gt; HasAttribute &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;OPTIONAL:Services.KnownExternalClientsAttribute&amp;quot;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb76534&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This didn&#039;t work however (CQL doesn&#039;t really have support for subqueries), and I couldn&#039;t really find anything in the language that would allow us to achieve what we wanted.  NDepend 4 introduces a new linq-based replacement called CQLinq that offers a lot more flexibility, so I figured I would see if I could write the query that we needed using it.  It ended up being much easier than I thought - CQLinq gives us access to most (if not all) of the standard LINQ operators, and the same functions for querying code using attributes and history that we had with CQL.  This is the query I came up with:&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;csharp&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;csharp&quot; id=&quot;cb90371&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// &amp;lt;Name&amp;gt;Test Query for Contract Changes&amp;lt;/Name&amp;gt;&lt;/span&gt;&lt;br /&gt;warnif count &amp;gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;0&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;let decoratedMethods = from m &lt;span style=&quot;color: #0600FF;&quot;&gt;in&lt;/span&gt; JustMyCode.&lt;span style=&quot;color: #0000FF;&quot;&gt;Methods&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; where m.&lt;span style=&quot;color: #0000FF;&quot;&gt;HasAttribute&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;quot;NDependSample.TestAttribute&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;amp;&amp;amp; m.&lt;span style=&quot;color: #0000FF;&quot;&gt;ParentNamespace&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Name&lt;/span&gt; == &lt;span style=&quot;color: #808080;&quot;&gt;&amp;quot;NDependSample.Services&amp;quot;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; select m&lt;br /&gt;&amp;nbsp;&lt;br /&gt;from t &lt;span style=&quot;color: #0600FF;&quot;&gt;in&lt;/span&gt; JustMyCode.&lt;span style=&quot;color: #0000FF;&quot;&gt;Types&lt;/span&gt;&lt;br /&gt;where &amp;nbsp;t.&lt;span style=&quot;color: #0000FF;&quot;&gt;ParentNamespace&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Name&lt;/span&gt; == &lt;span style=&quot;color: #808080;&quot;&gt;&amp;quot;NDependSample.Contracts&amp;quot;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;amp;&amp;amp; t.&lt;span style=&quot;color: #0000FF;&quot;&gt;CodeWasChanged&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;amp;&amp;amp; decoratedMethods.&lt;span style=&quot;color: #0600FF;&quot;&gt;Using&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;t&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Any&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;select t&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb29564&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Once we have the query we can mark it as critical, so we will have a failing build after the changes are made.  Only the first build after making the changes should fail, but that would be enough to trigger an investigation that would result in communicating the changes to the other team.&lt;/p&gt;

&lt;p&gt;CQL has always been my favorite feature of NDepend, so its no surprise that CQLinq is my favorite feature in this new release.  The LINQ based syntax feels much more natural to me when writing queries against a codebase than the SQL-like syntax of CQL, and still gives us all the same visualization goodies to foster quick understanding of the query results.  I&#039;m really excited to dig in a little more and see what else I can do with it.&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/Architect/DesigningSoftware/getting-flexible-with-ndepend-4-and-cqlinq&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>At my last job we had a non-functional attribute that another team used to decorate service methods that they consumed.  The other team was working on an alternative client to our WCF services, and they weren't on the same release schedule they needed to be able to target multiple versions of our services within a single version of their application.  Because of this requirement, they maintained a wrapper around our services that handled some of the differences   between versions.  The main use for this attribute was to foster communication between the teams, so that if we changed a decorated method we would let them know.  As I'm sure anyone on this other team would tell you, we weren't always that good about communicating these changes.</p>

<p>In an effort to make communication between teams easier we used a CQL query like this to report changes to these methods as part of our automated builds:</p>

<div class="codebox"><div class="codeheader"><span>sql</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb7003'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb7003','cb9732'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="sql" id="cb7003" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #993333; font-weight: bold;">SELECT</span> METHODS <span style="color: #993333; font-weight: bold;">FROM</span> NAMESPACES <span style="color: #ff0000;">&quot;Services&quot;</span></li><li style="" class="li2"><span style="color: #993333; font-weight: bold;">WHERE</span> HasAttribute <span style="color: #ff0000;">&quot;OPTIONAL:Services.KnownExternalClientsAttribute&quot;</span></li><li style="" class="li1"><span style="color: #993333; font-weight: bold;">AND</span> CodeWasChanged</li></ol></div><div id="cb9732" style="display: none; color: red;"></div></div></div>

<p>This was nice, but it only got us part of the way there.  This would alert us to signature changes or changes to the content of the method, but not necessarily changes to the message contracts passed in to the method.  In Pseudo-CQL the query I had in mind looks something like this:</p>

<div class="codebox"><div class="codeheader"><span>sql</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb7453'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb7453','cb41597'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="sql" id="cb7453" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #993333; font-weight: bold;">SELECT</span> TYPES <span style="color: #993333; font-weight: bold;">FROM</span> NAMESPACES <span style="color: #ff0000;">&quot;Services&quot;</span></li><li style="" class="li2"><span style="color: #993333; font-weight: bold;">WHERE</span> CodeWasChanged</li><li style="" class="li1"><span style="color: #993333; font-weight: bold;">AND</span> IsUsedBy <span style="color: #66cc66;">&#40;</span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">SELECT</span> METHODS <span style="color: #993333; font-weight: bold;">FROM</span> NAMESPACES <span style="color: #ff0000;">&quot;Services&quot;</span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">WHERE</span> HasAttribute <span style="color: #ff0000;">&quot;OPTIONAL:Services.KnownExternalClientsAttribute&quot;</span></li><li style="" class="li2"><span style="color: #66cc66;">&#41;</span></li></ol></div><div id="cb41597" style="display: none; color: red;"></div></div></div>

<p>This didn't work however (CQL doesn't really have support for subqueries), and I couldn't really find anything in the language that would allow us to achieve what we wanted.  NDepend 4 introduces a new linq-based replacement called CQLinq that offers a lot more flexibility, so I figured I would see if I could write the query that we needed using it.  It ended up being much easier than I thought - CQLinq gives us access to most (if not all) of the standard LINQ operators, and the same functions for querying code using attributes and history that we had with CQL.  This is the query I came up with:</p>

<div class="codebox"><div class="codeheader"><span>csharp</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb31269'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb31269','cb13695'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="csharp" id="cb31269" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #008080; font-style: italic;">// &lt;Name&gt;Test Query for Contract Changes&lt;/Name&gt;</span></li><li style="" class="li2">warnif count &gt; <span style="color: #FF0000;">0</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2">let decoratedMethods = from m <span style="color: #0600FF;">in</span> JustMyCode.<span style="color: #0000FF;">Methods</span></li><li style="" class="li1">&nbsp; &nbsp; where m.<span style="color: #0000FF;">HasAttribute</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;NDependSample.TestAttribute&quot;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &amp;&amp; m.<span style="color: #0000FF;">ParentNamespace</span>.<span style="color: #0000FF;">Name</span> == <span style="color: #808080;">&quot;NDependSample.Services&quot;</span></li><li style="" class="li1">&nbsp; &nbsp; select m</li><li style="" class="li2">&nbsp;</li><li style="" class="li1">from t <span style="color: #0600FF;">in</span> JustMyCode.<span style="color: #0000FF;">Types</span></li><li style="" class="li2">where &nbsp;t.<span style="color: #0000FF;">ParentNamespace</span>.<span style="color: #0000FF;">Name</span> == <span style="color: #808080;">&quot;NDependSample.Contracts&quot;</span></li><li style="" class="li1">&nbsp; &amp;&amp; t.<span style="color: #0000FF;">CodeWasChanged</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &amp;&amp; decoratedMethods.<span style="color: #0600FF;">Using</span><span style="color: #000000;">&#40;</span>t<span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Any</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li1">select t</li></ol></div><div id="cb13695" style="display: none; color: red;"></div></div></div>

<p>Once we have the query we can mark it as critical, so we will have a failing build after the changes are made.  Only the first build after making the changes should fail, but that would be enough to trigger an investigation that would result in communicating the changes to the other team.</p>

<p>CQL has always been my favorite feature of NDepend, so its no surprise that CQLinq is my favorite feature in this new release.  The LINQ based syntax feels much more natural to me when writing queries against a codebase than the SQL-like syntax of CQL, and still gives us all the same visualization goodies to foster quick understanding of the query results.  I'm really excited to dig in a little more and see what else I can do with it.</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/Architect/DesigningSoftware/getting-flexible-with-ndepend-4-and-cqlinq">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/Architect/DesigningSoftware/getting-flexible-with-ndepend-4-and-cqlinq#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/Architect/?tempskin=_rss2&#38;disp=comments&#38;p=1746</wfw:commentRss>
		</item>
				<item>
			<title>Adding User Emulation to an Application</title>
			<link>http://blogs.lessthandot.com/index.php/Architect/DesigningSoftware/adding-user-emulation-to-an</link>
			<pubDate>Wed, 27 Apr 2011 12:57:00 +0000</pubDate>			<dc:creator>Eli Weinstock-Herman (tarwn)</dc:creator>
			<category domain="main">Designing Software</category>			<guid isPermaLink="false">1206@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;One of the tricks I picked up from my last job (and our forum software, now that I think of it) is the idea of user emulation. I could log into the application, search for a user, and, at the push of a button, temporarily become that user. The only differences between emulating them and actually logging in as them were a black bar that indicated who I am (with a link to stop emulating), all audit records continued to reflect my own user id, and I didn&#039;t need to keep track of 30 different sample accounts and passwords.&lt;/p&gt;

&lt;p&gt;As I said, it&#039;s a neat trick. &lt;/p&gt;

&lt;h2&gt;Advantages&lt;/h2&gt;
&lt;p&gt;Implemented consistently, this stops being just a trick and becomes a very powerful tool. Developers, QA, even customer service and support see benefits from being able to quickly emulate end users.&lt;/p&gt;

&lt;h3&gt;Debugging&lt;/h3&gt;
&lt;p&gt;As developers the largest benefit for us is the ability to debug our systems from a variety of viewpoints. Rather than going through the trouble of creating and managing sample users for every impacted role, we can use existing user records with real data behind them. This not only reduces the time to start debugging and remove the time involved in ongoing maintenance of test accounts, but may actually force out a few extra bugs that we wouldn&#039;t catch with a new, vanilla user account.&lt;/p&gt;

&lt;h3&gt;Support&lt;/h3&gt;
&lt;p&gt;Duplicating a bug or answering a question becomes a lot easier when we can emulate the person on the other end of the bug report or phone. We can emulate the person in our production environment and in our development environment and verify that both environments break in the same way (or that development doesn&#039;t break after we fix it). We also get firsthand clues, which can knock hours off the bug-hunting process.&lt;/p&gt;

&lt;h3&gt;Customer Service&lt;/h3&gt;
&lt;p&gt;Just as developers and support benefit on the technical side, in some cases Customer Service representatives (or selected members of the business) can use emulation to provide business or first level user support. When an end user has a complex question about an order or report, the service representative no longer needs to imagine their way through the issue, but instead can emulate that user, walk through the process, and see exactly what their user is seeing. This can be even more critical in systems where users see only a subset of the functionality or data available to service representatives.&lt;/p&gt;

&lt;h2&gt;Implementation&lt;/h2&gt;
&lt;p&gt;So emulation is a useful tool as well as a neat trick. Like many things, it is generally easier to bake this in from the beginning than to add it after the fact. If the user information is accessed in a consistent fashion in existing software, it is possible to squeeze in emulation logic and clean up the few places people cut corners and accessed users outside the normal context. If the user information is loaded and accessed at will throughout the application, adding emulation will be much harder (though there is some additional benefit in that it forces you to clean up your architecture a bit).&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Sample Session Context Class&lt;/b&gt;&lt;/p&gt;
&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;vbnet&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;vbnet&quot; id=&quot;cb75035&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;Public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Class&lt;/span&gt; SessionContext&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Private&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Property&lt;/span&gt; EmulatedUser &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; User&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Private&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Property&lt;/span&gt; LoggedInUser &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; User&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Public&lt;/span&gt; ReadOnly &lt;span style=&quot;color: #0600FF;&quot;&gt;Property&lt;/span&gt; User &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; User&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Get&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; If &lt;span style=&quot;color: #0600FF;&quot;&gt;Me&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;EmulatedUser&lt;/span&gt; IsNot &lt;span style=&quot;color: #0600FF;&quot;&gt;Nothing&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Then&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Return &lt;span style=&quot;color: #0600FF;&quot;&gt;Me&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;EmulatedUser&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Else&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Return &lt;span style=&quot;color: #0600FF;&quot;&gt;Me&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;LoggedInUser&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; If&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Get&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Property&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Public&lt;/span&gt; ReadOnly &lt;span style=&quot;color: #0600FF;&quot;&gt;Property&lt;/span&gt; IsEmulating &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; Boolean&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Get&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Return &lt;span style=&quot;color: #0600FF;&quot;&gt;Me&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;EmulatedUser&lt;/span&gt; IsNot &lt;span style=&quot;color: #0600FF;&quot;&gt;Nothing&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Get&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Property&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;&#039;&#039;&#039; &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;&#039;&#039;&#039; Property used for accessing current&#039;s users information for auditing&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;&#039;&#039;&#039; &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Public&lt;/span&gt; ReadOnly &lt;span style=&quot;color: #0600FF;&quot;&gt;Property&lt;/span&gt; UserIdForAuditing &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Integer&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Get&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; If &lt;span style=&quot;color: #0600FF;&quot;&gt;Me&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;LoggedInUser&lt;/span&gt; IsNot &lt;span style=&quot;color: #0600FF;&quot;&gt;Nothing&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Then&lt;/span&gt; Return &lt;span style=&quot;color: #0600FF;&quot;&gt;Me&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;LoggedInUser&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;UserID&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Return &lt;span style=&quot;color: #FF0000;&quot;&gt;0&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Get&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Property&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Sub&lt;/span&gt; LogInUser&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;ByVal&lt;/span&gt; newUser &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; User&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Me&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;LoggedInUser&lt;/span&gt; = newUser&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Me&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;EmulatedUser&lt;/span&gt; = &lt;span style=&quot;color: #0600FF;&quot;&gt;Nothing&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;&#039; plus other login logic stuff&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Sub&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Sub&lt;/span&gt; LogOutUser&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Me&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;LoggedInUser&lt;/span&gt; = &lt;span style=&quot;color: #0600FF;&quot;&gt;Nothing&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Me&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;EmulatedUser&lt;/span&gt; = &lt;span style=&quot;color: #0600FF;&quot;&gt;Nothing&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Sub&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Sub&lt;/span&gt; StartEmulating&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;ByVal&lt;/span&gt; selectedUser &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; User&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Me&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;EmulatedUser&lt;/span&gt; = selectedUser&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Sub&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Sub&lt;/span&gt; StopEmulating&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Me&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;EmulatedUser&lt;/span&gt; = &lt;span style=&quot;color: #0600FF;&quot;&gt;Nothing&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Sub&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Class&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb53539&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Altogether not that complex a code construct, although I&#039;m sure it will grow more so over the lifetime of the application. &lt;/p&gt;

&lt;p&gt;As long as we consistently access user information through the exposed User property in the session and user the exposed UserIdForAuditing property for auditing purposes, then most of the work is done for us. The only other piece we need is a button on the UI to start emulating and some logic to handle the danger below.&lt;/p&gt;

&lt;h2&gt;Dangers&lt;/h2&gt;
&lt;p&gt;There are two main dangers to watch for. The first danger is making sure emulation doesn&#039;t grant users the ability to promote themselves. Either emulation needs to be reserved for administrative users, or logic needs to be added to make certain levels or roles unavailable for emulation (or assignment during emulation).&lt;/p&gt;

&lt;p&gt;The other main danger is that you now have a much greater chance (probably guarantee) that you will have the same user &quot;logged in&quot; in two locations at once. Most applications handle this just fine, but there are also many that cannot. Examples of this behavior are enforcing single location sign-ons, coded security that assumes multiple location means an account has been compromised, and making the mistake of storing session data keyed only to a user id instead of a unique session.&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/Architect/DesigningSoftware/adding-user-emulation-to-an&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>One of the tricks I picked up from my last job (and our forum software, now that I think of it) is the idea of user emulation. I could log into the application, search for a user, and, at the push of a button, temporarily become that user. The only differences between emulating them and actually logging in as them were a black bar that indicated who I am (with a link to stop emulating), all audit records continued to reflect my own user id, and I didn't need to keep track of 30 different sample accounts and passwords.</p>

<p>As I said, it's a neat trick. </p>

<h2>Advantages</h2>
<p>Implemented consistently, this stops being just a trick and becomes a very powerful tool. Developers, QA, even customer service and support see benefits from being able to quickly emulate end users.</p>

<h3>Debugging</h3>
<p>As developers the largest benefit for us is the ability to debug our systems from a variety of viewpoints. Rather than going through the trouble of creating and managing sample users for every impacted role, we can use existing user records with real data behind them. This not only reduces the time to start debugging and remove the time involved in ongoing maintenance of test accounts, but may actually force out a few extra bugs that we wouldn't catch with a new, vanilla user account.</p>

<h3>Support</h3>
<p>Duplicating a bug or answering a question becomes a lot easier when we can emulate the person on the other end of the bug report or phone. We can emulate the person in our production environment and in our development environment and verify that both environments break in the same way (or that development doesn't break after we fix it). We also get firsthand clues, which can knock hours off the bug-hunting process.</p>

<h3>Customer Service</h3>
<p>Just as developers and support benefit on the technical side, in some cases Customer Service representatives (or selected members of the business) can use emulation to provide business or first level user support. When an end user has a complex question about an order or report, the service representative no longer needs to imagine their way through the issue, but instead can emulate that user, walk through the process, and see exactly what their user is seeing. This can be even more critical in systems where users see only a subset of the functionality or data available to service representatives.</p>

<h2>Implementation</h2>
<p>So emulation is a useful tool as well as a neat trick. Like many things, it is generally easier to bake this in from the beginning than to add it after the fact. If the user information is accessed in a consistent fashion in existing software, it is possible to squeeze in emulation logic and clean up the few places people cut corners and accessed users outside the normal context. If the user information is loaded and accessed at will throughout the application, adding emulation will be much harder (though there is some additional benefit in that it forces you to clean up your architecture a bit).</p>

<p><b>Sample Session Context Class</b></p>
<div class="codebox"><div class="codeheader"><span>vbnet</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb14964'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb14964','cb78126'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="vbnet" id="cb14964" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #0600FF;">Public</span> <span style="color: #0600FF;">Class</span> SessionContext</li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #0600FF;">Private</span> <span style="color: #0600FF;">Property</span> EmulatedUser <span style="color: #0600FF;">As</span> User</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #0600FF;">Private</span> <span style="color: #0600FF;">Property</span> LoggedInUser <span style="color: #0600FF;">As</span> User</li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #0600FF;">Public</span> ReadOnly <span style="color: #0600FF;">Property</span> User <span style="color: #0600FF;">As</span> User</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Get</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If <span style="color: #0600FF;">Me</span>.<span style="color: #000000;">EmulatedUser</span> IsNot <span style="color: #0600FF;">Nothing</span> <span style="color: #0600FF;">Then</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Return <span style="color: #0600FF;">Me</span>.<span style="color: #000000;">EmulatedUser</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Else</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Return <span style="color: #0600FF;">Me</span>.<span style="color: #000000;">LoggedInUser</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> If</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Get</span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Property</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #0600FF;">Public</span> ReadOnly <span style="color: #0600FF;">Property</span> IsEmulating <span style="color: #0600FF;">As</span> Boolean</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Get</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Return <span style="color: #0600FF;">Me</span>.<span style="color: #000000;">EmulatedUser</span> IsNot <span style="color: #0600FF;">Nothing</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Get</span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Property</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">''' &lt;summary&gt;</span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">''' Property used for accessing current's users information for auditing</span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">''' &lt;/summary&gt;</span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #0600FF;">Public</span> ReadOnly <span style="color: #0600FF;">Property</span> UserIdForAuditing <span style="color: #0600FF;">As</span> <span style="color: #0600FF;">Integer</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Get</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If <span style="color: #0600FF;">Me</span>.<span style="color: #000000;">LoggedInUser</span> IsNot <span style="color: #0600FF;">Nothing</span> <span style="color: #0600FF;">Then</span> Return <span style="color: #0600FF;">Me</span>.<span style="color: #000000;">LoggedInUser</span>.<span style="color: #000000;">UserID</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Return <span style="color: #FF0000;">0</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Get</span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Property</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #0600FF;">Public</span> <span style="color: #0600FF;">Sub</span> LogInUser<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">ByVal</span> newUser <span style="color: #0600FF;">As</span> User<span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Me</span>.<span style="color: #000000;">LoggedInUser</span> = newUser</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Me</span>.<span style="color: #000000;">EmulatedUser</span> = <span style="color: #0600FF;">Nothing</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">' plus other login logic stuff</span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #0600FF;">Public</span> <span style="color: #0600FF;">Sub</span> LogOutUser<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Me</span>.<span style="color: #000000;">LoggedInUser</span> = <span style="color: #0600FF;">Nothing</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Me</span>.<span style="color: #000000;">EmulatedUser</span> = <span style="color: #0600FF;">Nothing</span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #0600FF;">Public</span> <span style="color: #0600FF;">Sub</span> StartEmulating<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">ByVal</span> selectedUser <span style="color: #0600FF;">As</span> User<span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Me</span>.<span style="color: #000000;">EmulatedUser</span> = selectedUser</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #0600FF;">Public</span> <span style="color: #0600FF;">Sub</span> StopEmulating<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Me</span>.<span style="color: #000000;">EmulatedUser</span> = <span style="color: #0600FF;">Nothing</span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span></li><li style="" class="li2"><span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Class</span></li></ol></div><div id="cb78126" style="display: none; color: red;"></div></div></div>

<p>Altogether not that complex a code construct, although I'm sure it will grow more so over the lifetime of the application. </p>

<p>As long as we consistently access user information through the exposed User property in the session and user the exposed UserIdForAuditing property for auditing purposes, then most of the work is done for us. The only other piece we need is a button on the UI to start emulating and some logic to handle the danger below.</p>

<h2>Dangers</h2>
<p>There are two main dangers to watch for. The first danger is making sure emulation doesn't grant users the ability to promote themselves. Either emulation needs to be reserved for administrative users, or logic needs to be added to make certain levels or roles unavailable for emulation (or assignment during emulation).</p>

<p>The other main danger is that you now have a much greater chance (probably guarantee) that you will have the same user "logged in" in two locations at once. Most applications handle this just fine, but there are also many that cannot. Examples of this behavior are enforcing single location sign-ons, coded security that assumes multiple location means an account has been compromised, and making the mistake of storing session data keyed only to a user id instead of a unique session.</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/Architect/DesigningSoftware/adding-user-emulation-to-an">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/Architect/DesigningSoftware/adding-user-emulation-to-an#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/Architect/?tempskin=_rss2&#38;disp=comments&#38;p=1206</wfw:commentRss>
		</item>
				<item>
			<title>Why (and How) I Model</title>
			<link>http://blogs.lessthandot.com/index.php/Architect/IntroductionArchitectureDesign/why-and-how-i-model</link>
			<pubDate>Fri, 15 Oct 2010 09:20:39 +0000</pubDate>			<dc:creator>Eli Weinstock-Herman (tarwn)</dc:creator>
			<category domain="main">Introduction to Architecture &amp; Design</category>			<guid isPermaLink="false">986@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;Over my years in (and before) IT, I&#039;ve seen long projects, failed projects, confused projects, wildly successful projects, and even fun projects that ended far differently than we expected. The consistent take-away for me is that I am a big picture type of person, and that understanding that big, abstract picture cuts out a lot of wasted time sprinting down the wrong paths.&lt;/p&gt;

&lt;div style=&quot;font-size: .8em; color: #666666; text-align: center;&quot;&gt;
&lt;img src=&quot;http://tiernok.com/LTDBlog/modeling/sprint.jpg&quot; alt=&quot;Don&#039;t Sprint Blindly&quot; /&gt;&lt;br /&gt;
Don&#039;t Sprint Blindly...&lt;br /&gt;(care of &lt;a href=&quot;http://www.dmitriev.com/blog/2009-04-14/wrong-sprint-burndown/&quot;&gt;dmitriev.com&lt;/a&gt;)
&lt;/div&gt;

&lt;p&gt;Creating a model forces me to refine a concept down to it&#039;s simplest elements, forces me to face the unknowns that my mind has so casually been skipping over. When done well, a model communicates a clear idea and replaces not only the thousands words required to explain it, but the 9000 I would have wasted getting there.&lt;/p&gt;

&lt;p&gt;I model to think through processes, question my assumptions, and provide guidance towards a solution. While it probably looks like something I threw together in about ten minutes, there are actually a lot of processes going on behind the scenes.&lt;/p&gt;

&lt;h2&gt;Purpose - What are We Drawing?&lt;/h2&gt;
&lt;div style=&quot;float: right; font-size: .8em; color: #666666; text-align: center;&quot;&gt;
&lt;img src=&quot;http://tiernok.com/LTDBlog/modeling/dostuff.jpg&quot; title=&quot;Do Stuff!&quot; /&gt;&lt;br /&gt;
No Goal? Here&#039;s a Diagram.
&lt;/div&gt;
&lt;p&gt;As with all things, a diagram should have a goal. A model that isn&#039;t trying to communicate an idea is filler for a report no one is going to read anyway. A goal should be concise and limited to a single subject or perspective:&lt;/p&gt;
&lt;ul style=&quot;margin-left: 1em;&quot;&gt;
  &lt;li&gt;The data flow from the end customer to our master data system&lt;/li&gt;
  &lt;li&gt;An order-to-cash business process&lt;/li&gt;
  &lt;li&gt;The functional architecture of a software application&lt;/li&gt;
  &lt;li&gt;A graphic representation of our current state&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Mess around with too many factors and at the end of the day a mess is all you&#039;ll  have:&lt;/p&gt;
&lt;ul style=&quot;margin-left: 1em;&quot;&gt;
  &lt;li&gt;The physical network topology combined with the disaster recovery plan and data flows between the systems&lt;/li&gt;
  &lt;li&gt;The application architecture with defined user work flows and user experience elements&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Or to translate: gobbledygook.&lt;/p&gt;

&lt;h2&gt;Constraint - Less is More&lt;/h2&gt;
&lt;p&gt;A goal provides me with my first constraint, and constraints are good. Defining constraints will keep my model simpler and consistent, which means the end message will be clearer. At the same time, a well-defined set of constraints will encourage creativity, providing a better end product.&lt;/p&gt;

&lt;p&gt;Often my constraints will include things like not allowing connections to cross, only using a very simple set of shapes, restricting myself to only a few shades of color, or setting time limits. I&#039;ll define the perspective I want to use with my goal, whether it will be a topological map, a flow, or just a set of connected shapes. &lt;/p&gt;

&lt;p&gt;This keeps me focused instead of playing with the entire palette of colors, shapes, and page sizes available in my favorite software tools.&lt;/p&gt;

&lt;h2&gt;Content - Work on a Temporary Surface&lt;/h2&gt;
&lt;p&gt;Even with constraints and a goal, I still don&#039;t know exactly where I will end up or what I will learn along the way, so I start on the whiteboard. With a whiteboard I can start diagramming out the pieces I know, add in new items or resolve question marks as I run into them, and easily combine and rearrange my thoughts. Some of my constraints will be ineffective at this stage, but natural constraints (like the number of markers I have and the board size) will replace them in helping my creativity and thought processes.&lt;/p&gt;

&lt;p&gt;This stage is also where I figure out my wording. Because it&#039;s so easy to see the big picture (heh) on my whiteboard, I also get a good feel for when words are too specific, not specific enough, or possibly just not quite the right word for what I am trying to communicate. Instead of focusing on getting all the boxes lined up, I can focus on using clear and consistent terminology that will help support the final model rather than detract from it.&lt;/p&gt;

&lt;h2&gt;Medium - Where is it Going?&lt;/h2&gt;
&lt;div style=&quot;float: left; font-size: .8em; color: #666666; text-align: center; margin: 2em 1em 1em 1em&quot;&gt;
&lt;img src=&quot;http://tiernok.com/trent/2004_11_05_04_sm.jpg&quot; title=&quot;Content needs context&quot; /&gt;&lt;br /&gt;
Content needs Context
&lt;/div&gt;
&lt;p&gt;As I make the transition from whiteboard to diagramming software, the last piece of the equation is to consider the medium I am going to use to communicate the model. A standalone diagram may put higher priority on further simplicity of shapes and colors, where a presentation model may put lower priority on text and higher priority on subtleties for deeper conversation. &lt;/p&gt;


&lt;p&gt;Will there need to be a legend? Is font-size 8 going to be a waste of time or readable font? If I use subtle shades of color will it all print the same color or show up in gloriously rendered imagery on a 12 foot display? Will adding a cartoon get a chuckle in a presentation or a frown in an executive review? Can I include a picture of my cat?&lt;/p&gt;

&lt;p&gt;The context the diagram will be communicating in will determine the last set of constraints.&lt;/p&gt;

&lt;h2&gt;Terminology - The Wrong Word Invalidates the Model&lt;/h2&gt;
&lt;div style=&quot;float: right; font-size: .8em; color: #666666; text-align: center;&quot;&gt;
&lt;img src=&quot;http://tiernok.com/LTDBlog/modeling/van-venn-diagram.jpg&quot; title=&quot;&#039;Van&#039; Diagram&quot; /&gt;&lt;br /&gt;
Using the right terminology, &lt;br /&gt;thanks &lt;a href=&quot;http://www.lolcaption.com/random-funny/what-is-a-van-diagram-you-ask-well-let-me-show-you/&quot;&gt;lolcaption.com&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt;General wording may have been roughed in on the whiteboard and some really good words may have been chosen, but these now need to be examined in light of the future medium as well as the audience. In many cases, using a word out of context can distract my audience or even negate the model&#039;s message entirely.&lt;/p&gt;

&lt;p&gt;That being said, endless anxiety over perfection is nowhere near as good as a cool beer at the end of a work day, so we need to strike a balance between working through the night and achieving good enough. So I&#039;ll be careful, in general, when using customer terminology and try to be pragmatic in my search for the perfect name for the third box from the left.&lt;/p&gt;

&lt;h2&gt;Composition - Additional Layers of Meaning&lt;/h2&gt;
&lt;p&gt;The last stage of the model, having transferred it from whiteboard to software and applied corrections to terminology, is to add some depth that supports the initial concept. &lt;/p&gt;

&lt;p&gt;Colors, re-arranging layout to alter proximity, fonts, and even line thicknesses are all tools I use to add subtle depth to a model. If I am planning on presenting the model, I can start the discussion on the general message of the model and dive into these subtleties as the discussion progresses. A thicker line between two systems can communicate greater bandwidth or a more secure transport layer. A common shading of colors between multiple objects communicates a relationship or similarity. As with the stages before, I try to use constraint. Applying the whole palette and a different shape for each object may seem fun, but it&#039;s going to communicate confusion (and possibly a desire for medication).&lt;/p&gt;

&lt;p&gt;While working with the composition, I will also create temporary versions to play with drastically different layouts or shapes. This gives me a fresh look at a concept that has undoubtedly been on my whiteboard for days, giving me an opportunity to catch last minute holes or simply provide alternative layout options.&lt;/p&gt;

&lt;h2&gt;Sounds Like a Lot of Work...&lt;/h2&gt;
&lt;p&gt;There are different levels of work involved in modeling. In some cases even finding the time to stop doing and try to draw an idea may seem like a waste. &lt;/p&gt;
&lt;div style=&quot;float: right; font-size: .8em; color: #666666; text-align: center;&quot;&gt;
&lt;img src=&quot;http://tiernok.com/LTDBlog/modeling/lookbothways.jpg&quot; title=&quot;No Need To Look Ahead&quot; /&gt;&lt;br /&gt;
Not looking ahead?&lt;br /&gt;Diagram for that too...
&lt;/div&gt;
&lt;div style=&quot;font-size: .8em; margin: 1em;  padding: 1em;&quot;&gt;
&lt;p&gt;How do I judge when it is worth spending the time?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5 Minutes:&lt;/strong&gt; If it only takes five minutes to draw a fast diagram of what I am intending to do, then that 5 minutes didn&#039;t cost much and I can move forward with confidence.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;30 Minutes:&lt;/strong&gt; If it takes 30 minutes, I&#039;ve erased and redrawn half of it, and the person I am explaining it to is still arguing with me, then it&#039;s time to draw a model. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3 Hours:&lt;/strong&gt; If it takes 3 hours, we end with more questions than we started with, half the questions have the potential for refocusing the project, and we&#039;re still trying to figure out what to call this thing...yeah, it&#039;s definitely time to get a handle on what we&#039;re spending time on.&lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;Jumping right into any project when we can&#039;t draw a high level summary means we&#039;re spending time and resources on something we can&#039;t adequately define. It doesn&#039;t matter how fast we&#039;re moving if we&#039;re spending that time running in random directions and ignoring cross-traffic.&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/Architect/IntroductionArchitectureDesign/why-and-how-i-model&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>Over my years in (and before) IT, I've seen long projects, failed projects, confused projects, wildly successful projects, and even fun projects that ended far differently than we expected. The consistent take-away for me is that I am a big picture type of person, and that understanding that big, abstract picture cuts out a lot of wasted time sprinting down the wrong paths.</p>

<div style="font-size: .8em; color: #666666; text-align: center;">
<img src="http://tiernok.com/LTDBlog/modeling/sprint.jpg" alt="Don't Sprint Blindly" /><br />
Don't Sprint Blindly...<br />(care of <a href="http://www.dmitriev.com/blog/2009-04-14/wrong-sprint-burndown/">dmitriev.com</a>)
</div>

<p>Creating a model forces me to refine a concept down to it's simplest elements, forces me to face the unknowns that my mind has so casually been skipping over. When done well, a model communicates a clear idea and replaces not only the thousands words required to explain it, but the 9000 I would have wasted getting there.</p>

<p>I model to think through processes, question my assumptions, and provide guidance towards a solution. While it probably looks like something I threw together in about ten minutes, there are actually a lot of processes going on behind the scenes.</p>

<h2>Purpose - What are We Drawing?</h2>
<div style="float: right; font-size: .8em; color: #666666; text-align: center;">
<img src="http://tiernok.com/LTDBlog/modeling/dostuff.jpg" title="Do Stuff!" /><br />
No Goal? Here's a Diagram.
</div>
<p>As with all things, a diagram should have a goal. A model that isn't trying to communicate an idea is filler for a report no one is going to read anyway. A goal should be concise and limited to a single subject or perspective:</p>
<ul style="margin-left: 1em;">
  <li>The data flow from the end customer to our master data system</li>
  <li>An order-to-cash business process</li>
  <li>The functional architecture of a software application</li>
  <li>A graphic representation of our current state</li>
</ul>

<p>Mess around with too many factors and at the end of the day a mess is all you'll  have:</p>
<ul style="margin-left: 1em;">
  <li>The physical network topology combined with the disaster recovery plan and data flows between the systems</li>
  <li>The application architecture with defined user work flows and user experience elements</li>
</ul>

<p>Or to translate: gobbledygook.</p>

<h2>Constraint - Less is More</h2>
<p>A goal provides me with my first constraint, and constraints are good. Defining constraints will keep my model simpler and consistent, which means the end message will be clearer. At the same time, a well-defined set of constraints will encourage creativity, providing a better end product.</p>

<p>Often my constraints will include things like not allowing connections to cross, only using a very simple set of shapes, restricting myself to only a few shades of color, or setting time limits. I'll define the perspective I want to use with my goal, whether it will be a topological map, a flow, or just a set of connected shapes. </p>

<p>This keeps me focused instead of playing with the entire palette of colors, shapes, and page sizes available in my favorite software tools.</p>

<h2>Content - Work on a Temporary Surface</h2>
<p>Even with constraints and a goal, I still don't know exactly where I will end up or what I will learn along the way, so I start on the whiteboard. With a whiteboard I can start diagramming out the pieces I know, add in new items or resolve question marks as I run into them, and easily combine and rearrange my thoughts. Some of my constraints will be ineffective at this stage, but natural constraints (like the number of markers I have and the board size) will replace them in helping my creativity and thought processes.</p>

<p>This stage is also where I figure out my wording. Because it's so easy to see the big picture (heh) on my whiteboard, I also get a good feel for when words are too specific, not specific enough, or possibly just not quite the right word for what I am trying to communicate. Instead of focusing on getting all the boxes lined up, I can focus on using clear and consistent terminology that will help support the final model rather than detract from it.</p>

<h2>Medium - Where is it Going?</h2>
<div style="float: left; font-size: .8em; color: #666666; text-align: center; margin: 2em 1em 1em 1em">
<img src="http://tiernok.com/trent/2004_11_05_04_sm.jpg" title="Content needs context" /><br />
Content needs Context
</div>
<p>As I make the transition from whiteboard to diagramming software, the last piece of the equation is to consider the medium I am going to use to communicate the model. A standalone diagram may put higher priority on further simplicity of shapes and colors, where a presentation model may put lower priority on text and higher priority on subtleties for deeper conversation. </p>


<p>Will there need to be a legend? Is font-size 8 going to be a waste of time or readable font? If I use subtle shades of color will it all print the same color or show up in gloriously rendered imagery on a 12 foot display? Will adding a cartoon get a chuckle in a presentation or a frown in an executive review? Can I include a picture of my cat?</p>

<p>The context the diagram will be communicating in will determine the last set of constraints.</p>

<h2>Terminology - The Wrong Word Invalidates the Model</h2>
<div style="float: right; font-size: .8em; color: #666666; text-align: center;">
<img src="http://tiernok.com/LTDBlog/modeling/van-venn-diagram.jpg" title="'Van' Diagram" /><br />
Using the right terminology, <br />thanks <a href="http://www.lolcaption.com/random-funny/what-is-a-van-diagram-you-ask-well-let-me-show-you/">lolcaption.com</a>
</div>
<p>General wording may have been roughed in on the whiteboard and some really good words may have been chosen, but these now need to be examined in light of the future medium as well as the audience. In many cases, using a word out of context can distract my audience or even negate the model's message entirely.</p>

<p>That being said, endless anxiety over perfection is nowhere near as good as a cool beer at the end of a work day, so we need to strike a balance between working through the night and achieving good enough. So I'll be careful, in general, when using customer terminology and try to be pragmatic in my search for the perfect name for the third box from the left.</p>

<h2>Composition - Additional Layers of Meaning</h2>
<p>The last stage of the model, having transferred it from whiteboard to software and applied corrections to terminology, is to add some depth that supports the initial concept. </p>

<p>Colors, re-arranging layout to alter proximity, fonts, and even line thicknesses are all tools I use to add subtle depth to a model. If I am planning on presenting the model, I can start the discussion on the general message of the model and dive into these subtleties as the discussion progresses. A thicker line between two systems can communicate greater bandwidth or a more secure transport layer. A common shading of colors between multiple objects communicates a relationship or similarity. As with the stages before, I try to use constraint. Applying the whole palette and a different shape for each object may seem fun, but it's going to communicate confusion (and possibly a desire for medication).</p>

<p>While working with the composition, I will also create temporary versions to play with drastically different layouts or shapes. This gives me a fresh look at a concept that has undoubtedly been on my whiteboard for days, giving me an opportunity to catch last minute holes or simply provide alternative layout options.</p>

<h2>Sounds Like a Lot of Work...</h2>
<p>There are different levels of work involved in modeling. In some cases even finding the time to stop doing and try to draw an idea may seem like a waste. </p>
<div style="float: right; font-size: .8em; color: #666666; text-align: center;">
<img src="http://tiernok.com/LTDBlog/modeling/lookbothways.jpg" title="No Need To Look Ahead" /><br />
Not looking ahead?<br />Diagram for that too...
</div>
<div style="font-size: .8em; margin: 1em;  padding: 1em;">
<p>How do I judge when it is worth spending the time?</p>

<p><strong>5 Minutes:</strong> If it only takes five minutes to draw a fast diagram of what I am intending to do, then that 5 minutes didn't cost much and I can move forward with confidence.</p>

<p><strong>30 Minutes:</strong> If it takes 30 minutes, I've erased and redrawn half of it, and the person I am explaining it to is still arguing with me, then it's time to draw a model. </p>

<p><strong>3 Hours:</strong> If it takes 3 hours, we end with more questions than we started with, half the questions have the potential for refocusing the project, and we're still trying to figure out what to call this thing...yeah, it's definitely time to get a handle on what we're spending time on.</p>
</div>

<p>Jumping right into any project when we can't draw a high level summary means we're spending time and resources on something we can't adequately define. It doesn't matter how fast we're moving if we're spending that time running in random directions and ignoring cross-traffic.</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/Architect/IntroductionArchitectureDesign/why-and-how-i-model">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/Architect/IntroductionArchitectureDesign/why-and-how-i-model#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/Architect/?tempskin=_rss2&#38;disp=comments&#38;p=986</wfw:commentRss>
		</item>
				<item>
			<title>CQL From Visual Studio With NDepend 3</title>
			<link>http://blogs.lessthandot.com/index.php/Architect/DesigningSoftware/cql-from-visual-studio-with-ndepend-3</link>
			<pubDate>Mon, 06 Sep 2010 20:29:00 +0000</pubDate>			<dc:creator>Alex Ullrich</dc:creator>
			<category domain="main">Designing Software</category>			<guid isPermaLink="false">955@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;For the last few months I&#039;ve had the pleasure of working with &lt;a href=&quot;http://ndepend.com/&quot;&gt;NDepend&lt;/a&gt; version 3.  Most of my development at home is on linux these days, so I haven&#039;t used it as much as I&#039;d like, but I have been using it to poke around in various codebases and see what the new Visual Studio integration is all about.  The last version integrated with Visual Studio, technically speaking, but it didn&#039;t seem nearly as thorough as what I&#039;ve seen in version 3.  I suspect the improved extensibility model in VS 2010 has a lot to do with this, but can&#039;t confirm (I haven&#039;t tried it with 2008 either).&lt;/p&gt;

&lt;p&gt;My favorite feature of NDepend has always been CQL, the SQL-like query language that allows you to query your codebase using a variety of common metrics.  This is the same as it ever was (the integration with VS is even quite similar) but with the more thorough integration it seems much more useful.  I like how easy it is now to keep an eye on my CQL constraints when I rebuild.&lt;/p&gt;

&lt;p&gt;My favorite CQL feature is the ability to set up CQL constraints &lt;em&gt;from now&lt;/em&gt;.  This is really cool for older projects, where it&#039;s unrealistic to think that your team will be able to fix everything right away.  But what you can do with this feature is ensure that all &lt;em&gt;new or modified&lt;/em&gt; code does measure up to your team&#039;s standards.  You may not be able to clean up all those 1,000 line methods right away, but you &lt;em&gt;can&lt;/em&gt; ensure that newer methods fit in a more reasonable size limit (like 975 &lt;img src=&quot;http://blogs.lessthandot.com/rsc/smilies/icon_wink.gif&quot; title=&quot;;)&quot; alt=&quot;;)&quot; class=&quot;middle&quot; width=&quot;15&quot; height=&quot;15&quot; /&gt; ).  This is one of the most useful features of the application, IMO.  The way it works is by allowing you to establish a baseline.  By comparing the code&#039;s current state to this baseline, future analyses are able to determine which methods/types/etc are new or changed, and apply the constraint to only these methods/types/etc.  Sometimes I feel like this would be useful just to be able to concisely see which methods have been changed as well (version control logs aren&#039;t the most friendly things to read, especially spread throughout a large codebase).  Below is a screenshot of this feature in action.&lt;/p&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;img src=&quot;http://blogs.lessthandot.com/media/blogs/Architect/CQL-VS-NDepend3/cqlexplorer.PNG&quot; alt=&quot;CQL Explorer&quot; title=&quot;CQL Explorer Screenshot&quot; width=&quot;971&quot; height=&quot;283&quot; /&gt;&lt;/div&gt;

&lt;p&gt;The first three queries listed are built in to NDepend.  I added the fourth, just to have a listing of new/changed methods ready.  The CQL for this query is simply &lt;/p&gt;&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;text&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;text&quot; id=&quot;cb69846&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;SELECT METHODS WHERE WasAdded OR CodeWasChanged&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb17262&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Not a bad way to keep an eye on what is getting changed in the codebase.  To get in this state I added three new methods to the codebase I was looking at (in a place that I could remove them easily since they are not only low quality but useless as well). Two had 7 parameters, putting them in violation of the constraint for basic quality principles.  I didn&#039;t add any tests, so all three were in violation of the test coverage constraint.  And finally they all showed up in the list of new methods.  It&#039;s worth noting the yellow circle at the bottom right as well - the yellow means that warnings were encountered when running the CQL portion of the analysis.  Green would be good, and red would mean I have some bad queries that can&#039;t be run.  &lt;/p&gt;

&lt;p&gt;Double clicking a row in the CQL Explorer will take you to the CQL Editor - from here you can view the results of the query, and the CQL it contains.  From there you can easily navigate to the method definition in your source code by double-clicking.  &lt;/p&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;img src=&quot;http://blogs.lessthandot.com/media/blogs/Architect/CQL-VS-NDepend3/cqleditor.PNG&quot; alt=&quot;CQL Editor&quot; title=&quot;CQL Editor Screenshot&quot; width=&quot;457&quot; height=&quot;913&quot; /&gt;&lt;/div&gt;

&lt;p&gt;One of the things I really like here is the comments in the built-in queries.  They contain numerous links to metric definitions on the NDepend website, and sometimes even links to blog entries where the lead developer, &lt;a href=&quot;http://codebetter.com/blogs/patricksmacchia/default.aspx&quot;&gt;Patrick Smacchia&lt;/a&gt; has explained features in greater detail.  I really like this form of documentation, it makes it easier to keep up to date and also minimizes what needs to be stored on the user&#039;s computer.  &lt;/p&gt;

&lt;p&gt;What I was happiest to find in the VS integration is the ability to superimpose CQL results onto the metrics view.  The metrics view consists of a grid where each block represents a unit of code (type, method, etc...) and they are sized according to their value for the metric in question.  When running CQL queries, the units of code matching your criteria are highlighted, giving a great visualization of how much code exhibits the properties you are looking for.&lt;/p&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;img src=&quot;http://blogs.lessthandot.com/media/blogs/Architect/CQL-VS-NDepend3/metricsexplorer.PNG&quot; alt=&quot;Metrics Explorer&quot; title=&quot;CQL Metrics Explorer&quot; width=&quot;887&quot; height=&quot;686&quot; /&gt;&lt;/div&gt;

&lt;p&gt;The selected query (about types having too many efferent couplings) is the currently selected query, and I had moused over the QueryParser class to highlight it in pink and show the metrics summary on the right.  I find that having this built right into visual studio really helps me figure out where to focus my refactoring energy.&lt;/p&gt;

&lt;p&gt;It looks as if a lot of effort went into &lt;a href=&quot;http://codebetter.com/blogs/patricksmacchia/archive/2010/08/29/validating-code-rules-in-visual-studio.aspx&quot;&gt;making the CQL validation phase fast&lt;/a&gt;: &lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;CQL rules validation phase is fast. The performance challenge was to make this happens almost instantly to avoid slowing the developer machine. Hopefully for a large 100K Lines of Code application, code gets re-analyzed and 200 CQL rules can get checked, all within 3 seconds after the (re)compilation of one or several .NET assemblies. These fast performances were made possible thanks to the development of a new technology of incremental code analysis. With incremental code analysis, only modified code gets re-analyzed. I can attest that this was extremely challenging and complex development!&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;From what I&#039;ve seen, the effort&#039;s been a success.  I&#039;ve mostly been using it to look at different versions of &lt;a href=&quot;http://lucene.apache.org/lucene.net/&quot;&gt;Lucene.net&lt;/a&gt;, as I&#039;ve got some work to do to get some of my code to build in VS2010.  For this size codebase (~23k lines) the analysis is completed very quickly, even if I disable the incremental analysis.  The CQL validation portion completes almost instantly, and memory usage doesn&#039;t seem to get out of hand even when keeping VS open for days.  I&#039;d imagine if your computer can handle running Visual Studio to begin with, it won&#039;t have too much trouble with the NDepend integration. I could see some of the VS add-ins that don&#039;t play well with others causing issues, especially with a very large codebase, so I hope to go back and test with a larger codebase and some other add-ins installed eventually.&lt;/p&gt;

&lt;p&gt;Most of the other NDepend goodies are available in VS now as well (Dependency Graphs, Test Coverage Analysis, Class Browser, etc...) but I won&#039;t get into all that here.  I really see CQL as the app&#039;s killer feature, and that is what I spend the most time thinking about.  There is a good overview of the app&#039;s capabilities &lt;a href=&quot;http://www.ndepend.com/Features.aspx#Tour&quot;&gt;here&lt;/a&gt; if you&#039;d like to read more.&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/Architect/DesigningSoftware/cql-from-visual-studio-with-ndepend-3&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>For the last few months I've had the pleasure of working with <a href="http://ndepend.com/">NDepend</a> version 3.  Most of my development at home is on linux these days, so I haven't used it as much as I'd like, but I have been using it to poke around in various codebases and see what the new Visual Studio integration is all about.  The last version integrated with Visual Studio, technically speaking, but it didn't seem nearly as thorough as what I've seen in version 3.  I suspect the improved extensibility model in VS 2010 has a lot to do with this, but can't confirm (I haven't tried it with 2008 either).</p>

<p>My favorite feature of NDepend has always been CQL, the SQL-like query language that allows you to query your codebase using a variety of common metrics.  This is the same as it ever was (the integration with VS is even quite similar) but with the more thorough integration it seems much more useful.  I like how easy it is now to keep an eye on my CQL constraints when I rebuild.</p>

<p>My favorite CQL feature is the ability to set up CQL constraints <em>from now</em>.  This is really cool for older projects, where it's unrealistic to think that your team will be able to fix everything right away.  But what you can do with this feature is ensure that all <em>new or modified</em> code does measure up to your team's standards.  You may not be able to clean up all those 1,000 line methods right away, but you <em>can</em> ensure that newer methods fit in a more reasonable size limit (like 975 <img src="http://blogs.lessthandot.com/rsc/smilies/icon_wink.gif" title=";)" alt=";)" class="middle" width="15" height="15" /> ).  This is one of the most useful features of the application, IMO.  The way it works is by allowing you to establish a baseline.  By comparing the code's current state to this baseline, future analyses are able to determine which methods/types/etc are new or changed, and apply the constraint to only these methods/types/etc.  Sometimes I feel like this would be useful just to be able to concisely see which methods have been changed as well (version control logs aren't the most friendly things to read, especially spread throughout a large codebase).  Below is a screenshot of this feature in action.</p>

<div class="image_block"><img src="http://blogs.lessthandot.com/media/blogs/Architect/CQL-VS-NDepend3/cqlexplorer.PNG" alt="CQL Explorer" title="CQL Explorer Screenshot" width="971" height="283" /></div>

<p>The first three queries listed are built in to NDepend.  I added the fourth, just to have a listing of new/changed methods ready.  The CQL for this query is simply </p><div class="codebox"><div class="codeheader"><span>text</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb73675'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb73675','cb54800'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="text" id="cb73675" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1">SELECT METHODS WHERE WasAdded OR CodeWasChanged</li></ol></div><div id="cb54800" style="display: none; color: red;"></div></div></div>
<p>Not a bad way to keep an eye on what is getting changed in the codebase.  To get in this state I added three new methods to the codebase I was looking at (in a place that I could remove them easily since they are not only low quality but useless as well). Two had 7 parameters, putting them in violation of the constraint for basic quality principles.  I didn't add any tests, so all three were in violation of the test coverage constraint.  And finally they all showed up in the list of new methods.  It's worth noting the yellow circle at the bottom right as well - the yellow means that warnings were encountered when running the CQL portion of the analysis.  Green would be good, and red would mean I have some bad queries that can't be run.  </p>

<p>Double clicking a row in the CQL Explorer will take you to the CQL Editor - from here you can view the results of the query, and the CQL it contains.  From there you can easily navigate to the method definition in your source code by double-clicking.  </p>

<div class="image_block"><img src="http://blogs.lessthandot.com/media/blogs/Architect/CQL-VS-NDepend3/cqleditor.PNG" alt="CQL Editor" title="CQL Editor Screenshot" width="457" height="913" /></div>

<p>One of the things I really like here is the comments in the built-in queries.  They contain numerous links to metric definitions on the NDepend website, and sometimes even links to blog entries where the lead developer, <a href="http://codebetter.com/blogs/patricksmacchia/default.aspx">Patrick Smacchia</a> has explained features in greater detail.  I really like this form of documentation, it makes it easier to keep up to date and also minimizes what needs to be stored on the user's computer.  </p>

<p>What I was happiest to find in the VS integration is the ability to superimpose CQL results onto the metrics view.  The metrics view consists of a grid where each block represents a unit of code (type, method, etc...) and they are sized according to their value for the metric in question.  When running CQL queries, the units of code matching your criteria are highlighted, giving a great visualization of how much code exhibits the properties you are looking for.</p>

<div class="image_block"><img src="http://blogs.lessthandot.com/media/blogs/Architect/CQL-VS-NDepend3/metricsexplorer.PNG" alt="Metrics Explorer" title="CQL Metrics Explorer" width="887" height="686" /></div>

<p>The selected query (about types having too many efferent couplings) is the currently selected query, and I had moused over the QueryParser class to highlight it in pink and show the metrics summary on the right.  I find that having this built right into visual studio really helps me figure out where to focus my refactoring energy.</p>

<p>It looks as if a lot of effort went into <a href="http://codebetter.com/blogs/patricksmacchia/archive/2010/08/29/validating-code-rules-in-visual-studio.aspx">making the CQL validation phase fast</a>: </p><blockquote><p>CQL rules validation phase is fast. The performance challenge was to make this happens almost instantly to avoid slowing the developer machine. Hopefully for a large 100K Lines of Code application, code gets re-analyzed and 200 CQL rules can get checked, all within 3 seconds after the (re)compilation of one or several .NET assemblies. These fast performances were made possible thanks to the development of a new technology of incremental code analysis. With incremental code analysis, only modified code gets re-analyzed. I can attest that this was extremely challenging and complex development!</p></blockquote>
<p>From what I've seen, the effort's been a success.  I've mostly been using it to look at different versions of <a href="http://lucene.apache.org/lucene.net/">Lucene.net</a>, as I've got some work to do to get some of my code to build in VS2010.  For this size codebase (~23k lines) the analysis is completed very quickly, even if I disable the incremental analysis.  The CQL validation portion completes almost instantly, and memory usage doesn't seem to get out of hand even when keeping VS open for days.  I'd imagine if your computer can handle running Visual Studio to begin with, it won't have too much trouble with the NDepend integration. I could see some of the VS add-ins that don't play well with others causing issues, especially with a very large codebase, so I hope to go back and test with a larger codebase and some other add-ins installed eventually.</p>

<p>Most of the other NDepend goodies are available in VS now as well (Dependency Graphs, Test Coverage Analysis, Class Browser, etc...) but I won't get into all that here.  I really see CQL as the app's killer feature, and that is what I spend the most time thinking about.  There is a good overview of the app's capabilities <a href="http://www.ndepend.com/Features.aspx#Tour">here</a> if you'd like to read more.</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/Architect/DesigningSoftware/cql-from-visual-studio-with-ndepend-3">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/Architect/DesigningSoftware/cql-from-visual-studio-with-ndepend-3#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/Architect/?tempskin=_rss2&#38;disp=comments&#38;p=955</wfw:commentRss>
		</item>
				<item>
			<title>You need to know a lot when you want to be a developer.</title>
			<link>http://blogs.lessthandot.com/index.php/Architect/HardwareInfrastructureDesign/you-need-to-know-a-lot-when-you-want-to</link>
			<pubDate>Fri, 30 Jul 2010 08:06:35 +0000</pubDate>			<dc:creator>Christiaan Baes (chrissie1)</dc:creator>
			<category domain="main">Hardware &amp; Infrastructure Design</category>			<guid isPermaLink="false">914@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;I was looking at the stack they used for the new channel9 website.&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;MVC 2.0, Unity (from P&amp;amp;P), NHibernate, Fluent NHibernate, Memcached, Enyim Managed Memcached driver, Azure &amp;#8211; Fabric, Storage, Diagnostics, SQL Azure, xUnit (testing only), Live ID, Spark View Engine, Akismet (spam filtering service), AntiXSS, Tinymce, jQuery, and Silverlight.&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;You can watch the video &lt;a href=&quot;http://channel9.msdn.com/shows/Going+Deep/Mike-Sampson-Inside-Rev9/&quot;&gt;by Mike Sampson on how they built the new site&lt;/a&gt; if you want to know more.&lt;/p&gt;

&lt;p&gt;But have you counted the number of frameworks/technologies required for such a site? I was going to say simple site but I don&#039;t think that exists anymore. I count 16 (I didn&#039;t count Storage and diagnostics). And I&#039;m sure they forgot a whole bunch that you just take for granted.&lt;/p&gt;

&lt;p&gt;Then I started counting the stack I use at work. In no particular order.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;nHibernate&lt;/li&gt;
  &lt;li&gt;WPF&lt;/li&gt;
  &lt;li&gt;Winforms&lt;/li&gt;
  &lt;li&gt;Log4net&lt;/li&gt;
  &lt;li&gt;NUnit&lt;/li&gt;
  &lt;li&gt;Rhino mocks&lt;/li&gt;
  &lt;li&gt;SQL-server&lt;/li&gt;
  &lt;li&gt;StructureMap&lt;/li&gt;
  &lt;li&gt;Microsoft reporting&lt;/li&gt;
  &lt;li&gt;ITextsharp&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Seems a whole lot less than what you need for web development. But the problem remains the same. You have to know all those things well to make them work together well and you need to know the tools that you can use to make them work together well.&lt;/p&gt;

&lt;p&gt;Here are just a few of the tools I use to make all that work well. Again in no particular order.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;SSMS&lt;/li&gt;
  &lt;li&gt;Redgate toolbelt&lt;/li&gt;
  &lt;li&gt;NDepend&lt;/li&gt;
  &lt;li&gt;Visual Studio 2010&lt;/li&gt;
  &lt;li&gt;Ncover/DotCover&lt;/li&gt;
  &lt;li&gt;Resharper&lt;/li&gt;
  &lt;li&gt;Finalbuilder&lt;/li&gt;
  &lt;li&gt;An enormous amount of third party controls&lt;/li&gt;
  &lt;li&gt;NHProf&lt;/li&gt;
  &lt;li&gt;SQLCop ;-)&lt;/li&gt;
  &lt;li&gt;VisualSVN&lt;/li&gt;
  &lt;li&gt;VMWare&lt;/li&gt;
  &lt;li&gt;Windows&lt;/li&gt;
  &lt;li&gt;Oracle&lt;/li&gt;
  &lt;li&gt;dotTrace&lt;/li&gt;
  &lt;li&gt;Sharepoint&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All these tools and frameworks you have to know and know well. Some you will only use once in a while but you have to know they exist and you have to know how to use them. And lets not forget all those things you tried and rejected. I think those make an even longer list.&lt;/p&gt;

&lt;p&gt;I&#039;m sure you could spend days and weeks just getting to grips with NDepend but you just don&#039;t have the time. And by the time you know all the above it is surely outdated. &lt;/p&gt;

&lt;p&gt;And then you also have to know something about hardware. &lt;/p&gt;

&lt;p&gt;But does that mean that the life of a developer is hard and harder than most other professionals? No, it isn&#039;t. I do the developing thing part time and the other part of the job takes just as much effort and commitment to do right as the development side of things. It&#039;s all part of the job. But you could do what you do with a lot less effort and commitment and some people do. But that doesn&#039;t make you better or worse then anyone else just different. Different people have different priorities. &lt;/p&gt;

&lt;p&gt;But I can sure understand why people don&#039;t want to learn new things and just do things with what they have now. &lt;/p&gt;

&lt;p&gt;I&#039;m just in it because I like to do what I do. As soon as it stops being fun I will move on. But for the moment I still have lots to learn and I&#039;m not as young as I used to be ;-) so it takes a little longer.&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/Architect/HardwareInfrastructureDesign/you-need-to-know-a-lot-when-you-want-to&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>I was looking at the stack they used for the new channel9 website.</p>

<blockquote><p>MVC 2.0, Unity (from P&amp;P), NHibernate, Fluent NHibernate, Memcached, Enyim Managed Memcached driver, Azure &#8211; Fabric, Storage, Diagnostics, SQL Azure, xUnit (testing only), Live ID, Spark View Engine, Akismet (spam filtering service), AntiXSS, Tinymce, jQuery, and Silverlight.</p></blockquote>

<p>You can watch the video <a href="http://channel9.msdn.com/shows/Going+Deep/Mike-Sampson-Inside-Rev9/">by Mike Sampson on how they built the new site</a> if you want to know more.</p>

<p>But have you counted the number of frameworks/technologies required for such a site? I was going to say simple site but I don't think that exists anymore. I count 16 (I didn't count Storage and diagnostics). And I'm sure they forgot a whole bunch that you just take for granted.</p>

<p>Then I started counting the stack I use at work. In no particular order.</p>

<ul>
  <li>nHibernate</li>
  <li>WPF</li>
  <li>Winforms</li>
  <li>Log4net</li>
  <li>NUnit</li>
  <li>Rhino mocks</li>
  <li>SQL-server</li>
  <li>StructureMap</li>
  <li>Microsoft reporting</li>
  <li>ITextsharp</li>
</ul>

<p>Seems a whole lot less than what you need for web development. But the problem remains the same. You have to know all those things well to make them work together well and you need to know the tools that you can use to make them work together well.</p>

<p>Here are just a few of the tools I use to make all that work well. Again in no particular order.</p>

<ul>
  <li>SSMS</li>
  <li>Redgate toolbelt</li>
  <li>NDepend</li>
  <li>Visual Studio 2010</li>
  <li>Ncover/DotCover</li>
  <li>Resharper</li>
  <li>Finalbuilder</li>
  <li>An enormous amount of third party controls</li>
  <li>NHProf</li>
  <li>SQLCop ;-)</li>
  <li>VisualSVN</li>
  <li>VMWare</li>
  <li>Windows</li>
  <li>Oracle</li>
  <li>dotTrace</li>
  <li>Sharepoint</li>
</ul>

<p>All these tools and frameworks you have to know and know well. Some you will only use once in a while but you have to know they exist and you have to know how to use them. And lets not forget all those things you tried and rejected. I think those make an even longer list.</p>

<p>I'm sure you could spend days and weeks just getting to grips with NDepend but you just don't have the time. And by the time you know all the above it is surely outdated. </p>

<p>And then you also have to know something about hardware. </p>

<p>But does that mean that the life of a developer is hard and harder than most other professionals? No, it isn't. I do the developing thing part time and the other part of the job takes just as much effort and commitment to do right as the development side of things. It's all part of the job. But you could do what you do with a lot less effort and commitment and some people do. But that doesn't make you better or worse then anyone else just different. Different people have different priorities. </p>

<p>But I can sure understand why people don't want to learn new things and just do things with what they have now. </p>

<p>I'm just in it because I like to do what I do. As soon as it stops being fun I will move on. But for the moment I still have lots to learn and I'm not as young as I used to be ;-) so it takes a little longer.</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/Architect/HardwareInfrastructureDesign/you-need-to-know-a-lot-when-you-want-to">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/Architect/HardwareInfrastructureDesign/you-need-to-know-a-lot-when-you-want-to#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/Architect/?tempskin=_rss2&#38;disp=comments&#38;p=914</wfw:commentRss>
		</item>
				<item>
			<title>Model-View-Presenter: Looking at Passive View</title>
			<link>http://blogs.lessthandot.com/index.php/Architect/DesigningSoftware/model-view-presenter-looking-at-passive</link>
			<pubDate>Thu, 15 Jul 2010 09:44:12 +0000</pubDate>			<dc:creator>Eli Weinstock-Herman (tarwn)</dc:creator>
			<category domain="main">Designing Software</category>
<category domain="alt">Introduction to Architecture &amp; Design</category>			<guid isPermaLink="false">889@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;Model-View-Presenter is an architecture pattern that defines a structure for behavior and logic at the UI level. M-V-P separates the logic of the presentation, such as interacting with back-end services and the business layer, from the mechanics of displaying buttons and interface components. &lt;/p&gt;

&lt;p&gt;I often build small projects to help understand and grow my skills as a developer, architect, and all-around technologist (as may be apparent from the &lt;a href=&quot;http://blogs.lessthandot.com/index.php/All/?disp=authdir&amp;amp;author=9&quot; target=&quot;_blank&quot; title=&quot;See all of my posts at LTD&quot;&gt;wide range of topics I post on&lt;/a&gt;). Today I worked with a combination of Visio and Visual Studio to build a sample project to play with the Passive View concept and to help grow my own understanding of the concept. This post will cover the Visio side of my learning-curve.&lt;/p&gt;

&lt;p&gt;You can read more about Model View Presenter at &lt;a href=&quot;http://en.wikipedia.org/wiki/Model-view-presenter&quot; target=&quot;_blank&quot; title=&quot;Model-View-Presenter at Wikipedia&quot;&gt;Wikipedia&lt;/a&gt; and &lt;a href=http://msdn.microsoft.com/en-us/magazine/cc188690.aspx&quot;&quot; target=&quot;_blank&quot; title=&quot;Model View Presenter by Jean-Paul Boodhoo on MSDN&quot;&gt;MSDN&lt;/a&gt;. Perhaps the best information can be found on Martin Fowler&#039;s site, where he has separate write-ups on &lt;a href=&quot;http://www.martinfowler.com/eaaDev/PassiveScreen.html&quot; target=_blank&quot; title=&quot;Passive View pattern&quot;&gt;Passive View&lt;/a&gt; and &lt;a href=&quot;http://www.martinfowler.com/eaaDev/SupervisingPresenter.html&quot; target=_blank&quot; title=&quot;Supervising Controller Pattern&quot;&gt;Supervising Controller&lt;/a&gt;.&lt;/p&gt;

&lt;div style=&quot;background-color:#FFFFCC; padding: .5em; margin: .5em; border: 1px solid #DDDDAA; color: #333333; font-size: 80%;&quot;&gt;Note: I know some people were waiting for another Virtual Lab entry this week, and here I am writing about Architecture instead. Don&#039;t worry, the virtual lab series will continue, I just felt like doing a write-up while I was playing this past weekend.&lt;/div&gt;

&lt;h2&gt;Passive View&lt;/h2&gt;
&lt;p&gt;Passive View is a subset of the Model-View-Presenter pattern. In Passive View, the interface is responsible for handling interface-specific logic, such as figuring out how to put a value in a textbox or react to events from button clicks, but all actions and logic outside of the raw UI are sent to the Presenter to execute or manage. The Presenter is responsible for calling business methods in the Business model and updating the data that is available in the View. &lt;/p&gt;

&lt;div style=&quot;text-align: center; font-size: .8em; color: #666666;&quot;&gt;
&lt;img src=&quot;http://tiernok.com/LTDBlog/MVP/mvp.png&quot; alt=&quot;Basic Model-View-Presenter diagram&quot; /&gt;&lt;br /&gt;
Basic Model-View-Presenter Diagram
&lt;/div&gt;

&lt;p&gt;From the outside in, the architecture for Passive View looks something like this:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;UI - The User Interface reflects what is going on beneath it by implementing one or more View interfaces&lt;/li&gt;
	&lt;li&gt;Presenter - The Presenter receives interactions from the UI or Model and updates the Views it is attached to&lt;/li&gt;
	&lt;li&gt;Model - The model is a facade or black box in our diagram, behind which is a business logic layer and data layer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In a flat architecture we would collect data from the interface, perhaps do some business and data validation, and then save it directly to a database using stored procedures or inline SQL. Defining a data access layer (or data model like entity framework) allows our application to operate on cohesive, defined objects that are meaningful to the application and stored and retrieved consistently. Defining a business logic layer allows us to centralize business rules that operate on entities in our application in a manner that is consistent with the business and internally consistent in the application, minimizing the risk that occurs when making changes to the business flow. Separating the logic of populating inputs and responding to button presses on the UI from the information being communicated to the end user and conceptual responses to their input allows the system to interact with the user consistently across any number of interfaces into the same application.&lt;/p&gt;

&lt;p&gt;The definition of each level increases our ability to automate testing and supports greater &lt;a href=&quot;http://en.wikipedia.org/wiki/Separation_of_concerns&quot; title=&quot;Separation of Concerns at Wikipedia&quot; target=&quot;_blank&quot;&gt;Separation of Concerns&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;Implementing a Sample Project&lt;/h2&gt;
&lt;p&gt;My learning exercise has been the the creation of an ASP.Net search page that allows an end user (customer) to search for finished products from the AdventureWorks sample database. The architecture and design decisions were done as an exercise in Visio using simple shapes and layouts.&lt;/p&gt;

&lt;p&gt;My example application has several functional and non-functional requirements:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;Functional - Display product number, name, list price, and available quantity in tabular format&lt;/li&gt;
	&lt;li&gt;Functional - Provide a basic search input and button to search product names&lt;/li&gt;
	&lt;li&gt;Non-Functional - Implement an M-V-P pattern - Obviously the purpose of this whole exercise&lt;/li&gt;
	&lt;li&gt;Non-Functional - Use a simple model stack that can be easily replaced with a Service-Oriented one at a later time&lt;/li&gt;
	&lt;li&gt;Non-Functional - Build with the idea that we will later create a Silverlight or WPF front-end&lt;/li&gt;
	&lt;li&gt;Non-Functional - Make pretty pictures for article&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;i&gt;My unwritten, final requirement was to finish the whole thing in half a day, though luckily I didn&#039;t define whether I intended that to mean 4 hours or 12.&lt;/i&gt;&lt;/p&gt;

&lt;h3&gt;Initial Architecture&lt;/h3&gt;
&lt;p&gt;To start I created a diagram of the application architecture:&lt;/p&gt;
&lt;div style=&quot;text-align: center; font-size: .8em; color: #666666;&quot;&gt;
&lt;img src=&quot;http://tiernok.com/LTDBlog/MVP/mvp_arch_01.png&quot; alt=&quot;More extensive M-V-P Diagram&quot; /&gt;&lt;br /&gt;
More Extensive Model-View-Presenter Diagram
&lt;/div&gt;
&lt;p&gt;The purple layer is my presentation layer, which reflects the View. The blue layer is my Presenter layer which contains the logic for interacting between the end user and interface as well as a definition, or contract, of the information available in the View. The Green is the Model (or is behind the model, depending on your viewpoint) and exposes business functions and data entities for the Presenter to interact with.&lt;/p&gt;

&lt;h3&gt;Class Layout&lt;/h3&gt;
&lt;p&gt;Once the high level diagram was completed, I could approach the task of creating some base classes and interfaces to use in implementing the project.&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;Model.IModel - Generic Model Interface to expose business calls to Presenters&lt;/li&gt;
	&lt;li&gt;Presenter.IView - Generic View Interface that all Presenters can interact with and all screens implement&lt;/li&gt;
	&lt;li&gt;Presenter.BasePresenter - Generic Presenter class that all Presenters will implement&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To keep the project to a single morning but also allow the ability to come back and build a more architecturally sound solution, I implemented the Model in a very basic fashion that was referenced locally by the Presenter project and makes direct calls to SQL Server using ADO and parametrized, inline SQL. This buys me the benefits of having a well-defined Model (via the interface) but allows me concentrate my time and effort on the learning part of the project (ie, the M-V-P interaction and structure). Defining the model interface also leaves me open to come back and replace it with better separated code and the ability to create a model that acts as a facade to a service stack, instead of local DLLs.&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;Model.BasicModel.Model - Basic implementation of a model that will interact with AdventureWorks on SQL Server&lt;/li&gt;
	&lt;li&gt;Model.Entities.Product - A Product Entity that can be communicated between an IModel instance and Presenter&lt;br /&gt;
	&lt;li&gt;Presenter.ProductSearchPresenter - A Presenter to manage product search interface&lt;/li&gt;
	&lt;li&gt;Presenter.IProductSearchView - A view of the data involved in a product search&lt;/li&gt;
	&lt;li&gt;ProductSearch.aspx - A web page that implements the IProductSearchView and interacts with the ProductSearchPresenter&lt;/li&gt;
&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;My final Visio diagram ended up looking like this:&lt;/p&gt;
&lt;div style=&quot;text-align: center; font-size: .8em; color: #666666;&quot;&gt;
&lt;img src=&quot;http://tiernok.com/LTDBlog/MVP/mvp_arch_02.png&quot; alt=&quot;Example Application Diagram&quot; /&gt;&lt;br /&gt;
Diagram of Example Application
&lt;/div&gt;

&lt;p&gt;In this case the left side represents basic components (bases classes and interfaces) that are used to define common structure or contracts on the right side. &lt;/p&gt;

&lt;h2&gt;The Code&lt;/h2&gt;
&lt;p&gt;For the purposes of the example project, my view has properties for Search Text, a Search Count (number of results), Results (a generic list of the Product entity), and a boolean indicating whether there are results to display. My Web Form implements these properties, tying them to elements on the screen.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;csharp&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;csharp&quot; id=&quot;cb45401&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; partial &lt;span style=&quot;color: #FF0000;&quot;&gt;class&lt;/span&gt; WebForm1 : &lt;span style=&quot;color: #000000;&quot;&gt;System&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Web&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;UI&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Page&lt;/span&gt;, Presenter.&lt;span style=&quot;color: #0000FF;&quot;&gt;Views&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;IProductSearchView&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Presenter.&lt;span style=&quot;color: #0000FF;&quot;&gt;ProductSearchPresenter&lt;/span&gt; _presenter;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;void&lt;/span&gt; Page_Load&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;object&lt;/span&gt; sender, EventArgs e&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; btnSearch.&lt;span style=&quot;color: #0000FF;&quot;&gt;Click&lt;/span&gt; += &lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; EventHandler&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;btnSearch_Click&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; rptProducts.&lt;span style=&quot;color: #0000FF;&quot;&gt;ItemDataBound&lt;/span&gt; += &lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; RepeaterItemEventHandler&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;rptProducts_ItemDataBound&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; _presenter = &lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; Presenter.&lt;span style=&quot;color: #0000FF;&quot;&gt;ProductSearchPresenter&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; Model.&lt;span style=&quot;color: #0000FF;&quot;&gt;LocalModel&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;BasicModel&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;System&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Configuration&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;ConfigurationManager&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;ConnectionStrings&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;quot;AdventureWorks&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;ConnectionString&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;, &lt;span style=&quot;color: #0600FF;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;void&lt;/span&gt; btnSearch_Click&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;object&lt;/span&gt; sender, EventArgs e&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;this&lt;/span&gt;._presenter.&lt;span style=&quot;color: #0000FF;&quot;&gt;ExecuteProductSearch&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #FF0000;&quot;&gt;string&lt;/span&gt; Presenter.&lt;span style=&quot;color: #0000FF;&quot;&gt;Views&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;IProductSearchView&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;SearchText&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; get &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;return&lt;/span&gt; tbSearch.&lt;span style=&quot;color: #0000FF;&quot;&gt;Text&lt;/span&gt;; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; set &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt; tbSearch.&lt;span style=&quot;color: #0000FF;&quot;&gt;Text&lt;/span&gt; = value; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #FF0000;&quot;&gt;int&lt;/span&gt; Presenter.&lt;span style=&quot;color: #0000FF;&quot;&gt;Views&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;IProductSearchView&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;ResultCount&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; set &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt; lblResultCount.&lt;span style=&quot;color: #0000FF;&quot;&gt;Text&lt;/span&gt; = value.&lt;span style=&quot;color: #0000FF;&quot;&gt;ToString&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; List&amp;lt;Model.&lt;span style=&quot;color: #0000FF;&quot;&gt;Entities&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Product&lt;/span&gt;&amp;gt; Presenter.&lt;span style=&quot;color: #0000FF;&quot;&gt;Views&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;IProductSearchView&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;SearchResults&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; set &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;value != &lt;span style=&quot;color: #0600FF;&quot;&gt;null&lt;/span&gt; &amp;amp;&amp;amp; value.&lt;span style=&quot;color: #0000FF;&quot;&gt;Count&lt;/span&gt; &amp;gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; rptProducts.&lt;span style=&quot;color: #0000FF;&quot;&gt;DataSource&lt;/span&gt; = value;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; rptProducts.&lt;span style=&quot;color: #0000FF;&quot;&gt;DataBind&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #FF0000;&quot;&gt;bool&lt;/span&gt; Presenter.&lt;span style=&quot;color: #0000FF;&quot;&gt;Views&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;IProductSearchView&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;DisplayResults&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; set &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt; tblResults.&lt;span style=&quot;color: #0000FF;&quot;&gt;Visible&lt;/span&gt; = value; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;...&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb7455&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;As the presenter populates properties in the view, the information is automatically reflected on the page. The actual logic of how the business functions are called and populate those properties are neatly packaged up in the Presenter and View interface and very little logic occurs in the actual web form.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;csharp&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;csharp&quot; id=&quot;cb55251&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;class&lt;/span&gt; ProductSearchPresenter : BasePresenter &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;protected&lt;/span&gt; Views.&lt;span style=&quot;color: #0000FF;&quot;&gt;IProductSearchView&lt;/span&gt; _view;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; ProductSearchPresenter&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Model.&lt;span style=&quot;color: #0000FF;&quot;&gt;IModel&lt;/span&gt; model, Views.&lt;span style=&quot;color: #0000FF;&quot;&gt;IProductSearchView&lt;/span&gt; view&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; : &lt;span style=&quot;color: #0600FF;&quot;&gt;base&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;model&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;this&lt;/span&gt;._view = view;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;this&lt;/span&gt;._view.&lt;span style=&quot;color: #0000FF;&quot;&gt;ResultCount&lt;/span&gt; = &lt;span style=&quot;color: #FF0000;&quot;&gt;0&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;this&lt;/span&gt;._view.&lt;span style=&quot;color: #0000FF;&quot;&gt;DisplayResults&lt;/span&gt; = &lt;span style=&quot;color: #0600FF;&quot;&gt;false&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;void&lt;/span&gt; ExecuteProductSearch&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; List&amp;lt;Model.&lt;span style=&quot;color: #0000FF;&quot;&gt;Entities&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Product&lt;/span&gt;&amp;gt; results;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; results = &lt;span style=&quot;color: #0600FF;&quot;&gt;this&lt;/span&gt;._model.&lt;span style=&quot;color: #0000FF;&quot;&gt;SearchProduct&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;this&lt;/span&gt;._view.&lt;span style=&quot;color: #0000FF;&quot;&gt;SearchText&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;results.&lt;span style=&quot;color: #0000FF;&quot;&gt;Count&lt;/span&gt; &amp;gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;this&lt;/span&gt;._view.&lt;span style=&quot;color: #0000FF;&quot;&gt;ResultCount&lt;/span&gt; = results.&lt;span style=&quot;color: #0000FF;&quot;&gt;Count&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;this&lt;/span&gt;._view.&lt;span style=&quot;color: #0000FF;&quot;&gt;DisplayResults&lt;/span&gt; = &lt;span style=&quot;color: #0600FF;&quot;&gt;true&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;this&lt;/span&gt;._view.&lt;span style=&quot;color: #0000FF;&quot;&gt;SearchResults&lt;/span&gt; = results;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;this&lt;/span&gt;._view.&lt;span style=&quot;color: #0000FF;&quot;&gt;ResultCount&lt;/span&gt; = &lt;span style=&quot;color: #FF0000;&quot;&gt;0&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;this&lt;/span&gt;._view.&lt;span style=&quot;color: #0000FF;&quot;&gt;DisplayResults&lt;/span&gt; = &lt;span style=&quot;color: #0600FF;&quot;&gt;false&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;this&lt;/span&gt;._view.&lt;span style=&quot;color: #0000FF;&quot;&gt;SearchResults&lt;/span&gt; = &lt;span style=&quot;color: #0600FF;&quot;&gt;null&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb24899&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;To create a unit test, we define a simple view that implements the view interface, execute the presenter logic, and verify the properties are populated the way we would expect when the same presenter calls are made from the interface.&lt;/p&gt;

&lt;h3&gt;Extending the Architecture Further&lt;/h3&gt;
&lt;p&gt;Extending the application to display product search in a different manner would only require the addition of a new interface that also implements the Product Search View. A Silverlight front-end would only require creating the basic project, implementing the product search View, and wiring the new interface controls to the view properties. To replace the direct mode reference with a service reference, we could create a service facade that implemented the IModel interface, connected to a local or remote WCF service behid the scenes to handle the real model logic. And finally, instead of counting on our QA department to test all of the application interactions, we can create unit tests directly against the Presenter and Views to ensure that all of the interactions below the top surface of the application are happening consistently and to our expectation.&lt;/p&gt;

&lt;h2&gt;Your Turn&lt;/h2&gt;
&lt;p&gt;Getting this much of the architecture working is a good first step. I took a number of shortcuts on the BasicModel class in my example, but I now have a functional Model-View-Presenter application to play with. Hopefully there was enough information in the article to interest you in trying this out on your own. I urge you to read the articles linked in the top of the post (or several more in my &lt;a href=&quot;http://delicious.com/tarwn/model-view-presenter&quot; title=&quot;Eli&#039;s Delicious bookmarks for M-V-P&quot; target=&quot;_blank&quot;&gt;Model-View-Presentation bookmarks&lt;/a&gt;) and come up with your own diagrams and sample project. Even doing a small project will force you to run into questions and considerations you wouldn&#039;t have had by simply reading about it, not to mention unrelated tidbits you will pick up along the way (for instance, I also learned about &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ms668604.aspx&quot; title=&quot;ObservableCollection at MSDN&quot; target=&quot;_blank&quot;&gt;ObservableCollections&lt;/a&gt; today).&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/Architect/DesigningSoftware/model-view-presenter-looking-at-passive&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>Model-View-Presenter is an architecture pattern that defines a structure for behavior and logic at the UI level. M-V-P separates the logic of the presentation, such as interacting with back-end services and the business layer, from the mechanics of displaying buttons and interface components. </p>

<p>I often build small projects to help understand and grow my skills as a developer, architect, and all-around technologist (as may be apparent from the <a href="http://blogs.lessthandot.com/index.php/All/?disp=authdir&amp;author=9" target="_blank" title="See all of my posts at LTD">wide range of topics I post on</a>). Today I worked with a combination of Visio and Visual Studio to build a sample project to play with the Passive View concept and to help grow my own understanding of the concept. This post will cover the Visio side of my learning-curve.</p>

<p>You can read more about Model View Presenter at <a href="http://en.wikipedia.org/wiki/Model-view-presenter" target="_blank" title="Model-View-Presenter at Wikipedia">Wikipedia</a> and <a href=http://msdn.microsoft.com/en-us/magazine/cc188690.aspx"" target="_blank" title="Model View Presenter by Jean-Paul Boodhoo on MSDN">MSDN</a>. Perhaps the best information can be found on Martin Fowler's site, where he has separate write-ups on <a href="http://www.martinfowler.com/eaaDev/PassiveScreen.html" target=_blank" title="Passive View pattern">Passive View</a> and <a href="http://www.martinfowler.com/eaaDev/SupervisingPresenter.html" target=_blank" title="Supervising Controller Pattern">Supervising Controller</a>.</p>

<div style="background-color:#FFFFCC; padding: .5em; margin: .5em; border: 1px solid #DDDDAA; color: #333333; font-size: 80%;">Note: I know some people were waiting for another Virtual Lab entry this week, and here I am writing about Architecture instead. Don't worry, the virtual lab series will continue, I just felt like doing a write-up while I was playing this past weekend.</div>

<h2>Passive View</h2>
<p>Passive View is a subset of the Model-View-Presenter pattern. In Passive View, the interface is responsible for handling interface-specific logic, such as figuring out how to put a value in a textbox or react to events from button clicks, but all actions and logic outside of the raw UI are sent to the Presenter to execute or manage. The Presenter is responsible for calling business methods in the Business model and updating the data that is available in the View. </p>

<div style="text-align: center; font-size: .8em; color: #666666;">
<img src="http://tiernok.com/LTDBlog/MVP/mvp.png" alt="Basic Model-View-Presenter diagram" /><br />
Basic Model-View-Presenter Diagram
</div>

<p>From the outside in, the architecture for Passive View looks something like this:</p>
<ul>
	<li>UI - The User Interface reflects what is going on beneath it by implementing one or more View interfaces</li>
	<li>Presenter - The Presenter receives interactions from the UI or Model and updates the Views it is attached to</li>
	<li>Model - The model is a facade or black box in our diagram, behind which is a business logic layer and data layer</li>
</ul>

<p>In a flat architecture we would collect data from the interface, perhaps do some business and data validation, and then save it directly to a database using stored procedures or inline SQL. Defining a data access layer (or data model like entity framework) allows our application to operate on cohesive, defined objects that are meaningful to the application and stored and retrieved consistently. Defining a business logic layer allows us to centralize business rules that operate on entities in our application in a manner that is consistent with the business and internally consistent in the application, minimizing the risk that occurs when making changes to the business flow. Separating the logic of populating inputs and responding to button presses on the UI from the information being communicated to the end user and conceptual responses to their input allows the system to interact with the user consistently across any number of interfaces into the same application.</p>

<p>The definition of each level increases our ability to automate testing and supports greater <a href="http://en.wikipedia.org/wiki/Separation_of_concerns" title="Separation of Concerns at Wikipedia" target="_blank">Separation of Concerns</a>.</p>

<h2>Implementing a Sample Project</h2>
<p>My learning exercise has been the the creation of an ASP.Net search page that allows an end user (customer) to search for finished products from the AdventureWorks sample database. The architecture and design decisions were done as an exercise in Visio using simple shapes and layouts.</p>

<p>My example application has several functional and non-functional requirements:</p>
<ol>
	<li>Functional - Display product number, name, list price, and available quantity in tabular format</li>
	<li>Functional - Provide a basic search input and button to search product names</li>
	<li>Non-Functional - Implement an M-V-P pattern - Obviously the purpose of this whole exercise</li>
	<li>Non-Functional - Use a simple model stack that can be easily replaced with a Service-Oriented one at a later time</li>
	<li>Non-Functional - Build with the idea that we will later create a Silverlight or WPF front-end</li>
	<li>Non-Functional - Make pretty pictures for article</li>
</ol>

<p><i>My unwritten, final requirement was to finish the whole thing in half a day, though luckily I didn't define whether I intended that to mean 4 hours or 12.</i></p>

<h3>Initial Architecture</h3>
<p>To start I created a diagram of the application architecture:</p>
<div style="text-align: center; font-size: .8em; color: #666666;">
<img src="http://tiernok.com/LTDBlog/MVP/mvp_arch_01.png" alt="More extensive M-V-P Diagram" /><br />
More Extensive Model-View-Presenter Diagram
</div>
<p>The purple layer is my presentation layer, which reflects the View. The blue layer is my Presenter layer which contains the logic for interacting between the end user and interface as well as a definition, or contract, of the information available in the View. The Green is the Model (or is behind the model, depending on your viewpoint) and exposes business functions and data entities for the Presenter to interact with.</p>

<h3>Class Layout</h3>
<p>Once the high level diagram was completed, I could approach the task of creating some base classes and interfaces to use in implementing the project.</p>
<ul>
	<li>Model.IModel - Generic Model Interface to expose business calls to Presenters</li>
	<li>Presenter.IView - Generic View Interface that all Presenters can interact with and all screens implement</li>
	<li>Presenter.BasePresenter - Generic Presenter class that all Presenters will implement</li>
</ul>

<p>To keep the project to a single morning but also allow the ability to come back and build a more architecturally sound solution, I implemented the Model in a very basic fashion that was referenced locally by the Presenter project and makes direct calls to SQL Server using ADO and parametrized, inline SQL. This buys me the benefits of having a well-defined Model (via the interface) but allows me concentrate my time and effort on the learning part of the project (ie, the M-V-P interaction and structure). Defining the model interface also leaves me open to come back and replace it with better separated code and the ability to create a model that acts as a facade to a service stack, instead of local DLLs.</p>
<ul>
	<li>Model.BasicModel.Model - Basic implementation of a model that will interact with AdventureWorks on SQL Server</li>
	<li>Model.Entities.Product - A Product Entity that can be communicated between an IModel instance and Presenter<br />
	<li>Presenter.ProductSearchPresenter - A Presenter to manage product search interface</li>
	<li>Presenter.IProductSearchView - A view of the data involved in a product search</li>
	<li>ProductSearch.aspx - A web page that implements the IProductSearchView and interacts with the ProductSearchPresenter</li>
</li></ul>

<p>My final Visio diagram ended up looking like this:</p>
<div style="text-align: center; font-size: .8em; color: #666666;">
<img src="http://tiernok.com/LTDBlog/MVP/mvp_arch_02.png" alt="Example Application Diagram" /><br />
Diagram of Example Application
</div>

<p>In this case the left side represents basic components (bases classes and interfaces) that are used to define common structure or contracts on the right side. </p>

<h2>The Code</h2>
<p>For the purposes of the example project, my view has properties for Search Text, a Search Count (number of results), Results (a generic list of the Product entity), and a boolean indicating whether there are results to display. My Web Form implements these properties, tying them to elements on the screen.</p>

<div class="codebox"><div class="codeheader"><span>csharp</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb11582'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb11582','cb47541'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="csharp" id="cb11582" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #0600FF;">public</span> partial <span style="color: #FF0000;">class</span> WebForm1 : <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Web</span>.<span style="color: #0000FF;">UI</span>.<span style="color: #0000FF;">Page</span>, Presenter.<span style="color: #0000FF;">Views</span>.<span style="color: #0000FF;">IProductSearchView</span> <span style="color: #000000;">&#123;</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; Presenter.<span style="color: #0000FF;">ProductSearchPresenter</span> _presenter;</li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">protected</span> <span style="color: #0600FF;">void</span> Page_Load<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">object</span> sender, EventArgs e<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; btnSearch.<span style="color: #0000FF;">Click</span> += <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> EventHandler<span style="color: #000000;">&#40;</span>btnSearch_Click<span style="color: #000000;">&#41;</span>;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rptProducts.<span style="color: #0000FF;">ItemDataBound</span> += <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> RepeaterItemEventHandler<span style="color: #000000;">&#40;</span>rptProducts_ItemDataBound<span style="color: #000000;">&#41;</span>;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _presenter = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Presenter.<span style="color: #0000FF;">ProductSearchPresenter</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Model.<span style="color: #0000FF;">LocalModel</span>.<span style="color: #0000FF;">BasicModel</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">System</span>.<span style="color: #0000FF;">Configuration</span>.<span style="color: #0000FF;">ConfigurationManager</span>.<span style="color: #0000FF;">ConnectionStrings</span><span style="color: #000000;">&#91;</span><span style="color: #808080;">&quot;AdventureWorks&quot;</span><span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">ConnectionString</span><span style="color: #000000;">&#41;</span>, <span style="color: #0600FF;">this</span><span style="color: #000000;">&#41;</span>;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; </li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">void</span> btnSearch_Click<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">object</span> sender, EventArgs e<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">this</span>._presenter.<span style="color: #0000FF;">ExecuteProductSearch</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">string</span> Presenter.<span style="color: #0000FF;">Views</span>.<span style="color: #0000FF;">IProductSearchView</span>.<span style="color: #0000FF;">SearchText</span> <span style="color: #000000;">&#123;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; get <span style="color: #000000;">&#123;</span> <span style="color: #0600FF;">return</span> tbSearch.<span style="color: #0000FF;">Text</span>; <span style="color: #000000;">&#125;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set <span style="color: #000000;">&#123;</span> tbSearch.<span style="color: #0000FF;">Text</span> = value; <span style="color: #000000;">&#125;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">int</span> Presenter.<span style="color: #0000FF;">Views</span>.<span style="color: #0000FF;">IProductSearchView</span>.<span style="color: #0000FF;">ResultCount</span> <span style="color: #000000;">&#123;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set <span style="color: #000000;">&#123;</span> lblResultCount.<span style="color: #0000FF;">Text</span> = value.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>; <span style="color: #000000;">&#125;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; List&lt;Model.<span style="color: #0000FF;">Entities</span>.<span style="color: #0000FF;">Product</span>&gt; Presenter.<span style="color: #0000FF;">Views</span>.<span style="color: #0000FF;">IProductSearchView</span>.<span style="color: #0000FF;">SearchResults</span> <span style="color: #000000;">&#123;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set <span style="color: #000000;">&#123;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>value != <span style="color: #0600FF;">null</span> &amp;&amp; value.<span style="color: #0000FF;">Count</span> &gt; <span style="color: #FF0000;">0</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rptProducts.<span style="color: #0000FF;">DataSource</span> = value;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rptProducts.<span style="color: #0000FF;">DataBind</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">bool</span> Presenter.<span style="color: #0000FF;">Views</span>.<span style="color: #0000FF;">IProductSearchView</span>.<span style="color: #0000FF;">DisplayResults</span> <span style="color: #000000;">&#123;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set <span style="color: #000000;">&#123;</span> tblResults.<span style="color: #0000FF;">Visible</span> = value; <span style="color: #000000;">&#125;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></li><li style="" class="li2">...</li></ol></div><div id="cb47541" style="display: none; color: red;"></div></div></div>

<p>As the presenter populates properties in the view, the information is automatically reflected on the page. The actual logic of how the business functions are called and populate those properties are neatly packaged up in the Presenter and View interface and very little logic occurs in the actual web form.</p>

<div class="codebox"><div class="codeheader"><span>csharp</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb14030'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb14030','cb19760'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="csharp" id="cb14030" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> ProductSearchPresenter : BasePresenter <span style="color: #000000;">&#123;</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">protected</span> Views.<span style="color: #0000FF;">IProductSearchView</span> _view;</li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">public</span> ProductSearchPresenter<span style="color: #000000;">&#40;</span>Model.<span style="color: #0000FF;">IModel</span> model, Views.<span style="color: #0000FF;">IProductSearchView</span> view<span style="color: #000000;">&#41;</span> : <span style="color: #0600FF;">base</span><span style="color: #000000;">&#40;</span>model<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">this</span>._view = view;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">this</span>._view.<span style="color: #0000FF;">ResultCount</span> = <span style="color: #FF0000;">0</span>;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">this</span>._view.<span style="color: #0000FF;">DisplayResults</span> = <span style="color: #0600FF;">false</span>;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> ExecuteProductSearch<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; List&lt;Model.<span style="color: #0000FF;">Entities</span>.<span style="color: #0000FF;">Product</span>&gt; results;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; results = <span style="color: #0600FF;">this</span>._model.<span style="color: #0000FF;">SearchProduct</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">this</span>._view.<span style="color: #0000FF;">SearchText</span><span style="color: #000000;">&#41;</span>;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>results.<span style="color: #0000FF;">Count</span> &gt; <span style="color: #FF0000;">0</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">this</span>._view.<span style="color: #0000FF;">ResultCount</span> = results.<span style="color: #0000FF;">Count</span>;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">this</span>._view.<span style="color: #0000FF;">DisplayResults</span> = <span style="color: #0600FF;">true</span>;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">this</span>._view.<span style="color: #0000FF;">SearchResults</span> = results;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">else</span> <span style="color: #000000;">&#123;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">this</span>._view.<span style="color: #0000FF;">ResultCount</span> = <span style="color: #FF0000;">0</span>;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">this</span>._view.<span style="color: #0000FF;">DisplayResults</span> = <span style="color: #0600FF;">false</span>;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">this</span>._view.<span style="color: #0000FF;">SearchResults</span> = <span style="color: #0600FF;">null</span>;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #000000;">&#125;</span></li></ol></div><div id="cb19760" style="display: none; color: red;"></div></div></div>

<p>To create a unit test, we define a simple view that implements the view interface, execute the presenter logic, and verify the properties are populated the way we would expect when the same presenter calls are made from the interface.</p>

<h3>Extending the Architecture Further</h3>
<p>Extending the application to display product search in a different manner would only require the addition of a new interface that also implements the Product Search View. A Silverlight front-end would only require creating the basic project, implementing the product search View, and wiring the new interface controls to the view properties. To replace the direct mode reference with a service reference, we could create a service facade that implemented the IModel interface, connected to a local or remote WCF service behid the scenes to handle the real model logic. And finally, instead of counting on our QA department to test all of the application interactions, we can create unit tests directly against the Presenter and Views to ensure that all of the interactions below the top surface of the application are happening consistently and to our expectation.</p>

<h2>Your Turn</h2>
<p>Getting this much of the architecture working is a good first step. I took a number of shortcuts on the BasicModel class in my example, but I now have a functional Model-View-Presenter application to play with. Hopefully there was enough information in the article to interest you in trying this out on your own. I urge you to read the articles linked in the top of the post (or several more in my <a href="http://delicious.com/tarwn/model-view-presenter" title="Eli's Delicious bookmarks for M-V-P" target="_blank">Model-View-Presentation bookmarks</a>) and come up with your own diagrams and sample project. Even doing a small project will force you to run into questions and considerations you wouldn't have had by simply reading about it, not to mention unrelated tidbits you will pick up along the way (for instance, I also learned about <a href="http://msdn.microsoft.com/en-us/library/ms668604.aspx" title="ObservableCollection at MSDN" target="_blank">ObservableCollections</a> today).</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/Architect/DesigningSoftware/model-view-presenter-looking-at-passive">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/Architect/DesigningSoftware/model-view-presenter-looking-at-passive#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/Architect/?tempskin=_rss2&#38;disp=comments&#38;p=889</wfw:commentRss>
		</item>
				<item>
			<title>MSDN giveaway winners</title>
			<link>http://blogs.lessthandot.com/index.php/Architect/HardwareInfrastructureDesign/msdn-giveaway-winners</link>
			<pubDate>Fri, 09 Jul 2010 15:23:42 +0000</pubDate>			<dc:creator>SQLDenis</dc:creator>
			<category domain="main">Hardware &amp; Infrastructure Design</category>			<guid isPermaLink="false">896@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;The winners of the MSDN Ultimate subscriptions are &lt;a href=&quot;http://blogs.lessthandot.com/index.php/All/?disp=authdir&amp;amp;author=71&quot;&gt;Emtucifor&lt;/a&gt; and &lt;a href=&quot;http://www.shawson.co.uk/codeblog&quot;&gt;Shawson&lt;/a&gt;. Originally we were going to select the winner based on comments, we also only had one subscription. Then Ted Krueger donated one of his subscriptions, there was only one comment that stood out and it was Emtucifor&#039;s. The comment is below&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;I have always dreamed of owning my own software company. A few years back I started doing some database development on the side, but then I got married, had a son, and began having some health challenges which together halted what I&#039;d been doing.&lt;/p&gt;

&lt;p&gt;But there is a special opportunity coming to me this Saturday to get back into the swing of things: my wife and son will be leaving the country for six weeks. I had already been planning to devote myself to developing one of many application ideas, but now:&lt;/p&gt;

&lt;p&gt;1) I would use MSDN Ultimate Subscription to build a secure server/file transfer/fetching/archiving/processing/reconciling/user worklist managing/cross-platform system (uncannily and quite coincidentally, exactly what is desperately needed at a company I know). It will help other people&#039;s lives in several ways: filling a need that many companies are bound to have and for a low price (as initially I will need to build market presence more than profit); increasing the number of small software development businesses out there, proving again that it can be done and providing inspiration for the masses; getting a family&#039;s Dad home so he can spend more time with them. If it helps, I&#039;ll blog about the development and growth of my application and business.&lt;/p&gt;

&lt;p&gt;2) The functionality I would use that is unique to VS Ultimate is Architecture and Modeling. I believe in &quot;starting the way you mean to finish.&quot; So even though I&#039;ll be a one-man shop at first, that means test-driven design, agile development, automated regression testing, version control, good backups, and all the infrastructure needed to hire employees when the time comes without having to change much. I&#039;ll be eager to add the layer diagramming abilities of VS Ultimate to this mix.&lt;/p&gt;

&lt;p&gt;3. Blogs and technical community activity:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/All/?disp=authdir&amp;amp;author=71&quot;&gt;http://blogs.lessthandot.com/index.php/All/?disp=authdir&amp;amp;author=71&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://stackoverflow.com/users/57611/emtucifor&quot;&gt;http://stackoverflow.com/users/57611/emtucifor&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://tek-tips.com/userinfo.cfm?member=emtucifor&quot;&gt;http://tek-tips.com/userinfo.cfm?member=emtucifor&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://squaredthoughts.blogspot.com/&quot;&gt;http://squaredthoughts.blogspot.com/&lt;/a&gt; (a bit out of date but still representative of my work)&lt;br /&gt;
not to mention &lt;a href=&quot;http://forum.lessthandot.com/memberlist.php?mode=viewprofile&amp;amp;u=98&quot;&gt;http://forum.lessthandot.com/memberlist.php?mode=viewprofile&amp;amp;u=98&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;Not only did we think that the comment was good but apparently someone else as well, he actually used parts of it as his own in Andy Leonard&#039;s giveaway here: &lt;a href=&quot;http://sqlblog.com/blogs/andy_leonard/archive/2010/07/03/a-visual-studio-2010-msdn-seeding-card-giveaway-contest.aspx&quot;&gt;http://sqlblog.com/blogs/andy_leonard/archive/2010/07/03/a-visual-studio-2010-msdn-seeding-card-giveaway-contest.aspx&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We decided to raffle of the other subscription by vote..so I already started to put the polls together. During that time David Taylor left a great comment&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;1) Why do you need this - Because I am a poor, seriously underpaid SQL Server 2008 DBA/Developer who can&#039;t even afford VS2010 Pro!&lt;br /&gt;
What are you going to build with this - I am going to build practice apps to learn from, as I am relatively new to development&lt;br /&gt;
will it help other people&#039;s lives? It is my hope that training myself will get me into a job in which I am helping other people.&lt;/p&gt;

&lt;p&gt;2) What specific functionality that is only part of Ultimate are you going to use? - Architecture Explorer&lt;/p&gt;

&lt;p&gt;3) You need to have a technical blog and provide the URL to that blog, if you are an active member of the technical community (stackoverflow, msdn forums etc etc) then also include those links. - &lt;a href=&quot;http://dyfhid.wordpress.com&quot;&gt;http://dyfhid.wordpress.com&lt;/a&gt;. Also, I am the Volunteer Coordinator for PASS&#039; APplication Development Virtual Chapter, located at &lt;a href=&quot;http://appdev.sqlpass.org&quot;&gt;http://appdev.sqlpass.org&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;Now we had a dilemma, do we yank the poll and give the award to David or not? We proceeded with the poll. Wouldn&#039;t you know it, David won Andy&#039;s contest, because of that I emailed him and we decided that he wouldn&#039;t be eligible here.&lt;/p&gt;

&lt;p&gt;Here are the results of the final poll: &lt;a href=&quot;http://forum.lessthandot.com/viewtopic.php?f=121&amp;amp;t=11550&quot;&gt;http://forum.lessthandot.com/viewtopic.php?f=121&amp;amp;t=11550&lt;/a&gt;&lt;/p&gt;


&lt;p&gt;Congratulations to both winners, hopefully they will let us know in a couple of months if this has indeed made their developer life easier&lt;/p&gt;


&lt;p&gt;Congratulations again from all of us at Lessthandot.&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/Architect/HardwareInfrastructureDesign/msdn-giveaway-winners&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>The winners of the MSDN Ultimate subscriptions are <a href="http://blogs.lessthandot.com/index.php/All/?disp=authdir&amp;author=71">Emtucifor</a> and <a href="http://www.shawson.co.uk/codeblog">Shawson</a>. Originally we were going to select the winner based on comments, we also only had one subscription. Then Ted Krueger donated one of his subscriptions, there was only one comment that stood out and it was Emtucifor's. The comment is below</p>

<blockquote><p>I have always dreamed of owning my own software company. A few years back I started doing some database development on the side, but then I got married, had a son, and began having some health challenges which together halted what I'd been doing.</p>

<p>But there is a special opportunity coming to me this Saturday to get back into the swing of things: my wife and son will be leaving the country for six weeks. I had already been planning to devote myself to developing one of many application ideas, but now:</p>

<p>1) I would use MSDN Ultimate Subscription to build a secure server/file transfer/fetching/archiving/processing/reconciling/user worklist managing/cross-platform system (uncannily and quite coincidentally, exactly what is desperately needed at a company I know). It will help other people's lives in several ways: filling a need that many companies are bound to have and for a low price (as initially I will need to build market presence more than profit); increasing the number of small software development businesses out there, proving again that it can be done and providing inspiration for the masses; getting a family's Dad home so he can spend more time with them. If it helps, I'll blog about the development and growth of my application and business.</p>

<p>2) The functionality I would use that is unique to VS Ultimate is Architecture and Modeling. I believe in "starting the way you mean to finish." So even though I'll be a one-man shop at first, that means test-driven design, agile development, automated regression testing, version control, good backups, and all the infrastructure needed to hire employees when the time comes without having to change much. I'll be eager to add the layer diagramming abilities of VS Ultimate to this mix.</p>

<p>3. Blogs and technical community activity:</p>

<p><a href="http://blogs.lessthandot.com/index.php/All/?disp=authdir&amp;author=71">http://blogs.lessthandot.com/index.php/All/?disp=authdir&amp;author=71</a><br />
<a href="http://stackoverflow.com/users/57611/emtucifor">http://stackoverflow.com/users/57611/emtucifor</a><br />
<a href="http://tek-tips.com/userinfo.cfm?member=emtucifor">http://tek-tips.com/userinfo.cfm?member=emtucifor</a><br />
<a href="http://squaredthoughts.blogspot.com/">http://squaredthoughts.blogspot.com/</a> (a bit out of date but still representative of my work)<br />
not to mention <a href="http://forum.lessthandot.com/memberlist.php?mode=viewprofile&amp;u=98">http://forum.lessthandot.com/memberlist.php?mode=viewprofile&amp;u=98</a></p></blockquote>

<p>Not only did we think that the comment was good but apparently someone else as well, he actually used parts of it as his own in Andy Leonard's giveaway here: <a href="http://sqlblog.com/blogs/andy_leonard/archive/2010/07/03/a-visual-studio-2010-msdn-seeding-card-giveaway-contest.aspx">http://sqlblog.com/blogs/andy_leonard/archive/2010/07/03/a-visual-studio-2010-msdn-seeding-card-giveaway-contest.aspx</a></p>

<p>We decided to raffle of the other subscription by vote..so I already started to put the polls together. During that time David Taylor left a great comment</p>

<blockquote><p>1) Why do you need this - Because I am a poor, seriously underpaid SQL Server 2008 DBA/Developer who can't even afford VS2010 Pro!<br />
What are you going to build with this - I am going to build practice apps to learn from, as I am relatively new to development<br />
will it help other people's lives? It is my hope that training myself will get me into a job in which I am helping other people.</p>

<p>2) What specific functionality that is only part of Ultimate are you going to use? - Architecture Explorer</p>

<p>3) You need to have a technical blog and provide the URL to that blog, if you are an active member of the technical community (stackoverflow, msdn forums etc etc) then also include those links. - <a href="http://dyfhid.wordpress.com">http://dyfhid.wordpress.com</a>. Also, I am the Volunteer Coordinator for PASS' APplication Development Virtual Chapter, located at <a href="http://appdev.sqlpass.org">http://appdev.sqlpass.org</a></p></blockquote>

<p>Now we had a dilemma, do we yank the poll and give the award to David or not? We proceeded with the poll. Wouldn't you know it, David won Andy's contest, because of that I emailed him and we decided that he wouldn't be eligible here.</p>

<p>Here are the results of the final poll: <a href="http://forum.lessthandot.com/viewtopic.php?f=121&amp;t=11550">http://forum.lessthandot.com/viewtopic.php?f=121&amp;t=11550</a></p>


<p>Congratulations to both winners, hopefully they will let us know in a couple of months if this has indeed made their developer life easier</p>


<p>Congratulations again from all of us at Lessthandot.</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/Architect/HardwareInfrastructureDesign/msdn-giveaway-winners">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/Architect/HardwareInfrastructureDesign/msdn-giveaway-winners#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/Architect/?tempskin=_rss2&#38;disp=comments&#38;p=896</wfw:commentRss>
		</item>
				<item>
			<title>Final vote for the MSDN giveaway</title>
			<link>http://blogs.lessthandot.com/index.php/Architect/HardwareInfrastructureDesign/final-vote-for-the-msdn-giveaway</link>
			<pubDate>Fri, 09 Jul 2010 10:47:59 +0000</pubDate>			<dc:creator>SQLDenis</dc:creator>
			<category domain="main">Hardware &amp; Infrastructure Design</category>			<guid isPermaLink="false">895@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;We are giving away 2 MSDN ultimate subscriptions, for the original announcement see here: &lt;a href=&quot;http://blogs.lessthandot.com/index.php/Architect/HardwareInfrastructureDesign/msdn-ultimate-subscription-giveaway&quot;&gt;MSDN Ultimate Subscription giveaway&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We did not include David Taylor because he won this morning at sqlblog: &lt;a href=&quot;http://sqlblog.com/blogs/andy_leonard/archive/2010/07/09/and-the-winner-is.aspx&quot;&gt;http://sqlblog.com/blogs/andy_leonard/archive/2010/07/09/and-the-winner-is.aspx&lt;/a&gt; and he was fine with us taking him off.&lt;/p&gt;

&lt;p&gt;Here are the 6 finalist, I picked the top 3 from each group that people had a chance to vote on: &lt;a href=&quot;http://forum.lessthandot.com/viewtopic.php?f=121&amp;amp;t=11533&quot;&gt;http://forum.lessthandot.com/viewtopic.php?f=121&amp;amp;t=11533&lt;/a&gt; and &lt;a href=&quot;http://forum.lessthandot.com/posting.php?mode=edit&amp;amp;f=121&amp;amp;p=56403&quot;&gt;http://forum.lessthandot.com/posting.php?mode=edit&amp;amp;f=121&amp;amp;p=56403&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This vote will end in 3 hours, at noon Eastern Standard Time (GMT -5)&lt;br /&gt;
Here are the candidates and their replies&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Shawson&lt;/strong&gt;&lt;br /&gt;
1) I will build games with it. I am getting into indie game development with a view to moving from my current profession of web development into games development. I&#039;m just completing a browser game using just javascript and the new html5 media and canvas elements, to see whats possible in the near future without flash! So i will be using it for c# xna, as well as javascript and html. I also wish to do some work with the new odata stuff, to deal with the highscores, as well as a chance to use the latest iteration of the entity framework. &lt;/p&gt;

&lt;p&gt;2) The historical debugger would be awesome, especially when debugging realtime code which is changing all the time, as you see in game loops. I&#039;m also interested to see the designer tools letting you visually build systems with UML and have the basic structural code generated for you. &lt;/p&gt;

&lt;p&gt;3) &lt;a href=&quot;http://www.shawson.co.uk/codeblog&quot;&gt;http://www.shawson.co.uk/codeblog&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://8weekgame.shawson.co.uk&quot;&gt;http://8weekgame.shawson.co.uk&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://stackoverflow.com/users/192305/shawson&quot;&gt;http://stackoverflow.com/users/192305/shawson&lt;/a&gt;&lt;/p&gt;


&lt;p&gt;&lt;strong&gt;Roger Pence&lt;/strong&gt;&lt;br /&gt;
1. I need this subscription to help me simplify healthcare-related software. Simpler software is easier to use correctly. Improve record keeping improves lives.&lt;br /&gt;
2. Better ALM, Architecture and Modeling, and DB support would help make me a better developer.&lt;br /&gt;
3. &lt;a href=&quot;http://rogerpence.com/blog&quot;&gt;http://rogerpence.com/blog&lt;/a&gt;&lt;/p&gt;


&lt;p&gt;&lt;strong&gt;Naomi&lt;/strong&gt;&lt;br /&gt;
&lt;a href=&quot;http://blogs.lessthandot.com/index.php/All/?disp=authdir&amp;amp;author=218&quot;&gt;http://blogs.lessthandot.com/index.php/All/?disp=authdir&amp;amp;author=218&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://beyondrelational.com/blogs/naomi/archive/2010/03/22/why-left-join-doesn-t-bring-all-records-from-the-left-table.aspx&quot;&gt;http://beyondrelational.com/blogs/naomi/archive/2010/03/22/why-left-join-doesn-t-bring-all-records-from-the-left-table.aspx&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Active answerer at many technical sites:&lt;/p&gt;

&lt;p&gt;MSDN &lt;br /&gt;
ASP.NET/Forums&lt;br /&gt;
universalthread.com&lt;br /&gt;
tek-ips.com&lt;/p&gt;


&lt;p&gt;&lt;strong&gt;Dave Ballantyne&lt;/strong&gt;&lt;br /&gt;
1) I am now running my a user group ( &lt;a href=&quot;http://sqlsocialkent20100818.eventbrite.com/)&quot;&gt;http://sqlsocialkent20100818.eventbrite.com/)&lt;/a&gt; , so would like to speak with more authority about DataDude and such issues.&lt;br /&gt;
2) Intellitrace looks good as do the architecture components.&lt;br /&gt;
3) &lt;a href=&quot;http://sqlblogcasts.com/blogs/sqlandthelike/&quot;&gt;http://sqlblogcasts.com/blogs/sqlandthelike/&lt;/a&gt; , active in SqlServerCentral and msdn online forums, User groups twitter, fingers cross for a session at SqlBits&lt;/p&gt;


&lt;p&gt;&lt;strong&gt;dennydotnet&lt;/strong&gt;&lt;br /&gt;
1. I am working on a startup idea. Currently using ASP.NET MVC 1, VS 2008. Would love to move up to VS 2010 / .NET 4 and latest MVC version. Idea is around helping people find great deals on products/services.&lt;/p&gt;

&lt;p&gt;2. I could certainly use the feature packs / architecture / modeling tools and the latest Visual Studio 2010. I&#039;d also be interested in playing with Expression Studio Ultimate. Any Windows Phone 7 stuff (if available) would be nice to experiment with as well.&lt;/p&gt;

&lt;p&gt;3. &lt;a href=&quot;http://www.dennydotnet.com&quot;&gt;http://www.dennydotnet.com&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://stackoverflow.com/users/113474/dennydotnet&quot;&gt;http://stackoverflow.com/users/113474/dennydotnet&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://forums.asp.net/members/superghost.aspx&quot;&gt;http://forums.asp.net/members/superghost.aspx&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Meile Zetstra&lt;/strong&gt;&lt;br /&gt;
1) I&#039;m currently running VS2010 Premium, but it just lacks the of all the architectural stuff that&#039;s in the Ultimate version. I&#039;d use that to build some tooling or VS extension that revolves arround code inspection, code reflection and generations of diagrams from existing assemblies.&lt;/p&gt;

&lt;p&gt;2) The architecture and modeling stuff. Also the use of the just released Visualization and Modeling Feature Pack is on my wish-to-use list.&lt;/p&gt;

&lt;p&gt;3) My blog: &lt;a href=&quot;http://blogger.xs4all.nl/mzetstra&quot;&gt;http://blogger.xs4all.nl/mzetstra&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://sequenceviz.codeplex.com&quot;&gt;http://sequenceviz.codeplex.com&lt;/a&gt;&lt;/p&gt;


&lt;p&gt;&lt;strong&gt;You can vote here: &lt;a href=&quot;http://forum.lessthandot.com/viewtopic.php?f=121&amp;amp;t=11550&quot;&gt;http://forum.lessthandot.com/viewtopic.php?f=121&amp;amp;t=11550&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/Architect/HardwareInfrastructureDesign/final-vote-for-the-msdn-giveaway&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>We are giving away 2 MSDN ultimate subscriptions, for the original announcement see here: <a href="http://blogs.lessthandot.com/index.php/Architect/HardwareInfrastructureDesign/msdn-ultimate-subscription-giveaway">MSDN Ultimate Subscription giveaway</a></p>

<p>We did not include David Taylor because he won this morning at sqlblog: <a href="http://sqlblog.com/blogs/andy_leonard/archive/2010/07/09/and-the-winner-is.aspx">http://sqlblog.com/blogs/andy_leonard/archive/2010/07/09/and-the-winner-is.aspx</a> and he was fine with us taking him off.</p>

<p>Here are the 6 finalist, I picked the top 3 from each group that people had a chance to vote on: <a href="http://forum.lessthandot.com/viewtopic.php?f=121&amp;t=11533">http://forum.lessthandot.com/viewtopic.php?f=121&amp;t=11533</a> and <a href="http://forum.lessthandot.com/posting.php?mode=edit&amp;f=121&amp;p=56403">http://forum.lessthandot.com/posting.php?mode=edit&amp;f=121&amp;p=56403</a></p>

<p>This vote will end in 3 hours, at noon Eastern Standard Time (GMT -5)<br />
Here are the candidates and their replies</p>

<p><strong>Shawson</strong><br />
1) I will build games with it. I am getting into indie game development with a view to moving from my current profession of web development into games development. I'm just completing a browser game using just javascript and the new html5 media and canvas elements, to see whats possible in the near future without flash! So i will be using it for c# xna, as well as javascript and html. I also wish to do some work with the new odata stuff, to deal with the highscores, as well as a chance to use the latest iteration of the entity framework. </p>

<p>2) The historical debugger would be awesome, especially when debugging realtime code which is changing all the time, as you see in game loops. I'm also interested to see the designer tools letting you visually build systems with UML and have the basic structural code generated for you. </p>

<p>3) <a href="http://www.shawson.co.uk/codeblog">http://www.shawson.co.uk/codeblog</a><br />
<a href="http://8weekgame.shawson.co.uk">http://8weekgame.shawson.co.uk</a><br />
<a href="http://stackoverflow.com/users/192305/shawson">http://stackoverflow.com/users/192305/shawson</a></p>


<p><strong>Roger Pence</strong><br />
1. I need this subscription to help me simplify healthcare-related software. Simpler software is easier to use correctly. Improve record keeping improves lives.<br />
2. Better ALM, Architecture and Modeling, and DB support would help make me a better developer.<br />
3. <a href="http://rogerpence.com/blog">http://rogerpence.com/blog</a></p>


<p><strong>Naomi</strong><br />
<a href="http://blogs.lessthandot.com/index.php/All/?disp=authdir&amp;author=218">http://blogs.lessthandot.com/index.php/All/?disp=authdir&amp;author=218</a><br />
<a href="http://beyondrelational.com/blogs/naomi/archive/2010/03/22/why-left-join-doesn-t-bring-all-records-from-the-left-table.aspx">http://beyondrelational.com/blogs/naomi/archive/2010/03/22/why-left-join-doesn-t-bring-all-records-from-the-left-table.aspx</a></p>

<p>Active answerer at many technical sites:</p>

<p>MSDN <br />
ASP.NET/Forums<br />
universalthread.com<br />
tek-ips.com</p>


<p><strong>Dave Ballantyne</strong><br />
1) I am now running my a user group ( <a href="http://sqlsocialkent20100818.eventbrite.com/)">http://sqlsocialkent20100818.eventbrite.com/)</a> , so would like to speak with more authority about DataDude and such issues.<br />
2) Intellitrace looks good as do the architecture components.<br />
3) <a href="http://sqlblogcasts.com/blogs/sqlandthelike/">http://sqlblogcasts.com/blogs/sqlandthelike/</a> , active in SqlServerCentral and msdn online forums, User groups twitter, fingers cross for a session at SqlBits</p>


<p><strong>dennydotnet</strong><br />
1. I am working on a startup idea. Currently using ASP.NET MVC 1, VS 2008. Would love to move up to VS 2010 / .NET 4 and latest MVC version. Idea is around helping people find great deals on products/services.</p>

<p>2. I could certainly use the feature packs / architecture / modeling tools and the latest Visual Studio 2010. I'd also be interested in playing with Expression Studio Ultimate. Any Windows Phone 7 stuff (if available) would be nice to experiment with as well.</p>

<p>3. <a href="http://www.dennydotnet.com">http://www.dennydotnet.com</a><br />
<a href="http://stackoverflow.com/users/113474/dennydotnet">http://stackoverflow.com/users/113474/dennydotnet</a><br />
<a href="http://forums.asp.net/members/superghost.aspx">http://forums.asp.net/members/superghost.aspx</a></p>

<p><strong>Meile Zetstra</strong><br />
1) I'm currently running VS2010 Premium, but it just lacks the of all the architectural stuff that's in the Ultimate version. I'd use that to build some tooling or VS extension that revolves arround code inspection, code reflection and generations of diagrams from existing assemblies.</p>

<p>2) The architecture and modeling stuff. Also the use of the just released Visualization and Modeling Feature Pack is on my wish-to-use list.</p>

<p>3) My blog: <a href="http://blogger.xs4all.nl/mzetstra">http://blogger.xs4all.nl/mzetstra</a><br />
<a href="http://sequenceviz.codeplex.com">http://sequenceviz.codeplex.com</a></p>


<p><strong>You can vote here: <a href="http://forum.lessthandot.com/viewtopic.php?f=121&amp;t=11550">http://forum.lessthandot.com/viewtopic.php?f=121&amp;t=11550</a></strong></p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/Architect/HardwareInfrastructureDesign/final-vote-for-the-msdn-giveaway">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/Architect/HardwareInfrastructureDesign/final-vote-for-the-msdn-giveaway#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/Architect/?tempskin=_rss2&#38;disp=comments&#38;p=895</wfw:commentRss>
		</item>
				<item>
			<title>Vote for the MSDN giveaway winner</title>
			<link>http://blogs.lessthandot.com/index.php/Architect/HardwareInfrastructureDesign/vote-for-the-msdn-giveaway-winner</link>
			<pubDate>Thu, 08 Jul 2010 15:17:37 +0000</pubDate>			<dc:creator>SQLDenis</dc:creator>
			<category domain="main">Hardware &amp; Infrastructure Design</category>			<guid isPermaLink="false">894@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;As you might know we are giving away 2 MSDN ultimate subscriptions, for the original announcement see here: &lt;a href=&quot;http://blogs.lessthandot.com/index.php/Architect/HardwareInfrastructureDesign/msdn-ultimate-subscription-giveaway&quot;&gt;MSDN Ultimate Subscription giveaway&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We decided on one of the winners already, for the other winner I decided to pull a Pontius Pilate on you so that nobody can blame me that they didn&#039;t win....yes I know it sounds like a  cop out...that is because it is...and this is more fun.&lt;/p&gt;

&lt;p&gt;Here is what I did..I picked the 20 best answers and put them in 2 groups of 10. In each group 3 people will advance to a final vote, you can vote for two people. The results of those two polls will be looked at tomorrow morning around 9 AM EST and then a new poll will be created with the final 6 contestants.&lt;/p&gt;


&lt;p&gt;Make sure that you look at every person&#039;s answer, also check their links so that you can decide who should advance.&lt;/p&gt;


&lt;p&gt;The group A people can be found here: &lt;a href=&quot;http://forum.lessthandot.com/viewtopic.php?f=121&amp;amp;t=11533&quot;&gt;http://forum.lessthandot.com/viewtopic.php?f=121&amp;amp;t=11533&lt;/a&gt;&lt;br /&gt;
The group B people can be found here: &lt;a href=&quot;http://forum.lessthandot.com/viewtopic.php?f=121&amp;amp;t=11532&quot;&gt;http://forum.lessthandot.com/viewtopic.php?f=121&amp;amp;t=11532&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Good luck everyone&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/Architect/HardwareInfrastructureDesign/vote-for-the-msdn-giveaway-winner&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>As you might know we are giving away 2 MSDN ultimate subscriptions, for the original announcement see here: <a href="http://blogs.lessthandot.com/index.php/Architect/HardwareInfrastructureDesign/msdn-ultimate-subscription-giveaway">MSDN Ultimate Subscription giveaway</a></p>

<p>We decided on one of the winners already, for the other winner I decided to pull a Pontius Pilate on you so that nobody can blame me that they didn't win....yes I know it sounds like a  cop out...that is because it is...and this is more fun.</p>

<p>Here is what I did..I picked the 20 best answers and put them in 2 groups of 10. In each group 3 people will advance to a final vote, you can vote for two people. The results of those two polls will be looked at tomorrow morning around 9 AM EST and then a new poll will be created with the final 6 contestants.</p>


<p>Make sure that you look at every person's answer, also check their links so that you can decide who should advance.</p>


<p>The group A people can be found here: <a href="http://forum.lessthandot.com/viewtopic.php?f=121&amp;t=11533">http://forum.lessthandot.com/viewtopic.php?f=121&amp;t=11533</a><br />
The group B people can be found here: <a href="http://forum.lessthandot.com/viewtopic.php?f=121&amp;t=11532">http://forum.lessthandot.com/viewtopic.php?f=121&amp;t=11532</a></p>

<p>Good luck everyone</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/Architect/HardwareInfrastructureDesign/vote-for-the-msdn-giveaway-winner">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/Architect/HardwareInfrastructureDesign/vote-for-the-msdn-giveaway-winner#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/Architect/?tempskin=_rss2&#38;disp=comments&#38;p=894</wfw:commentRss>
		</item>
			</channel>
</rss>
