<?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>Sankofa &#187; Coding Horror</title>
	<atom:link href="http://blog.ianuy.com/tag/coding-horror/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.ianuy.com</link>
	<description>From Script Kiddie to Professional Software Developer</description>
	<lastBuildDate>Fri, 31 Dec 2010 17:42:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>The Importance of a Dedicated Build Machine</title>
		<link>http://blog.ianuy.com/2009/06/07/the-importance-of-a-dedicated-build-machine/</link>
		<comments>http://blog.ianuy.com/2009/06/07/the-importance-of-a-dedicated-build-machine/#comments</comments>
		<pubDate>Sun, 07 Jun 2009 14:36:59 +0000</pubDate>
		<dc:creator>Ian Uy</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Coding Horror]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://blog.ianuy.com/?p=374</guid>
		<description><![CDATA[
When I was an Intern at a large Global 500 company, my major responsibility is to deliver a Software Delivery process that uses the software engineering practice called Continuous Integration. In simple terms, I am responsible for a project to create and setup a Continuous Integration Build Server that will be used to &#8220;build&#8221; the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.ianuy.com/wp-content/uploads/2009/06/serverroom_3.jpg"><img class="aligncenter size-medium wp-image-375" title="Build Server" src="http://blog.ianuy.com/wp-content/uploads/2009/06/serverroom_3-200x300.jpg" alt="Build Server" width="200" height="300" /></a></p>
<p>When I was an Intern at a large Global 500 company, my major responsibility is to deliver a <a title="Software Delivery" href="http://en.wikipedia.org/wiki/Software_delivery" target="_blank">Software Delivery</a> process that uses the software engineering practice called <a title="Continuous Integration" href="http://en.wikipedia.org/wiki/Continuous_integration" target="_blank">Continuous Integration</a>. In simple terms, I am responsible for a project to create and setup a Continuous Integration Build Server that will be used to &#8220;build&#8221; the company&#8217;s products.</p>
<p>During those days, when I hear the word &#8220;build&#8221; or &#8220;compile&#8221;, the first thing that comes into mind is to press the F5 button. Ever since I started programming, when someone asks me for a copy of my program or if I need to distribute the &#8220;binaries&#8221; of my program, all I do is press the F5 button to create an EXE (sometimes with a DLL), then browse to the output folder(Bin) and copy the binaries. Suffice to say, that is my &#8220;Software Delivery&#8221; process however crude it is.</p>
<p>In College, I got a little bit more sophisticated. My major projects are all carefully packaged in a very neat MSI installer &#8212; but that is just for the major projects. Most of my standalone tools are still made using the &#8220;Press F5 button to build&#8221; method. <img src='http://blog.ianuy.com/wp-includes/images/smilies/icon_lol.gif' alt=':lol:' class='wp-smiley' /> </p>
<p><span id="more-374"></span></p>
<p>So you can just imagine my horror when the Software Architect presented me my task on my first day at work. I don&#8217;t know anything about Software Delivery, more so Continuous Integration. What is more scary is that I am expected to deliver my output in just 240 hours (my Internship duration). But thru the continuous support of the said Software Architect, I somehow managed to cram the concept of Software Delivery and Continuous Integration in just 2 weeks. Also, <a title="Expert .NET Delivery Using NAnt and CruiseControl.NET" href="http://www.apress.com/book/view/1590594851" target="_blank">this book</a> helped a lot, too!</p>
<p style="text-align: left;">
<div id="attachment_379" class="wp-caption aligncenter" style="width: 238px"><a href="http://blog.ianuy.com/wp-content/uploads/2009/06/1590594851500fm6.gif"><img class="size-full wp-image-379" title="Expert .NET Delivery Using NAnt and CruiseControl.NET" src="http://blog.ianuy.com/wp-content/uploads/2009/06/1590594851500fm6.gif" alt="Expert .NET Delivery Using NAnt and CruiseControl.NET" width="228" height="301" /></a><p class="wp-caption-text">Expert .NET Delivery Using NAnt and CruiseControl.NET</p></div>
<p style="text-align: left;">The build process that I created is quite simple and somewhat standard. However, there was a special requirement that the test harness be run on a different machine and that made the build process a little bit more complicated. This are the different stages of my build process:</p>
<ol>
<li><strong>Clean-up: </strong>Before starting a new build, delete all the previous directories (Source codes, Artifacts, etc.)</li>
<li><strong>Fetch: </strong>Get the latest copy from the source code repository</li>
<li><strong>Build:</strong> Compile the different projects</li>
<li><strong>Archive: </strong>Tag the build then archive it</li>
<li><strong>Test: </strong>Run the unit tests, measure code coverage and perform static code analysis</li>
<li><strong>Feedback: </strong>Provide feedback by generating reports (with beautiful graphs!) <img src='http://blog.ianuy.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
</ol>
<div id="attachment_380" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.ianuy.com/wp-content/uploads/2009/06/graph.png"><img class="size-medium wp-image-380" title="CruiseControl.NET Build History" src="http://blog.ianuy.com/wp-content/uploads/2009/06/graph-300x239.png" alt="CruiseControl.NET Build History" width="300" height="239" /></a><p class="wp-caption-text">CruiseControl.NET Build History</p></div>
<p>The build process will automatically check for any changes in the Source Code Repository every 15 minutes, if it detects any change in the code, it will automatically start the build process. That is one of the advantage of using Continuous Integration &#8212; there is no need for a costly &#8220;Integration&#8221; phase.</p>
<p>In my <a href="http://blog.ianuy.com/2009/05/10/migration-why-developers-hate-microsoft-or-my-first-encounter-how-microsoft-can-break-your-software/" target="_blank">previous blog posts</a>, I&#8217;ve mentioned that I am working on a certain product that will be shipped later this month. Well, that project is nearing its completion. We now have a &#8220;Beta&#8221; build for our product and it won&#8217;t be long before an official Release Candidate is available.</p>
<p>During our weekly status meeting, I brought up a concern regarding how we are building our Beta builds that are being sent to the Test Department. Our current Build Machine (which is physically located locally) also acts as our Development Machine. All of the development activities like bug fixing are being done on the Build Machine. If you are REALLY REALLY careful, this is fine but still, a little bit crazy. But since we are Software Developers, we are never too careful. We are programmers, we cause accidents. <img src='http://blog.ianuy.com/wp-includes/images/smilies/icon_lol.gif' alt=':lol:' class='wp-smiley' /> </p>
<p>So why is it important to have a dedicated build machine? Here&#8217;s why.</p>
<ol>
<li><strong>Pristine</strong> &#8211; You want to keep the build machine as clean as possible to make sure that only the needed resources are being included in the build. If your build machine also acts as your development machine, keeping a pristine state is a very tough task. When I inspected our latest Beta build, I was shocked to see that there are *.pdb (debug) files included in the install image.</li>
<li><strong>Control </strong>- It is very important to control your Build Environment. All of your builds must be coming from a standard setup from a standard state. The keyword here is standard. This means that the &#8220;exact state&#8221; of the machine used in creating Build 001 should also be used in creating Build 002. When you use your Build Machine as a Development Machine, it is almost impossible to maintain this &#8220;exact state&#8221; every time for every build. When we were migrating our product from SQL 2000 to SQL 2005, we added the SQL2005 installer to our local build machine but somehow, someone forgot to add the SQL 2005 installer to the source code repository. When we tried building from a new build machine, the installer would no longer work.</li>
<li><strong>Reliability </strong>- All builds coming from the build machine must be Reliable. If you are using your Build Machine as a Development Machine, most often the not, your builds are coming from your local copy and not from the Source Code Repository. In most cases, this is okay. But in our case where the final build will be built using the official build machine (located in the US), this is a big problem. One of the problem that we encountered is that the local copy is not in sync with the repository copy. We are Humans, sometimes we forget to check-in our changes.</li>
</ol>
<p>To solve the above problems (and since we don&#8217;t have any spare machines <img src='http://blog.ianuy.com/wp-includes/images/smilies/icon_lol.gif' alt=':lol:' class='wp-smiley' />  ), I used a Virtual Machine! Yes, I used a Virtual Machine as a Build Machine. After 3 days of fixing the build scripts and updating the unsync&#8217;d files, I was able to create a clean and working build from my VM Build Machine.</p>
<div id="attachment_384" class="wp-caption aligncenter" style="width: 300px"><a href="http://blog.ianuy.com/wp-content/uploads/2009/06/vbox_eps_cmyk2_ico.png"><img class="size-medium wp-image-384" title="VBOX" src="http://blog.ianuy.com/wp-content/uploads/2009/06/vbox_eps_cmyk2_ico-290x300.png" alt="I'm a big VirtualBox fan!" width="290" height="300" /></a><p class="wp-caption-text">I&#39;m a big VirtualBox fan!</p></div>
<p>Virtual Machines are perfect as Build Machines. You can always maintain a <strong>pristine</strong> state by creating a <a title="HOWTO: VirtualBox Snapshots. The Ins and Outs of Snapshots." href="http://ubuntuforums.org/showthread.php?t=689982" target="_blank">snapshot</a> of a freshly installed setup build environment and always building from there. Everytime that you need to create a build, you can just rollback to that pristine state. This feature of build machines gives you <strong>control</strong> over your build environment. Since you are always rolling back to a pristine state, you will then be forced to always fetch the latest copy from your source code repository! This means that you can be confident the builds coming out from your build machine is always <strong>reliable</strong>.</p>
<p>Before, I have no faith in our source code repository copy. As a result, I am always too anxious in making sure that I don&#8217;t break the local copy. There&#8217;s always that constant fear that the official copy from the Source Code Repository is broken or the official copy does not reflect the local &#8220;tested&#8221; copy. Now, I am always confident that anytime, anywhere in the company, we can always create a clean and reliable build that will work straigth from the repository. That feeling is very liberating! <img src='http://blog.ianuy.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>



Share and Enjoy:


	<a rel="nofollow" href="mailto:?subject=The%20Importance%20of%20a%20Dedicated%20Build%20Machine&amp;body=http%3A%2F%2Fblog.ianuy.com%2F2009%2F06%2F07%2Fthe-importance-of-a-dedicated-build-machine%2F" title="E-mail this story to a friend!"><img src="http://blog.ianuy.com/wp-content/plugins/sociable/images/email_link.png" title="E-mail this story to a friend!" alt="E-mail this story to a friend!" class="sociable-hovers" /></a>
	<a rel="nofollow" target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fblog.ianuy.com%2F2009%2F06%2F07%2Fthe-importance-of-a-dedicated-build-machine%2F&amp;title=The%20Importance%20of%20a%20Dedicated%20Build%20Machine&amp;bodytext=%0D%0A%0D%0AWhen%20I%20was%20an%20Intern%20at%20a%20large%20Global%20500%20company%2C%20my%20major%20responsibility%20is%20to%20deliver%20a%20Software%20Delivery%20process%20that%20uses%20the%20software%20engineering%20practice%20called%20Continuous%20Integration.%20In%20simple%20terms%2C%20I%20am%20responsible%20for%20a%20project%20to%20cr" title="Digg"><img src="http://blog.ianuy.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fblog.ianuy.com%2F2009%2F06%2F07%2Fthe-importance-of-a-dedicated-build-machine%2F&amp;title=The%20Importance%20of%20a%20Dedicated%20Build%20Machine" title="Reddit"><img src="http://blog.ianuy.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow" target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fblog.ianuy.com%2F2009%2F06%2F07%2Fthe-importance-of-a-dedicated-build-machine%2F&amp;title=The%20Importance%20of%20a%20Dedicated%20Build%20Machine&amp;notes=%0D%0A%0D%0AWhen%20I%20was%20an%20Intern%20at%20a%20large%20Global%20500%20company%2C%20my%20major%20responsibility%20is%20to%20deliver%20a%20Software%20Delivery%20process%20that%20uses%20the%20software%20engineering%20practice%20called%20Continuous%20Integration.%20In%20simple%20terms%2C%20I%20am%20responsible%20for%20a%20project%20to%20cr" title="del.icio.us"><img src="http://blog.ianuy.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://twitter.com/home?status=The%20Importance%20of%20a%20Dedicated%20Build%20Machine%20-%20http%3A%2F%2Fblog.ianuy.com%2F2009%2F06%2F07%2Fthe-importance-of-a-dedicated-build-machine%2F" title="Twitter"><img src="http://blog.ianuy.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow" target="_blank" href="http://slashdot.org/bookmark.pl?title=The%20Importance%20of%20a%20Dedicated%20Build%20Machine&amp;url=http%3A%2F%2Fblog.ianuy.com%2F2009%2F06%2F07%2Fthe-importance-of-a-dedicated-build-machine%2F" title="Slashdot"><img src="http://blog.ianuy.com/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fblog.ianuy.com%2F2009%2F06%2F07%2Fthe-importance-of-a-dedicated-build-machine%2F&amp;t=The%20Importance%20of%20a%20Dedicated%20Build%20Machine" title="Facebook"><img src="http://blog.ianuy.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fblog.ianuy.com%2F2009%2F06%2F07%2Fthe-importance-of-a-dedicated-build-machine%2F&amp;t=The%20Importance%20of%20a%20Dedicated%20Build%20Machine" title="MySpace"><img src="http://blog.ianuy.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow" target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fblog.ianuy.com%2F2009%2F06%2F07%2Fthe-importance-of-a-dedicated-build-machine%2F&amp;title=The%20Importance%20of%20a%20Dedicated%20Build%20Machine&amp;annotation=%0D%0A%0D%0AWhen%20I%20was%20an%20Intern%20at%20a%20large%20Global%20500%20company%2C%20my%20major%20responsibility%20is%20to%20deliver%20a%20Software%20Delivery%20process%20that%20uses%20the%20software%20engineering%20practice%20called%20Continuous%20Integration.%20In%20simple%20terms%2C%20I%20am%20responsible%20for%20a%20project%20to%20cr" title="Google Bookmarks"><img src="http://blog.ianuy.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow" target="_blank" href="http://www.dotnetkicks.com/kick/?url=http%3A%2F%2Fblog.ianuy.com%2F2009%2F06%2F07%2Fthe-importance-of-a-dedicated-build-machine%2F&amp;title=The%20Importance%20of%20a%20Dedicated%20Build%20Machine" title="DotNetKicks"><img src="http://blog.ianuy.com/wp-content/plugins/sociable/images/dotnetkicks.png" title="DotNetKicks" alt="DotNetKicks" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.ianuy.com/2009/06/07/the-importance-of-a-dedicated-build-machine/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Coding Horror 01: Readability vs Efficiency</title>
		<link>http://blog.ianuy.com/2009/04/26/coding-horror-01-readability-vs-efficiency/</link>
		<comments>http://blog.ianuy.com/2009/04/26/coding-horror-01-readability-vs-efficiency/#comments</comments>
		<pubDate>Sun, 26 Apr 2009 12:15:08 +0000</pubDate>
		<dc:creator>Ian Uy</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Coding Horror]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://blog.ianuy.com/?p=173</guid>
		<description><![CDATA[Back in College, I have a friend who&#8217;s programming prowess is so godly that it can surpass or match mine  . He is a C++ Junkie and belongs to the Java Cult. His mental agility is so great that he can beat me in writing complex algorithms anytime of the day. In fact, I [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_174" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.ianuy.com/wp-content/uploads/2009/04/coding-horror-stickers.jpg"><img class="size-medium wp-image-174" title="coding-horror-stickers" src="http://blog.ianuy.com/wp-content/uploads/2009/04/coding-horror-stickers-300x225.jpg" alt="My First Official &quot;Coding Horror&quot; Encouter" width="300" height="225" /></a><p class="wp-caption-text">My First Official &quot;Coding Horror&quot; Encounter</p></div>
<p>Back in College, I have a friend who&#8217;s programming prowess is so godly that it can surpass or match mine <img src='http://blog.ianuy.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> . He is a C++ Junkie and belongs to the Java Cult. His mental agility is so great that he can beat me in writing complex algorithms anytime of the day. In fact, I chose him to be the &#8220;Architect&#8221; for our project in Compiler Theory Class (<a title="Kompayler Studio 2008: The First Tagalog Kompayler, Programming Language and IDE" href="http://ianuy.multiply.com/journal/item/40" target="_blank">Kompayler Studio 2008: The First Tagalog Kompayler, Programming Language and IDE</a>). He is THAT great of a programmer&#8230; BUT</p>
<blockquote>
<h5 style="text-align: center;">Being a Great Programmer is not the same as being a Great Software Developer</h5>
</blockquote>
<p>&#8220;Aren&#8217;t programming and software development the same?&#8221; Uhhmm, NO. Programming is just a single part of Software Development. Software Development, on the other hand, is an entirely different song and dance.</p>
<p>In one of our converstations, I told him that instead of reading books about programming he should try to read books about software development. I gave him that advice not because I want him to suck in programming (I&#8217;m not that envious). I gave him that advice because I want him to realize that programming alone won&#8217;t make a great software product and that programming prowess alone won&#8217;t give him the best programming job around&#8230; at least here in the Philippines.</p>
<p>One of our main differences is reflected on how we write code (which eventually shows in our software). For example, say that we have a project that requires us to deliver a Simple Number Sorting Application that will ask the user to input 50 numbers and sort it. This project is resource constrained in such a way that we need to deliver it in 2 days.</p>
<p><span id="more-173"></span></p>
<p style="text-align: left;">What I would do is use a pre-existing <strong>bubble sort</strong> algorithm available in the class library (in .NET, I suppose), then I would add additional functionality, then create a test harness (unit test) to test my functions and then I&#8217;m done with the &#8220;coding&#8221; part. Then I would use the rest of my time to design an intuitive user-interface, provide a user manual and work on the packaging.</p>
<div id="attachment_180" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.ianuy.com/wp-content/uploads/2009/04/simplesorter.jpg"><img class="size-medium wp-image-180" title="simplesorter" src="http://blog.ianuy.com/wp-content/uploads/2009/04/simplesorter-300x245.jpg" alt="My Simple Sorting Application" width="300" height="245" /></a><p class="wp-caption-text">My Simple Sorting Application</p></div>
<p style="text-align: left;">On the other hand, my friend would create a <strong>complex multi-threaded sorting algorithm</strong> that will have a runtime efficiency of  O(Log N). Not only that, it will be written in Haskel (or any other hardcore programming language) and it will also be invoked via command-line! So hackerish. <img src='http://blog.ianuy.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p style="text-align: center;">
<div id="attachment_181" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.ianuy.com/wp-content/uploads/2009/04/complexsorter.jpg"><img class="size-medium wp-image-181" title="complexsorter" src="http://blog.ianuy.com/wp-content/uploads/2009/04/complexsorter-300x151.jpg" alt="His Complex Sorting &quot;Tool&quot;" width="300" height="151" /></a><p class="wp-caption-text">His Complex Sorting &quot;Tool&quot;</p></div>
<p>My point is simple&#8230; <em>In Software Development, there is a thing called <span style="text-decoration: underline;"><strong>Tradeoffs</strong></span></em>. What do I mean by Tradeoff? Take the above example. I traded-off the uber-cool <strong>complex multi-threaded sorting algorithm </strong>to <strong>USABILITY</strong> <strong>AND FUNCTIONALITY </strong>which, by the way, has more practical and positive impact to my users. You could argue that I suck for using bubble sort and not the <strong>complex multi-threaded sorting algorithm </strong>and you could also argue that my bubble sort has a runtime complexity of O(N^2). But being a Software Developer, I know that using that &#8220;<strong>complex multi-threaded sorting algorithm&#8221; </strong>would only be faster by 0.000000000000001312 seconds (remember, we are only sorting 50 elements) and that &#8220;improvement&#8221; will not be of any <em>significant </em>use to my end-users and I might as well use my time in creating extra  features, such as Print and Copy to Clipboard, that will surely make my product more functional and easy to use.</p>
<p>At work, I am working on a project to &#8220;migrate&#8221; our products to Vista. To Migrate meaning &#8220;<em>to make it compatible with Vista&#8221;</em>. One of our product has an <strong>Autorun</strong> executable which will decide which &#8220;components&#8221; (SQL Server, VC++ 8.0 Redistributable, .NET Framework) to install. During a routine test run at the Test Deparment, they found out that this certain product is not working on Vista and filled a Track against it. The said Track was assigned to me and I&#8217;m expected to fix it. So I pulled the Visual Basic 6.0 source code of the Autorun executable from our TFS and performed an investigation. While investigating, I saw a very weird block of code&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Private</span> <span style="color: #000080;">dim</span> VCREDIST <span style="color: #000080;">as</span> <span style="color: #000080;">long</span>
<span style="color: #000080;">Private</span> <span style="color: #000080;">dim</span> NETFRAMEWORK <span style="color: #000080;">as</span> <span style="color: #000080;">long</span>
<span style="color: #000080;">Private</span> <span style="color: #000080;">dim</span> SQLSERVER <span style="color: #000080;">as</span> <span style="color: #000080;">long</span>
<span style="color: #000080;">Private</span> <span style="color: #000080;">dim</span> COMPONENT1 <span style="color: #000080;">as</span> <span style="color: #000080;">long</span>
<span style="color: #000080;">Private</span> <span style="color: #000080;">dim</span> COMPONENT2 <span style="color: #000080;">as</span> <span style="color: #000080;">long</span>
<span style="color: #000080;">Private</span> <span style="color: #000080;">dim</span> COMPONENT3 <span style="color: #000080;">as</span> <span style="color: #000080;">long</span>
<span style="color: #000080;">Private</span> <span style="color: #000080;">dim</span> COMPONENT16 <span style="color: #000080;">as</span> <span style="color: #000080;">long</span>
&nbsp;
VCREDIST = 1
NETFRAMEWORK = 2
SQLSERVER = 4
COMPONENT1 = 8
COMPONENT2 = 16
COMPONENT3 = 32
COMPONENT16 = 65536</pre></div></div>

<p>If you see a 1 or a 0 in the code, its pretty normal because you know that it is a <em>flag</em> for something . But if you see a 7 or 16 or 32, you know something is wrong. So I ignored that and went straight to the actual function that does the shell execution to install the component and I saw something like this&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">While</span> ComponentInstalled != 13
&nbsp;
	installNum = GetNextComponent	
&nbsp;
	<span style="color: #000080;">if</span> installNum <span style="color: #000080;">AND</span> 1 <span style="color: #000080;">then</span>
		InstallComponent(installNum)
	<span style="color: #000080;">else</span>
		installNum = installNum * 2
	<span style="color: #000080;">end</span> <span style="color: #000080;">if</span>
&nbsp;
<span style="color: #000080;">End</span> <span style="color: #000080;">While</span></pre></div></div>

<p>I was dumbfounded and stupified, why is there an &#8220;AND 1&#8243; in that code? and what is the purpose of the * 2? So I asked my manager for his input. And after staring at the code for 30 minutes, my brilliant manager shouted &#8220;That code is using <strong>BIT PATTERNS!</strong>&#8220;. Instantly, I understood what the code does.</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;">VCREDIST = 1                 <span style="color: #008000;">'0000 0000 0001
</span>NETFRAMEWORK = 2        <span style="color: #008000;">'0000 0000 0011
</span>SQLSERVER = 4              <span style="color: #008000;">'0000 0000 0111
</span>COMPONENT1 = 8           <span style="color: #008000;">'0000 0000 1111
</span>COMPONENT2 = 16          <span style="color: #008000;">'0000 0001 1111
</span>COMPONENT3 = 32          <span style="color: #008000;">'0000 0011 1111
</span>COMPONENT16 = 65536    '1111 1111 1111</pre></div></div>

<p>That block of code is actually a binary pattern used for flagging the components. Each placeholder in that binary pattern is a FLAG (1 or 0) which actually tells the function GetNextComponent if that component should be installed or not. The *2 is used for shifthing the binary pattern so that the active placeholder for a certain flag will be at the rightmost (last bit) of the pattern! Brilliant!</p>
<p>To solve the issue, I just needed to force the Autorun to Install <strong>VCREDIST</strong> in Vista by adding this line of code in the Vista Condition of the <em>GetNextComponent</em> function:</p>
<pre>VCREDIST = VCREDIST OR 1</pre>
<p>So it will always install the Visual C++ 8.0 Redistributable in Vista. The actual problem is that the Autorun Executable thinks that Vista does not need the redistributable and will not install it.  That&#8217;s why our product that needs the redistributable will not work.</p>
<p>I have great admiration for the brilliance of the programmer who wrote this. The method is so efficient that instead of declaring 12 Integers for Flag, he would only need to use a single long! My manager told me that the one who wrote this application is actually a &#8220;CONTROLLER&#8221; programmer. A type of programmer in our organization that writes the firmwares for our hardware controllers.</p>
<p>When writing firmwares that needs to be tight and needs to run in realtime, time complexity is your biggest enemy and you need to code against that. But in an Autorun application for installation, you <strong>DONT!</strong> In this example, <span style="text-decoration: underline;"><em><strong>Readability and Maintability was traded-off to efficiency that was not even needed!</strong></em></span> In turn, a simple issue that can be fixed in a matter of seconds was fixed in half a day.</p>
<p>As Software Developers, we should have the right mindset to decide on what trade offs are necessary. We should not only be Great Programmers who can write great codes but we should transcend to being Great Software Developers who can &#8220;take a concept, build a team, set up state of the art development processes, design a software product, the right software product, and produce it. Not just any software product: a high quality software product that solves a problem and delights your users. With documentation. A web page. A setup program. Test cases. Norwegian versions. Bokmål and Nynorsk. Appetizers, dessert, and twenty seven eight-by-ten color glossy photographs with circles and arrows and a paragraph on the back of each one explaining what each one was.&#8221;</p>
<p>As for my Friend, he is now working at Oracle. My only wish is that he would be able to work on their database management system where efficiency has higher value than code-readability.</p>



Share and Enjoy:


	<a rel="nofollow" href="mailto:?subject=Coding%20Horror%2001%3A%20Readability%20vs%20Efficiency&amp;body=http%3A%2F%2Fblog.ianuy.com%2F2009%2F04%2F26%2Fcoding-horror-01-readability-vs-efficiency%2F" title="E-mail this story to a friend!"><img src="http://blog.ianuy.com/wp-content/plugins/sociable/images/email_link.png" title="E-mail this story to a friend!" alt="E-mail this story to a friend!" class="sociable-hovers" /></a>
	<a rel="nofollow" target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fblog.ianuy.com%2F2009%2F04%2F26%2Fcoding-horror-01-readability-vs-efficiency%2F&amp;title=Coding%20Horror%2001%3A%20Readability%20vs%20Efficiency&amp;bodytext=%0A%0D%0ABack%20in%20College%2C%20I%20have%20a%20friend%20who%27s%20programming%20prowess%20is%20so%20godly%20that%20it%20can%20surpass%20or%20match%20mine%20%3AD.%20He%20is%20a%20C%2B%2B%20Junkie%20and%20belongs%20to%20the%20Java%20Cult.%20His%20mental%20agility%20is%20so%20great%20that%20he%20can%20beat%20me%20in%20writing%20complex%20algorithms%20anytime%20" title="Digg"><img src="http://blog.ianuy.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fblog.ianuy.com%2F2009%2F04%2F26%2Fcoding-horror-01-readability-vs-efficiency%2F&amp;title=Coding%20Horror%2001%3A%20Readability%20vs%20Efficiency" title="Reddit"><img src="http://blog.ianuy.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow" target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fblog.ianuy.com%2F2009%2F04%2F26%2Fcoding-horror-01-readability-vs-efficiency%2F&amp;title=Coding%20Horror%2001%3A%20Readability%20vs%20Efficiency&amp;notes=%0A%0D%0ABack%20in%20College%2C%20I%20have%20a%20friend%20who%27s%20programming%20prowess%20is%20so%20godly%20that%20it%20can%20surpass%20or%20match%20mine%20%3AD.%20He%20is%20a%20C%2B%2B%20Junkie%20and%20belongs%20to%20the%20Java%20Cult.%20His%20mental%20agility%20is%20so%20great%20that%20he%20can%20beat%20me%20in%20writing%20complex%20algorithms%20anytime%20" title="del.icio.us"><img src="http://blog.ianuy.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://twitter.com/home?status=Coding%20Horror%2001%3A%20Readability%20vs%20Efficiency%20-%20http%3A%2F%2Fblog.ianuy.com%2F2009%2F04%2F26%2Fcoding-horror-01-readability-vs-efficiency%2F" title="Twitter"><img src="http://blog.ianuy.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow" target="_blank" href="http://slashdot.org/bookmark.pl?title=Coding%20Horror%2001%3A%20Readability%20vs%20Efficiency&amp;url=http%3A%2F%2Fblog.ianuy.com%2F2009%2F04%2F26%2Fcoding-horror-01-readability-vs-efficiency%2F" title="Slashdot"><img src="http://blog.ianuy.com/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fblog.ianuy.com%2F2009%2F04%2F26%2Fcoding-horror-01-readability-vs-efficiency%2F&amp;t=Coding%20Horror%2001%3A%20Readability%20vs%20Efficiency" title="Facebook"><img src="http://blog.ianuy.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fblog.ianuy.com%2F2009%2F04%2F26%2Fcoding-horror-01-readability-vs-efficiency%2F&amp;t=Coding%20Horror%2001%3A%20Readability%20vs%20Efficiency" title="MySpace"><img src="http://blog.ianuy.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow" target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fblog.ianuy.com%2F2009%2F04%2F26%2Fcoding-horror-01-readability-vs-efficiency%2F&amp;title=Coding%20Horror%2001%3A%20Readability%20vs%20Efficiency&amp;annotation=%0A%0D%0ABack%20in%20College%2C%20I%20have%20a%20friend%20who%27s%20programming%20prowess%20is%20so%20godly%20that%20it%20can%20surpass%20or%20match%20mine%20%3AD.%20He%20is%20a%20C%2B%2B%20Junkie%20and%20belongs%20to%20the%20Java%20Cult.%20His%20mental%20agility%20is%20so%20great%20that%20he%20can%20beat%20me%20in%20writing%20complex%20algorithms%20anytime%20" title="Google Bookmarks"><img src="http://blog.ianuy.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow" target="_blank" href="http://www.dotnetkicks.com/kick/?url=http%3A%2F%2Fblog.ianuy.com%2F2009%2F04%2F26%2Fcoding-horror-01-readability-vs-efficiency%2F&amp;title=Coding%20Horror%2001%3A%20Readability%20vs%20Efficiency" title="DotNetKicks"><img src="http://blog.ianuy.com/wp-content/plugins/sociable/images/dotnetkicks.png" title="DotNetKicks" alt="DotNetKicks" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.ianuy.com/2009/04/26/coding-horror-01-readability-vs-efficiency/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>

