<?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>Pathfinder Software &#187; Karthik Muthupalaniappan</title>
	<atom:link href="http://pathfindersoftware.com/author/karthik-muthupalaniappan/feed/" rel="self" type="application/rss+xml" />
	<link>http://pathfindersoftware.com</link>
	<description>The Fastest Way to Launch Successful Software</description>
	<lastBuildDate>Thu, 19 Jan 2012 16:31:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Simple Rails Performance Tip &#8211; ActiveRecord Batch Retrieval</title>
		<link>http://pathfindersoftware.com/2010/10/simple-performance-tip-rails-activerecord-batch-retrieval/</link>
		<comments>http://pathfindersoftware.com/2010/10/simple-performance-tip-rails-activerecord-batch-retrieval/#comments</comments>
		<pubDate>Fri, 08 Oct 2010 11:14:20 +0000</pubDate>
		<dc:creator>Karthik Muthupalaniappan</dc:creator>
				<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=5876</guid>
		<description><![CDATA[Users.each do &#124;user&#124; puts user.name end Ever wondered about how expensive a simple &#8220;.each&#8221; on an ActiveRecord object collection is. This essentially means for every iteration of the loop, there is going to be a database fetch. Imagine looping over a collection that has 10,000 records (forget millions..). Yes, I have made use of this ...]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F10%2Fsimple-performance-tip-rails-activerecord-batch-retrieval%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F10%2Fsimple-performance-tip-rails-activerecord-batch-retrieval%2F&amp;source=PathSoft&amp;style=normal&amp;service=bit.ly&amp;service_api=R_8a1154b608af9e55718b231fb0025d40&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<blockquote>
<pre>Users.each do |user|</pre>
<pre>  puts user.name</pre>
<pre>end</pre>
</blockquote>
<p>Ever wondered about how expensive a simple <strong>&#8220;.each&#8221;</strong> on an ActiveRecord object collection is. This essentially means for every iteration of the loop, there is going to be a database fetch. Imagine looping over a collection that has 10,000 records (forget millions..). Yes, I have made use of this very same thing a bunch of times without realising the kind of performance implications this could have. Not until last week I discovered that there was a very less-expensive way to do this.</p>
<p>I was perusing the <a href="http://guides.rubyonrails.org/" target="_blank">Rails guides</a> casually looking for something else when I hit upon this. <strong>&#8220;.find_each&#8221;</strong>. What does this do? It makes looping over a collection of Active record objects much much cheaper by performing a batch retreival of the database records and caching them. The batch size can be altered by passing in a batch_size param like this <strong>&#8220;.find_each(:batch_size =&gt; 500&#8243;</strong>).</p>
<blockquote>
<pre>Users.find_each(:batch_size =&gt; 200) do |user|</pre>
<pre>  puts user.name</pre>
<pre>end</pre>
</blockquote>
<p>I have almost stopped using <strong>&#8220;.each&#8221;</strong> these days and let<strong> &#8220;.find_each&#8221;</strong> do the job.
<p><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F10%2Fsimple-performance-tip-rails-activerecord-batch-retrieval%2F&amp;linkname=Simple%20Rails%20Performance%20Tip%20%26%238211%3B%20ActiveRecord%20Batch%20Retrieval" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_stumbleupon" href="http://www.addtoany.com/add_to/stumbleupon?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F10%2Fsimple-performance-tip-rails-activerecord-batch-retrieval%2F&amp;linkname=Simple%20Rails%20Performance%20Tip%20%26%238211%3B%20ActiveRecord%20Batch%20Retrieval" title="StumbleUpon" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/stumbleupon.png" width="16" height="16" alt="StumbleUpon"/></a><a class="a2a_button_digg" href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F10%2Fsimple-performance-tip-rails-activerecord-batch-retrieval%2F&amp;linkname=Simple%20Rails%20Performance%20Tip%20%26%238211%3B%20ActiveRecord%20Batch%20Retrieval" title="Digg" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F10%2Fsimple-performance-tip-rails-activerecord-batch-retrieval%2F&amp;linkname=Simple%20Rails%20Performance%20Tip%20%26%238211%3B%20ActiveRecord%20Batch%20Retrieval" title="DZone" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_reddit" href="http://www.addtoany.com/add_to/reddit?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F10%2Fsimple-performance-tip-rails-activerecord-batch-retrieval%2F&amp;linkname=Simple%20Rails%20Performance%20Tip%20%26%238211%3B%20ActiveRecord%20Batch%20Retrieval" title="Reddit" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/reddit.png" width="16" height="16" alt="Reddit"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F10%2Fsimple-performance-tip-rails-activerecord-batch-retrieval%2F&amp;linkname=Simple%20Rails%20Performance%20Tip%20%26%238211%3B%20ActiveRecord%20Batch%20Retrieval" title="Delicious" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_evernote" href="http://www.addtoany.com/add_to/evernote?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F10%2Fsimple-performance-tip-rails-activerecord-batch-retrieval%2F&amp;linkname=Simple%20Rails%20Performance%20Tip%20%26%238211%3B%20ActiveRecord%20Batch%20Retrieval" title="Evernote" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/evernote.png" width="16" height="16" alt="Evernote"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F10%2Fsimple-performance-tip-rails-activerecord-batch-retrieval%2F&amp;title=Simple%20Rails%20Performance%20Tip%20%26%238211%3B%20ActiveRecord%20Batch%20Retrieval" id="wpa2a_2">Share/Bookmark</a></p>
]]></content:encoded>
			<wfw:commentRss>http://pathfindersoftware.com/2010/10/simple-performance-tip-rails-activerecord-batch-retrieval/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails URL Validation, made simple!</title>
		<link>http://pathfindersoftware.com/2010/08/rails-url-validation-made-simple/</link>
		<comments>http://pathfindersoftware.com/2010/08/rails-url-validation-made-simple/#comments</comments>
		<pubDate>Thu, 12 Aug 2010 19:45:23 +0000</pubDate>
		<dc:creator>Karthik Muthupalaniappan</dc:creator>
				<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=5491</guid>
		<description><![CDATA[There are a number of approaches out there for validating the format of a URL input. Looking at the different approaches, the most commonly used and the quick &#38; dirty one was of course the regex matcher approach. This is the regex solution which is easy enough to implement but I m not sure if ...]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F08%2Frails-url-validation-made-simple%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F08%2Frails-url-validation-made-simple%2F&amp;source=PathSoft&amp;style=normal&amp;service=bit.ly&amp;service_api=R_8a1154b608af9e55718b231fb0025d40&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>There are a number of approaches out there for validating the format of a URL input. Looking at the different approaches, the most commonly used and the quick &amp; dirty one was of course the regex matcher approach. This is the regex solution which is easy enough to implement but I m not sure if would handle all the different possible scenarios. Regex is tricky (atleast for me <img src='http://pathfindersoftware.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> ).</p>
<pre>validates_format_of :url ,
:with =&gt; /^(http|https)://[a-z0-9]+([-.]{1}[a-z0-9]+)* .[a-z]{2,5}(([0-9]{1,5})?/.*)?$/ix</pre>
<p>The other possible solution was to use the URI.parse method to determine if the URL is a valid url.  This involves calling the URI.parse method passing in the url and checking if the class for the URI is a valid one.</p>
<pre>def validate
  begin
    uri = URI.parse(url)
    if uri.class != URI::HTTP
      errors.add(:url, 'Only HTTP protocol addresses can be used')
    end
    rescue URI::InvalidURIError
      errors.add(:url, 'The format of the url is not valid.')
    end
  end</pre>
<p>There’s probably one caveat to the above approach. Sometimes, URI.parse returns a URI::Generic which is the parent of the other URI types in which case even though the URL in question could be a like a valid non HTTP URL, our validation would fail.</p>
<p>The solution I came across most recently was this.</p>
<pre>validates_format_of :url, :with =&gt; URI::regexp</pre>
<p>I think it works great and is probably the best way to validate a URL in rails.
<p><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F08%2Frails-url-validation-made-simple%2F&amp;linkname=Rails%20URL%20Validation%2C%20made%20simple%21" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_stumbleupon" href="http://www.addtoany.com/add_to/stumbleupon?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F08%2Frails-url-validation-made-simple%2F&amp;linkname=Rails%20URL%20Validation%2C%20made%20simple%21" title="StumbleUpon" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/stumbleupon.png" width="16" height="16" alt="StumbleUpon"/></a><a class="a2a_button_digg" href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F08%2Frails-url-validation-made-simple%2F&amp;linkname=Rails%20URL%20Validation%2C%20made%20simple%21" title="Digg" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F08%2Frails-url-validation-made-simple%2F&amp;linkname=Rails%20URL%20Validation%2C%20made%20simple%21" title="DZone" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_reddit" href="http://www.addtoany.com/add_to/reddit?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F08%2Frails-url-validation-made-simple%2F&amp;linkname=Rails%20URL%20Validation%2C%20made%20simple%21" title="Reddit" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/reddit.png" width="16" height="16" alt="Reddit"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F08%2Frails-url-validation-made-simple%2F&amp;linkname=Rails%20URL%20Validation%2C%20made%20simple%21" title="Delicious" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_evernote" href="http://www.addtoany.com/add_to/evernote?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F08%2Frails-url-validation-made-simple%2F&amp;linkname=Rails%20URL%20Validation%2C%20made%20simple%21" title="Evernote" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/evernote.png" width="16" height="16" alt="Evernote"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F08%2Frails-url-validation-made-simple%2F&amp;title=Rails%20URL%20Validation%2C%20made%20simple%21" id="wpa2a_4">Share/Bookmark</a></p>
]]></content:encoded>
			<wfw:commentRss>http://pathfindersoftware.com/2010/08/rails-url-validation-made-simple/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>jQuery&#039;s Clone() and FireQuery</title>
		<link>http://pathfindersoftware.com/2010/05/jquery-trick-learnt-firequery-plugin-firefox/</link>
		<comments>http://pathfindersoftware.com/2010/05/jquery-trick-learnt-firequery-plugin-firefox/#comments</comments>
		<pubDate>Mon, 03 May 2010 16:56:36 +0000</pubDate>
		<dc:creator>Karthik Muthupalaniappan</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Rich Internet Apps]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Clone()]]></category>
		<category><![CDATA[FireQuery]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=5125</guid>
		<description><![CDATA[So there was this need for providing ajax-style add/remove item-rows on the last project I worked on.  What I thought might be pretty straight-forward to achieve using jQuery-fu eventually turned out to be little hairy for me. The approach that I used to implement this was to use a hidden item(a div with some content ...]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F05%2Fjquery-trick-learnt-firequery-plugin-firefox%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F05%2Fjquery-trick-learnt-firequery-plugin-firefox%2F&amp;source=PathSoft&amp;style=normal&amp;service=bit.ly&amp;service_api=R_8a1154b608af9e55718b231fb0025d40&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>So there was this need for providing ajax-style add/remove item-rows on the last project I worked on.  What I thought might be pretty straight-forward to achieve using jQuery-fu eventually turned out to be little hairy for me.</p>
<p><span id="more-5125"></span></p>
<p>The approach that I used to implement this was to use a hidden item(a div with some content in this case) and clone it using the <a href="http://api.jquery.com/clone/" target="_blank">jQuery clone()</a> method to make a new copy of the item and then append it to the collection under a parent div.  The cloning and adding worked like a charm. What bothered me was the remove of the item-row. Each item-row had a remove link/button to delete the item. The remove was supposed to work using the jQuery click event handler on the remove link/button. It did&#8217;nt work as expected <img src='http://pathfindersoftware.com/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> .  The click event handler was&#8217;nt getting hit for some reason and I did not have clue as to why as the same remove handler was working without issues in a different section on the same page.</p>
<p>What I came to my rescue was <a href="http://firequery.binaryage.com/" target="_blank">FireQuery. </a></p>
<p>FireQuery is a cool little add-on for Firefox that integrates with Firebug. It allows inspection of jQuery expressions, methods, events in the firebug console making it a great debugging assistant for jQuery. Using FireQuery, I was able to confirm that the cloned item-rows did not have the click remove handler attached to them. This made me realise that the clone() was not copying the jQuery event handler after all.  Thanks to Google, I finally figured out clone(true) would fix the problem and it did! Apparently, clone(true) is like a deep copy of the DOM element/object along with its events.</p>
<p>I m a jQuery newbie but I have already started loving it over Prototype and other JS libraries I have used in the past. Hoping to make more use of it (and FireQuery too!) in the future.</p>
<p><img src="http://pathfindersoftware.com/wp-content/uploads/Screen-shot-2010-05-03-at-11.49.29-AM1.png" alt="JQuery Clone and Append" width="485" height="179" />
<p><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F05%2Fjquery-trick-learnt-firequery-plugin-firefox%2F&amp;linkname=jQuery%26%23039%3Bs%20Clone%28%29%20and%20FireQuery" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_stumbleupon" href="http://www.addtoany.com/add_to/stumbleupon?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F05%2Fjquery-trick-learnt-firequery-plugin-firefox%2F&amp;linkname=jQuery%26%23039%3Bs%20Clone%28%29%20and%20FireQuery" title="StumbleUpon" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/stumbleupon.png" width="16" height="16" alt="StumbleUpon"/></a><a class="a2a_button_digg" href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F05%2Fjquery-trick-learnt-firequery-plugin-firefox%2F&amp;linkname=jQuery%26%23039%3Bs%20Clone%28%29%20and%20FireQuery" title="Digg" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F05%2Fjquery-trick-learnt-firequery-plugin-firefox%2F&amp;linkname=jQuery%26%23039%3Bs%20Clone%28%29%20and%20FireQuery" title="DZone" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_reddit" href="http://www.addtoany.com/add_to/reddit?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F05%2Fjquery-trick-learnt-firequery-plugin-firefox%2F&amp;linkname=jQuery%26%23039%3Bs%20Clone%28%29%20and%20FireQuery" title="Reddit" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/reddit.png" width="16" height="16" alt="Reddit"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F05%2Fjquery-trick-learnt-firequery-plugin-firefox%2F&amp;linkname=jQuery%26%23039%3Bs%20Clone%28%29%20and%20FireQuery" title="Delicious" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_evernote" href="http://www.addtoany.com/add_to/evernote?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F05%2Fjquery-trick-learnt-firequery-plugin-firefox%2F&amp;linkname=jQuery%26%23039%3Bs%20Clone%28%29%20and%20FireQuery" title="Evernote" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/evernote.png" width="16" height="16" alt="Evernote"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F05%2Fjquery-trick-learnt-firequery-plugin-firefox%2F&amp;title=jQuery%26%23039%3Bs%20Clone%28%29%20and%20FireQuery" id="wpa2a_6">Share/Bookmark</a></p>
]]></content:encoded>
			<wfw:commentRss>http://pathfindersoftware.com/2010/05/jquery-trick-learnt-firequery-plugin-firefox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Opera Mini for the iPhone (Bye-Bye Safari!)</title>
		<link>http://pathfindersoftware.com/2010/04/opera-mini-iphone-bye-bye-safari/</link>
		<comments>http://pathfindersoftware.com/2010/04/opera-mini-iphone-bye-bye-safari/#comments</comments>
		<pubDate>Tue, 13 Apr 2010 16:12:41 +0000</pubDate>
		<dc:creator>Karthik Muthupalaniappan</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Technologies and Platforms]]></category>
		<category><![CDATA[User Experience Design]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Opera]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=5003</guid>
		<description><![CDATA[So Opera Mini for the iPhone got approved and is available in the App store since last night.  I downloaded it this morning and should say I am mighty impressed with it. It is zippy, fast and intuitive.  There was a quite a bit of speculation around whether this would get approved by Apple.  I ...]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F04%2Fopera-mini-iphone-bye-bye-safari%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F04%2Fopera-mini-iphone-bye-bye-safari%2F&amp;source=PathSoft&amp;style=normal&amp;service=bit.ly&amp;service_api=R_8a1154b608af9e55718b231fb0025d40&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>So <a href="http://itunes.apple.com/us/app/opera-mini-web-browser/id363729560?mt=8" target="_blank">Opera Mini for the iPhone</a> got approved and is available in the App store since last night.  I downloaded it this morning and should say I am mighty impressed with it. It is zippy, fast and intuitive.  There was a quite a bit of <a href="http://www.pathf.com/blogs/2010/04/opera-apples-netscape/" target="_blank">speculation</a> around whether this would get approved by Apple.  I m happy that Apple approved it.</p>
<p>I did notice a few quirks with the Browser but they are in no way deal-breakers. From my brief interaction with it, the browser looks awesome to me! I dont deny Safari being a solid mobile browser itself but with Opera out now, its &#8220;Bye-Bye Safari&#8221; for me <img src='http://pathfindersoftware.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div id="attachment_5004" class="wp-caption aligncenter" style="width: 330px"><img class="size-full wp-image-5004 " src="http://pathfindersoftware.com/wp-content/uploads/photo3.jpg" alt="photo" width="320" height="480" />
<p class="wp-caption-text">Opera Mini for the iPhone</p>
</div>
<p><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F04%2Fopera-mini-iphone-bye-bye-safari%2F&amp;linkname=Opera%20Mini%20for%20the%20iPhone%20%28Bye-Bye%20Safari%21%29" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_stumbleupon" href="http://www.addtoany.com/add_to/stumbleupon?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F04%2Fopera-mini-iphone-bye-bye-safari%2F&amp;linkname=Opera%20Mini%20for%20the%20iPhone%20%28Bye-Bye%20Safari%21%29" title="StumbleUpon" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/stumbleupon.png" width="16" height="16" alt="StumbleUpon"/></a><a class="a2a_button_digg" href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F04%2Fopera-mini-iphone-bye-bye-safari%2F&amp;linkname=Opera%20Mini%20for%20the%20iPhone%20%28Bye-Bye%20Safari%21%29" title="Digg" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F04%2Fopera-mini-iphone-bye-bye-safari%2F&amp;linkname=Opera%20Mini%20for%20the%20iPhone%20%28Bye-Bye%20Safari%21%29" title="DZone" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_reddit" href="http://www.addtoany.com/add_to/reddit?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F04%2Fopera-mini-iphone-bye-bye-safari%2F&amp;linkname=Opera%20Mini%20for%20the%20iPhone%20%28Bye-Bye%20Safari%21%29" title="Reddit" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/reddit.png" width="16" height="16" alt="Reddit"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F04%2Fopera-mini-iphone-bye-bye-safari%2F&amp;linkname=Opera%20Mini%20for%20the%20iPhone%20%28Bye-Bye%20Safari%21%29" title="Delicious" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_evernote" href="http://www.addtoany.com/add_to/evernote?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F04%2Fopera-mini-iphone-bye-bye-safari%2F&amp;linkname=Opera%20Mini%20for%20the%20iPhone%20%28Bye-Bye%20Safari%21%29" title="Evernote" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/evernote.png" width="16" height="16" alt="Evernote"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F04%2Fopera-mini-iphone-bye-bye-safari%2F&amp;title=Opera%20Mini%20for%20the%20iPhone%20%28Bye-Bye%20Safari%21%29" id="wpa2a_8">Share/Bookmark</a></p>
]]></content:encoded>
			<wfw:commentRss>http://pathfindersoftware.com/2010/04/opera-mini-iphone-bye-bye-safari/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Tiling a 2-D Polygon using C# GDI+</title>
		<link>http://pathfindersoftware.com/2010/02/tiling-2d-polygon-gdi/</link>
		<comments>http://pathfindersoftware.com/2010/02/tiling-2d-polygon-gdi/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 22:14:33 +0000</pubDate>
		<dc:creator>Karthik Muthupalaniappan</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Technologies and Platforms]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Drawing]]></category>
		<category><![CDATA[GDI+]]></category>
		<category><![CDATA[Window Forms Development]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=4781</guid>
		<description><![CDATA[One of the most challenging problems I came across working on a .NET PDF Annotator and Editor application was to tile a 2-D polygon and also accurately determine the number of tiles that fill the surface of the polygon.  The tiling part was not as much of a challenge as the counting part. The tiled ...]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F02%2Ftiling-2d-polygon-gdi%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F02%2Ftiling-2d-polygon-gdi%2F&amp;source=PathSoft&amp;style=normal&amp;service=bit.ly&amp;service_api=R_8a1154b608af9e55718b231fb0025d40&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<div id="attachment_4787" class="wp-caption alignnone" style="width: 543px"><img class="size-full wp-image-4787" title="Tiling a Polygon" src="http://pathfindersoftware.com/wp-content/uploads/Tiling-Polygon1.png" alt="Tiling a Polygon" width="533" height="388" />
<p class="wp-caption-text">Tiling a Polygon</p>
</div>
<p>One of the most challenging problems I came across working on a <a href="http://www.pathf.com/showcase/success-stories/pdf-annotation-software/" target="_blank">.NET PDF Annotator and Editor application</a> was to tile a 2-D polygon and also accurately determine the number of tiles that fill the surface of the polygon.  The tiling part was not as much of a challenge as the counting part. The tiled polygon was to be rendered on a PDF document since the application in question is a PDF Annotating and Editing tool. We looked for anything the third party .NET PDF rendering/manipulation API that was used could provide for the tile rendering but there was nothing unfortunately.<br />
<span id="more-4781"></span><br />
So we set out to use <a href="http://msdn.microsoft.com/en-us/library/ms533798%28VS.85%29.aspx" target="_blank">C#&#8217;s native GDI+ library</a> to render the tiles for the polygon.  After trying out different approaches to accomplish the rendering of the tiles, we discovered the one that would work best. The idea was simple. Every 2-D shape on the drawing surface has a bounding rectangle that encloses the shape. Starting from the top left bounding point of the rectangle, iteratively render a rectangle (tile with whatever length and width) across the X axis until the right most edge of the rectangle and this iteration needs to happen over the Y-axis (not sure if I explained clearly enough <img src='http://pathfindersoftware.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> .  So now we have rectangular tiles laid out across the bounding rectangle for the polygon. GDI+ gives us a clip method that allows us to clip the rendering surface to a specific graphics path or region. Using the clip method, clip the drawing surface to be the graphics path for just the Polygon so that only tiles within the polygon&#8217;s graphics path get rendered on the screen. We could apply other transformations to the rendered tiles like offseting, rotation or a gap between each tile.</p>
<p>Coming up with the most efficient way to count the number of tiles (including partial tiles) was a little trickier than rendering the tiles.  It turned out that the ideal approach was to essentially count each tile as it was drawn and checking whether the tile was partially or fully part of the polygon&#8217;s graphics path/region. So, there is this method <a href="http://msdn.microsoft.com/en-us/library/system.drawing.region.isvisible%28VS.71%29.aspx" target="_blank">Region.IsVisible</a> that lets you test whether a rectangle is partially or fully contained within a graphics region. During the rendering of each rectangular tile, the method was used to check whether the tile was going to be part of the region associated with the polygon and was counted if it was going to be. Even though, this was the most efficient solution for the problem, we did nt see 100% accuracy sometimes when rotation transformation was applied to the tiles. Still havent found an answer to this anomaly.
<p><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F02%2Ftiling-2d-polygon-gdi%2F&amp;linkname=Tiling%20a%202-D%20Polygon%20using%20C%23%20GDI%2B" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_stumbleupon" href="http://www.addtoany.com/add_to/stumbleupon?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F02%2Ftiling-2d-polygon-gdi%2F&amp;linkname=Tiling%20a%202-D%20Polygon%20using%20C%23%20GDI%2B" title="StumbleUpon" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/stumbleupon.png" width="16" height="16" alt="StumbleUpon"/></a><a class="a2a_button_digg" href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F02%2Ftiling-2d-polygon-gdi%2F&amp;linkname=Tiling%20a%202-D%20Polygon%20using%20C%23%20GDI%2B" title="Digg" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F02%2Ftiling-2d-polygon-gdi%2F&amp;linkname=Tiling%20a%202-D%20Polygon%20using%20C%23%20GDI%2B" title="DZone" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_reddit" href="http://www.addtoany.com/add_to/reddit?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F02%2Ftiling-2d-polygon-gdi%2F&amp;linkname=Tiling%20a%202-D%20Polygon%20using%20C%23%20GDI%2B" title="Reddit" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/reddit.png" width="16" height="16" alt="Reddit"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F02%2Ftiling-2d-polygon-gdi%2F&amp;linkname=Tiling%20a%202-D%20Polygon%20using%20C%23%20GDI%2B" title="Delicious" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_evernote" href="http://www.addtoany.com/add_to/evernote?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F02%2Ftiling-2d-polygon-gdi%2F&amp;linkname=Tiling%20a%202-D%20Polygon%20using%20C%23%20GDI%2B" title="Evernote" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/evernote.png" width="16" height="16" alt="Evernote"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fpathfindersoftware.com%2F2010%2F02%2Ftiling-2d-polygon-gdi%2F&amp;title=Tiling%20a%202-D%20Polygon%20using%20C%23%20GDI%2B" id="wpa2a_10">Share/Bookmark</a></p>
]]></content:encoded>
			<wfw:commentRss>http://pathfindersoftware.com/2010/02/tiling-2d-polygon-gdi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Upgrading Rails Applications &#8211; Some things to keep in mind!</title>
		<link>http://pathfindersoftware.com/2009/12/upgrading-rails-applications-mind/</link>
		<comments>http://pathfindersoftware.com/2009/12/upgrading-rails-applications-mind/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 20:06:27 +0000</pubDate>
		<dc:creator>Karthik Muthupalaniappan</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Upgrade]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=4517</guid>
		<description><![CDATA[So we just went through this humongous (believe me!) effort of upgrading the technical platform for one of our existing Rails applications that was running Rails 2.1, Ruby 1.7 and Mongrel cluster. The goal was to upgrade to Rails 2.3, Enterprise Ruby 1.8.6 and Passenger. It all started out as well as you would think. ...]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F12%2Fupgrading-rails-applications-mind%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F12%2Fupgrading-rails-applications-mind%2F&amp;source=PathSoft&amp;style=normal&amp;service=bit.ly&amp;service_api=R_8a1154b608af9e55718b231fb0025d40&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>So we just went through this humongous (believe me!) effort of upgrading the technical platform for one of our existing Rails applications that was running Rails 2.1, Ruby 1.7 and Mongrel cluster. The goal was to upgrade to Rails 2.3, Enterprise Ruby 1.8.6 and Passenger. It all started out as well as you would think. Updating the Rails gem, Ruby version, installing/configuring <a href="http://www.modrails.com/" target="_blank">Passenger</a> and updating relevant gems was pretty quick and smooth. Some quick and dirty testing of the application did not reveal any major problems or issues. Great! You are thinking the upgrade is mostly done att this point before you move on to the tests in the application!</p>
<p><strong>Tests</strong></p>
<p>Tests can prove to be major hurdle in upgrading Rails applications.  In our specific case,  close to 70% of the tests were either broken or failing due to a number of reasons.  Actually, the number of broken tests was way way greater than failing tests which led us to think the changes in the Rails testing API caused most of these issues.  Some of the issues were also caused by a plugin or gem that was used to support the tests not being compatible with the new API. It took us quite a bit of effort to figure out the reasons for the issues and also find the fixes.<br />
<span id="more-4517"></span><br />
<strong>Plugins</strong></p>
<p>I think this is other major pain point. If your application uses a bunch of plugins to support what it does, then be wary of the roadblocks they can pose when it is time to upgrade Rails or Ruby in your application.  The problem mostly arises because of the fact that the community or the user group that built the plugin dont continue to support it or doesnt bother to make it compatible with newer versions of Ruby or Rails. In situations like these, you get thrown into a state of dilemma thinking about whether to write a new plugin to replace the existing one or fix the existing one both of which could be time-consuming.  It makes sense to spend time finding about what exactly is the need for the plugin in the application and if it is indispensable etc before making a wise decision.</p>
<p><strong>Deploying the upgraded application</strong></p>
<p>Though this may not be as hairy as the first two, it could be still prove to be a challenge especially when your the application server is changing (Mongrel -&gt; Passenger).  I think it is important to ensure the script is modified appropriately and is tested adequately in your staging environment before you deploy the upgraded application to the real-world.</p>
<p><strong>Session handling issue with Rails 2.3</strong></p>
<p>For the benefit of Rails community out there, I d like to briefly recount one of the problems that caused me a quite a bit of headache during the upgrade.  The application in question is a content management website with multiple subdomains. The issue that I saw after the upgrade was after user logged into the one of the subdomains in the site and navigated away to a different subdomain, the user got logged out. When the user returned to the subdomain where he logged in originally, he was logged in again.  After several hours of effort trying to debug the issue (at one point,  I was even thinking about stripping out Restful authentication and plugging in Authlogic), this <a href="http://stackoverflow.com/questions/941939/share-rails-sessions-among-applications" target="_blank">post</a> saved the day for me.  It boiled down to setting this in the &lt;environment&gt;.rb file for the different environments :</p>
<pre lang="ruby">config.action_controller.session = {
  :domain => "<root-domain-name>"
}
</pre>
<p>This allowed the session information to be persisted across multiple subdomains of the site.</p>
<p><strong>Some Advice</strong></p>
<ul>
<li>Generally, the amount of effort to upgrade is going to be directly proportional to the time between the upgrades. So, upgrade your application often!</li>
<li>When choosing plugins or gems to support your application, consider the upgradability of these before you decide to use them!</li>
<li>Last but not the least, spend atleast 25% of the time necessary for the upgrade itself to estimate how long it might take to get it done <img src='http://pathfindersoftware.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </li>
</ul>
<p><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F12%2Fupgrading-rails-applications-mind%2F&amp;linkname=Upgrading%20Rails%20Applications%20%26%238211%3B%20Some%20things%20to%20keep%20in%20mind%21" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_stumbleupon" href="http://www.addtoany.com/add_to/stumbleupon?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F12%2Fupgrading-rails-applications-mind%2F&amp;linkname=Upgrading%20Rails%20Applications%20%26%238211%3B%20Some%20things%20to%20keep%20in%20mind%21" title="StumbleUpon" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/stumbleupon.png" width="16" height="16" alt="StumbleUpon"/></a><a class="a2a_button_digg" href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F12%2Fupgrading-rails-applications-mind%2F&amp;linkname=Upgrading%20Rails%20Applications%20%26%238211%3B%20Some%20things%20to%20keep%20in%20mind%21" title="Digg" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F12%2Fupgrading-rails-applications-mind%2F&amp;linkname=Upgrading%20Rails%20Applications%20%26%238211%3B%20Some%20things%20to%20keep%20in%20mind%21" title="DZone" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_reddit" href="http://www.addtoany.com/add_to/reddit?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F12%2Fupgrading-rails-applications-mind%2F&amp;linkname=Upgrading%20Rails%20Applications%20%26%238211%3B%20Some%20things%20to%20keep%20in%20mind%21" title="Reddit" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/reddit.png" width="16" height="16" alt="Reddit"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F12%2Fupgrading-rails-applications-mind%2F&amp;linkname=Upgrading%20Rails%20Applications%20%26%238211%3B%20Some%20things%20to%20keep%20in%20mind%21" title="Delicious" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_evernote" href="http://www.addtoany.com/add_to/evernote?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F12%2Fupgrading-rails-applications-mind%2F&amp;linkname=Upgrading%20Rails%20Applications%20%26%238211%3B%20Some%20things%20to%20keep%20in%20mind%21" title="Evernote" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/evernote.png" width="16" height="16" alt="Evernote"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F12%2Fupgrading-rails-applications-mind%2F&amp;title=Upgrading%20Rails%20Applications%20%26%238211%3B%20Some%20things%20to%20keep%20in%20mind%21" id="wpa2a_12">Share/Bookmark</a></p>
]]></content:encoded>
			<wfw:commentRss>http://pathfindersoftware.com/2009/12/upgrading-rails-applications-mind/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OO Design Patterns that can make a difference</title>
		<link>http://pathfindersoftware.com/2009/10/oo-design-patterns-difference/</link>
		<comments>http://pathfindersoftware.com/2009/10/oo-design-patterns-difference/#comments</comments>
		<pubDate>Wed, 07 Oct 2009 16:53:32 +0000</pubDate>
		<dc:creator>Karthik Muthupalaniappan</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Gang of Four]]></category>
		<category><![CDATA[OOP]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=4235</guid>
		<description><![CDATA[Design patterns. I think they are the one of the most intriguing areas of object oriented application design and development. There are so many out there that can puzzle you each and every time you try to take a crack at them (I can name a few of them that I still can&#8217;t figure how ...]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F10%2Foo-design-patterns-difference%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F10%2Foo-design-patterns-difference%2F&amp;source=PathSoft&amp;style=normal&amp;service=bit.ly&amp;service_api=R_8a1154b608af9e55718b231fb0025d40&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<div style="float:right;padding:10px;"><img title="building_blocks" src="http://pathfindersoftware.com/wp-content/uploads/building_blocks1.jpg" border="0" alt="" width="250" height="250" align="absMiddle" /></div>
<p><a title="Design Patterns" href="http://en.wikipedia.org/wiki/Design_pattern_%28computer_science%29" target="_blank">Design patterns</a>. I think they are the one of the most intriguing areas of object oriented application design and development. There are so many out there that can puzzle you each and every time you try to take a crack at them (I can name a few of them that I still can&#8217;t figure how they are to be used or implemented).  But a thing that most programmers would agree is if used wisely and appropriately, these design patterns can provide really powerful benefits that can enhance one&#8217;s programming experience and also the software that is being built. There are several patterns I have used/implemented in my projects that I think are awesome. I ll touch upon how I used some of them and why every Object oriented programmer needs to master them.</p>
<p><span id="more-4235"></span></p>
<p><strong>Factory Method </strong></p>
<p><a title="This" href="http://en.wikipedia.org/wiki/Factory_method" target="_blank">This</a> must be one of the most commonly used patterns out there. We indeed have used it the most in our projects. The crux of this pattern is essentially delegating the task of creating objects to a method that basically takes in information about what kind of object is to be created etc.  There were a number of instances in the applications we built where there was a base domain object that had a bunch of derived types. In most of these instances, single method/interface that returned the base domain object type but created instances of the appropriate the derived type was used. The benefit? The object creator is decoupled from the users of the objects and makes the code more reusable and maintainable.</p>
<p><strong>Dependency Injection</strong></p>
<p>I m absolutely in love with <a title="this" href="http://en.wikipedia.org/wiki/Dependency_injection" target="_blank">this </a>design pattern. It is a very effective design approach in my opinion. What it advocates is lazy/runtime injection of object dependencies or modules instead of hard-wiring them.  There are a number of third party dependency injection frameworks like <a title="Spring" href="http://www.springframework.net/" target="_blank">Spring</a>, <a title="Object Builder" href="http://www.codeplex.com/Wiki/View.aspx?ProjectName=ObjectBuilder" target="_blank">Object Builder</a> etc that let you implement dependency injection out of the box. A very simple example of how I used this on a recent project : Consider the application needs to talk to a remote service for what ever reason. We also built out a fake service that mocked the real remote service to enable us to test/run the application when the real one was unavailable or being developed. We needed a way for the application to swap dependencies (basically the real service and the fake one) at run time. Spring .NET&#8217;s dependency injection enabled me to implement this.</p>
<p><strong>Command Pattern</strong></p>
<p>A really powerful <a href="http://en.wikipedia.org/wiki/Command_pattern" target="_blank">design pattern</a> that helped us a great deal in implementing an undo/redo feature  in one of our desktop application projects. The idea is pretty simple. Every operation that you want to be undone/redone is encapsulated in the form of a command object that contains information about the method or delegate that needs to be invoked for that operation, parameters for that method or delegate, the undo method etc. Every time, any such command is executed, it is pushed to an undo stack. If the command needs to be undone, it is simply popped off the stack and the undo method is invoked. There is a redo stack for handling redo operations.</p>
<p>Other patterns that I have used widely are the Singleton, Facade, MVC, Pure MVC and MVP. These are effective in their own different ways.
<p><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F10%2Foo-design-patterns-difference%2F&amp;linkname=OO%20Design%20Patterns%20that%20can%20make%20a%20difference" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_stumbleupon" href="http://www.addtoany.com/add_to/stumbleupon?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F10%2Foo-design-patterns-difference%2F&amp;linkname=OO%20Design%20Patterns%20that%20can%20make%20a%20difference" title="StumbleUpon" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/stumbleupon.png" width="16" height="16" alt="StumbleUpon"/></a><a class="a2a_button_digg" href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F10%2Foo-design-patterns-difference%2F&amp;linkname=OO%20Design%20Patterns%20that%20can%20make%20a%20difference" title="Digg" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F10%2Foo-design-patterns-difference%2F&amp;linkname=OO%20Design%20Patterns%20that%20can%20make%20a%20difference" title="DZone" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_reddit" href="http://www.addtoany.com/add_to/reddit?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F10%2Foo-design-patterns-difference%2F&amp;linkname=OO%20Design%20Patterns%20that%20can%20make%20a%20difference" title="Reddit" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/reddit.png" width="16" height="16" alt="Reddit"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F10%2Foo-design-patterns-difference%2F&amp;linkname=OO%20Design%20Patterns%20that%20can%20make%20a%20difference" title="Delicious" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_evernote" href="http://www.addtoany.com/add_to/evernote?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F10%2Foo-design-patterns-difference%2F&amp;linkname=OO%20Design%20Patterns%20that%20can%20make%20a%20difference" title="Evernote" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/evernote.png" width="16" height="16" alt="Evernote"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F10%2Foo-design-patterns-difference%2F&amp;title=OO%20Design%20Patterns%20that%20can%20make%20a%20difference" id="wpa2a_14">Share/Bookmark</a></p>
]]></content:encoded>
			<wfw:commentRss>http://pathfindersoftware.com/2009/10/oo-design-patterns-difference/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>More on Pure MVC for C#</title>
		<link>http://pathfindersoftware.com/2009/07/more-on-pure-mvc-for-c/</link>
		<comments>http://pathfindersoftware.com/2009/07/more-on-pure-mvc-for-c/#comments</comments>
		<pubDate>Wed, 29 Jul 2009 05:51:15 +0000</pubDate>
		<dc:creator>Karthik Muthupalaniappan</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[.Net Development]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[Pure MVC]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=3374</guid>
		<description><![CDATA[Last week, Karega Scott made a nice post on how Pure MVC makes development of Windows applications using C# simple. I thought I ll piggyback on this post and share some of my thoughts regarding this popular framework. I think the framework, if understood completely and adopted intelligently, has to offer some really cool benefits ...]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F07%2Fmore-on-pure-mvc-for-c%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F07%2Fmore-on-pure-mvc-for-c%2F&amp;source=PathSoft&amp;style=normal&amp;service=bit.ly&amp;service_api=R_8a1154b608af9e55718b231fb0025d40&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><img class="alignright size-full wp-image-3379" style="float:right;padding:10px" title="puremvc" src="http://pathfindersoftware.com/wp-content/uploads/puremvc-icon1.jpg" alt="puremvc" width="318" height="200" /></p>
<p>Last week, Karega Scott made a nice <a href="http://www.pathf.com/blogs/2009/07/winforms-development-made-simple-with-puremvc/" target="_blank">post</a> on how<a href="http://puremvc.org/" target="_blank"> Pure MVC </a>makes development of Windows applications using C# simple. I thought I ll piggyback on this post and share some of my thoughts regarding this popular framework. I think the framework, if understood completely and adopted intelligently, has to offer some really cool benefits like :</p>
<ul>
<li>Light-weight messaging mechanism (using Notification/Observer patterns) between different parts of the application without having to create custom events/hooks all over the place.</li>
<li>Highly Decoupled Components allowing abstraction and seperation of logic.</li>
<li>The application&#8217;s testability is enhanced greatly because of the reason stated above.</li>
<li>A Centralized singleton Facade component that mediates between the different components in the application.</li>
<li>The use of commands in the framework can help in building complex applications that need to perform several different UI-driven functions.</li>
</ul>
<p><span id="more-3374"></span></p>
<p>The framework&#8217;s limitations (or should I say &#8220;perceived weaknesses&#8221;) are :</p>
<ul>
<li>Registering and removing components on the Facade? Could there have been a better way to accomplish this? May be.</li>
<li>Named references for components were not helpful at all.</li>
<li>If the framework&#8217;s notification mechanisms are not used appropriately,  there are chances of infinite message loops leading to debugging hell.</li>
</ul>
<p>There was considerable ramp up time involved in understanding the framework&#8217;s capabilities/strengths/weaknesses. I still don&#8217;t think I have realized the complete potential of Pure MVC  and I hope to explore more of it these coming days.</p>
<p>Related Services:  <a href="http://www.pathf.com/services/technology-expertise/.net-development/">.Net Application Development</a>, <a href="http://www.pathf.com/services">Custom Software Development</a>
<p><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F07%2Fmore-on-pure-mvc-for-c%2F&amp;linkname=More%20on%20Pure%20MVC%20for%20C%23" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_stumbleupon" href="http://www.addtoany.com/add_to/stumbleupon?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F07%2Fmore-on-pure-mvc-for-c%2F&amp;linkname=More%20on%20Pure%20MVC%20for%20C%23" title="StumbleUpon" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/stumbleupon.png" width="16" height="16" alt="StumbleUpon"/></a><a class="a2a_button_digg" href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F07%2Fmore-on-pure-mvc-for-c%2F&amp;linkname=More%20on%20Pure%20MVC%20for%20C%23" title="Digg" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F07%2Fmore-on-pure-mvc-for-c%2F&amp;linkname=More%20on%20Pure%20MVC%20for%20C%23" title="DZone" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_reddit" href="http://www.addtoany.com/add_to/reddit?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F07%2Fmore-on-pure-mvc-for-c%2F&amp;linkname=More%20on%20Pure%20MVC%20for%20C%23" title="Reddit" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/reddit.png" width="16" height="16" alt="Reddit"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F07%2Fmore-on-pure-mvc-for-c%2F&amp;linkname=More%20on%20Pure%20MVC%20for%20C%23" title="Delicious" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_evernote" href="http://www.addtoany.com/add_to/evernote?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F07%2Fmore-on-pure-mvc-for-c%2F&amp;linkname=More%20on%20Pure%20MVC%20for%20C%23" title="Evernote" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/evernote.png" width="16" height="16" alt="Evernote"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F07%2Fmore-on-pure-mvc-for-c%2F&amp;title=More%20on%20Pure%20MVC%20for%20C%23" id="wpa2a_16">Share/Bookmark</a></p>
]]></content:encoded>
			<wfw:commentRss>http://pathfindersoftware.com/2009/07/more-on-pure-mvc-for-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fluently NHibernate</title>
		<link>http://pathfindersoftware.com/2009/06/fluently-nhibernate/</link>
		<comments>http://pathfindersoftware.com/2009/06/fluently-nhibernate/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 15:50:47 +0000</pubDate>
		<dc:creator>Karthik Muthupalaniappan</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Technologies and Platforms]]></category>
		<category><![CDATA[Data Mapper]]></category>
		<category><![CDATA[Fluent]]></category>
		<category><![CDATA[NHibernate]]></category>
		<category><![CDATA[ORM]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=3089</guid>
		<description><![CDATA[Fluent NHibernate is an extension of the widely used and very popular NHibernate framework for Microsoft .NET. It is an open source framework that sits on top of the NHibernate layer and utilises all the core NHibernate methods. This framework provides an alternative to the standard XML based mappings (.hbm xml files) of NHibernate. It lets you define ...]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F06%2Ffluently-nhibernate%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F06%2Ffluently-nhibernate%2F&amp;source=PathSoft&amp;style=normal&amp;service=bit.ly&amp;service_api=R_8a1154b608af9e55718b231fb0025d40&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<div class="right"><img class="alignnone size-full wp-image-3090" title="logo" src="http://pathfindersoftware.com/wp-content/uploads/logo1.png" alt="logo" width="200" height="117" /></div>
<p><a href="http://wiki.fluentnhibernate.org/show/GettingStartedIntroduction" target="_blank">Fluent NHibernate</a> is an extension of the widely used and very popular NHibernate framework for Microsoft .NET. It is an open source framework that sits on top of the NHibernate layer and utilises all the core NHibernate methods. This framework provides an alternative to the standard XML based mappings (.hbm xml files) of NHibernate. It lets you define the NHibernate mappings in strongly typed and concise C# code.  For those who are new to NHibernate, <a href="https://www.hibernate.org/343.html" target="_blank">here</a> is more information.</p>
<p><span id="more-3089"></span></p>
<p> <strong>Traditional NHibernate XML mapping</strong></p>
<pre class="xml"> &lt;?xml version="1.0" encoding="utf-8" ?&gt; 
&lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" 
  namespace="QuickStart" assembly="QuickStart"&gt; 
 
  &lt;class name="Cat" table="Cat"&gt; 
    &lt;id name="Id"&gt; 
      &lt;generator class="identity" /&gt; 
    &lt;/id&gt; 
 
    &lt;property name="Name"&gt; 
      &lt;column name="Name" length="16" not-null="true" /&gt; 
    &lt;/property&gt; 
    &lt;property name="Sex" /&gt; 
    &lt;many-to-one name="Mate" /&gt; 
    &lt;bag name="Kittens"&gt; 
      &lt;key column="mother_id"/&gt; 
        &lt;one-to-many class="Cat"/&gt; 
      &lt;/bag&gt; 
  &lt;/class&gt; 
&lt;/hibernate-mapping&gt; </pre>
<p><strong>Fluent NHibernate equivalent</strong></p>
<pre class="bar">public class CatMap : ClassMap&lt;Cat&gt;  
{  
  public CatMap()  
  {  
    Id(x =&gt; x.Id);  
    Map(x =&gt; x.Name)  
      .WithLengthOf(16)  
      .Not.Nullable();  
    Map(x =&gt; x.Sex);  
    References(x =&gt; x.Mate);  
    HasMany(x =&gt; x.Kittens);  
  }  
}</pre>
<p> Why use Fluent NHibernate? Here are some benefits that it offers:</p>
<ul>
<li>It favors convention over configuration and overcomes the repetitiveness that is there with NHibernate. For instance, NHibernate requires string properties to be not null and have a default value. You don&#8217;t have to handle this if you go fluent.</li>
<li>By getting rid of XML based mappings, it paves way for easy-to-read code that can be refactored and maintained in a simpler way. The mappings sit along with your code so any refactorings/changes to the code will cause the mappings to be affected as well. This helps catch compile errors/bugs with mappings.</li>
<li>One other obvious benefit is that the XML verbosity of NHibernate can be avoided.</li>
</ul>
<p>I think <a href="http://wiki.fluentnhibernate.org/show/GettingStartedFirstProject" target="_blank">this</a> is a good place to start picking up Fluent. You find a nice little project example that talks about mapping a simple database schema and building an application to read data using the fluent mappings.
<p><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F06%2Ffluently-nhibernate%2F&amp;linkname=Fluently%20NHibernate" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_stumbleupon" href="http://www.addtoany.com/add_to/stumbleupon?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F06%2Ffluently-nhibernate%2F&amp;linkname=Fluently%20NHibernate" title="StumbleUpon" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/stumbleupon.png" width="16" height="16" alt="StumbleUpon"/></a><a class="a2a_button_digg" href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F06%2Ffluently-nhibernate%2F&amp;linkname=Fluently%20NHibernate" title="Digg" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F06%2Ffluently-nhibernate%2F&amp;linkname=Fluently%20NHibernate" title="DZone" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_reddit" href="http://www.addtoany.com/add_to/reddit?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F06%2Ffluently-nhibernate%2F&amp;linkname=Fluently%20NHibernate" title="Reddit" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/reddit.png" width="16" height="16" alt="Reddit"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F06%2Ffluently-nhibernate%2F&amp;linkname=Fluently%20NHibernate" title="Delicious" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_evernote" href="http://www.addtoany.com/add_to/evernote?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F06%2Ffluently-nhibernate%2F&amp;linkname=Fluently%20NHibernate" title="Evernote" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/evernote.png" width="16" height="16" alt="Evernote"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F06%2Ffluently-nhibernate%2F&amp;title=Fluently%20NHibernate" id="wpa2a_18">Share/Bookmark</a></p>
]]></content:encoded>
			<wfw:commentRss>http://pathfindersoftware.com/2009/06/fluently-nhibernate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.NET Web Browser Control Gotchas</title>
		<link>http://pathfindersoftware.com/2009/06/net-web-browser-control-gotchas/</link>
		<comments>http://pathfindersoftware.com/2009/06/net-web-browser-control-gotchas/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 13:30:48 +0000</pubDate>
		<dc:creator>Karthik Muthupalaniappan</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[.NET Browser Control]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=2581</guid>
		<description><![CDATA[How many of you folks out there have used the .NET Web browser control for Windows applications? I bet most of you, at some point, must have done some head-scratching as to why Microsoft did not make this control as powerful as it should have been. This control does offer all of the navigation functions ...]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F06%2Fnet-web-browser-control-gotchas%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F06%2Fnet-web-browser-control-gotchas%2F&amp;source=PathSoft&amp;style=normal&amp;service=bit.ly&amp;service_api=R_8a1154b608af9e55718b231fb0025d40&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>How many of you folks out there have used the .NET Web browser control for Windows applications? I bet most of you, at some point, must have done some head-scratching as to why Microsoft did not make this control as powerful as it should have been. This control does offer all of the navigation functions and basic browser capabilities but there is lot more that could have been done to enchance it&#8217;s utility value. After some persistent fighting with this control in our current project, here are some gotchas that I have to offer.</p>
<p><span id="more-2581"></span><strong>Where the heck is print?</strong></p>
<p>There is a print method that is available on this control which directly prints the current web page without popping up the print dialog. This is fine but what if I want the print dialog to be show up? After some digging into the msdn documentation and googling around, I determined there was a way to do this. The trick is to use the <a href="http://msdn.microsoft.com/en-us/library/ms536419(VS.85).aspx" target="_blank">execcommand</a> method on the browser&#8217;s document object. The syntax goes like this: </p>
<p> Browser.Document.ExecCommand(&#8220;Print&#8221;, false, 0)</p>
<p>I believe this method basically executes the specified command on the underlying Microsoft active-x/html control. There are number of <a href="http://msdn.microsoft.com/en-us/library/ms533049(VS.85).aspx" target="_blank">different commands</a> such as cut, copy, paste, undo, redo etc that are available. One thing to keep in mind is that all the edit commands operate directly on the DOM elements of the HTML document. </p>
<p><strong>What about Search?</strong></p>
<p>This one did take quite a while to figure out.  The browser control did not offer anything directly for searching the current web page.  If  its the Control-F search (that you normally get to see on the browser) is what you want, there is a simple way to enable that on the browser control.  Set the <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser.webbrowsershortcutsenabled.aspx" target="_blank">WebBrowserShortcutsEnabled </a>property to true and you have it. This also enables other shortcut operations like control-C, Control-V, Delete etc.  I came across a number of posts that talked about using interop to get to the underlying active-x control to accomplish functions like search, copy, cut, paste etc. I guess you can avoid all this trouble by making use of this property on the control.</p>
<p>Any other gotchas with this control? Feel free to let me know.</p>
<p> </p>
<p> </p>
<p><strong><br />
</strong>
<p><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F06%2Fnet-web-browser-control-gotchas%2F&amp;linkname=.NET%20Web%20Browser%20Control%20Gotchas" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_stumbleupon" href="http://www.addtoany.com/add_to/stumbleupon?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F06%2Fnet-web-browser-control-gotchas%2F&amp;linkname=.NET%20Web%20Browser%20Control%20Gotchas" title="StumbleUpon" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/stumbleupon.png" width="16" height="16" alt="StumbleUpon"/></a><a class="a2a_button_digg" href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F06%2Fnet-web-browser-control-gotchas%2F&amp;linkname=.NET%20Web%20Browser%20Control%20Gotchas" title="Digg" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F06%2Fnet-web-browser-control-gotchas%2F&amp;linkname=.NET%20Web%20Browser%20Control%20Gotchas" title="DZone" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_reddit" href="http://www.addtoany.com/add_to/reddit?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F06%2Fnet-web-browser-control-gotchas%2F&amp;linkname=.NET%20Web%20Browser%20Control%20Gotchas" title="Reddit" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/reddit.png" width="16" height="16" alt="Reddit"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F06%2Fnet-web-browser-control-gotchas%2F&amp;linkname=.NET%20Web%20Browser%20Control%20Gotchas" title="Delicious" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_evernote" href="http://www.addtoany.com/add_to/evernote?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F06%2Fnet-web-browser-control-gotchas%2F&amp;linkname=.NET%20Web%20Browser%20Control%20Gotchas" title="Evernote" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/evernote.png" width="16" height="16" alt="Evernote"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F06%2Fnet-web-browser-control-gotchas%2F&amp;title=.NET%20Web%20Browser%20Control%20Gotchas" id="wpa2a_20">Share/Bookmark</a></p>
]]></content:encoded>
			<wfw:commentRss>http://pathfindersoftware.com/2009/06/net-web-browser-control-gotchas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic (User agent is rejected)
Page Caching using memcached (User agent is rejected)

Served from: pathfindersoftware.com @ 2012-02-10 00:53:17 -->
