<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Programmers Unlimited</title>
	<atom:link href="http://programmersunlimited.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://programmersunlimited.wordpress.com</link>
	<description>Knowledge is power</description>
	<lastBuildDate>Wed, 16 May 2012 03:47:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='programmersunlimited.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Programmers Unlimited</title>
		<link>http://programmersunlimited.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://programmersunlimited.wordpress.com/osd.xml" title="Programmers Unlimited" />
	<atom:link rel='hub' href='http://programmersunlimited.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Introducing ConnectionString Manager</title>
		<link>http://programmersunlimited.wordpress.com/2012/05/16/introducing-connectionstring-manager/</link>
		<comments>http://programmersunlimited.wordpress.com/2012/05/16/introducing-connectionstring-manager/#comments</comments>
		<pubDate>Wed, 16 May 2012 03:45:53 +0000</pubDate>
		<dc:creator>programmersunlimited</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">https://programmersunlimited.wordpress.com/?p=522</guid>
		<description><![CDATA[I have just release my latest Visual Studio Extension, ConnectionString Manager. Find it in the Visual Studio Gallery. http://visualstudiogallery.msdn.microsoft.com/78c6d440-7a65-4ce3-af99-7e8f8e0676dc What is it? ConnectionString Manager is a tool that allows developers to manage all connection strings in a solution from a centralized location. Features There are quite a few features that I’ve added to this extension [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=programmersunlimited.wordpress.com&#038;blog=14241067&#038;post=522&#038;subd=programmersunlimited&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have just release my latest Visual Studio Extension, <a href="http://visualstudiogallery.msdn.microsoft.com/78c6d440-7a65-4ce3-af99-7e8f8e0676dc">ConnectionString Manager</a>. Find it in the Visual Studio Gallery. <a href="http://visualstudiogallery.msdn.microsoft.com/78c6d440-7a65-4ce3-af99-7e8f8e0676dc">http://visualstudiogallery.msdn.microsoft.com/78c6d440-7a65-4ce3-af99-7e8f8e0676dc</a></p>
<h1>What is it?</h1>
<p><a href="http://visualstudiogallery.msdn.microsoft.com/78c6d440-7a65-4ce3-af99-7e8f8e0676dc">ConnectionString Manager</a> is a tool that allows developers to manage all connection strings in a solution from a centralized location.</p>
<h1>Features</h1>
<p>There are quite a few features that I’ve added to this extension</p>
<p><strong><span style="text-decoration:underline;">Quickly View all connection strings in a solution</span></strong><br />
When the extension is ran, it scans the entire solution and extracts all connection strings from the configuration files and displays the project, config file, connection name, connection string and the connectivity status.</p>
<p><a href="http://programmersunlimited.files.wordpress.com/2012/05/connectionstringmanager.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="ConnectionStringManager" src="http://programmersunlimited.files.wordpress.com/2012/05/connectionstringmanager_thumb.jpg?w=644&h=345" alt="ConnectionStringManager" width="644" height="345" border="0" /></a></p>
<p><strong><span style="text-decoration:underline;">Test one or all connection strings</span></strong><br />
Quickly validate connection strings with a single click, without leaving Visual Studio. Testing can be done from almost any dialog.</p>
<p><a href="http://programmersunlimited.files.wordpress.com/2012/05/connectionstringmanager_test.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="ConnectionStringManager_Test" src="http://programmersunlimited.files.wordpress.com/2012/05/connectionstringmanager_test_thumb.jpg?w=644&h=345" alt="ConnectionStringManager_Test" width="644" height="345" border="0" /></a></p>
<p><strong><span style="text-decoration:underline;">Quick open</span><br />
</strong>Quickly open the host configuration file for any connection string. No more hunting through solutions and projects to find the configs.</p>
<p><a href="http://programmersunlimited.files.wordpress.com/2012/05/connectionstringmanager_quickopen.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="ConnectionStringManager_QuickOpen" src="http://programmersunlimited.files.wordpress.com/2012/05/connectionstringmanager_quickopen_thumb.jpg?w=644&h=268" alt="ConnectionStringManager_QuickOpen" width="644" height="268" border="0" /></a></p>
<p><strong><span style="text-decoration:underline;">Add, Edit, Remove connection strings</span></strong><br />
Add, edit and remove connections strings all from a centralized utility window. No more hunting for and jumping between config files to make edits.</p>
<p><a href="http://programmersunlimited.files.wordpress.com/2012/05/connectionstringmanager_edit.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="ConnectionStringManager_Edit" src="http://programmersunlimited.files.wordpress.com/2012/05/connectionstringmanager_edit_thumb.jpg?w=644&h=345" alt="ConnectionStringManager_Edit" width="644" height="345" border="0" /></a></p>
<p><span style="text-decoration:underline;"><strong>Save connections for later</strong><br />
</span>With the saved connections feature, you can store common connection strings for use in other projects.</p>
<p><a href="http://programmersunlimited.files.wordpress.com/2012/05/connectionstringmanager_saveforlater.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="ConnectionStringManager_SaveForLater" src="http://programmersunlimited.files.wordpress.com/2012/05/connectionstringmanager_saveforlater_thumb.jpg?w=644&h=345" alt="ConnectionStringManager_SaveForLater" width="644" height="345" border="0" /></a></p>
<p><span style="text-decoration:underline;"><strong>Swap connection strings</strong><br />
</span>Quickly change a connection string to a saved connection string quickly with the quick list</p>
<p><a href="http://programmersunlimited.files.wordpress.com/2012/05/connectionstringmanager_swap.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="ConnectionStringManager_Swap" src="http://programmersunlimited.files.wordpress.com/2012/05/connectionstringmanager_swap_thumb.jpg?w=644&h=345" alt="ConnectionStringManager_Swap" width="644" height="345" border="0" /></a></p>
<p><strong><span style="text-decoration:underline;">Add multiple connection strings to multiple configs at once</span></strong><br />
New and saved connections can be added to many configuration files with just a few clicks. No more copy &amp; paste. Enter the new connection string data and/or select one or more saved connections, then choose which configs to write them to.</p>
<p><a href="http://programmersunlimited.files.wordpress.com/2012/05/connectionstringmanager_addmultiple.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="ConnectionStringManager_AddMultiple" src="http://programmersunlimited.files.wordpress.com/2012/05/connectionstringmanager_addmultiple_thumb.jpg?w=458&h=484" alt="ConnectionStringManager_AddMultiple" width="458" height="484" border="0" /></a></p>
<h1>Why did I build this?</h1>
<p>Working on a medium sized project with a small team and an old version of TFS, we had some issues with connection strings being changed in the configs and no one knowing about it until runtime. We also have split config files to deal with. I decided to write this tool to reduce the time it takes to correct and test the connection strings since it had to be done over multiple projects.</p>
<p>I’d love to get your feedback on this extension. It’s free to everyone.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/programmersunlimited.wordpress.com/522/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/programmersunlimited.wordpress.com/522/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/programmersunlimited.wordpress.com/522/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/programmersunlimited.wordpress.com/522/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/programmersunlimited.wordpress.com/522/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/programmersunlimited.wordpress.com/522/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/programmersunlimited.wordpress.com/522/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/programmersunlimited.wordpress.com/522/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/programmersunlimited.wordpress.com/522/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/programmersunlimited.wordpress.com/522/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/programmersunlimited.wordpress.com/522/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/programmersunlimited.wordpress.com/522/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/programmersunlimited.wordpress.com/522/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/programmersunlimited.wordpress.com/522/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=programmersunlimited.wordpress.com&#038;blog=14241067&#038;post=522&#038;subd=programmersunlimited&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://programmersunlimited.wordpress.com/2012/05/16/introducing-connectionstring-manager/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c9e4d72e0a29be3bf43a6c8e0cbd656d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">programmersunlimited</media:title>
		</media:content>

		<media:content url="http://programmersunlimited.files.wordpress.com/2012/05/connectionstringmanager_thumb.jpg" medium="image">
			<media:title type="html">ConnectionStringManager</media:title>
		</media:content>

		<media:content url="http://programmersunlimited.files.wordpress.com/2012/05/connectionstringmanager_test_thumb.jpg" medium="image">
			<media:title type="html">ConnectionStringManager_Test</media:title>
		</media:content>

		<media:content url="http://programmersunlimited.files.wordpress.com/2012/05/connectionstringmanager_quickopen_thumb.jpg" medium="image">
			<media:title type="html">ConnectionStringManager_QuickOpen</media:title>
		</media:content>

		<media:content url="http://programmersunlimited.files.wordpress.com/2012/05/connectionstringmanager_edit_thumb.jpg" medium="image">
			<media:title type="html">ConnectionStringManager_Edit</media:title>
		</media:content>

		<media:content url="http://programmersunlimited.files.wordpress.com/2012/05/connectionstringmanager_saveforlater_thumb.jpg" medium="image">
			<media:title type="html">ConnectionStringManager_SaveForLater</media:title>
		</media:content>

		<media:content url="http://programmersunlimited.files.wordpress.com/2012/05/connectionstringmanager_swap_thumb.jpg" medium="image">
			<media:title type="html">ConnectionStringManager_Swap</media:title>
		</media:content>

		<media:content url="http://programmersunlimited.files.wordpress.com/2012/05/connectionstringmanager_addmultiple_thumb.jpg" medium="image">
			<media:title type="html">ConnectionStringManager_AddMultiple</media:title>
		</media:content>
	</item>
		<item>
		<title>Reducing latency with message queues</title>
		<link>http://programmersunlimited.wordpress.com/2012/04/11/reducing-latency-with-message-queues/</link>
		<comments>http://programmersunlimited.wordpress.com/2012/04/11/reducing-latency-with-message-queues/#comments</comments>
		<pubDate>Wed, 11 Apr 2012 19:48:55 +0000</pubDate>
		<dc:creator>programmersunlimited</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">https://programmersunlimited.wordpress.com/?p=492</guid>
		<description><![CDATA[While working for an internet marketing company I was tasked with reviewing an application for performance optimization opportunities. The goal was to reduce the latency of each web request. The application was nothing more than a tracking web site that was used to track clicks from PPC (pay-per-click) advertisements (e.x, AdWords). When a user clicked [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=programmersunlimited.wordpress.com&#038;blog=14241067&#038;post=492&#038;subd=programmersunlimited&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>While working for an internet marketing company I was tasked with reviewing an application for performance optimization opportunities. The goal was to reduce the latency of each web request. The application was nothing more than a tracking web site that was used to track clicks from PPC (pay-per-click) advertisements (e.x, AdWords). When a user clicked on an ad, they would be sent to the web app and then redirected to the final destination URL.</p>
<h2>Problem?</h2>
<p>It’s the same old story. The system started out fast and as time went on (read: as more data/traffic came in) the latency increased for each request. After adding five additional servers for load balancing, the latency didn’t improve.</p>
<p>The definition of slow was 80-100ms. The target was 20ms. After investigation, I found that the web app was writing the details of each request to a database. Not just any database though, the only database the company had. The same database that every other application relied on.</p>
<p>The concept of scalability was lacking.</p>
<p>Continuing my investigation, I ask the usual questions about the data that was being logged, how it’s used, how often and of course, how fresh does it have to be? The answers made it very clear on how I could meet the goal of 20ms. The data was stored in a table where it would be processed every hour by some other process, but only data from the previous hour would be handled. In summary the data did not need to be delivered in real time. It just needed to eventually get delivered.</p>
<h2>Solution!</h2>
<p>Since there was no way that I could optimize the database, or calls to it, I went ahead and decided to optimize the architecture of the web app instead.</p>
<p><a href="http://programmersunlimited.files.wordpress.com/2012/04/msgarch.jpg"><img title="MSGArch" src="http://programmersunlimited.files.wordpress.com/2012/04/msgarch.jpg?w=627&h=114" alt="" width="627" height="114" /></a></p>
<p>Instead of sending the request details to the database one-by-one, they would now go into a message queue. MSMQ to be exact. Sending messages to a local queue is extremely fast and is very simple to implement.</p>
<p><pre class="brush: csharp;">
using System.Messaging;

namespace MSMQExample
{
    class Program
    {
        static void Main(string[] args)
        {
            var msg = new Message();
            msg.Body = &quot;Hello!&quot;;

            var queue = new MessageQueue(&quot;.\\Private$\\requestdata&quot;);
            queue.Send(msg);
        }
    }
}
</pre></p>
<p>To get the data into the database I built a worker application that would dequeue the messages and then perform a bulk insert into the database. Bulk inserts allow for a very large number of rows to be inserted in milliseconds compared to individual inserts.</p>
<p>Now each request to the web app would enqueue the request details and then redirect the user to their final destination. On a set schedule (every 15 minutes), the worker application would process the queued items and perform the database insert.</p>
<p>The end result? ~19ms. The web app was no longer hindered by the database and doing bulk inserts every 15 minutes eliminated unnecessary load on the database.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/programmersunlimited.wordpress.com/492/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/programmersunlimited.wordpress.com/492/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/programmersunlimited.wordpress.com/492/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/programmersunlimited.wordpress.com/492/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/programmersunlimited.wordpress.com/492/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/programmersunlimited.wordpress.com/492/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/programmersunlimited.wordpress.com/492/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/programmersunlimited.wordpress.com/492/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/programmersunlimited.wordpress.com/492/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/programmersunlimited.wordpress.com/492/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/programmersunlimited.wordpress.com/492/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/programmersunlimited.wordpress.com/492/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/programmersunlimited.wordpress.com/492/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/programmersunlimited.wordpress.com/492/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=programmersunlimited.wordpress.com&#038;blog=14241067&#038;post=492&#038;subd=programmersunlimited&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://programmersunlimited.wordpress.com/2012/04/11/reducing-latency-with-message-queues/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c9e4d72e0a29be3bf43a6c8e0cbd656d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">programmersunlimited</media:title>
		</media:content>

		<media:content url="http://programmersunlimited.files.wordpress.com/2012/04/msgarch.jpg" medium="image">
			<media:title type="html">MSGArch</media:title>
		</media:content>
	</item>
		<item>
		<title>Website optimization via static content</title>
		<link>http://programmersunlimited.wordpress.com/2012/03/23/website-optimization-via-static-content/</link>
		<comments>http://programmersunlimited.wordpress.com/2012/03/23/website-optimization-via-static-content/#comments</comments>
		<pubDate>Fri, 23 Mar 2012 22:03:27 +0000</pubDate>
		<dc:creator>programmersunlimited</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">https://programmersunlimited.wordpress.com/?p=459</guid>
		<description><![CDATA[Continuing my path along optimization posts, I thought I would write about a trick that I use to optimize website performance and help scalability by reducing resource consumption. I recently read a post about continuous cache warming techniques for Rails. Even though the author specifically states you shouldn’t use the techniques in production, I know [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=programmersunlimited.wordpress.com&#038;blog=14241067&#038;post=459&#038;subd=programmersunlimited&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Continuing my path along optimization posts, I thought I would write about a trick that I use to optimize website performance and help scalability by reducing resource consumption.</p>
<p>I recently read a post about continuous cache warming techniques for Rails. Even though the author specifically states you shouldn’t use the techniques in production, I know that there are developers who do. Sometimes we do crazy things for performance reasons. Cache warming is priming the cache; artificially hitting a resource to put it in cache or reset it’s expiration. But this is unnecessary and It defeats the purpose of cache expiration and can unnecessarily consume memory.</p>
<h2>Before we start&#8230;</h2>
<p>I really want to stress that while I&#8217;m discussing a specific technique, I want you to think about the concept behind it as it can be applied to other areas in different ways, not just web pages.</p>
<h2>The problem</h2>
<p>The problem is content, or at least the generation of content. Web pages can contain many different areas that are dynamically assembled when the page is requested. Often times when I&#8217;m evaluating a poorly performing web site I see areas of content that are generated far too often (sometimes on each request) while using resources like calls to a database to accomplish the task. I always have to ask the question, how often does the data change and how fresh does it actually have to be?</p>
<p>Examples of these types of areas are</p>
<ul>
<li>Latest comments</li>
<li>Poll results</li>
<li>Statistics</li>
<li>Trending topics</li>
</ul>
<p>Let’s evaluate the <a href="http://www.iedotnetug.org">Inland Empire .NET Users Group</a> website home page as an example.</p>
<p><a href="http://programmersunlimited.files.wordpress.com/2012/03/iednugsite.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="iednugsite" src="http://programmersunlimited.files.wordpress.com/2012/03/iednugsite_thumb.jpg?w=640&h=421" alt="iednugsite" width="640" height="421" border="0" /></a></p>
<p>We’ll focus on only two areas of this page. The first area (red box) is the main content. This describes the next event and gives speaker details and other information. The second area (green box) shows a leaderboard for the Most Valuable Member program (yes, I’m currently leading at the time of this post).</p>
<p>Both areas get their data from a data store. On each page load both areas must make at least one request to query the data store and get the information to be displayed. So each page request will make multiple calls to the data store? Probably not. Mechanisms like page caching will prevent this by serving the previously rendered output of a page (or widget) from memory for each subsequent request thus by-passing any need to render the content again.</p>
<p>But what does this really mean? It could mean different things to different sites. With page caching, the rendered output will go into memory which is a limited resource. It also means that the request must still go through the ASP.NET pipeline. At some point the cache will be cleared. Either by expiration, need for more memory or from the app pool recycling. This means the page will need to be rendered again on the next request. For a page that changes very frequently this might be the desired process. Our example site changes once or twice a month so it isn&#8217;t optimal.</p>
<h2>Solution?</h2>
<p>A technique I use involves the file system. Yep, I generate actual .html files. Let’s take the leader board area of the example page. It’s nothing more than an unordered list in the end. It changes once a month. Why would I want to make calls to the database more than once a month when the results will be 100% the same? Why would I want to store a snippet of simple HTML in my limited memory when that content isn&#8217;t being requested? Why would I want a request for the leaderboard HTML to go through the ASP.NET pipeline? I don’t want to do any of those things for a piece of content that will more than likely be the same as the last time it was requested.</p>
<p>Caching the leaderboard HTML to an actual .html file accomplishes a few things. First, it saves the rendered html for later use so there is no need to rebuild it (i.e., no unnecessary calls to the data store). Second, it stores the rendered content outside of the memory. We&#8217;re safe from cache expiration and app pool recycles. Third, the content becomes a static resource which means it will be served by IIS using the StaticResource handler, which is blazingly fast, instead of going through the ASP.NET pipeline. Your setup may vary.</p>
<h2>When to build content</h2>
<p>The majority of the time I use schedules tasks to regenerate the content at set schedules based on the content and how fresh it has to be. Other times I will need a trigger to kick off the process. For triggers I tend to use message queues. The goal is to move the work outside of the web application, especially if the generation of content takes abnormal amounts of time.</p>
<p>I’m purposely being generic by not going into how to implement the technique because there are numerous ways and it depends on you, your team and you’re project. I’ve used server side includes and JQuery requests for calling content (and async loading) and T4 to generate content. I like to use scheduled tasks or cron jobs (when possible) to kick off scheduled builds and message queues like MSMQ for triggering a build.</p>
<h2>Is it right for me?</h2>
<p>Maybe. There are some things to consider first. Is the time to implement this technique worth the result? Bandwidth can be another concern. Depending on how the static HTML is requested (e.g., JQuery GET), you may run into bandwidth issues if the browser isn&#8217;t serving the request from cache. Another issue is content that changes based on parameters. You may not have access to the server to setup a scheduled job or a message based trigger system. Disk space can also become an issue.</p>
<p>Let me know your thoughts.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/programmersunlimited.wordpress.com/459/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/programmersunlimited.wordpress.com/459/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/programmersunlimited.wordpress.com/459/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/programmersunlimited.wordpress.com/459/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/programmersunlimited.wordpress.com/459/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/programmersunlimited.wordpress.com/459/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/programmersunlimited.wordpress.com/459/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/programmersunlimited.wordpress.com/459/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/programmersunlimited.wordpress.com/459/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/programmersunlimited.wordpress.com/459/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/programmersunlimited.wordpress.com/459/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/programmersunlimited.wordpress.com/459/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/programmersunlimited.wordpress.com/459/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/programmersunlimited.wordpress.com/459/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=programmersunlimited.wordpress.com&#038;blog=14241067&#038;post=459&#038;subd=programmersunlimited&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://programmersunlimited.wordpress.com/2012/03/23/website-optimization-via-static-content/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c9e4d72e0a29be3bf43a6c8e0cbd656d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">programmersunlimited</media:title>
		</media:content>

		<media:content url="http://programmersunlimited.files.wordpress.com/2012/03/iednugsite_thumb.jpg" medium="image">
			<media:title type="html">iednugsite</media:title>
		</media:content>
	</item>
		<item>
		<title>The cost of a handshake &#8211; performance optimization in synchronous processes</title>
		<link>http://programmersunlimited.wordpress.com/2012/03/05/the-cost-of-a-handshake-performance-optimization-in-synchronous-processes/</link>
		<comments>http://programmersunlimited.wordpress.com/2012/03/05/the-cost-of-a-handshake-performance-optimization-in-synchronous-processes/#comments</comments>
		<pubDate>Mon, 05 Mar 2012 22:09:16 +0000</pubDate>
		<dc:creator>programmersunlimited</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://programmersunlimited.wordpress.com/?p=445</guid>
		<description><![CDATA[I recently meet with the development team to evaluate a poorly performing application. I started out by having them explain what it was supposed to do and how it worked. The application is supposed to request data from a service, insert that data into the database and then send some data back to the service. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=programmersunlimited.wordpress.com&#038;blog=14241067&#038;post=445&#038;subd=programmersunlimited&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I recently meet with the development team to evaluate a poorly performing application. I started out by having them explain what it was supposed to do and how it worked. The application is supposed to request data from a service, insert that data into the database and then send some data back to the service. The application is doing some synchronization between the client and vendor systems. The process is reported as taking a considerable amount of time (as in days and weeks) to synchronize 200 accounts. This was an obvious red flag and why it needed to be evaluated.</p>
<p>So I started asking my usual questions, &#8220;How does it work?&#8221;, &#8220;How does it really work?&#8221; (yes those are two different questions). After a high level review (because usually developers don&#8217;t want to expose their design decisions to criticism you end up with broad answers) I break down the process into smaller chunks and ask specific questions about each step. After about 20 minutes I found that the a large set of data was coming down from the service and 1-by-1 each record was being inserted (with a blocking call) into the database. After that, 1-by-1 data was being sent back to the service.</p>
<p>Already at this point I see a major issue, but I need more details to confirm. So I ask, are the records in the dataset dependent upon each other or do they have any relationship? The answer (as I already knew) was no, all of the records were individual. Then I asked, what data is being sent back to the service? The answer was a key for the record. The entire process is</p>
<ol>
<li>Get dataset from vendor&#8217;s service</li>
<li>Insert each record into database, generating a key</li>
<li>Send the key for the record back to the vendor&#8217;s service</li>
</ol>
<p>It&#8217;s a fairly simple process, so why is it taking so long to execute? The answer starts with the numbers. Each account that needs to be synchronized has about 10,000-30,000 records. But that really isn&#8217;t a whole lot especially since there aren&#8217;t any computational aspects, just simple CRUD. With the details we have now, we know that each record has to be inserted into the database, the key has to be retrieved and then it has to be sent back to the service. We know that each record is processed 1-by-1 using blocking calls.</p>
<p>If each record takes average of ~500ms and the account has 10,000 records, that&#8217;s 5,000 seconds or 1.3 hours per account. With 200 accounts that&#8217;s 11 days. Since the the record is being inserted using a stored procedure that inserts the row then returns the key, which is then sent back to the service, we can quickly shave some time off by making that call to the stored procedure asynchronous. The call would no longer be blocking and when the callback was invoked, it could then send the key back to the service while not bothering the other records. No more blocking.</p>
<p>Alright, that&#8217;s a step in the right direction. Or is it? It isn&#8217;t. Think about it this way, there are 10,000 individual transactions that need to occur on the database which means connections, locking, constraint checking and transaction management. Some of this stuff has to occur regardless, but not all of it. If the handshake part of each call takes ~150ms, that&#8217;s 25 minutes of just handshakes. Wasted time. Even though making the calls asynchronous will reduce that time, it&#8217;s still going to take far too long and will consume resources unnecessarily. Here is a chance to start shaving time and reducing resource consumption. But how?</p>
<p>SQL Server supports bulk inserts. Bulk inserts are a way of inserting many records into a table at one time. What does this mean? Time savings. Bulk inserts work with a single connection, a single table lock (usually) and disables constraint checking to achieve it&#8217;s performance. 10,000 records can be inserted into a table in fractions of a second. Let&#8217;s review</p>
<ol>
<li>Get dataset from vendor&#8217;s service</li>
<li>Bulk insert records into database</li>
<li>Retrieve newly inserted keys</li>
<li>Send each record key back to the service</li>
</ol>
<p>At this point we can make the calls to the service asynchronous to shave some time off. However, I asked some more questions, &#8220;Does the service have any throttling or connection limits?&#8221;. The answer was yes, there are limits. So I then ask, &#8220;Does the service support batching or bulk submissions?&#8221;. The answer was yes. So there you have it. We can apply the same logic to the HTTP handshake as we did with the database handshake. It takes time to resolve the DNS, make the connection and start the transfer. Even though these operations are amazingly fast when you look at them individually, multiply that amazingly fast time by 10,000 and it becomes a different picture.</p>
<p>Reducing or removing the cost of the handshake by using bulk operations can significantly reduce overall execution time. Without using multi-threading or other concurrent execution techniques, we&#8217;ve reduced the execution time from 1.3 hours to &lt; 3 minutes per account (depending on vendor&#8217;s connectivity limitations). That&#8217;s still 10 hours for the over all process but it beats waiting 11 days. We can further reduce this by running more than one account at once, but this will depend on the vendor&#8217;s service.</p>
<p>I&#8217;d like to hear about processes you&#8217;ve optimized and how you did it.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/programmersunlimited.wordpress.com/445/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/programmersunlimited.wordpress.com/445/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/programmersunlimited.wordpress.com/445/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/programmersunlimited.wordpress.com/445/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/programmersunlimited.wordpress.com/445/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/programmersunlimited.wordpress.com/445/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/programmersunlimited.wordpress.com/445/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/programmersunlimited.wordpress.com/445/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/programmersunlimited.wordpress.com/445/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/programmersunlimited.wordpress.com/445/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/programmersunlimited.wordpress.com/445/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/programmersunlimited.wordpress.com/445/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/programmersunlimited.wordpress.com/445/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/programmersunlimited.wordpress.com/445/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=programmersunlimited.wordpress.com&#038;blog=14241067&#038;post=445&#038;subd=programmersunlimited&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://programmersunlimited.wordpress.com/2012/03/05/the-cost-of-a-handshake-performance-optimization-in-synchronous-processes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c9e4d72e0a29be3bf43a6c8e0cbd656d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">programmersunlimited</media:title>
		</media:content>
	</item>
		<item>
		<title>FREE Pluralsight today</title>
		<link>http://programmersunlimited.wordpress.com/2012/02/29/free-pluralsight-today/</link>
		<comments>http://programmersunlimited.wordpress.com/2012/02/29/free-pluralsight-today/#comments</comments>
		<pubDate>Wed, 29 Feb 2012 18:39:17 +0000</pubDate>
		<dc:creator>programmersunlimited</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://programmersunlimited.wordpress.com/?p=441</guid>
		<description><![CDATA[Pluralsight is letting everyone view their library for free for today only, Feb 29th. Please check out my course on Code Generation with T4 Templates http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=t4-templates http://blog.pluralsight.com/2012/02/28/leap-ahead-with-free-pluralsight-training-on-leap-day/<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=programmersunlimited.wordpress.com&#038;blog=14241067&#038;post=441&#038;subd=programmersunlimited&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Pluralsight is letting everyone view their library for free for today only, Feb 29th. Please check out my course on Code Generation with T4 Templates <a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=t4-templates">http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=t4-templates</a></p>
<p><a href="http://blog.pluralsight.com/2012/02/28/leap-ahead-with-free-pluralsight-training-on-leap-day/">http://blog.pluralsight.com/2012/02/28/leap-ahead-with-free-pluralsight-training-on-leap-day/</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/programmersunlimited.wordpress.com/441/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/programmersunlimited.wordpress.com/441/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/programmersunlimited.wordpress.com/441/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/programmersunlimited.wordpress.com/441/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/programmersunlimited.wordpress.com/441/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/programmersunlimited.wordpress.com/441/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/programmersunlimited.wordpress.com/441/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/programmersunlimited.wordpress.com/441/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/programmersunlimited.wordpress.com/441/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/programmersunlimited.wordpress.com/441/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/programmersunlimited.wordpress.com/441/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/programmersunlimited.wordpress.com/441/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/programmersunlimited.wordpress.com/441/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/programmersunlimited.wordpress.com/441/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=programmersunlimited.wordpress.com&#038;blog=14241067&#038;post=441&#038;subd=programmersunlimited&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://programmersunlimited.wordpress.com/2012/02/29/free-pluralsight-today/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c9e4d72e0a29be3bf43a6c8e0cbd656d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">programmersunlimited</media:title>
		</media:content>
	</item>
		<item>
		<title>It&#8217;s ok to mock a Person</title>
		<link>http://programmersunlimited.wordpress.com/2012/02/02/its-ok-to-mock-a-person/</link>
		<comments>http://programmersunlimited.wordpress.com/2012/02/02/its-ok-to-mock-a-person/#comments</comments>
		<pubDate>Thu, 02 Feb 2012 06:39:06 +0000</pubDate>
		<dc:creator>programmersunlimited</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">https://programmersunlimited.wordpress.com/?p=427</guid>
		<description><![CDATA[Update I worked up a video on Typemock. Check it out. Original Post Ok, that’s a bad attempt at a humorous pun, but it’s still a valid statement. TDD exploded a few years ago and has gained tremendous following and prestige in the development community. I’ve never actually practiced TDD other than tutorials and more [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=programmersunlimited.wordpress.com&#038;blog=14241067&#038;post=427&#038;subd=programmersunlimited&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>Update</h2>
<p>I worked up a video on Typemock. Check it out.</p>
<span style="text-align:center; display: block;"><a href="http://programmersunlimited.wordpress.com/2012/02/02/its-ok-to-mock-a-person/"><img src="http://img.youtube.com/vi/m79sqbFp3EE/2.jpg" alt="" /></a></span>
<h2>Original Post</h2>
<p>Ok, that’s a bad attempt at a humorous pun, but it’s still a valid statement. TDD exploded a few years ago and has gained tremendous following and prestige in the development community. I’ve never actually practiced TDD other than tutorials and more recently I’ve been doing TDD katas. If you haven’t done a TDD kata, I recommend it. I’ve learned about myself that I over think the requirements causing me to spend time on a solution I don’t need (<a href="http://en.wikipedia.org/wiki/You_Ain't_Gonna_Need_It">YAGNI principal</a>). I’m working on that though thanks to the TDD katas.</p>
<p>I&#8217;m a bit late to the unit testing and TDD game but I have a large need for it at the moment, so when I had the chance to grab a copy of TypeMock’s Isolator at the <a href="http://www.iedotnetug.org">Inland Empire .NET Users Group</a>, I jumped on it. I’ve been playing around with it and it’s pretty cool to say the least.</p>
<h2>Why do we need mocks?</h2>
<p>Mocks are needed to isolate a specific method for testing. Methods can have external dependencies that, for whatever reason, are not appropriate to have in the unit test. The best example of this is a method that makes a database call via a repository. Actually having database calls in a unit test is not a great idea. For one thing it’s slow. But really it’s pointless. If the database connection fails for whatever reason, the test will fail. You might think that this is a good thing but it isn’t. Database connectivity is an integration test, not a unit test.</p>
<p>Anyway, the point is to isolate methods. TypeMock Isolator makes this pretty easy. Mocking frameworks have come a long way in the last 2 years and TypeMock is pretty impressive. Let’s take a look at a few examples.</p>
<h2>Mocking Bird</h2>
<p>When will my attempts at humor end? Sorry. The stage is pretty typical. An order processor needs to get the order and update the sales tax based on the order total. The repository makes a call to authenticate on instantiation. CalculateTax just does some math based on the order’s state and returns the value. Very pointless but this is a blog, not a real world application <img class="wlEmoticon wlEmoticon-winkingsmile" style="border-style:none;" src="http://programmersunlimited.files.wordpress.com/2012/02/wlemoticon-winkingsmile.png?w=627" alt="Winking smile" /></p>
<p><pre class="brush: csharp;">
public class OrderProcessor
{
    public decimal CalculateTax(int orderId)
    {
        OrderRepository rpo = new OrderRepository();
        var ord = rpo.GetOrder(orderId);

        var taxRates = new Dictionary()
        {
            { &quot;CA&quot;, 0.50m }, //Bastards!
            { &quot;NV&quot;, 0.0685m }
            };

        return ord.OrderTotal * taxRates[ord.address.State];
    }
}

public sealed class Security
{
    public static bool Authenticate()
    {
        throw new NotImplementedException();
    }
}

public class OrderRepository
{
    public OrderRepository()
    {
        if (!Security.Authenticate())
        {
            throw new InvalidOperationException(&quot;Could not authenticate user&quot;);
        }
    }
    public Order GetOrder(int id)
    {
        throw new NotImplementedException();
    }
}

public class Order
{
    public int OrderId { get; set; }
    public Address address { get; set; }
    public decimal OrderTotal { get; set; }
    public decimal Shipping { get; set; }
    public decimal Tax { get; set; }
}

public class Address
{
    public string Street { get; set; }
    public string City { get; set; }
    public string State { get; set; }
    public string Zip { get; set; }
}
</pre></p>
<p>Nothing special. Notice that the repo and security don’t do anything, but throw exceptions instead. This doesn’t matter since we don’t care about those actions anyway. We are only interested in making sure the sales tax is calculated correctly.</p>
<p>Now let’s see the code for our test.</p>
<p><pre class="brush: csharp;">
[TestMethod()]
public void OrderProcessor_CalculateSalesTaxForCalifornia()
{
    Order fakeOrder = new Order()
    {
        OrderTotal = 100.00m,
        Shipping = 25.00m,
        OrderId = 10,
        address = new Address()
        {
            State = &quot;CA&quot;
        },
    };

    Isolate.WhenCalled(() =&gt; Security.Authenticate()).WillReturn(true);

    var repo = Isolate.Fake.Instance();
    Isolate.Swap.AllInstances().With(repo);
    Isolate.WhenCalled(() =&gt; repo.GetOrder(0)).WillReturn(fakeOrder);

    OrderProcessor target = new OrderProcessor();
    int orderId = 10;
    decimal expected = 50.0m;
    decimal actual;
    actual = target.CalculateTax(orderId);
    Assert.AreEqual(expected, actual);
}
</pre></p>
<p>First we new up a dummy order populating the needed data. Then we use Isolator to specify that whenever a call to Security.Authenticate() is made, it will intercept it and return true. This way we can always test our method without needing to bother with setting up credentials, etc etc etc. We don’t care about security, it has nothing to do with sales tax!</p>
<p>Then we create a fake repository object using Isolator.Fake. Then, using Isolator.Swap, we tell Isolator that anytime a new instance of OrderRepository is instantiated, we replace it with our fake instance. Then we specify that anytime the GetOrder method is called on the fake repo instance, we will intercept and return our dummy order instance.</p>
<p>Finally, we instantiate a copy of OrderProcessor and make a call to CalculateTax. We assert that the returned value matches what we expect it to be.</p>
<h2>Conclusion</h2>
<p>Even though a call to the CalculateTax method requires a call to the database and a security check, we were able to isolate the tax calculation logic by mocking up the dependencies. I like the way Isolator works because you don’t have to specifically code your classes for unit testing/IoC/DI in order to pass in the fakes and mock objects.</p>
<p>There is plenty more that TypeMock Isolator will do so make sure you check out their documentation.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/programmersunlimited.wordpress.com/427/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/programmersunlimited.wordpress.com/427/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/programmersunlimited.wordpress.com/427/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/programmersunlimited.wordpress.com/427/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/programmersunlimited.wordpress.com/427/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/programmersunlimited.wordpress.com/427/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/programmersunlimited.wordpress.com/427/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/programmersunlimited.wordpress.com/427/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/programmersunlimited.wordpress.com/427/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/programmersunlimited.wordpress.com/427/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/programmersunlimited.wordpress.com/427/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/programmersunlimited.wordpress.com/427/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/programmersunlimited.wordpress.com/427/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/programmersunlimited.wordpress.com/427/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=programmersunlimited.wordpress.com&#038;blog=14241067&#038;post=427&#038;subd=programmersunlimited&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://programmersunlimited.wordpress.com/2012/02/02/its-ok-to-mock-a-person/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c9e4d72e0a29be3bf43a6c8e0cbd656d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">programmersunlimited</media:title>
		</media:content>

		<media:content url="http://programmersunlimited.files.wordpress.com/2012/02/wlemoticon-winkingsmile.png" medium="image">
			<media:title type="html">Winking smile</media:title>
		</media:content>
	</item>
		<item>
		<title>What I&#8217;ve learned by presenting at code camps</title>
		<link>http://programmersunlimited.wordpress.com/2012/01/30/what-ive-learned-by-presenting-at-code-camps/</link>
		<comments>http://programmersunlimited.wordpress.com/2012/01/30/what-ive-learned-by-presenting-at-code-camps/#comments</comments>
		<pubDate>Mon, 30 Jan 2012 17:51:29 +0000</pubDate>
		<dc:creator>programmersunlimited</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">https://programmersunlimited.wordpress.com/?p=421</guid>
		<description><![CDATA[Last year, out of no where, I decided that I wanted to present at the San Diego Code Camp after receiving the email announcing it. I had never attended a code camp but I wanted to go. Why I wanted to present, not having any previous experience with code camps, is beyond me. I’m a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=programmersunlimited.wordpress.com&#038;blog=14241067&#038;post=421&#038;subd=programmersunlimited&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Last year, out of no where, I decided that I wanted to present at the San Diego Code Camp after receiving the email announcing it. I had never attended a code camp but I wanted to go. Why I wanted to present, not having any previous experience with code camps, is beyond me. I’m a very shy person.</p>
<p>I knew that I wanted to present about aspect oriented programming since I had already done a user group session about it and I was pretty familiar with the topic. But for some reason, I wanted to do another session (yes, two sessions!) on parallel programming.</p>
<h2>Presenting: Then</h2>
<p>I had enough time to build my slide decks, notes and examples but I still found myself making last minute changes. I was not prepared. I did not practice at all. I had pages of notes that I thought I could just read from. Bad idea. The first session on AOP went ok because I was already very familiar with the material, but the parallel programming session was a flop in my opinion. I stuttered, lost my train of thought and was confusing the audience. Even worse, I went 15 minutes over and I wasn’t even 1/2 done with my material. People started leaving.</p>
<h2>Presenting: Now</h2>
<p>Last weekend was the Fullerton code camp in which I also had two sessions. With 2 previous code camps under my belt, and a mass of user group sessions and an entire PluralSight course, I still found myself making last minute changes to the slide decks and notes but I nailed both of my sessions. I received many compliments on both sessions which was not entirely surprising. This is not to say that I’m being arrogant, but I made several changes to my approach and I was expecting them to pay off. It did.</p>
<h2>Preparing: Then</h2>
<p>Having no speaking experience, I really didn’t know what you needed to do other than makes some slides and do some examples. I’ll be standing in front of a crowd of people who all attended knowing I would be speaking. Some of them are just there for the swag, but still they expect a good performance. I can’t hide behind anything. I’m there face to face with 5-100 people.</p>
<h3>Slides</h3>
<p>My slide decks were basically for me, not for the audience. I made my slide decks packed with text. I thought the more info I put in there, the better. This is a big mistake. First of all, the audience isn’t going to read all of that text (if they can even see it). Second of all, they are looking at ME, not my slides.</p>
<p>I found myself reading the slides instead of talking to the audience. This makes for a poor performance.</p>
<h3>Notes</h3>
<p>I have a problem when it comes to vocalizing my thoughts. Sometimes I get things mixed up as they come out or I forget how I wanted to verbalize a thought. To help this, I had pages and pages of notes. I thought I could address my notes at any time and make sure I hit the nail on the head. Wrong! I had paragraphs of notes which made it hard to find specific points quickly so I lost my place and I lost which page I was on. Big mess. Confused myself and confused the audience.</p>
<p>After realizing the flaws on this approach I moved to a very succinct bullet point list with all the points I wanted to make in a specific order. It was easier to find my place, stay on track but did nothing to help me remember how to say what I wanted to say and I left out large chunks of information that I really needed to deliver to the crowd.</p>
<h3>Confidence</h3>
<p>Being a shy person, it was hard for me to get up in front of people. I don’t like being the center of attention. Knowing that I have a problem with verbalizing my thoughts, I was nervous even more than normal. I was not confident that I knew the material well enough to not have my notes and slides as crutches. I stuttered, said “uh” a lot and was always forgetting what I wanted to say.</p>
<h3>Practice</h3>
<p>Biggest reason I was not confident is because I didn’t practice. Sure, I would read my notes over and over but I never practiced saying anything out loud. I never liked to hear myself. Voice recordings, video, voicemail, it doesn’t matter. I don’t like listening to myself talk. It’s weird. You get what you pay for and that’s the truth of it.</p>
<h2>Preparing Now</h2>
<p>Things have changed. I’ve learned a lot since doing my first speaking session 3 years ago. But it’s taken a long time and a lot of embarrassment.</p>
<h3>Slides</h3>
<p>My slide decks are barren. They have become my list of bullet points. They offer only a hint on what I’m currently blabbering about or they display some diagram or example that I’m explaining. Some people have asked me to send them my slides before the session, and I do, but really it’s pointless because the slides have no context now.</p>
<p>This works. The audience doesn’t care about your slides, they’re looking at you. The slides are just there for reference and whenever I feel lost I can quickly glace at the screen as I’m changing slides. I make it look like I’m just making sure the slide actually changed <img class="wlEmoticon wlEmoticon-winkingsmile" style="border-style:none;" src="http://programmersunlimited.files.wordpress.com/2012/01/wlemoticon-winkingsmile.png?w=627" alt="Winking smile" /></p>
<h3>Notes</h3>
<p>I have combined the two previous techniques on notes. First I create my list of bullet points; the things I wants to talk about. Then from that list, I create the slides. Then I write out detailed scripts on each point/slide. Up to 10 pages for some topics.</p>
<p>The difference is now I use that script to practice, not a reference during a live session.</p>
<h3>Practice</h3>
<p>No, I don’t like talking to myself and I don’t like hearing myself. Heck, I don’t even sing out loud to my favorite songs. But, they only way (for me at least) to really practice and get it down is speak out loud. This is where the script comes in. I start by reading it quietly to myself to check for any weirdness. Then I read it out loud. After making any changes, I read it out loud again. Then I read it as I’m flipping through my slide deck as if I’m doing a real session. I do this as many times as I need to. Then I’ll glance over it just before a session is going to start. Now I don’t need to do this and when I realize that, it means I’ve prepared enough.</p>
<h3>Confidence</h3>
<p>Confidence isn’t affected by stage fright. It’s affected by how well you know your material. The more confident you are, the better you will perform. You’ve already done this (assuming you practiced enough). You know how it turns out so just do it again. The only difference is that some people might be watching you. The audience is attracted to confidence. Even if you’re full of crap, you can BS your way through a tough session by showing confidence. This is how salesman sell crowds.</p>
<h2>Tips</h2>
<p><strong>Be prepared</strong>. Don’t wait until the last minute to check if you have a cable. If you have a mac, you should have the correct converter cable. The audience might not have one you can use so don’t bother to ask. Know what your setup will require. This is usually a VGA cable. Have HDMI only? Well I’m sorry but the majority of projectors you’re going to be presenting on will be VGA so go buy an adapter or use an old laptop.</p>
<p>Show up early enough to figure out the lighting. Some places leave you to fend for yourself and it can be tough to figure out the lighting and AV systems.</p>
<p><strong>Practice!</strong> This should be obvious, but you really must practice. More than once. If you can do a video of yourself or even an audio recording, you will benefit from it. You can see any weird ticks you have and hear how many times you say “Um” or “Uh”. If you’re confident (practiced enough) then you should be fluid and won’t need to use filler words.</p>
<p>Practicing also help you nail the timing. You only get a certain amount of time. You don’t want to go over and you don’t want to go under. Going over leaves out points that need to be made and the audience feels obligated to stay until you finish which upsets them because they want to go to their next session. Going under feels like a rip-off. They came for the show not the previews.</p>
<p><strong>Address the audience</strong>. Ask them questions, get them involved. This helps you loosen up and feel less nervous. I like to start off by asking about their experience with the specific session topic. It makes them feel comfortable with you. This can be hard to do if you’re not confident though. Try a few things and see what works. Be sure to talk to the audience, not just one person. Move around, <span style="text-decoration:underline;">come out from behind the podium</span>. Stepping away from the podium shows confidence. You shouldn’t need to be there unless you’re doing a demo.</p>
<p><strong>Get some equipment</strong>. I highly recommend getting a presentation mouse. It’s a small device that let’s you go back and forth on slides without being at the podium. I believe this has improved my presentations tremendously. I’m not rushing back and forth to the podium to change slides so I am free to roam and talk.</p>
<p>A laser pointer is also a great tool. Sometimes the projector screens are pretty high up and you can’t point out specific things unless you go back to the podium and use the mouse.</p>
<p><strong>Don’t do live code!</strong> The audience doesn’t want to see you write code. They want points, content and action. This is a time waster. Especially when you make mistakes and have to figure them out. Don’t copy and paste either. Open the completed project and walk through the code. If you go to fast, it doesn’t matter. You can always send them the code and they can go over it later.</p>
<h2>Conclusion</h2>
<p>Everyone has their own personality. I’ve seen many great speakers of all different types. Some of them were witty and energetic and others were plain Jane. Be yourself. If you know what you’re talking about and you’ve practiced your material, things will be fine.</p>
<p>Don’t be discouraged when you have a bad session. Sometimes they just don’t work out. Oh well. I’m just now finding my groove and it’s working. But I still have a lot to learn.</p>
<p>I’ve had many flops, regardless of how nice the audience is after, I know I sucked and I fix the things I did wrong so next time will be a little better.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/programmersunlimited.wordpress.com/421/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/programmersunlimited.wordpress.com/421/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/programmersunlimited.wordpress.com/421/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/programmersunlimited.wordpress.com/421/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/programmersunlimited.wordpress.com/421/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/programmersunlimited.wordpress.com/421/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/programmersunlimited.wordpress.com/421/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/programmersunlimited.wordpress.com/421/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/programmersunlimited.wordpress.com/421/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/programmersunlimited.wordpress.com/421/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/programmersunlimited.wordpress.com/421/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/programmersunlimited.wordpress.com/421/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/programmersunlimited.wordpress.com/421/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/programmersunlimited.wordpress.com/421/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=programmersunlimited.wordpress.com&#038;blog=14241067&#038;post=421&#038;subd=programmersunlimited&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://programmersunlimited.wordpress.com/2012/01/30/what-ive-learned-by-presenting-at-code-camps/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c9e4d72e0a29be3bf43a6c8e0cbd656d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">programmersunlimited</media:title>
		</media:content>

		<media:content url="http://programmersunlimited.files.wordpress.com/2012/01/wlemoticon-winkingsmile.png" medium="image">
			<media:title type="html">Winking smile</media:title>
		</media:content>
	</item>
		<item>
		<title>PostSharp with projects targeted at x64</title>
		<link>http://programmersunlimited.wordpress.com/2012/01/27/postsharp-with-projects-targeted-at-x64/</link>
		<comments>http://programmersunlimited.wordpress.com/2012/01/27/postsharp-with-projects-targeted-at-x64/#comments</comments>
		<pubDate>Fri, 27 Jan 2012 20:02:35 +0000</pubDate>
		<dc:creator>programmersunlimited</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">https://programmersunlimited.wordpress.com/?p=414</guid>
		<description><![CDATA[I’ve been working with a project that processes a large set of data so I’m targeting x64 only. I needed to apply my performance and logging aspects to check execution times of each method but when I went to compile I received a build error from PostSharp “Platform mismatch. You cannot run PostSharp on a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=programmersunlimited.wordpress.com&#038;blog=14241067&#038;post=414&#038;subd=programmersunlimited&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I’ve been working with a project that processes a large set of data so I’m targeting x64 only. I needed to apply my performance and logging aspects to check execution times of each method but when I went to compile I received a build error from PostSharp</p>
<p><em>“Platform mismatch. You cannot run PostSharp on a 64-bit application from a 32-bit operating system.”</em></p>
<p>It was obvious that PostSharp was trying to run it’s post processor in x86 mode because my OS is 64-bit and the project is targeting x64 only. The question was &#8220;how do I tell PostSharp to work in x64 mode?&#8221;. The answer to resolving this issue is pretty easy because the developers at SharpCrafters have come through once again with great tooling for their product. You simply need to go into the project properties and click on the PostSharp tab, then set the “Processor Architecture” to x64. After that, you’re good to go.</p>
<p><a href="http://programmersunlimited.files.wordpress.com/2012/01/ps-tab.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="ps-tab" src="http://programmersunlimited.files.wordpress.com/2012/01/ps-tab_thumb.jpg?w=694&h=403" alt="ps-tab" width="694" height="403" border="0" /></a></p>
<p>What else can you do in here? Well you can also enable/disable PostSharp, enable/disable support for obfuscation and pass in additional properties to PostSharp just to name a few.</p>
<p>If you don’t have the latest version of PostSharp, grab it from <a href="http://www.sharpcrafters.com/postsharp/download">PostSharp 2.1</a> and if you’re new to AOP or PostSharp, have a look at <a href="http://programmersunlimited.wordpress.com/postsharp-principals/">PostSharp Principals</a> to quickly get to speed with PostSharp.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/programmersunlimited.wordpress.com/414/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/programmersunlimited.wordpress.com/414/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/programmersunlimited.wordpress.com/414/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/programmersunlimited.wordpress.com/414/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/programmersunlimited.wordpress.com/414/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/programmersunlimited.wordpress.com/414/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/programmersunlimited.wordpress.com/414/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/programmersunlimited.wordpress.com/414/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/programmersunlimited.wordpress.com/414/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/programmersunlimited.wordpress.com/414/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/programmersunlimited.wordpress.com/414/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/programmersunlimited.wordpress.com/414/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/programmersunlimited.wordpress.com/414/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/programmersunlimited.wordpress.com/414/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=programmersunlimited.wordpress.com&#038;blog=14241067&#038;post=414&#038;subd=programmersunlimited&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://programmersunlimited.wordpress.com/2012/01/27/postsharp-with-projects-targeted-at-x64/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c9e4d72e0a29be3bf43a6c8e0cbd656d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">programmersunlimited</media:title>
		</media:content>

		<media:content url="http://programmersunlimited.files.wordpress.com/2012/01/ps-tab_thumb.jpg" medium="image">
			<media:title type="html">ps-tab</media:title>
		</media:content>
	</item>
		<item>
		<title>DataTables != Thread Safe</title>
		<link>http://programmersunlimited.wordpress.com/2012/01/26/datatables-thread-safe/</link>
		<comments>http://programmersunlimited.wordpress.com/2012/01/26/datatables-thread-safe/#comments</comments>
		<pubDate>Thu, 26 Jan 2012 19:55:49 +0000</pubDate>
		<dc:creator>programmersunlimited</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">https://programmersunlimited.wordpress.com/?p=405</guid>
		<description><![CDATA[The title of this post might seem really silly considering MSDN specifically says they aren’t thread safe, but there’s more to it than that. It says DataTables are not thread safe for WRITE operations which is a major &#8216;”Duh” statement, but in reality they are not safe for some read operations. I’ve been having some [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=programmersunlimited.wordpress.com&#038;blog=14241067&#038;post=405&#038;subd=programmersunlimited&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The title of this post might seem really silly considering MSDN specifically says they aren’t thread safe, but there’s more to it than that. It says DataTables are not thread safe for WRITE operations which is a major &#8216;”Duh” statement, but in reality they are not safe for some read operations. I’ve been having some strange issues with DataRows in parallel loops so I started to investigate.</p>
<p>I saw a post stating that DataTable.Select() is actually a write operation so it isn’t thread safe and requires a lock. I don’t see anything on MSDN about this. So I got to thinking and that’s when I opened up dotPeek. What did I find?</p>
<p>DataTable.NewRow() is not thread safe! The point of this method is to create a new row with the same schema as the table. According to MSDN you have to then add that row to the table&#8217;s DataRowCollection, it is not automatically added to the row collection when calling NewRow(). This, for the most part, is a read operation which would be thread safe. BUT, at one point in the internals, a call to NewRow(int) is made which creates the new record object, then sets that record to a class scoped field before passing it along to a DataRowBuilder. This is where it is no longer thread safe.</p>
<p>I was seeing so many problems because I was using NewRow() in a parallel loop and data was being corrupted at the end. This was why. To combat this, I generated a cache of new rows before the parallel loop, in a ConcurrentBag&lt;DataRow&gt; and then use a TryTake() inside of the loop. No more problems.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/programmersunlimited.wordpress.com/405/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/programmersunlimited.wordpress.com/405/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/programmersunlimited.wordpress.com/405/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/programmersunlimited.wordpress.com/405/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/programmersunlimited.wordpress.com/405/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/programmersunlimited.wordpress.com/405/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/programmersunlimited.wordpress.com/405/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/programmersunlimited.wordpress.com/405/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/programmersunlimited.wordpress.com/405/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/programmersunlimited.wordpress.com/405/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/programmersunlimited.wordpress.com/405/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/programmersunlimited.wordpress.com/405/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/programmersunlimited.wordpress.com/405/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/programmersunlimited.wordpress.com/405/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=programmersunlimited.wordpress.com&#038;blog=14241067&#038;post=405&#038;subd=programmersunlimited&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://programmersunlimited.wordpress.com/2012/01/26/datatables-thread-safe/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c9e4d72e0a29be3bf43a6c8e0cbd656d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">programmersunlimited</media:title>
		</media:content>
	</item>
		<item>
		<title>Change Request Pattern &#8211; Parallelism and non thread safe collections</title>
		<link>http://programmersunlimited.wordpress.com/2012/01/24/change-request-pattern-parallelism-and-non-thread-safe-collections/</link>
		<comments>http://programmersunlimited.wordpress.com/2012/01/24/change-request-pattern-parallelism-and-non-thread-safe-collections/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 22:48:49 +0000</pubDate>
		<dc:creator>programmersunlimited</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://programmersunlimited.wordpress.com/?p=399</guid>
		<description><![CDATA[My current project makes heavy use of DataTables and parallel processing via the TPL. DataTables are not thread safe and really bite the dust hard when asked to do more than one thing at once. My project breaks up operations that need to be performed on a DataTable into groups that can be executed concurrently. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=programmersunlimited.wordpress.com&#038;blog=14241067&#038;post=399&#038;subd=programmersunlimited&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>My current project makes heavy use of DataTables and parallel processing via the TPL. DataTables are not thread safe and really bite the dust hard when asked to do more than one thing at once.</p>
<p>My project breaks up operations that need to be performed on a DataTable into groups that can be executed concurrently. In total that are about 15 groups each with 2-5 concurrent processes. Each process works with certain columns on a DataRow but still, the DataTable can&#8217;t handle more than one change request at a time or it just has a stroke. It&#8217;s very annoying. I could easily combat this by using POCOs instead of DataTables but it isn&#8217;t an option. So how do I do it? Using what I call the Change Request pattern.</p>
<p>The concept is simple, there are operations reading and making changes to each row in the DataTable. Usually data correction, number crunching, etc. Instead of writing the new value back to the DataColumn, it queues up the change in a thread safe collection using a POCO to describe what has to change. When the operations in the group have finished, the changes are processed one-by-one in a thread safe manner.</p>
<p><pre class="brush: csharp;">
private void DoWork(DataTable table)
{
    var chgcrd = new ChangeCoordinator(table);
   
    Task t1 = Task.Factory.StartNew(new Action(() =&gt; { UpdateColumn1(table, chgcrd); }));
    Task t2 = Task.Factory.StartNew(new Action(() =&gt; { UpdateColumn2(table, chgcrd); }));

    Task.WaitAll(t1, t2);

    chgcrd.ProcessChanges();
}

private void UpdateColumn2(DataTable table, ChangeCoordinator changes)
{
    Parallel.For(0, table.Rows.Count, new Action&lt;int&gt;((i) =&gt;
    {
        int oldValue = table.Rows[i].Field&lt;int&gt;(&quot;column2&quot;);
        int newValue = oldValue * 5;
        long rowId = table.Rows[i].Field&lt;long&gt;(&quot;id&quot;);

        changes.ScheduleChange(new ChangeRequest(rowId, &quot;column2&quot;, newValue));
    }));
}

private void UpdateColumn1(DataTable table, ChangeCoordinator changes)
{
    Parallel.For(0, table.Rows.Count, new Action&lt;int&gt;((i) =&gt;
    {
        int oldValue = table.Rows[i].Field&lt;int&gt;(&quot;column1&quot;);
        int newValue = oldValue * 2;
        long rowId = table.Rows[i].Field&lt;long&gt;(&quot;id&quot;);

        changes.ScheduleChange(new ChangeRequest(rowId, &quot;column1&quot;, newValue));                
    }));
}
</pre></p>
<p><pre class="brush: csharp;">
public class ChangeRequest
{
    public long ID { get; set; }
    public string Column { get; set; }
    public object Value { get; set; }

    public ChangeRequest(long id, string column, object value)
    {
        this.ID = id;
        this.Column = column;
        this.Value = value;
    }
}
</pre></p>
<p><pre class="brush: csharp;">
public class ChangeCoordinator
{  
    public ChangeCoordinator(DataTable table) 
    {
        _table = table;
    }

    private ConcurrentBag&lt;ChangeRequest&gt; _changes = new ConcurrentBag&lt;ChangeRequest&gt;();
    private DataTable _table;

    public void ScheduleChange(ChangeRequest request)
    {
        _changes.Add(request);
    }

    public void ProcessChanges()
    {
        ChangeRequest cr;
            
        while(_changes.TryTake(out cr)) 
        {
            var row = _table.Rows.Find(cr.ID);
            if (row == null) { continue; }

            row[cr.Column] = cr.Value;
        }

        _table.AcceptChanges();            
    }
}
</pre></p>
<p>The code is a dumbed down version of what I&#8217;ve implemented, just to show the basic concept. The applications are numerous but I chose to use the DataTable example because it&#8217;s a thorn in my side at the moment.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/programmersunlimited.wordpress.com/399/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/programmersunlimited.wordpress.com/399/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/programmersunlimited.wordpress.com/399/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/programmersunlimited.wordpress.com/399/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/programmersunlimited.wordpress.com/399/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/programmersunlimited.wordpress.com/399/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/programmersunlimited.wordpress.com/399/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/programmersunlimited.wordpress.com/399/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/programmersunlimited.wordpress.com/399/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/programmersunlimited.wordpress.com/399/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/programmersunlimited.wordpress.com/399/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/programmersunlimited.wordpress.com/399/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/programmersunlimited.wordpress.com/399/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/programmersunlimited.wordpress.com/399/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=programmersunlimited.wordpress.com&#038;blog=14241067&#038;post=399&#038;subd=programmersunlimited&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://programmersunlimited.wordpress.com/2012/01/24/change-request-pattern-parallelism-and-non-thread-safe-collections/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c9e4d72e0a29be3bf43a6c8e0cbd656d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">programmersunlimited</media:title>
		</media:content>
	</item>
	</channel>
</rss>
