<?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/"
	>

<channel>
	<title>Alkampfer&#039;s Place&#187; Experiences</title>
	<atom:link href="http://www.codewrecks.com/blog/index.php/category/programming/experiences/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.codewrecks.com/blog</link>
	<description>Wrecks of code floating in the sea of Internet By Ricci Gian Maria</description>
	<lastBuildDate>Wed, 08 Feb 2012 17:49:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
		<item>
		<title>Budget for Hardware</title>
		<link>http://www.codewrecks.com/blog/index.php/2011/11/10/budget-for-hardware/</link>
		<comments>http://www.codewrecks.com/blog/index.php/2011/11/10/budget-for-hardware/#comments</comments>
		<pubDate>Thu, 10 Nov 2011 09:05:03 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
				<category><![CDATA[Experiences]]></category>
		<category><![CDATA[Hardware]]></category>

		<guid isPermaLink="false">http://www.codewrecks.com/blog/index.php/2011/11/10/budget-for-hardware/</guid>
		<description><![CDATA[I’ve just read this blog post that deals about the benefit of having the right hardware to work for developers. Quite often having or not having an SSD is not the real problem, because developers works with machine with low ram and slow disks and this is especially true for people working with laptop, that [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a target="_blank" href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.codewrecks.com%2Fblog%2Findex.php%2F2011%2F11%2F10%2Fbudget-for-hardware%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.codewrecks.com%2Fblog%2Findex.php%2F2011%2F11%2F10%2Fbudget-for-hardware%2F&amp;source=alkampfer&amp;style=normal&amp;hashtags=Hardware&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I’ve just read <a target="_blank" href="http://davybrion.com/blog/2011/11/faster-hardware-not-on-our-budget/">this blog post</a> that deals about the benefit of having the right <a title="hardware" href="http://www.codewrecks.com/blog/index.php/tag/hardware/">hardware</a> to work for developers. Quite often having or not having an SSD is not the real problem, because developers works with machine with low ram and slow disks and this is especially true for people working with laptop, that often uses 5.400 standard RPM disks. </p>
<p>It is difficult to understand how much minutes or hours per day a developer can save moving <em>from an average speed <a title="hardware" href="http://www.codewrecks.com/blog/index.php/tag/hardware/">hardware</a> to a top speed hardware</em> and without these numbers it is difficult to justify the expense of buying top speed hardware. On the opposite, if it is difficult to demonstrate the<em> gain in productivity with</em> <em>fast hardware</em>, it is quite simpler to demonstrate the <em>lack of productivity with crappy hardware.</em></p>
<p><img src="http://fixmyslowcomputer.org/wp-content/uploads/2010/01/Fix-computer-registry.gif" width="191" height="176" /></p>
<p>Developers are strange kind of workers, quite often they like their work and working with crappy hardware will make a developer sad and frustrated. I’ve seen people that must wait for minutes to do a Subversion updates and minutes to fully rebuild a solution just because they have 5.400 RPM disks and 2 GB of RAM. The first bad effect of having crappy hardware is creating frustration in developers and a frustrated employee usually is less productive.</p>
<p><img src="http://www.pcmedic-pr.com/Images/slow_computer.jpg" /></p>
<p>If the developer should wait for 2 minutes to build the solution, he will tend to utilize that time to do other stuff, because watching compiler output for 2 minutes is not a viable option <img src='http://www.codewrecks.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> ; but 2 minutes is not enough time to do anything useful, then the programmer <em>will do something “not useful”</em> like: facebook, twitter, or else. Usually it will end with the compiler finished working and the developer still occupied answering to twitter.</p>
<p><img src="http://lovell.com/wp-content/uploads/2011/06/Whats-Distracting-You.jpg" width="309" height="252" /></p>
<p>Another problem is losing the “context”, if you need to wait a long time waiting for your tool of choice to compile and <a title="test" href="http://www.codewrecks.com/blog/index.php/2007/09/03/test/">test</a> your modification you loose your stream of thought. This is especially true if you are fixing complex bug, or you are doing a complex task, if you spend long time waiting for the result, your mind start to thinking to other stuff and you lose your focus.</p>
<p><img src="http://maximizedpc.com/wp-content/uploads/slow-pc.png" /></p>
<p>When you are used to crappy hardware, you start thinking that the company will never spend money even for useful <a target="_blank" title="tools" href="http://www.codewrecks.com/blog/index.php/tag/tools/">tools</a>, so you start to lose time <a href="http://dilbert.com/strips/comic/2007-11-08/">reinventing the weel</a> or doing work in the wrong way.</p>
<p><img src="http://americaexplained.files.wordpress.com/2010/12/reinventthe-wheel.png" width="270" height="165" /></p>
<p>My suggestion is, if you are not convinced that you developer will really need Top Speed Hardware, please convince yourself that they need at least Average Speed Hardware, because the lack of productivity of a developer with low performing hardware is terrific.</p>
<p>But in the end I can confirm also that the gain of speed of having a top speed machine is worth the price and I strongly encourage to buy fast SSD for every developer and machine with at leash 8 GB of RAM and an i5 or i7 CPU, this will make your developers more productive and usually happier and not frustrated.</p>
<p>Gian Maria.</p>]]></content:encoded>
			<wfw:commentRss>http://www.codewrecks.com/blog/index.php/2011/11/10/budget-for-hardware/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The good part of having a lot of RAM</title>
		<link>http://www.codewrecks.com/blog/index.php/2011/09/17/the-good-part-of-having-a-lot-of-ram/</link>
		<comments>http://www.codewrecks.com/blog/index.php/2011/09/17/the-good-part-of-having-a-lot-of-ram/#comments</comments>
		<pubDate>Sat, 17 Sep 2011 14:12:15 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
				<category><![CDATA[Experiences]]></category>
		<category><![CDATA[Hardware]]></category>

		<guid isPermaLink="false">http://www.codewrecks.com/blog/index.php/2011/09/17/the-good-part-of-having-a-lot-of-ram/</guid>
		<description><![CDATA[I’ve learned in the past a precious rule about hardware: try to imagine how you will use your pc in at least one or two years period before thinking to buy some piece of hardware. I remember a lot of years ago, when I bought a pc with a 1.6 GB Hard Disk, a size [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a target="_blank" href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.codewrecks.com%2Fblog%2Findex.php%2F2011%2F09%2F17%2Fthe-good-part-of-having-a-lot-of-ram%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.codewrecks.com%2Fblog%2Findex.php%2F2011%2F09%2F17%2Fthe-good-part-of-having-a-lot-of-ram%2F&amp;source=alkampfer&amp;style=normal&amp;hashtags=Hardware&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I’ve learned in the past a precious rule about <a title="hardware" href="http://www.codewrecks.com/blog/index.php/tag/hardware/">hardware</a>: try to imagine how you will use your pc in at least one or two years period before thinking to buy some piece of <a title="hardware" href="http://www.codewrecks.com/blog/index.php/tag/hardware/">hardware</a>.</p>
<p>I remember a lot of years ago, when I bought a pc with a 1.6 GB Hard Disk, a size that was really big for these period, when standard pc had 512 MB Hard Disk or less. I remember a couple of friends of mine told me “why you spent money on such a big Hard Disk, it is really too big, you will never need such a big space”. After one year, I ran in those machine a partition of Windows 95, one for DOS, a stable partition with Linux Slackware distribution and a fourth partition to experiment the new distribution of linux that we downloaded from the university. I’ve plenty of space while my friends strived themselves to keep everything inside 512 MB.</p>
<p>Today I installed a <a target="_blank" title="virtual machine" href="http://www.codewrecks.com/blog/index.php/tag/virtual-machine/">virtual machine</a> to experiment <a title="TFS" href="http://msdn.microsoft.com/en-us/vstudio/ff637362">TFS</a> 11 and saw that during installation of SharePoint foundation there is a warning telling me that 10GB RAM is suggested for best experience, so I go to VM setting, and gave 12 GB of RAM to the VM. <img src='http://www.codewrecks.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><a href="http://www.codewrecks.com/blog/wp-content/uploads/2011/09/seeee.jpg"><img style="border: 0px currentcolor; display: inline; background-image: none;" title="seeee" border="0" alt="seeee" src="http://www.codewrecks.com/blog/wp-content/uploads/2011/09/seeee_thumb.jpg" width="690" height="495" /></a></p>
<p>Actually there is no need to have 12 GB to experiment with TFS11, a 4 GB machine will be enough to create a <a target="_blank" title="test" href="http://www.codewrecks.com/blog/index.php/2007/09/03/test/">test</a> environment, but having 16 GB of ram and an SSD on my machine permits me to play with a superfast <a title="test" href="http://www.codewrecks.com/blog/index.php/2007/09/03/test/">test</a> <a title="TFS" href="http://msdn.microsoft.com/en-us/vstudio/ff637362">TFS</a> 11 machine.</p>
<p>And I rethink to a couple of friends of mine, that 4 month ago told me that spending money on 16 GB of ram is not so useful, because 8 GB is surely enough for any usage <img src='http://www.codewrecks.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>Now I’m moving toward a QNAP External HD case, and probably for Christmas another SSD (A Vertex 3) <img src='http://www.codewrecks.com/blog/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> , I love hardware. </p>
<p>Alk.</p>]]></content:encoded>
			<wfw:commentRss>http://www.codewrecks.com/blog/index.php/2011/09/17/the-good-part-of-having-a-lot-of-ram/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I love virtual machines</title>
		<link>http://www.codewrecks.com/blog/index.php/2011/09/16/i-love-virtual-machines/</link>
		<comments>http://www.codewrecks.com/blog/index.php/2011/09/16/i-love-virtual-machines/#comments</comments>
		<pubDate>Fri, 16 Sep 2011 15:42:44 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
				<category><![CDATA[Experiences]]></category>
		<category><![CDATA[Tfs]]></category>

		<guid isPermaLink="false">http://www.codewrecks.com/blog/index.php/2011/09/16/i-love-virtual-machines/</guid>
		<description><![CDATA[I’m installing TFS 11 developer preview and I got this. So I clicked settings, added another 4 gb ram to the machine (to a total of 6 GB), vmWare workstation suspend the machine for a bunch of seconds, then I rerun check and magically I can move on. And I’m a few seconds away to [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a target="_blank" href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.codewrecks.com%2Fblog%2Findex.php%2F2011%2F09%2F16%2Fi-love-virtual-machines%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.codewrecks.com%2Fblog%2Findex.php%2F2011%2F09%2F16%2Fi-love-virtual-machines%2F&amp;source=alkampfer&amp;style=normal&amp;hashtags=Tfs&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I’m installing <a target="_blank" title="TFS" href="http://msdn.microsoft.com/en-us/vstudio/ff637362">TFS</a> 11 developer preview and I got this.</p>
<p><a href="http://www.codewrecks.com/blog/wp-content/uploads/2011/09/image1.png"><img style="border: 0px currentcolor; display: inline; background-image: none;" title="image" border="0" alt="image" src="http://www.codewrecks.com/blog/wp-content/uploads/2011/09/image_thumb1.png" width="602" height="196" /></a></p>
<p>So I clicked settings, added another 4 gb ram to the machine (to a total of 6 GB), vmWare workstation suspend the machine for a bunch of seconds, then I rerun check and magically I can move on.</p>
<p>And I’m a few seconds away to have a <a target="_blank" title="TFS" href="http://msdn.microsoft.com/en-us/vstudio/ff637362">TFS</a> 11 to play with <a title="dev11" href="http://www.codewrecks.com/blog/index.php/tag/dev11/">dev11</a> bits <img src='http://www.codewrecks.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> , I’m exited.</p>
<p>Gian Maria.</p>]]></content:encoded>
			<wfw:commentRss>http://www.codewrecks.com/blog/index.php/2011/09/16/i-love-virtual-machines/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How could I work without resharper</title>
		<link>http://www.codewrecks.com/blog/index.php/2011/02/23/how-could-i-work-without-resharper/</link>
		<comments>http://www.codewrecks.com/blog/index.php/2011/02/23/how-could-i-work-without-resharper/#comments</comments>
		<pubDate>Wed, 23 Feb 2011 10:15:03 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
				<category><![CDATA[Experiences]]></category>
		<category><![CDATA[Resharper]]></category>

		<guid isPermaLink="false">http://www.codewrecks.com/blog/index.php/2011/02/23/how-could-i-work-without-resharper/</guid>
		<description><![CDATA[In a system that use heavily IoC principle, it is common during component modification, to discover that to add a new functionality that component need to add a dependency on some interface. Here is the constructor of a component 1: public MainNavigator( 2: IEBrochureService brochureService, 3: IBroker broker) 4: { Now I need to add [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a target="_blank" href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.codewrecks.com%2Fblog%2Findex.php%2F2011%2F02%2F23%2Fhow-could-i-work-without-resharper%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.codewrecks.com%2Fblog%2Findex.php%2F2011%2F02%2F23%2Fhow-could-i-work-without-resharper%2F&amp;source=alkampfer&amp;style=normal&amp;hashtags=Resharper&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>In a system that use heavily IoC principle, it is common during component modification, to discover that to add a new functionality that component need to add a dependency on some interface. Here is the constructor of a component</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #0000ff">public</span> MainNavigator(</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span>     IEBrochureService brochureService, </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span>     IBroker broker)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span> {</pre>
<p><!--CRLF--></div>
</div>
<p>Now I need to add dependency from the IWpfSystem interface, so I simply add another parameter to the constructor, and R# suggests me a lot of action that could be triggered from this modification</p>
<p><a href="http://www.codewrecks.com/blog/wp-content/uploads/2011/02/image7.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.codewrecks.com/blog/wp-content/uploads/2011/02/image_thumb7.png" width="455" height="218" /></a></p>
<p>The first one automatically declare a field called _engine and initialize into the constructor, but I have a lot of other options, like applying change signature refactoring, and change all call to this constructor, creating an overload version without this new parameter or even check for null assignment. </p>
<p>Shortcut like these one can tremendously boost up your productivity.</p>
<p>alk.</p>]]></content:encoded>
			<wfw:commentRss>http://www.codewrecks.com/blog/index.php/2011/02/23/how-could-i-work-without-resharper/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>GeckoFX for c#, strange behavior</title>
		<link>http://www.codewrecks.com/blog/index.php/2011/01/28/geckofx-for-c-strange-behavior/</link>
		<comments>http://www.codewrecks.com/blog/index.php/2011/01/28/geckofx-for-c-strange-behavior/#comments</comments>
		<pubDate>Fri, 28 Jan 2011 14:40:25 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
				<category><![CDATA[Experiences]]></category>
		<category><![CDATA[Gecko]]></category>

		<guid isPermaLink="false">http://www.codewrecks.com/blog/index.php/2011/01/28/geckofx-for-c-strange-behavior/</guid>
		<description><![CDATA[Today I faced a very strange problem with GeckoBrowser, after navigating a page I simply need to grab all the HTML of the page to analyze it. I try to access the GeckoBrowser.Document.TextContentv property but it is always null. I searched on the web and found this discussion but it does not work, because the [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a target="_blank" href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.codewrecks.com%2Fblog%2Findex.php%2F2011%2F01%2F28%2Fgeckofx-for-c-strange-behavior%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.codewrecks.com%2Fblog%2Findex.php%2F2011%2F01%2F28%2Fgeckofx-for-c-strange-behavior%2F&amp;source=alkampfer&amp;style=normal&amp;hashtags=Gecko&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Today I faced a very strange problem with GeckoBrowser, after navigating a page I simply need to grab all the HTML of the page to analyze it. I try to access the <strong><em>GeckoBrowser.Document.TextContentv </em></strong>property but it is always null.</p>
<p>I searched on the web and found <a target="_blank" href="http://geckofx.org/viewtopic.php?id=805">this discussion</a> but it does not work, because the DocumentElement.InnerHtml throws a nullreferenceexception, how sad. In that post a user suggest to download the text manually, but saving bandwidth is one of the requirements, so I really need to use the HTML already downloaded by <a title="Gecko" href="http://www.codewrecks.com/blog/index.php/tag/gecko/">Gecko</a> Browser.</p>
<p>After some inspection of the GeckoBrowser class I found this code that works, it is not optimal because it requires a save and a read to disk, but in my situation is more acceptable than use bandwidth to download the code again.</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> String tempFile = Path.ChangeExtension(</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> Path.GetTempFileName(), <span style="color: #006080">&quot;.html&quot;</span>);</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> GeckoBrowser.SaveDocument(tempFile);</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span> String content = File.ReadAllText(tempFile);</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span> File.Delete(tempFile);</pre>
<p><!--CRLF--></div>
</div>
<p>The solution is to use the SaveDocument function that seems to save correctly all the content of the page. This solution is not really performant because it needs to access disk, but surely it save bandwidth, and is usually quicker respect downloading again the whole content with a WebRequest, and moreover it does not have problem of site with login etc etc.</p>
<p>Alk.</p>]]></content:encoded>
			<wfw:commentRss>http://www.codewrecks.com/blog/index.php/2011/01/28/geckofx-for-c-strange-behavior/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add a cache and&#8230; you&#8217;ve created a security bug</title>
		<link>http://www.codewrecks.com/blog/index.php/2011/01/25/add-a-cache-and-youve-created-a-security-bug/</link>
		<comments>http://www.codewrecks.com/blog/index.php/2011/01/25/add-a-cache-and-youve-created-a-security-bug/#comments</comments>
		<pubDate>Tue, 25 Jan 2011 16:13:02 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
				<category><![CDATA[Experiences]]></category>

		<guid isPermaLink="false">http://www.codewrecks.com/blog/index.php/2011/01/25/add-a-cache-and-youve-created-a-security-bug/</guid>
		<description><![CDATA[This is the history of a nasty bug happened today. There is some service that has a method called GetCustomers() and this function is used from a web application and a Windows application. Since landing web page use this function to show all customers data, and since&#160; Customers entity changes rarely we decide to put [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a target="_blank" href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.codewrecks.com%2Fblog%2Findex.php%2F2011%2F01%2F25%2Fadd-a-cache-and-youve-created-a-security-bug%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.codewrecks.com%2Fblog%2Findex.php%2F2011%2F01%2F25%2Fadd-a-cache-and-youve-created-a-security-bug%2F&amp;source=alkampfer&amp;style=normal&amp;hashtags=Experiences&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>This is the history of a nasty bug happened today. There is some service that has a method called GetCustomers() and this function is used from a web application and a Windows application. Since landing web page use this function to show all customers data, and since&#160; Customers <a target="_blank" title="entity" href="http://en.wikipedia.org/wiki/Domain-driven_design#Building_blocks_of_DDD">entity</a> changes rarely we decide to put the result of this service call in Cache with 1 hour absolute expiration.</p>
<p>Web interface is made in WebForms, so we used an ObjectDataSource to communicate with the service, here is the code.</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> String cachekey = <span style="color: #006080">&quot;34F56C51-1941-480A-9801-70C6B1E31DF0&quot;</span>;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> IList&lt;CustomerDto&gt; result;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> <span style="color: #0000ff">if</span> ((result = HttpContext.Current.Cache.Get(cachekey) <span style="color: #0000ff">as</span> IList&lt;CustomerDto&gt;) == <span style="color: #0000ff">null</span>)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span> {</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>    <span style="color: #008000">//result isnot in cache, get from service and add to cache</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>    result = ItemService.GetCustomers();</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span>    HttpContext.Current.Cache.Insert(cachekey, result, <span style="color: #0000ff">null</span>, DateTime.Now.AddMinutes(60),Cache.NoSlidingExpiration );</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span> }</pre>
<p><!--CRLF--></div>
</div>
<p>This code works ok, it uses an unique guid as cache key because the GetAllCustomers() has no parameters, so we simply check if the result is in cache, if not, call the service and put the result in the cache.</p>
<p>Everything seems okâ€¦ or not?</p>
<p>The question is: is it correct to store result in cache if we know that we can wait for one hour to see updated data?</p>
<p><a href="http://www.codewrecks.com/blog/wp-content/uploads/2011/01/image19.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.codewrecks.com/blog/wp-content/uploads/2011/01/image_thumb19.png" width="244" height="159" /></a></p>
<p>The correct answer is: you cannot answer to this question if you do not know the implementation of GetAllCustomers() service function. What we need to know is that service method answers with the same result when we call it with the same parameters or the method depends from some other data of the environment.</p>
<p>This code works fine, until requirements changed. A new requirements introduced a new role in the system (called SimpleUser), and users belonging to this role are allowed to see only a subset of all Customers, and this subset is handled from Administrator roles. This functionality was implemented inside the GetAllCustomers() service function. If current user belongs to this new role, the service will issue a query on Customers object with a join to the AllowedCustomers table and the name of current user to show only allowed customersâ€¦ and this introduced a bug</p>
<p><img src="http://www.mspmentor.net/wp-content/uploads/2010/01/symantec-endpoint-security-bug.jpg" /></p>
<p>Do you spot the problem???</p>
<p>Suppose this scenario, an administrator enters in the system, data source issued the call to GetAllCustomers() service method and put data in cache. Now a SimpleUser logs to the system, data source object find the result of GetAllCustomers() in cache and simply returns it.. showing the result of all customersâ€¦. wow, now if the user choose an unassociated user the system chrashes with a securityException but worst of all, he see data from all Customers, even those he have not access toâ€¦.</p>
<p>The obvious solution is adding the name of the logged user to the cache key when the user belong to the SimpleUser Role, but this bug reminded me of how really difficult is creating a good cache strategy. </p>
<p>Alk.</p>]]></content:encoded>
			<wfw:commentRss>http://www.codewrecks.com/blog/index.php/2011/01/25/add-a-cache-and-youve-created-a-security-bug/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>When it is time of quick and dirty hotfix</title>
		<link>http://www.codewrecks.com/blog/index.php/2010/11/04/when-it-is-time-of-quick-and-dirty-hotfix/</link>
		<comments>http://www.codewrecks.com/blog/index.php/2010/11/04/when-it-is-time-of-quick-and-dirty-hotfix/#comments</comments>
		<pubDate>Thu, 04 Nov 2010 14:06:24 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
				<category><![CDATA[Experiences]]></category>

		<guid isPermaLink="false">http://www.codewrecks.com/blog/index.php/2010/11/04/when-it-is-time-of-quick-and-dirty-hotfix/</guid>
		<description><![CDATA[Iâ€™ve a software composed by many pieces, one of them was deployed 9 month ago and works well, today we find a little bug and need to change a string in it. The obvious solution is, take the release branch, change the string, compile and deploy again, but there is even a dirtier approach, Iâ€™ve [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a target="_blank" href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.codewrecks.com%2Fblog%2Findex.php%2F2010%2F11%2F04%2Fwhen-it-is-time-of-quick-and-dirty-hotfix%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.codewrecks.com%2Fblog%2Findex.php%2F2010%2F11%2F04%2Fwhen-it-is-time-of-quick-and-dirty-hotfix%2F&amp;source=alkampfer&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Iâ€™ve a software composed by many pieces, one of them was deployed 9 month ago and works well, today we find a little bug and need to change a string in it. </p>
<p>The obvious solution is, take the release <a title="branch" href="http://www.codewrecks.com/blog/index.php/tag/branch/">branch</a>, change the string, compile and deploy again, but there is even a dirtier approach, Iâ€™ve simply disassembled the file with ildasm, changed the string and finally assemble it again (and clearly I changed the string even in the <a title="branch" href="http://www.codewrecks.com/blog/index.php/tag/branch/">branch</a>).</p>
<p>This saved me the need to redeploy the entire application (uploading stuff via ftp, etc etc), and I was able to do the hotfix directly in production server with a simple remote desktop.</p>
<p>This is probably the dirtiest patch Iâ€™ve made in years <img style="border-bottom-style: none; border-right-style: none; border-top-style: none; border-left-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://www.codewrecks.com/blog/wp-content/uploads/2010/11/wlEmoticon-smile.png" /></p>
<p>alk.</p>]]></content:encoded>
			<wfw:commentRss>http://www.codewrecks.com/blog/index.php/2010/11/04/when-it-is-time-of-quick-and-dirty-hotfix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

