<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>IndianGeek</title>
	
	<link>http://www.indiangeek.net</link>
	<description>Perspectives on Computer Science and Software Engineering</description>
	<lastBuildDate>Tue, 09 Mar 2010 20:24:33 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Indiangeek" /><feedburner:info uri="indiangeek" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>soapUI – Web Service tool</title>
		<link>http://feedproxy.google.com/~r/Indiangeek/~3/xBBJlqJhwfA/</link>
		<comments>http://www.indiangeek.net/2010/03/09/soapui-web-service-tool/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 20:24:33 +0000</pubDate>
		<dc:creator>sijin</dc:creator>
				<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://www.indiangeek.net/2010/03/09/soapui-web-service-tool/</guid>
		<description><![CDATA[
<p>Sometimes a you come across a tool that just makes you think why you never used it before, I ran across one such tool last month, it&#8217;s called soapUI (http://www.soapui.org/ ). </p>
</p>
<p>This is an open source tool for testing web services, everything I wanted to do for testing some of the web services that we [...]]]></description>
			<content:encoded><![CDATA[<div class='posterous_autopost'>
<p>Sometimes a you come across a tool that just makes you think why you never used it before, I ran across one such tool last month, it&#8217;s called soapUI (<a href="http://www.soapui.org/">http://www.soapui.org/</a> ). </p>
</p>
<p>This is an open source tool for testing web services, everything I wanted to do for testing some of the web services that we were developing including unit testing and load testing was provided out of the box by this awesome tool. Also I think the UI is quite well thought out and mature.</p>
</p>
<p>Here&#8217;s a list of the features at a high level, </p>
</p>
<p>soapUI is a free and open source desktop application for </p>
<ul type="disc" style="margin-top: 0in;">
<li style=""><a href="http://www.soapui.org/features.html#Web_Service_Inspection_and_Invocation">inspecting Web Services</a></li>
<li style=""><a href="http://www.soapui.org/features.html#Web_Service_Inspection_and_Invocation">invoking Web Services</a> </li>
<li style=""><a href="http://www.soapui.org/features.html#Web_Service_Development_and_Validation">developing Web Services</a> </li>
<li style=""><a href="http://www.soapui.org/features.html#Web_Service_Simulation">Web Services Simulation and Mocking</a></li>
<li style=""><a href="http://www.soapui.org/features.html#Web_Service_Functional_Testing">Functional, Load and Compliance testing of Web Services</a> </li>
</ul>
<p>It is mainly aimed at developers and testers providing or consuming WSDL or REST based Web Services (Java, .net, etc). Functional and Load Testing can be done both interactively in soapUI or within an automated build or integration process using the soapUI <a href="http://www.soapui.org/userguide/commandline/index.html">command line tools</a>. </p>
<p>Mock Web Services can easily be created for any WSDL and hosted from within soapUI or using the command-line MockService runner. IDE-plugins are available for </p>
<ul type="disc" style="margin-top: 0in;">
<li style=""><a href="http://www.soapui.org/eclipse/index.html">eclipse plug in</a></li>
<li style=""><a href="http://www.soapui.org/intellij/index.html">IntelliJ IDEA plug in</a></li>
<li style=""><a href="http://www.soapui.org/netbeans/index.html">NetBeans plug in</a></li>
</ul>
<p>soapUI requires Java 1.5 and is licensed under the <a href="http://www.soapui.org/license.html">LGPL license</a>. </p>
</p>
<p>See their features page <a href="http://www.soapui.org/features.html">http://www.soapui.org/features.html</a> for some screenshots of the cool stuff you can do using this.</p>
<p style="font-size: 10px;">  <a href="http://posterous.com">Posted via email</a>   from <a href="http://sijin.posterous.com/soapui-web-service-tool">Sijin Joseph</a>  </p>
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.indiangeek.net/2010/03/09/soapui-web-service-tool/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.indiangeek.net/2010/03/09/soapui-web-service-tool/</feedburner:origLink></item>
		<item>
		<title>OutOfMemory/Heap space errors in Java</title>
		<link>http://feedproxy.google.com/~r/Indiangeek/~3/Rf5pXDi_xck/</link>
		<comments>http://www.indiangeek.net/2010/03/07/outofmemoryheap-space-errors-in-java/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 02:18:42 +0000</pubDate>
		<dc:creator>sijin</dc:creator>
				<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://www.indiangeek.net/2010/03/07/outofmemoryheap-space-errors-in-java/</guid>
		<description><![CDATA[
</p>

<p>Recently I had to work on a Java based rule modeling tool that was built on Java/Eclipse. The tool was pushing both eclipse and the JVM to the limits in terms of memory and I was getting a lot of OutOfMemory exceptions and out of heap space errors, usually these can be fixed by increasing [...]]]></description>
			<content:encoded><![CDATA[<div class='posterous_autopost'><a href='http://posterous.com/getfile/files.posterous.com/sijin/VPIhBOnrcyxyeEx7fFJ3qwUaBdQhzeoi1BR6HeSCcVpsDuVEFuZIE8dVW1VI/jvm-eclipse-settings.png'><img src="http://posterous.com/getfile/files.posterous.com/sijin/LNqytBd2tPT2CZ4PPzhu3wU3eGgH2wGSDUPb5XCtphr9AUtvrJCwi9BZ1JXw/jvm-eclipse-settings.png.scaled.500.jpg" width="500" height="400"/></a>
</p>
<div>
<p>Recently I had to work on a Java based rule modeling tool that was built on Java/Eclipse. The tool was pushing both eclipse and the JVM to the limits in terms of memory and I was getting a lot of OutOfMemory exceptions and out of heap space errors, usually these can be fixed by increasing the default limits. </p>
</p>
<p>The important settings in question are arguments passed to the JVM on startup, <a href="http://java.sun.com/javase/6/docs/technotes/tools/windows/java.html">http://java.sun.com/javase/6/docs/technotes/tools/windows/java.html</a></p>
</p>
<p><b><span style="font-size: 9.0pt; font-family: Arial,sans-serif; color: black;">-Xms<i>n</i></span></b></p>
<p style="margin-left: .5in;"><span style="font-size: 9.0pt; font-family: Arial,sans-serif; color: black;">Specify the initial size, in bytes, of the memory allocation pool. This value must be a multiple of 1024 greater than 1MB. Append the letter<span class="apple-converted-space">&nbsp;</span></span><tt><span style="font-size: 10.0pt; font-family: Courier; color: #444444;">k</span></tt><span class="apple-converted-space"><span style="font-size: 9.0pt; font-family: Arial,sans-serif; color: black;">&nbsp;</span></span><span style="font-size: 9.0pt; font-family: Arial,sans-serif; color: black;">or<span class="apple-converted-space">&nbsp;</span></span><tt><span style="font-size: 10.0pt; font-family: Courier; color: #444444;">K</span></tt><span class="apple-converted-space"><span style="font-size: 9.0pt; font-family: Arial,sans-serif; color: black;">&nbsp;</span></span><span style="font-size: 9.0pt; font-family: Arial,sans-serif; color: black;">to indicate kilobytes, or<span class="apple-converted-space">&nbsp;</span></span><tt><span style="font-size: 10.0pt; font-family: Courier; color: #444444;">m</span></tt><span class="apple-converted-space"><span style="font-size: 9.0pt; font-family: Arial,sans-serif; color: black;">&nbsp;</span></span><span style="font-size: 9.0pt; font-family: Arial,sans-serif; color: black;">or<span class="apple-converted-space">&nbsp;</span></span><tt><span style="font-size: 10.0pt; font-family: Courier; color: #444444;">M</span></tt><span class="apple-converted-space"><span style="font-size: 9.0pt; font-family: Arial,sans-serif; color: black;">&nbsp;</span></span><span style="font-size: 9.0pt; font-family: Arial,sans-serif; color: black;">to indicate megabytes. The default value is chosen at runtime based on system configuration. For more information, see<span class="apple-converted-space">&nbsp;</span><a href="http://java.sun.com/javase/6/docs/technotes/guides/vm/gc-ergonomics.html"><span style="color: black;">HotSpot Ergonomics</span></a><span class="apple-converted-space">&nbsp;</span><br /> Examples:</span></p>
<pre style="margin-left: .5in;"><span style="font-family: Courier; color: #444444;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -Xms6291456</span></pre>
<pre style="margin-left: .5in;"><span style="font-family: Courier; color: #444444;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -Xms6144k</span></pre>
<pre style="margin-left: .5in;"><span style="font-family: Courier; color: #444444;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -Xms6m</span></pre>
<pre style="margin-left: .5in;"><span style="font-family: Courier; color: #444444;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></pre>
<p><b><span style="font-size: 9.0pt; font-family: Arial,sans-serif; color: black;">-Xmx<i>n</i></span></b></p>
<p style="margin-left: .5in;"><span style="font-size: 9.0pt; font-family: Arial,sans-serif; color: black;">Specify the maximum size, in bytes, of the memory allocation pool. This value must a multiple of 1024 greater than 2MB. Append the letter<span class="apple-converted-space">&nbsp;</span></span><tt><span style="font-size: 10.0pt; font-family: Courier; color: #444444;">k</span></tt><span class="apple-converted-space"><span style="font-size: 9.0pt; font-family: Arial,sans-serif; color: black;">&nbsp;</span></span><span style="font-size: 9.0pt; font-family: Arial,sans-serif; color: black;">or<span class="apple-converted-space">&nbsp;</span></span><tt><span style="font-size: 10.0pt; font-family: Courier; color: #444444;">K</span></tt><span class="apple-converted-space"><span style="font-size: 9.0pt; font-family: Arial,sans-serif; color: black;">&nbsp;</span></span><span style="font-size: 9.0pt; font-family: Arial,sans-serif; color: black;">to indicate kilobytes, or<span class="apple-converted-space">&nbsp;</span></span><tt><span style="font-size: 10.0pt; font-family: Courier; color: #444444;">m</span></tt><span class="apple-converted-space"><span style="font-size: 9.0pt; font-family: Arial,sans-serif; color: black;">&nbsp;</span></span><span style="font-size: 9.0pt; font-family: Arial,sans-serif; color: black;">or<span class="apple-converted-space">&nbsp;</span></span><tt><span style="font-size: 10.0pt; font-family: Courier; color: #444444;">M</span></tt><span class="apple-converted-space"><span style="font-size: 9.0pt; font-family: Arial,sans-serif; color: black;">&nbsp;</span></span><span style="font-size: 9.0pt; font-family: Arial,sans-serif; color: black;">to indicate megabytes. The default value is chosen at runtime based on system configuration. For more information, see<span class="apple-converted-space">&nbsp;</span><a href="http://java.sun.com/javase/6/docs/technotes/guides/vm/gc-ergonomics.html"><span style="color: black;">HotSpot Ergonomics</span></a><span class="apple-converted-space">&nbsp;</span><br /> Examples:</span></p>
<pre style="margin-left: .5in;"><span style="font-family: Courier; color: #444444;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -Xmx83886080</span></pre>
<pre style="margin-left: .5in;"><span style="font-family: Courier; color: #444444;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -Xmx81920k</span></pre>
<pre style="margin-left: .5in;"><span style="font-family: Courier; color: #444444;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -Xmx80m</span></pre>
<pre style="margin-left: .5in;"><span style="font-family: Courier; color: #444444;"></span></pre>
<p>Other advanced VM settings are documented here, <a href="http://java.sun.com/javase/technologies/hotspot/vmoptions.jsp">http://java.sun.com/javase/technologies/hotspot/vmoptions.jsp</a></p>
</p>
<p class="MsoListParagraph" style=""><span style="">1.<span style="font: 7.0pt Times New Roman;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span>Eclipse IDE &#8211; If the IDE itself is running out of memory when compiling or editing code then you can increase the maximum memory pool using the Xmx option in eclipse.ini file present in the same folder as eclipse.exe.</p>
<p class="MsoListParagraph">
<p class="MsoListParagraph" style=""><span style="">2.<span style="font: 7.0pt Times New Roman;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span>JVM from within eclipse &#8211; If the JVM is running out of memory when running an app from within eclipse, then you can adjust the memory settings from the JVM configuration tab within eclipse.</p>
<p class="MsoListParagraph">
<p class="MsoListParagraph" style=""><span style="">3.<span style="font: 7.0pt Times New Roman;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span>JVM from Tomcat &#8211; On the Apache Tomcat configuration utility on the Java tab, you can specify the memory and heap settings.</p>
<p class="MsoListParagraph">
</p>
</div>
<p style="font-size: 10px;">  <a href="http://posterous.com">Posted via email</a>   from <a href="http://sijin.posterous.com/outofmemoryheap-space-errors-in-java">Sijin Joseph</a>  </p>
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.indiangeek.net/2010/03/07/outofmemoryheap-space-errors-in-java/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.indiangeek.net/2010/03/07/outofmemoryheap-space-errors-in-java/</feedburner:origLink></item>
		<item>
		<title>Tools don’t matter</title>
		<link>http://feedproxy.google.com/~r/Indiangeek/~3/vLxv0prMNps/</link>
		<comments>http://www.indiangeek.net/2009/11/16/tools-dont-matter/#comments</comments>
		<pubDate>Mon, 16 Nov 2009 11:26:29 +0000</pubDate>
		<dc:creator>sijin</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[computer science]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[software engineering]]></category>

		<guid isPermaLink="false">http://www.indiangeek.net/?p=468</guid>
		<description><![CDATA[Tools don&#8217;t matter
I don&#8217;t use vim or emacs, but for some reason whenever I used to read a vim or emacs article or blog post, I used to download, install and spend the rest of the day reading books, manuals and playing with the editors. I&#8217;ve done this several times in the last few years [...]]]></description>
			<content:encoded><![CDATA[<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Tools don&#8217;t matter</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">I don&#8217;t use vim or emacs, but for some reason whenever I used to read a vim or emacs article or blog post, I used to download, install and spend the rest of the day reading books, manuals and playing with the editors. I&#8217;ve done this several times in the last few years with each iteration making a more firm resolve to switch to vim/emacs for my day to day tasks. However, I always ended back at Visual Studio.Net/Eclipse/Notepad++ as the tools of my day to day work. For some reason I always felt inferior to all the Guru* Hackers** using vim and emacs and having this crazy productivity and superior intellect. Why couldn&#8217;t I be part of this &#8220;elite&#8221; club? The same holds true for several other areas as well, for e.g. downloading Python, Ruby, J and spending the day learning the language only to forget the next week.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">All this kind of reminded me of my experiences with finding the perfect weapon while playing Call of Duty 4 over the past year. I spent 3 hours a day almost every day for the past one year playing this game, reaching the max prestige level (the &#8220;elite&#8221; club) in the multiplayer version. I became really really good at it and could kick a lot of ass no matter what weapon I was using. But I remember when I started out and I really sucked, I became obsessed with finding the perfect weapon with the perfect set of perks and addons. I used to wander the forums asking people about which weapons and perks to use on which map and what the best tips were etc. Thinking that having the perfect weapon would make me a good player. In the end, the only thing that mattered was all the hours I put in to learn all the maps, routes, tricks and my ability(I like to think). The surprising thing was that once I mastered the game, it didn&#8217;t really matter what weapon I chose, I was able to adapt any weapon and do a decent job.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Based on my experiences with the game I started thinking about why I felt I needed to be using vim/emacs. I realized that I was really efficient at doing everything that vim/emacs claimed to do using my own toolchain. And I didn&#8217;t really need to un-learn the toolset that I am the master at and pick up another toolset because a lot of people claim that it&#8217;s only way to do it right. The same applies to my language/platform of choice (C#/.Net) and my OS of choice (Vista). For some reason I was giving more weight to the opinions posted by people on the Internet than to my own experiences. I have no angst for the vim/emacs folks, they&#8217;re probably folks whose first editor was vim/emacs and that&#8217;s what they became comfortable with like to share their passion for the tool and help others in mastering it. For me coming from a DOS background with Turbo Pascal and Turbo C++ as the first tools, it&#8217;s a different perspective of what an editor should be able to do.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">I&#8217;ve now made peace with my choice of tools, I know it&#8217;s limitatons and advantages compared to the other tools and I think that&#8217;s more important. The reason I have this confidence now is that I&#8217;ve written, read and debugged enough code to have an appreciation for our craft and what it entails. You just can&#8217;t get here by reading blog posts and books, you have to actually do it to the get confidence to be able to make those decisions. I am going to continue checking out new tools because I inherently love learning new things, but I&#8217;ve learned to be comfortable in my own choices.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">To summarize, I&#8217;d say Pick a tool/language/platform &#8220;YOU&#8221; are comfortable with, stick with it for a non-trivial time and once you master it, you can do everything that some other tool claims to do, because in the end the tool does not matter, what really matters is the mind using It.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">*,** &#8211; Really interesting that I spewed the term Guru Hackers&#8230;Guru was what the term used for master programmers before Paul Graham made Hacker the defacto term.</div>
<p><span style="background-color: #ffffff;">I don&#8217;t use vim or emacs, but for some reason whenever I used to read a vim or emacs article or blog post, I used to download, install and spend the rest of the day reading books, manuals and playing with the editors. I&#8217;ve done this several times in the last few years with each iteration making a more firm resolve to switch to vim/emacs for my day to day tasks. However, I always ended back at Visual Studio.Net/Eclipse/Notepad++ as the tools of my day to day work. For some reason I always felt inferior to all the Guru* Hackers** using vim and emacs and having this crazy productivity and superior intellect. Why couldn&#8217;t I be part of this &#8220;elite&#8221; club? The same holds true for several other areas as well, for e.g. downloading Python, Ruby, J and spending the day learning the language only to forget the next week.</span></p>
<p>All this kind of reminded me of my experiences with finding the perfect weapon while playing Call of Duty 4 over the past year. I spent 3 hours a day almost every day for the past one year playing this game, reaching the max prestige level (the &#8220;elite&#8221; club) in the multi-player version. I became really really good at it and could kick a lot of ass no matter what weapon I was using. But I remember when I started out and I really sucked, I became obsessed with finding the perfect weapon with the perfect set of perks and addons. I used to wander the forums asking people about which weapons and perks to use on which map and what the best tips were etc. Thinking that having the perfect weapon would make me a good player. In the end, the only thing that mattered was all the hours I put in to learn all the maps, routes, tricks and my ability(I like to think). The surprising thing was that once I mastered the game, it didn&#8217;t really matter what weapon I chose, I was able to adapt any weapon and do a decent job.</p>
<p>Based on my experiences with the game I started thinking about why I felt I needed to be using vim/emacs. I realized that I was really efficient at doing everything that vim/emacs claimed to do using my own toolchain. And I didn&#8217;t really need to un-learn the toolset that I am the master at and pick up another toolset because a lot of people claim that it&#8217;s only way to do it right. The same applies to my language/platform of choice (C#/.Net) and my OS of choice (Vista). For some reason I was giving more weight to the opinions posted by people on the Internet than to my own experiences. I have no angst for the vim/emacs folks, they&#8217;re probably folks whose first editor was vim/emacs and that&#8217;s what they became comfortable with like to share their passion for the tool and help others in mastering it. For me coming from a DOS background with Turbo Pascal and Turbo C++ as the first tools, it&#8217;s a different perspective of what an editor should be able to do. I like the deep intellisense that Visual Studio and Eclipse are able to provide, this coupled with Notepad++ for quick edits is all I need right now.</p>
<p>I&#8217;ve now made peace with my choice of tools, I know it&#8217;s limitations and advantages compared to the other tools and I think that&#8217;s more important. The reason I have this confidence now is that I&#8217;ve written, read and debugged enough code to have an appreciation for our craft and what it entails and I don&#8217;t think I could have gotten this confidence by reading blog posts and books, you have to actually do it to the get confidence to be able to make those decisions. I am going to continue checking out new tools because I inherently love learning new things, but I&#8217;ve learned to have confidence in my own choices and to make an objective decision on the tool to use for a particular task.</p>
<p>To summarize, I&#8217;d say Pick a tool/language/platform &#8220;YOU&#8221; are comfortable with, stick with it for a non-trivial time and once you master it, you can do everything that some other tool claims to do, because in the end the tool does not matter a lot, what really matters is the mind using It.</p>
<p>*,** &#8211; Really interesting that I spewed the adjective Guru Hackers, &#8220;Guru&#8221; was what the term used for master programmers before Paul Graham popularized &#8220;Hacker&#8221; as the de facto term.</p>
<div class="wp-caption alignleft" style="width: 750px"><a href="http://xkcd.com/378/"><img title="XCKD: Real Programmers" src="http://imgs.xkcd.com/comics/real_programmers.png" alt="Real Programmers" width="740" height="406" /></a><p class="wp-caption-text">Real Programmers</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.indiangeek.net/2009/11/16/tools-dont-matter/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		<feedburner:origLink>http://www.indiangeek.net/2009/11/16/tools-dont-matter/</feedburner:origLink></item>
		<item>
		<title>The Enlightened Newbie Syndrome</title>
		<link>http://feedproxy.google.com/~r/Indiangeek/~3/xuwy0UIF9xk/</link>
		<comments>http://www.indiangeek.net/2009/05/01/the-enlightened-newbie-syndrome/#comments</comments>
		<pubDate>Fri, 01 May 2009 14:55:56 +0000</pubDate>
		<dc:creator>sijin</dc:creator>
				<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://www.indiangeek.net/?p=465</guid>
		<description><![CDATA[<p>Recently I was reviewing some code written by a new programmer, this person had demonstrated good knowledge of his domain and was quite well regarded by everyone. However when I looked at his code I saw a familiar pattern that I had seen before which I like to call the &#8220;Enlightened Newbie Syndrome&#8221; (ENS).</p>
<p>You can [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I was reviewing some code written by a new programmer, this person had demonstrated good knowledge of his domain and was quite well regarded by everyone. However when I looked at his code I saw a familiar pattern that I had seen before which I like to call the <strong>&#8220;Enlightened Newbie Syndrome&#8221; </strong>(ENS).</p>
<p>You can detect ENS when you see code that is a mish-mash of good code intermingled with overkill on &#8220;best practices&#8221;. The Enlightened Newbie will focus on making sure that his code adheres to the latest naming conventions, follows TDD but doesn&#8217;t test the right things and applies design patterns too liberally <img src='http://www.indiangeek.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>In this particular case the programmer had used different naming conventions for variables based on it&#8217;s usage, so for e.g. pascal case for params, all caps with underscroes for local variables etc. Another classic sympton was the elaborate comments about assignment statements complete with box decorations around the comment. Further the variables if named properly would have been enough to indicate their usage but instead the variable names were extremely generic and then had big comment boxes near them to describe what the variable was used for.</p>
<p>The saving grace of the code was that logically it was setup correctly, but it was clear that the programmer had not unit tested his code at all, my first invocation of the code gave me wrong results and upon further analysis it looked like a lot of the edge cases had been missed out.</p>
<p>I remember being an enlightened newbie once, I had read all the books on design patterns, refactoring, TDD etc. but had not yet written a lot of code. So when I worked on my real project it was very tough for me to find the style that worked for me and I ended up with a bit of everything at the start. However as I worked on that code for the next 3 years all the things that I had read started to make sense and I realized that the essence is to not follow a practice religiously but to make use of good judgement to see what applies where.</p>
<p>So in my mind there is only one cure for ENS and that is to just write a lot of software in a team environment. Note that I am not talking about just chruning out code but actual working software, and again not in isolation but in a team. Because</p>
<p>1. You can write a lot of code and only improve your typing and not learn a lot about programming, however when you build an actual product/service and then have users or other systems interacting with it, you get a lot of feedback on what works and what does not. Based on the feedback and other external requirements the software usually goes through a lot of changes and when you have to go back into your code and make changes then you really appreciate brevity, simplicty and the DRY principle.</p>
<p>2. Working in a team environment exposes you to code that is both better and worse than you, it gives you more exposure to the different ways something can be done and all the different ways you can use tools to make your work easier. Teams are just fantastic platforms for improving your skill, knowledge and productivity.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.indiangeek.net/2009/05/01/the-enlightened-newbie-syndrome/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://www.indiangeek.net/2009/05/01/the-enlightened-newbie-syndrome/</feedburner:origLink></item>
		<item>
		<title>Windows Azure Distilled – A Programmer’s view</title>
		<link>http://feedproxy.google.com/~r/Indiangeek/~3/gkgUDgdWXbQ/</link>
		<comments>http://www.indiangeek.net/2008/11/14/windows-azure-distilled/#comments</comments>
		<pubDate>Fri, 14 Nov 2008 20:20:02 +0000</pubDate>
		<dc:creator>sijin</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[azure]]></category>
		<category><![CDATA[cloud computing]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://www.indiangeek.net/?p=420</guid>
		<description><![CDATA[<p></p>
<p>The launch of Windows Azure has coincided with the launch of the entire cloud computing initiative from Microsoft which makes a lot of business sense but it also makes it hard to differntiate the individual parts of the initiative, here&#8217;s my understanding so far.</p>
<p>
</p>
Windows Azure
<p>This is the base platform that provides a generic cloud computing [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone" title="Azure" src="http://www.microsoft.com/azure/images/servicesPlatform.jpg" alt="" width="490" height="226" /></p>
<p>The launch of Windows Azure has coincided with the launch of the entire cloud computing initiative from Microsoft which makes a lot of business sense but it also makes it hard to differntiate the individual parts of the initiative, here&#8217;s my understanding so far.</p>
<p><span style="color: #551a8b; text-decoration: underline;"><br />
</span></p>
<h2>Windows Azure</h2>
<p>This is the base platform that provides a generic cloud computing platform for developers to host applications on.  Azure basically offers two core services,</p>
<h3>Compute Service</h3>
<p style="padding-left: 30px; ">This is what people would normally associate with cloud computing. You write an app that <a href="http://msdn.microsoft.com/en-us/library/dd179369.aspx" target="_blank">conforms to the cloud hosting requirements</a> and then deploy it to the cloud where it can be managed and scaled as per the load and performance requirements. Currently there are two types of compute services that can be deployed on Azure</p>
<p style="padding-left: 60px; "><strong>Web Role</strong> &#8211; This currently is a WebForms ASP.Net application, but looks like support for ASP.Net MVC and other languages are in the works too. This is just like hosting your application with a hosting provider except that you get load balancing, failover etc. for free. One important caveat here is that the load balancing does not support sticky sessions(as of the CTP) which is a good thing but it does require the developer to use the storage service to store session data.</p>
<p style="padding-left: 60px; "><strong>Worker Role</strong> &#8211; This is more like a Windows Service that is deployed on the cloud, it can make outgoing connections but incoming connections are disallowed. But again you get the benefits of load balancing and failover.</p>
<p style="padding-left: 30px; ">The compute services are different from other similar cloud computing options available because it does not require the developer to supply a VM image (unlike <a href="http://aws.amazon.com/ec2/" target="_blank">Amazon EC2</a>) of the application environment to host,  instead the applications run in VMs that are built and maintained by the Microsoft Data Centers that host the applications.</p>
<p style="padding-left: 30px; ">This decision definitely has it pros and cons, it&#8217;s good because</p>
<p style="padding-left: 60px;">- No licensing costs for the OS</p>
<p style="padding-left: 60px;">- No need for updating of the VMs as the applications evolve</p>
<p style="padding-left: 60px;">- Simpler deployment strategy</p>
<p style="padding-left: 60px;">- API available for management of service instances and for reporting on application health</p>
<p style="padding-left: 30px; ">on the other hand</p>
<p style="padding-left: 60px;">- it does restrict the flexibility of what software and services can be accessed from the host VM</p>
<p style="padding-left: 30px; ">This diagram from MSDN gives a nice overview</p>
<p style="padding-left: 30px; "><img class="alignnone" title="Azure Compute Services" src="http://i.msdn.microsoft.com/Dd179341.06fd0ae8-9fef-48fd-9cee-69b83fdbbe47(en-us,MSDN.10).gif" alt="" width="943" height="612" /></p>
<p style="padding-left: 30px; ">All though in reality the deployment internally looks like below with IIS7 and Windows Server 2008 VMs.</p>
<p style="padding-left: 30px; "> </p>
<div id="attachment_427" class="wp-caption aligncenter" style="width: 510px"><a href="http://www.indiangeek.net/wp-content/uploads/2008/11/azure-hosting1.png"><img class="size-full wp-image-427" title="azure-hosting1" src="http://www.indiangeek.net/wp-content/uploads/2008/11/azure-hosting1.png" alt="Azure Hosting" width="500" height="330" /></a><p class="wp-caption-text">Azure Hosting</p></div>
<p style="padding-left: 30px; "> </p>
<h3>Storage Service</h3>
<p style="padding-left: 30px; ">This is the second part of the base Azure platform and is the equivalent of Amazon <a href="http://aws.amazon.com/s3/" target="_blank">S3</a>, <a href="http://aws.amazon.com/sqs/" target="_blank">SQS </a>and <a href="http://aws.amazon.com/simpledb/" target="_blank">SimpleDB </a>all rolled under one name. The equivalents in the Storage Service are called,</p>
<p style="padding-left: 60px; "><strong>Blob </strong>- For storing binary data, most commonly file streams.</p>
<p style="padding-left: 60px; "><strong>Queue  </strong>- For reliable persistent messaging. I found it strange that it was lumped with the storage services because the primary purpose of this seems to be inter service communication between the applications running in the cloud. </p>
<p style="padding-left: 60px; "><strong>Table </strong>- For storing tabular data, different from traditional database tables though.</p>
<p style="padding-left: 30px; ">The important thing to remember here is that these services are available to any application that can talk over HTTP so WPF, WinForms, and non-cloud ASP.Net applications can make use of the storage services as well and benefit from having their data stored in an easily scaled environment. The storage services expose a RESTFul API which makes it easy to access these services from any platform that can talk over HTTP but ofcourse if you&#8217;re using .Net you get some builtin support from the framework.</p>
<p style="padding-left: 30px; "> </p>
<div id="attachment_426" class="wp-caption aligncenter" style="width: 510px"><a href="http://www.indiangeek.net/wp-content/uploads/2008/11/azure-storage-services.png"><img class="size-full wp-image-426" title="azure-storage-services" src="http://www.indiangeek.net/wp-content/uploads/2008/11/azure-storage-services.png" alt="Azure Storage Services" width="500" height="325" /></a><p class="wp-caption-text">Azure Storage Services</p></div>
<p> </p>
<p>The developer story for Windows Azure is as good as anything else from Microsoft, the SDK includes tools to simulate both the compute services and the storage services on your development box, further with the VS addin you can deploy your cloud application straight to the Azure hosting platform, talk about ease of deployment. Here&#8217;s a quick overview of the important tools included in the Azure SDK.</p>
<p style="padding-left: 30px; "><strong>Development Fabric</strong> &#8211; Simulates the Azure Compute Services (aka Azure Fabric) on your dev machine complete with a load balancer and failover monitoring.</p>
<p style="padding-left: 30px; "><strong>Development Storage</strong> &#8211; Simulates the Azure storage services on your dev machine, the CTP implmentation requires SQL Server 2008 Express but you can also work with SQL Server 2008 if you want.</p>
<p style="padding-left: 30px; "><strong>CSPack</strong> &#8211; Command line tool that prepares a service for deployment either to the Development Fabric or to the Windows Azure Fabric.</p>
<p style="padding-left: 30px; "><strong>CSRun </strong>- Command line tool that runs a service (generated from CSPack) on the Development Fabric.</p>
<p>So the development cycle for a Azure app consists of developing locally using the Development Fabric and Development Storage and then deploying to the Azure platform when ready.  Deployments would not normally bring down the sites because the instances are load balanced and are not sticky. </p>
<p>The other good thing is that services can be configured manually be editing the service configuration file or programatically by accessing the ServiceHosting API at runtime, so no redeployment is required if only service configurations are changed (which includes things like number of instances to run).</p>
<p>That&#8217;s basically the core Azure platform, the rest of the stack (<a href="http://www.microsoft.com/azure/netservices.mspx" target="_blank">.Net Services</a>, <a href="http://www.microsoft.com/azure/sql.mspx" target="_blank">SQL Data Services</a> and <a href="http://dev.live.com/" target="_blank">Live Services</a>) are cloud applications built by Microsoft on top of the core Azure platform. Again all these applications expose their API in a RESTFul manner as well making them open to both any technology that can talk over HTTP.</p>
<p> </p>
<div id="attachment_430" class="wp-caption aligncenter" style="width: 510px"><a href="http://www.indiangeek.net/wp-content/uploads/2008/11/azure-services-platform.png"><img class="size-full wp-image-430" title="azure-services-platform" src="http://www.indiangeek.net/wp-content/uploads/2008/11/azure-services-platform.png" alt="Azure Services Platform" width="500" height="311" /></a><p class="wp-caption-text">Azure Services Platform</p></div>
<p> </p>
<p>Personally for me the <a href="http://msdn.microsoft.com/en-us/library/dd179367.aspx" target="_blank">Windows Azure SDK section from MSDN </a>and this <a href="http://download.microsoft.com/download/e/4/3/e43bb484-3b52-4fa8-a9f9-ec60a32954bc/Azure_Services_Platform.docx">document from David Chappel</a> were the most useful pieces of documentation to understand the entire stack.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.indiangeek.net/2008/11/14/windows-azure-distilled/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.indiangeek.net/2008/11/14/windows-azure-distilled/</feedburner:origLink></item>
		<item>
		<title>Using Windows Azure SDK with SQL Server 2005/2008</title>
		<link>http://feedproxy.google.com/~r/Indiangeek/~3/0qSj3rUzX8Q/</link>
		<comments>http://www.indiangeek.net/2008/10/29/using-windows-azure-with-sql-server-20052008/#comments</comments>
		<pubDate>Wed, 29 Oct 2008 19:10:29 +0000</pubDate>
		<dc:creator>sijin</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[windows azure programming microsoft]]></category>

		<guid isPermaLink="false">http://www.indiangeek.net/?p=415</guid>
		<description><![CDATA[<p>I downloaded the Windows Azure SDK today and was going through the quick starts from MSDN , the quickstarts mention that you need SQL Server Express 2005/2008 to run the samples, but I only had SQL Server 2008 developer edition installed. I decided to give it a try anyways and immediately hit a snag when trying [...]]]></description>
			<content:encoded><![CDATA[<p>I downloaded the <a href="http://www.microsoft.com/azure/default.mspx" target="_self">Windows Azure SDK</a> today and was going through the<a href="http://msdn.microsoft.com/en-us/library/dd179419.aspx" target="_blank"> quick starts from MSDN</a> , the quickstarts mention that you need SQL Server Express 2005/2008 to run the samples, but I only had SQL Server 2008 developer edition installed. I decided to give it a try anyways and immediately hit a snag when trying to build the samples because as expected it could not find the SQLExpress instance that it was assuming would be present on the localhost.</p>
<p>Here are the changes I had to make to get the samples and the SDK to work with SQLServer 2008 installed without an instance name on my laptop.</p>
<p>1. In Windows Azure SDK\v1.0\samples\MSBuild\Microsoft.Samples.ServiceHosting.targets , add the &#8220;/server&#8221; option to the UpdateSampleTablesDB target to make it look like</p>
<blockquote><p>&lt;Target Name=&#8221;UpdateSamplesTableDB&#8221; DependsOnTargets=&#8221;BuildSubProjects&#8221;&gt;</p>
<p>    &lt;Message Text=&#8221;$(DevTableGenCommand) /database:$(SamplesDBName) /server:localhost $(DevtableGenForceCreateFlag) @(DevTableGenAssemblies)&#8221;/&gt;</p>
<p>    &lt;Exec Condition=&#8221;&#8216;$(SamplesDBName)&#8217;!=&#8221;&#8221; </p>
<p>            Command=&#8221;$(DevTableGenCommand) /database:$(SamplesDBName) <strong>/server:localhost</strong> $(DevtableGenForceCreateFlag) @(DevTableGenAssemblies)&#8221; </p>
<p>    WorkingDirectory=&#8221;$(MSBuildProjectDirectory)&#8221;/&gt;</p>
<p>  &lt;/Target&gt;</p></blockquote>
<p>2. Change the datasource in the connection string used in  &#8221;Windows Azure SDK\v1.0\bin\DevelopmentStorage.exe.config&#8221; to localhost</p>
<blockquote><p>&lt;connectionStrings&gt;</p>
<p>    &lt;add name=&#8221;DevelopmentStorageDbConnectionString&#8221;</p>
<p>         connectionString=&#8221;Data Source=<strong>localhost</strong>;Initial Catalog=DevelopmentStorageDb;Integrated Security=True&#8221;</p>
<p>         providerName=&#8221;System.Data.SqlClient&#8221; /&gt;</p>
<p>  &lt;/connectionStrings&gt;</p></blockquote>
<p>3. Change the dbServer for the Table service in the developmentStorageConfig section to localhost in &#8220;Windows Azure SDK\v1.0\bin\DevelopmentStorage.exe.config&#8221;</p>
<blockquote><p>    &lt;services&gt;</p>
<p>      &lt;service name=&#8221;Blob&#8221;</p>
<p>               url=&#8221;http://127.0.0.1:10000/&#8221;/&gt;</p>
<p>      &lt;service name=&#8221;Queue&#8221;</p>
<p>               url=&#8221;http://127.0.0.1:10001/&#8221;/&gt;</p>
<p>      &lt;service name=&#8221;Table&#8221;</p>
<p>               url=&#8221;http://127.0.0.1:10002/&#8221;</p>
<p><span> </span>         dbServer=&#8221;<strong>localhost</strong>&#8220;/&gt;</p>
<p> </p>
<p>    &lt;/services&gt;</p></blockquote>
<p>HTH</p>
]]></content:encoded>
			<wfw:commentRss>http://www.indiangeek.net/2008/10/29/using-windows-azure-with-sql-server-20052008/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.indiangeek.net/2008/10/29/using-windows-azure-with-sql-server-20052008/</feedburner:origLink></item>
		<item>
		<title>A case study in micro-optimization</title>
		<link>http://feedproxy.google.com/~r/Indiangeek/~3/VtSnxqTjSvs/</link>
		<comments>http://www.indiangeek.net/2008/08/29/a-case-study-in-micro-optimization/#comments</comments>
		<pubDate>Fri, 29 Aug 2008 15:17:22 +0000</pubDate>
		<dc:creator>sijin</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[algorithms]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.indiangeek.net/?p=393</guid>
		<description><![CDATA[<p>Last week I saw a wrap up from cedric&#8217;s coding challenge on his blog, the problem looked simple enough, &#8220;write a counter function that counts from 1 to max but only returns numbers whose digits don&#8217;t repeat&#8221;.</p>
<p>My first stab at it consisted of a brute force solution of looking at every natural number up to [...]]]></description>
			<content:encoded><![CDATA[<p>Last week I saw a wrap up from <a title="Cedric's Coding Challenge Wrapup" href="http://beust.com/weblog/archives/000493.html">cedric&#8217;s coding challenge</a> on his blog, the problem looked simple enough, <em><strong>&#8220;write a counter function that counts from 1 to max but only returns numbers whose digits don&#8217;t repeat&#8221;</strong></em>.</p>
<p>My first stab at it consisted of a brute force solution of looking at every natural number up to a given limit and determining if the digits were unique, the crux of which was this function that given a number determined if the digits repeated or not</p>
<pre class="brush: c#">
private static bool DoDigitsRepeat(long num) {
····//Used to track which digits have already been encountered
····int used = 0;
····while (num &gt; 0) {
········int digit = (int)num % 10;
········num = num / 10;

········int index = 1 &lt;&lt; digit;
········if ((used &amp; index) == index) {
············return true;
········}
········else {
············used |= index;
········}
····}
····return false;
}
</pre>
<p>The good thing about this solution was that it met the secondary goal for the problem which was to determine the biggest gap in the sequence of generated numbers, but in terms of performance it sucked! It worked well for the smaller limits defined in the problem but when you tried to push and generate all matching numbers till the max possible i.e. 9876543210 it just took too long (I think it was under a minute, but that was still too long)</p>
<p>I went back to the problem page and saw that the scripting weenies who had tried to use string functions to prune numbers had the worst performance of all solutions, that made me feel a bit better until I saw <a title="Crazy Bob's wicked fast solution" href="http://crazybob.org/FastBeustSequence.java.html">CrazyBob&#8217;s Java solution(the fast version)</a>, the comments indicated that the solution found the total count in under half a second. This solution was not able to determine the biggest gap though because the numbers were generated out of order but nevertheless this was an excellent solution.</p>
<p>So began my quest to come up with a faster solution. I felt sure that I could use the <a title="Bit Twiddling Hacks" href="http://graphics.stanford.edu/~seander/bithacks.html">bit twiddling hacks</a> to come up with a faster solution, it was just a question of hitting the right spot.</p>
<p>The first non-brute force solution that I tried was to enumerate all possible subsets of {0,1,2,3,4,5,6,7,8,9} and then to generate permutations from that set making sure that zero was never in the first place. Subset generation is pretty easy to do, all you need to do is count from 0 to 2^n where n is the number of elements in the set, the bit patterns of all the numbers in this range can be used to generate all the subsets. For the first cut I tried to be Object-Oriented and used the below class to implement a BitTable.</p>
<pre class="brush: c#">
public class BitTable
{
····private uint _storage = 0;
····public BitTable(uint value) {
········_storage = value;
····}

····public void Set(int index) {
········Debug.Assert(index &gt;= 0 &amp;&amp; index &lt; 32);
········_storage |= (uint)(1 &lt;&lt; index);
····}

····public void Reset(int index) {
········Debug.Assert(index &gt;= 0 &amp;&amp; index &lt; 32);
········_storage &amp;= (uint)~(1 &lt;&lt; index);
····}

····public bool IsSet(int index) {
········Debug.Assert(index &gt;= 0 &amp;&amp; index &lt; 32);
········uint val = (uint)(1 &lt;&lt; index);
········return (_storage &amp; val) == val;
····}
}
</pre>
<p>Of course as I soon found out, all the method calls to BitTable were really slowing things down (and by slow I mean a 1-2 seconds slower than CrazyBob&#8217;s solution), so I dropped the class and moved all the operations inline, also I realized that since I was using value types to hold the state in the search/call tree, I didn&#8217;t need to set and unset the state after each recursive call. Here&#8217;s the final version of this line of thinking.</p>
<pre class="brush: c#">
class Beust4
{
private static int _total = 0;
public static void Run() {
····_total = 0;
····//Generate all possible subsets of a set of 10 elements
····//2^10 = 1024
····for (int i = 1; i &lt;= 1024; ++i) {
········Permute(i, 0L);
····}

····Console.WriteLine(&quot;nTotal: {0}&quot;, _total);
}

private static void Permute(int digits, long current) {
····for (int index = (current &gt; 0) ? 0 : 1; index &lt;= 9; ++index) {
········if ((digits &amp; (1 &lt;&lt; index)) == (1 &lt;&lt; index)) {
············if ((digits &amp; ~(1 &lt;&lt; index)) == 0) {
················//Console.Write(&quot;{0}, &quot;, (current * 10) + index);
················++_total;
················return;
············}
············else {
················Permute(digits &amp; ~(1 &lt;&lt; index), (current * 10) + index);
············}
········}
····}
}
</pre>
<p>I felt really good about this attempt but to my surprise when I ran it, I took 1.2 seconds on average which was still more than 2 times slower than CrazyBob&#8217;s Java solution. I got really stuck at this point and I had to make sure that there was not something obvious that I was missing. The first thing I did was to port CrazyBob&#8217;s solution to .Net so that I could compare both solutions, I&#8217;ve uploaded the <a title="C# version of CrazyBob's solution" href="http://pastebin.com/f9f714a4" target="_blank">C# version of CrazyBob&#8217;s solution </a>here in case anyone wants to take a look.</p>
<p>On the surface it looks like the bit twiddling based solution should run faster because it does not make all those method calls, the other thing that I suspected was causing problems was the number of recursive function calls that were being made, so I put in some code to check the number of recursive function calls that were being made and to my surprise I found that CrazyBob&#8217;s solution was making 8877691 recursive calls as compared to my solution which was making almost 10 times that number. Also the actual soultion count is 8877690 which meant that the number of calls in CrazyBob&#8217;s solution was near optimal. So it was clear that it was the number of calls that were costing me the half second. Btw CrazyBob&#8217;s C# version still ran in <strong>700ms</strong> on average on my laptop, which was still <strong>500ms</strong> faster than my C# version.</p>
<p>I then started to think about alternate ways to attack the issue, one track I went down was to consider all the digits as a complete graph and then coming up with a way to enumerate all paths in the graph, traversing a n edge in the graph would remove other edges from the graph and make them not available. This reminded me on <a title="Dancing Links Algorithm" href="http://en.wikipedia.org/wiki/Dancing_Links" target="_blank">Knuth&#8217;s Dancing Links Algorithm</a> and I read up on that a bit, this <a title="Dancing Links" href="http://lanl.arxiv.org/pdf/cs/0011047" target="_blank">paper from Knuth</a> on the subject was an excellent read. It looked to me that CrazyBob had used an approach similar to the DLX algorithm, but after reading the entire paper from Knuth it still didn&#8217;t strike me as to why using a DLX approach would provide such excellent performance as compared to my version.</p>
<p>So I went back a bit to comparing both solutions and I think the two key observations that I saw that</p>
<ol>
<li>CrazyBob&#8217;s solution went down the search tree to one level above the last  and then just generated all the solution from there instead of recursing down to the last level, so for e.g. supposing it was generating 5 digit numbers and it had already generated 4321, then at that level it didn&#8217;t make additional recursive calls to add the final digit, it was able to add the last digit at the same level pruning the search tree quite a bit. In contrast my solution was basically doing a method call for every digit of every number in the solution set.</li>
<li>The above optimization was made possible by using the length of the final solution as the key, so first all 1 digit solutions were generated, followed by two digit ones and so on.</li>
</ol>
<p>Cool, so now I ported my bit twiddling version to generate based on the length of the numbers and the optimization to prune the search tree one level above the last came naturally. I ran my solution and guess what, it was still 200 ms slower than CrazyBob <img src='http://www.indiangeek.net/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' />  Aaaarghhhh!!!!!</p>
<pre class="brush: c#">
for (int len = 1; len &lt;= 10; ++len) {
····Generate(len, 0, 0xFFF &gt;&gt; 2, 0);
}

private static void Generate(int maxLen, int currentLen, int availableDigits, long currentValue) {
····bool last = (currentLen == maxLen - 1);
····for (int digit = (currentValue == 0) ? 1 : 0; digit &lt;= 9; ++digit) {
········if ((availableDigits &amp; (1 &lt;&lt; digit)) != (1 &lt;&lt; digit))
············continue;

········if (last) {
············++_total;
············//Console.Write(&quot;{0}, &quot;, (currentValue * 10) + i);
········}
········else {
············Generate(maxLen, currentLen + 1, availableDigits &amp; ~(1 &lt;&lt; digit), (currentValue * 10) + digit);
········}
····}
}
</pre>
<p>But I knew I was getting close, at this point I knew what was killing me basically to determine which bits were set I was iterating from 0 to 9 and then testing if that bit was set in the number or not, this test was killing me because most of the times the bit was not set and I was doing a huge huge number of unnecessary tests. So I needed a way to iterate through only the set bits. The first solution I tried used a hashtable but that caused a even bigger degradation in performance. Finally for a lack of a better way to express this in C# I had to waste 4KB of memory and use an array to allow me to iterate through the indexes of the set bits in a number.</p>
<p>The final solution ran in 350ms on average, almost a 50% improvement over CrazyBob&#8217;s solution, woot!!!!! A further optimzation to move the if statement from inside the loop to outside which makes the code more readable but incredibly smelly because of the near duplicate code in both the if and else blocks shaved off another 50ms. Here&#8217;s the final version without the optimzation for moving the if statement outside which makes the code a bit shorter.</p>
<pre class="brush: c#">
class Beust5
{
····private static int _total = 0;
····private static int[] _pre = null;
····public static void Run() {
········_total = 0;
········_pre = new int[(1 &lt;&lt; 10) + 1];
········for (int i = 0; i &lt;= 10; ++i) {
············_pre[1 &lt;&lt; i] = i;
········}

········for (int len = 1; len &lt;= 10; ++len) {
············Generate2(len, 0, 0xFFF &gt;&gt; 2, 0);
········}

········Console.WriteLine(&quot;nTotal: {0}&quot;, _total);
····}

····private static void Generate2(int maxLen, int currentLen, int availableDigits, long currentValue) {
········bool last = (currentLen == maxLen - 1);
········int x = availableDigits;
········while (x != 0) {
············//digit will contain the lowest set bit
············int digit = _pre[x ^ (x &amp; (x - 1))];
············x &amp;= (x - 1);

············//Avoid starting with zero
············if (digit == 0 &amp;&amp; currentValue == 0)
················continue;

············if (last) {
················++_total;
················//Console.Write(&quot;{0}, &quot;, (currentValue * 10) + i);
············}
············else {
················Generate2(maxLen, currentLen + 1, availableDigits &amp; ~(1 &lt;&lt; digit), (currentValue * 10) + digit);
············}
········}
····}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.indiangeek.net/2008/08/29/a-case-study-in-micro-optimization/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://www.indiangeek.net/2008/08/29/a-case-study-in-micro-optimization/</feedburner:origLink></item>
		<item>
		<title>What will be the next generation internet application platform?</title>
		<link>http://feedproxy.google.com/~r/Indiangeek/~3/ByfHVaAmwMI/</link>
		<comments>http://www.indiangeek.net/2008/06/24/what-will-be-the-next-generation-internet-application-platform/#comments</comments>
		<pubDate>Tue, 24 Jun 2008 14:44:41 +0000</pubDate>
		<dc:creator>sijin</dc:creator>
				<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://www.indiangeek.net/2008/06/24/what-will-be-the-next-generation-internet-application-platform/</guid>
		<description><![CDATA[<p>A few years ago I was a firm believer in the Rich Connected Client application model, which was based on running applications installed locally on the users desktop. From the time of the Ajaxian explosion, the quality and quantity of Ajax based web applications has continued to increase, applications like FaceBook have introduced new paradigms [...]]]></description>
			<content:encoded><![CDATA[<p>A few years ago I was a firm believer in the Rich Connected Client application model, which was based on running applications installed locally on the users desktop. From the time of the <a href="http://en.wikipedia.org/wiki/Cambrian_explosion" title="Cambrian Explosion" target="_blank">Ajaxian explosion</a>, the quality and quantity of Ajax based web applications has continued to increase, applications like FaceBook have introduced new paradigms whereas apps like Live Maps have made existing apps much more convenient and accessible. Today you have to really argue hard to even consider a desktop based application for anything that is non-computation intensive (Even this category is questionable now, for e.g. a few years back movie editing web apps would have been out of the question).</p>
<p>So what is it that makes the web such a successful application platform</p>
<ul>
<li><b>Uniform and simple model (Web Browser, urls, can click when hand is visible)</b> &#8211; Once a user learns the basics of working with a web application that knowledge can be easily applied to other applications.</li>
<li><b>Client platform independence</b> &#8211; The decoupling of the server and client with an agreed contract  (HTML+CSS+JS) means that the traditional problems of targetting various platforms with different APIs is no longer existent on the client side.</li>
<li><b>Machine independence </b>- The user is no longer restricted to the machine on which the application was installed. This also results in a much simpler deployment model.</li>
<li><b>Data independence</b> &#8211; The user&#8217;s data is now available on the network which means that not only can the user run the application from anywhere but can also access his data from anywhere.</li>
</ul>
<p>Now what would the next generation internet application platform look like? I think that in addition to the above characteristics, the next generation of platforms would involve the following.</p>
<ul>
<li><b>Full use of computing resources available locally</b> &#8211; Having a powerful CPU and GPU seems like such a waste when all your applications have to be funnelled through the browser. So the next generation platform would allow access to the computing power available locally.</li>
<li><b>Better integration with the local resources</b> &#8211; This is sort of related to the point above, but would allow internet applications to access local disks, settings, registry etc. </li>
<li><b>Better security model</b> &#8211; Of course all this has already been attempted with ActiveX and XPCOM, but the security models there have been weak and non-intutive to users, a better solution is needed.</li>
</ul>
<p>So it looks like the direction being taken by <a href="http://silverlight.net/" title="Microsoft Silverlight" target="_blank">Microsoft Silverlight</a> and <a href="http://www.adobe.com/products/air/" title="Adobe AIR" target="_blank">Adobe AIR </a>are steps in the right direction to building the next generation internet application platform. However Microsoft has a great oppurtunity here push the envelope with Silverlight and introduce new standards for desktop integration of internet applications, their extensive user base means that any API created by them has a very good chance of being successful and catching on with the other players in this space.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.indiangeek.net/2008/06/24/what-will-be-the-next-generation-internet-application-platform/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.indiangeek.net/2008/06/24/what-will-be-the-next-generation-internet-application-platform/</feedburner:origLink></item>
		<item>
		<title>PsTools to the rescue</title>
		<link>http://feedproxy.google.com/~r/Indiangeek/~3/hMIFgyP-DqA/</link>
		<comments>http://www.indiangeek.net/2008/05/29/pstools-to-the-rescue/#comments</comments>
		<pubDate>Thu, 29 May 2008 15:56:57 +0000</pubDate>
		<dc:creator>sijin</dc:creator>
				<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://www.indiangeek.net/2008/05/29/pstools-to-the-rescue/</guid>
		<description><![CDATA[<p>We were having memory issues on one of our production servers today, no one was able to get in via Remote Desktop or any other remote access tools. PsTools by Mark Russinovich was a life saver, it allowed me to query the processes running on the remote machine and also their memory usage, we were [...]]]></description>
			<content:encoded><![CDATA[<p>We were having memory issues on one of our production servers today, no one was able to get in via Remote Desktop or any other remote access tools. <a href="http://technet.microsoft.com/en-us/sysinternals/bb896649.aspx" title="PsTools" target="_blank">PsTools</a> by Mark Russinovich was a life saver, it allowed me to query the processes running on the remote machine and also their memory usage, we were able to diagnose the issue and fix it quickly once we knew what the cause was. The tool suite also has a bunch of other useful tools that work on remote boxes as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.indiangeek.net/2008/05/29/pstools-to-the-rescue/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.indiangeek.net/2008/05/29/pstools-to-the-rescue/</feedburner:origLink></item>
		<item>
		<title>Hacking democracy</title>
		<link>http://feedproxy.google.com/~r/Indiangeek/~3/sWoVy4iULj0/</link>
		<comments>http://www.indiangeek.net/2008/05/29/hacking-democracy/#comments</comments>
		<pubDate>Thu, 29 May 2008 13:04:35 +0000</pubDate>
		<dc:creator>sijin</dc:creator>
				<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://www.indiangeek.net/2008/05/29/hacking-democracy/</guid>
		<description><![CDATA[<p>Just saw Hacking Democracy on HBO, it&#8217;s available online as well. I can&#8217;t believe the whole electronic voting system is built on Access and a VB frontend!!</p>
]]></description>
			<content:encoded><![CDATA[<p>Just saw Hacking Democracy on HBO, it&#8217;s <a href="http://video.google.com/videoplay?docid=4463776866669054201" title="Hacking Democracy" target="_blank">available online </a>as well. I can&#8217;t believe the whole electronic voting system is built on Access and a VB frontend!!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.indiangeek.net/2008/05/29/hacking-democracy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.indiangeek.net/2008/05/29/hacking-democracy/</feedburner:origLink></item>
	</channel>
</rss>
