<?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; Programming</title>
	<atom:link href="http://blog.ianuy.com/tag/programming/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>On the High Turnover Rate of Software Developers or How to Retain your Best Software Developers and Programmers</title>
		<link>http://blog.ianuy.com/2010/09/26/on-the-high-turnover-rate-of-software-developers-or-how-to-retain-your-best-software-developers-and-programmers/</link>
		<comments>http://blog.ianuy.com/2010/09/26/on-the-high-turnover-rate-of-software-developers-or-how-to-retain-your-best-software-developers-and-programmers/#comments</comments>
		<pubDate>Sun, 26 Sep 2010 11:10:40 +0000</pubDate>
		<dc:creator>Ian Uy</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Job]]></category>
		<category><![CDATA[Programmers]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://blog.ianuy.com/?p=943</guid>
		<description><![CDATA[
 It is not exactly news that programmers love to quit their job. It is an industry-wide obsession. The annual turnover rate for the High-Tech industry in 2008 is a little bit above 20% (2 out of 10 employees quit every year). A typical programmer on a typical software company stays for about 23 months [...]]]></description>
			<content:encoded><![CDATA[<p><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.ianuy.com%2F2010%2F09%2F26%2Fon-the-high-turnover-rate-of-software-developers-or-how-to-retain-your-best-software-developers-and-programmers%2F&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:70px;" allowTransparency="true"></iframe><br />
<a href="http://blog.ianuy.com/wp-content/uploads/2010/09/resign.jpg"><img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="_resign" src="http://blog.ianuy.com/wp-content/uploads/2010/09/resign_thumb.jpg" border="0" alt="_resign" width="278" height="278" /></a> It is not exactly news that programmers love to quit their job. It is an industry-wide obsession. The annual turnover rate for the High-Tech industry in <a title="Turnover data collected by CompData" href="http://compforce.typepad.com/compensation_force/2009/03/2008-turnover-rates-by-industry.html" target="_blank">2008</a> is a little bit above 20% (2 out of 10 employees quit every year). A typical programmer on a typical software company stays for about 23 months on average. For an employer, these figures are scary – especially if you employ skilled workers such as programmers and software developers. High turnover rates of skilled professionals can pose as a risk to the business or organization, due to the human capital (such as skills, training, and knowledge) lost.</p>
<p>Having been a newbie software developer (and I’m still fairly “new”), I did not understood why software developers in our company are quitting. Having been a fresh graduate, I was, then, still amazed by the fact that there are people out there in the real world that will pay me real world money just to write code – a hobby that I will do for free. I was puzzled. We are working in an environment that fosters creativity and innovation, a company that strictly subscribes to the “<a title="Thou shall have two monitors!" href="http://www.codinghorror.com/blog/2006/08/the-programmers-bill-of-rights.html" target="_blank">programmers’ bill of rights</a>”, and a company that scores high in the <a title="Hell yeah, we use souce control. Who doesn't?" href="http://www.joelonsoftware.com/articles/fog0000000043.html" target="_blank">Joel Test</a> (11/12).  Those, plus the fact that we can surf Facebook anytime and drink all the brewed coffee in the pantry, made me believe that this is the best company to work for locally; it made me believe that anyone leaving our company is insane.</p>
<p><a href="http://blog.ianuy.com/wp-content/uploads/2010/09/1783Hackers_and_Painters_Big_Ideas_from_the_Computer_Age.jpg"><img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="_1783-Hackers_and_Painters_Big_Ideas_from_the_Computer_Age" src="http://blog.ianuy.com/wp-content/uploads/2010/09/1783Hackers_and_Painters_Big_Ideas_from_the_Computer_Age_thumb.jpg" border="0" alt="_1783-Hackers_and_Painters_Big_Ideas_from_the_Computer_Age" width="159" height="242" /></a> Just a few months after starting my job (I had my internship there for 6 months), one of the <strong>bestest</strong> programmer I know (he’s actually a “software architect”, but hates being called one), my mentor when I was still an intern, filed his letter of resignation. This guy is one of the most passionate programmer I know. He gets it. <a title="Hackers and Painters" href="http://blog.ianuy.com/2009/09/17/ordinary-programmers-vs-great-hackers/" target="_blank">Paul Graham</a> classifies him as a hacker and he actually worked for Microsoft (in Redmond, not the local whatever-they-are-doing-there branch).</p>
<p>For some, asking people why they quit their job is taboo; I actually enjoy having those type of conversation. Gives me insight. So I asked the fallen hacker, “<strong>Why did you quit?</strong>”. He pointed to the picture of his new born baby (his desktop wallpaper) and said with an enthusiastic smile “<strong>He is my new priority</strong>”. He then explained to me, in a fashion that I would understand, why working overseas means “better opportunity” for his family. Being a bit unconvinced with his explanation, I asked him “<strong>Is that all? Better opportunity</strong>?” and he replied back with a playful smile, “<strong>In my new job, I will be able to code again. I will no longer be a ‘Word Programmer’”</strong>. He has always joked about being a Word Programmer – programming in Microsoft Word using narrative texts (use cases, scenarios, etc) and <a title="Those documents with boxes and lines and tiny little captions" href="http://en.wikipedia.org/wiki/Unified_Modeling_Language" target="_blank">UML diagrams</a>; programming by story telling. He was indeed a hacker.</p>
<p>Having spent a year and a half on this job, I can say that I now have a vague idea on why programmers (or I.T people, in general) quit. Even though I’m only a year-and-half year old in corporate servitude, I had been handled by four managers and had been transferred to four teams and that gave me great insights on the crucial dynamics that affects employee turnovers. In my year-and-half stay, I have seen three managers, a project manager, two architects, four senior developers and a handful of intermediate developers go. Just a few months ago, four of my teammates left. The statistics above is a little off; <strong>it is more than 20%</strong>.</p>
<p><span id="more-943"></span></p>
<h1>So why do programmers quit?</h1>
<p><a href="http://blog.ianuy.com/wp-content/uploads/2010/09/twofactormodel.png"><img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="_two-factor-model" src="http://blog.ianuy.com/wp-content/uploads/2010/09/twofactormodel_thumb.png" border="0" alt="_two-factor-model" width="459" height="341" /></a> There are a lot of <a title="Models of Turnover" href="http://en.wikipedia.org/wiki/Turnover_%28employment%29#Models_of_turnover" target="_blank">models</a> that scientifically explains turnover, but most of them does not really cover the programmers psyche because most of them are written three decades ago. These <a title="Two factor theory" href="http://en.wikipedia.org/wiki/Two_factor_theory" target="_blank">models</a> are not exactly wrong; they just don’t capture how programmers think and react.</p>
<p>So let me present to you my model. Let’s call it the Programmer Turnover Model. There are only two controlling variables on this model: <strong>Opportunities</strong> and <strong>Grievances</strong>. When these two factors achieve “equilibrium” (fancy word eh?), the employee will finally pull the trigger and call it quits. Seldom do I see or hear that a programmer quits just by one of these controlling variables; <strong>it is usually a combination of both</strong>. But it is not unheard of that an employee quits just because of opportunities or grievances: If you’re boss is verbally abusing (Grievances) you everyday, that is enough reason to quit.</p>
<h2>Opportunities</h2>
<p><strong><a href="http://blog.ianuy.com/wp-content/uploads/2010/09/grassgreener.jpg"><img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="_grass-greener" src="http://blog.ianuy.com/wp-content/uploads/2010/09/grassgreener_thumb.jpg" border="0" alt="_grass-greener" width="349" height="286" /></a> </strong><strong>Opportunities</strong> are the voice inside us that always yells “The grass is greener on the other side”. It is the greedy side of the human emotion. It is the human emotion that seeks larger paychecks and better benefits.</p>
<p><strong>Programmers have all the incentives in the world to quit</strong>. In fact, if you want to suddenly increase your salary, all you have to do is quit your job and find another one. A 25% increase in salary between job hops is typical. In fact, most local programmers do it. You don’t even need to be highly competent to do this; you just need to impress the interviewers and pass the interview. In an industry that caters to outsourced work (typically boring business systems) and software maintenance jobs, the bar that is being set is not that high (not “Google high”). Fact of the matter is, most grown-ups (including my mom) advice I.T. workers to just “get a few years of experience and switch jobs”.</p>
<p>Local industry culture believes that the sooner you get overseas, the better it is for you. Those programmers that work or have worked overseas are perceived to be “successful”. And what better way to increase your chance working abroad than to beef-up your resume with “experiences”? Not only that you get larger paychecks and better benefits when hopping jobs, you also <strong>get a set of fresh credentials to put into your resume</strong>. When you work for a single company, you’re stuck with their technology. And in an industry where your skills are obsolete within five years (max), being stuck in a technology is a really really bad thing for you.</p>
<p>It seems that the game is rigged for the employers. Employers are nearly powerless in stopping the greedy side of human emotion. Aside for paying large sums of cash to these spoiled programmers, they incur the risk of losing expensive human capital. All hope is not lost, the human emotion provides some form of protection against job hoppers. The loving side of the human emotion.</p>
<p>A few moments ago, I made it sound that it is so easy to job hop. Well, it is for soulless programmers (and about half of programmers are). But programmers are human too and they possess some of that soft, caring, vulnerable human emotion. People just don’t quit their job out of greediness. They are attached to their officemates, they been used to the smell of that particular brand of brewed coffee in the morning, they love how their $5 dollar computer chair squeaks when they lean back while waiting for their programs to compile, they love those once-a-month company parties, they know their way into their programs and they’re quite competent in it, they love to see their crush on the opposite cubicle, they are considered the domain expert inside the department. <strong>Humans resist change because attachments are hard to break.</strong></p>
<p>It is painful to leave a company and that is what stops most people to quit their job even if they know that there are better opportunities out there.</p>
<h2>Grievances</h2>
<p><strong><a href="http://blog.ianuy.com/wp-content/uploads/2010/09/ihatemybossbutton.jpg"><img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="_i-hate-my-boss-button" src="http://blog.ianuy.com/wp-content/uploads/2010/09/ihatemybossbutton_thumb.jpg" border="0" alt="_i-hate-my-boss-button" width="235" height="247" /></a> </strong><strong>Grievances </strong>are the devil’s advocate that whispers “Stop taking this sh*t and quit”. <strong>Opportunities </strong>provide all the incentives in the world to switch jobs and although the touchy human emotion tells us to stay because it is painful to leave, grievances makes it justifiable and easy to quit.</p>
<p>Grievances builds up over time that’s why it’s hard to avoid it. It stacks up high. Each person have a certain threshold on how high they can keep their grievances stack before it falls down and crumble (translation: Each person can only take so much bullshit).</p>
<p>There are many forms of grievances, but all of them contributes to the metaphorical grievances stack:</p>
<ul>
<li>My company is still coding in Cobol when there are better technologies available.</li>
<li>We don’t have source control.</li>
<li>My boss is a back-seat driver. His hobbies are micromanagement and micromanagement.</li>
<li>The elevator takes forever.</li>
<li>The air conditioner is too cold.</li>
<li>The code base is so poorly written that it breaks in 27 different places when you add a single line of code. The previous developer maintaining the code base is a literal arts major.</li>
<li>We are responsible for testing our own code.</li>
<li>My teammates are bozos.</li>
<li>I hate my project. It’s not fun and exciting. It’s grunt work.</li>
<li>I have written just 150 lines of code in the last 2 years.</li>
</ul>
<p>Grievances have many forms but grievances are simply things that gets listed down in the “I do not want” column of your employees checklist.</p>
<p>The good thing about grievances is that managers and employers can manage and control them. Unlike <strong>Opportunities</strong> where employers are powerless, Grievances can be managed and controlled. It’s not easy but it’s doable. And the first thing that needs to happen is <strong>communication</strong>.</p>
<p><strong>If you’re an employer/manager working with programmers, understand that your programmers have all the incentives in the world to leave you for better opportunities. Do not make it easy for them by giving them reasons to quit.</strong></p>
<h1>The Price of Turnover in Software Development</h1>
<p><a href="http://blog.ianuy.com/wp-content/uploads/2010/09/mythicalmanmonth.jpg"><img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="_mythical-man-month" src="http://blog.ianuy.com/wp-content/uploads/2010/09/mythicalmanmonth_thumb.jpg" border="0" alt="_mythical-man-month" width="206" height="293" /></a> In his influential book, “<a title="READ THIS NOW" href="http://www.amazon.com/Mythical-Man-Month-Software-Engineering-Anniversary/dp/0201835959" target="_blank">The Mythical Man-Month</a>”, Fred Brooks emphasized the importance of <strong>Conceptual Integrity</strong> in software design and architecture:</p>
<blockquote><p>Most European cathedrals show differences in plan or architectural style between parts built in different generations by different builders. The later builders were tempted to &#8220;improve&#8221; upon the designs of the earlier ones, to reflect both changes in fashion and differences in individual taste. So the peaceful Norman transept abuts and contradicts the soaring Gothic nave, and the result proclaims the pridefulness of the builders as much as the glory of God.</p>
<p>Against these, the architectural unity of Reims stands in glorious contrast. The joy that stirs the beholder comes as much from the integrity of the design as from any particular excellences. As the guidebook tells, this integrity was achieved by the self-abnegation of eight generations of builders, each of whom sacrificed some of his ideas so that the whole might be of pure design. The result proclaims not only the glory of God, but also His power to salvage fallen men from their pride.</p>
<p>Even though they have not taken centuries to build, most programming systems reflect conceptual disunity far worse than that of cathedrals. <strong>Usually this arises not from a serial succession of master designers</strong>, <strong>but from the separation of design into many tasks done by many men</strong>.</p>
<p><strong>I will contend that conceptual integrity is the most important consideration in system design</strong>. It is better to have a system omit certain anomalous features and improvements, but to reflect one set of design ideas, than to have one that contains many good but independent and uncoordinated ideas.</p></blockquote>
<p>The conceptual integrity of software is a measure of how well software conforms to a single, simple set of design principles. When done properly, it provides the most <a href="http://en.wikipedia.org/wiki/Function_%28engineering%29">functionality</a> using the simplest <a href="http://en.wikipedia.org/wiki/Programming_idiom">idioms</a>. It makes software easier to use <strong>by making it simple to create and learn</strong>.</p>
<p>Conceptual integrity is achieved when the software’s design proceeds from a small number of agreeing individuals. For software to maintain conceptual integrity, the design must be controlled by a single, small group.</p>
<p>When turnover is high, the conceptual integrity of your product is being sacrificed. And because conceptual integrity is the most important consideration in system design, having bad conceptual integrity will make your product hard to use. This in turn will affect your sales and eventually your bottom line.</p>
<p>Not only will the loss of conceptual integrity of your product negatively affects your sale, it will also affect the morale of your best programmers. High turnover rates induces the <strong><a title="The codebase stinks" href="http://en.wikipedia.org/wiki/Software_Peter_principle" target="_blank">Software Peter Principle</a></strong>:</p>
<blockquote><p>The <strong>software Peter principle</strong> is used in <a href="http://en.wikipedia.org/wiki/Software_engineering">software engineering</a> to describe a dying project which has little by little become too complex to be understood even by its own developers.</p>
<p>It is well known in the industry as a silent killer of projects, and by the time the <a href="http://en.wikipedia.org/wiki/Symptom">symptoms</a> arise it is often too late to do anything about it. Good managers can avoid this disaster by establishing clear coding practices where unnecessarily complicated code and design is avoided.</p></blockquote>
<p>When your project becomes too complex to be understood by your best programmers, they will be naturally be forced to rewrite it. They will go into their manager’s office and ask for a re-write, the manager’s will then disagree because there are no “business reasons” to do so (and maybe they are right because “<a title="Things you should never do" href="http://www.joelonsoftware.com/articles/fog0000000069.html" target="_blank">rewriting is probably the ‘single worst strategic mistake that any software company can make</a>’”), so you’re best programmers go back to their cubicle grumpy and dives into the unmaintainable piece-of-crap that is your codebase. Soon, they quit (because there are better opportunities and you gave them enough reason to leave you).</p>
<p>The managers then instruct their H.R. people to hire a new software developer to maintain the unmaintainable codebase. But since the programmer is new, and inexperienced,  he makes implementation choices that work but have unintended negative consequences. Further degrading the conceptual integrity of your product; making it increasingly difficult to understand. It’s a death spiral.</p>
<p>If there is one thing that the best programmers hate other than maintaining crappy software, it is working with incompetent programmers. And because you have a crappy codebase and you need software “maintainers” to maintain your codebase, you hire cheap, incompetent programmers and that will send you down further in the death spiral. <a title="What Happened to Yahoo?" href="http://www.paulgraham.com/yahoo.html" target="_blank">Paul Graham</a> puts it nicely in his essay “What Happened to Yahoo!”:</p>
<blockquote><p>Microsoft (back in the day), Google, and Facebook have all been obsessed with hiring the best programmers. Yahoo wasn&#8217;t. They preferred good programmers to bad ones, but they didn&#8217;t have the kind of single-minded, almost obnoxiously elitist focus on hiring the smartest people that the big winners have had.</p>
<p>Why would great programmers want to work for a company that didn&#8217;t have a hacker-centric culture, as long as there were others that did? I can imagine two reasons: if they were paid a huge amount, or if the domain was interesting and none of the companies in it were hacker-centric. Otherwise you can&#8217;t attract good programmers to work in a suit-centric culture. And without good programmers you won&#8217;t get good software, no matter how many people you put on a task, or how many procedures you establish to ensure &#8220;quality.&#8221;</p>
<p><strong>In technology, once you have bad programmers, you&#8217;re doomed.</strong> I can&#8217;t think of an instance where a company has sunk into technical mediocrity and recovered. Good programmers want to work with other good programmers. So once the quality of programmers at your company starts to drop, you enter a death spiral from which there is no recovery.</p></blockquote>
<p>Turnover reduces the conceptual integrity of your product. When there is no conceptual integrity, your product becomes hard to use and hard to maintain for programmers. The programmers maintaining the products hate the code so much that they quit. You hire new inexperienced programmers that further reduces the conceptual integrity of your product. You enter into a death spiral and you can no longer attract the best programmers because your <a title="In computer programming, code smell is any symptom in the source code of a program that possibly indicates a deeper problem." href="http://en.wikipedia.org/wiki/Code_smell" target="_blank">code stinks</a>. You enter another death spiral from which there is no recovery. <strong>That is the price of high turnover in software development: You lose your best talents then you lose your product and eventually your company.</strong></p>
<h1>How <span style="text-decoration: underline;">NOT</span> to Retain your Best Software Developers and Programmers</h1>
<p><a href="http://blog.ianuy.com/wp-content/uploads/2010/09/slavery.jpg"><img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="_slavery" src="http://blog.ianuy.com/wp-content/uploads/2010/09/slavery_thumb.jpg" border="0" alt="_slavery" width="280" height="216" /></a> One of the most popular form of “employee retention” is Training Bonds. Although it is not legally enforceable (or if it is but the company won’t really run after you because it is expensive to sue), most bright programmers will never sign a training bond. For most hackers, a training bond is a sign that a company is being ran by “suits”. <a title="NDAs and Contracts That You Should Never Sign" href="http://www.joelonsoftware.com/articles/fog0000000071.html" target="_blank">Joel Spolsky</a> attributes training bonds to “<strong>blind loyalty</strong>”:</p>
<blockquote><p>I think that companies need to keep their employees loyal by <strong>treating them well</strong>, not by enforcing blind loyalty though a contract. I am not going to make the mistake of signing this clause again. Fortunately, with today&#8217;s shortage of qualified programmers, the balance of power today is sharply in your favor when you start a new job, and I think you have a very high chance of getting a job without signing restrictive employment clauses.</p></blockquote>
<p><a href="http://blog.ianuy.com/wp-content/uploads/2010/09/counteroffer.jpg"><img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="_counteroffer" src="http://blog.ianuy.com/wp-content/uploads/2010/09/counteroffer_thumb.jpg" border="0" alt="_counteroffer" width="235" height="244" /></a> Another popular form of employee retention mechanism is <strong>counter-offer</strong>. Counter-offer is when your current employer gives you an offer (counter-offer) that is larger than the offer you received from the company you intend to jump to. Counter-offer is a big no-no because it sends the following message to your employee:</p>
<blockquote><p>We have not really paid you the amount you deserve. But since we really need you to stay, we are willing to pay you more. We don’t think that you deserve this, but our hands are tied.</p></blockquote>
<p>It is much worse when the news of a counter-offer leaks to your other employees. They will also feel that they are not being paid the amount they deserve, they will feel cheated and eventually quit. More turnovers, yay! <strong>Always remember the bribery never promotes loyalty</strong>.</p>
<p><a href="http://blog.ianuy.com/wp-content/uploads/2010/09/incentive_pay.jpg"><span style="color: #000000;"> </span><img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="_incentive_pay" src="http://blog.ianuy.com/wp-content/uploads/2010/09/incentive_pay_thumb.jpg" border="0" alt="_incentive_pay" width="164" height="241" /></a> If you think bribing your programmers when they accomplish something extraordinary will increase their loyalty: <strong>you are wrong</strong>. A lot of <a title="Peopleware: Productive Projects and Teams" href="http://www.amazon.com/Peopleware-Productive-Projects-Teams-Second/dp/0932633439" target="_blank">books</a> have been written on the subject of <strong><a title="Incentive Pay Considered Harmful" href="http://www.joelonsoftware.com/articles/fog0000000070.html" target="_blank">incentive pay and why it is considered harmful</a></strong>:</p>
<blockquote><p>… <strong>&#8220;incentives (or bribes) simply can&#8217;t work in the workplace&#8221;</strong>. DeMarco and Lister go further, stating unequivocally that any kind of workplace competition, any scheme of rewards and punishments, and even the old fashion trick of &#8220;catching people doing something right and rewarding them,&#8221; all do more harm than good. Giving somebody <em>positive</em> reinforcement (such as stupid company ceremonies where people get plaques) implies that they only did it for the lucite plaque; it implies that they are not independent enough to work unless they are going to get a cookie; and it&#8217;s insulting and demeaning.</p></blockquote>
<p>I know that the title says “How to Retain your Best Software Developers and Programmers”, but I was only able to give the “How NOT to do it” guide. It took me a year-and-a-half to understand what motivates programmers to quit their job. It may take me another year-and-a-half to understand how to motivate them to <strong>NOT</strong> quit their jobs. You may wait for it, or you can just read <a title="Software Development Bible" href="http://www.joelonsoftware.com/" target="_blank">Spolsky’s blog</a> for a complete guide on how to manage and retain the best programmers that you will ever find.</p>



Share and Enjoy:


	<a rel="nofollow" href="mailto:?subject=On%20the%20High%20Turnover%20Rate%20of%20Software%20Developers%20or%20How%20to%20Retain%20your%20Best%20Software%20Developers%20and%20Programmers&amp;body=http%3A%2F%2Fblog.ianuy.com%2F2010%2F09%2F26%2Fon-the-high-turnover-rate-of-software-developers-or-how-to-retain-your-best-software-developers-and-programmers%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%2F2010%2F09%2F26%2Fon-the-high-turnover-rate-of-software-developers-or-how-to-retain-your-best-software-developers-and-programmers%2F&amp;title=On%20the%20High%20Turnover%20Rate%20of%20Software%20Developers%20or%20How%20to%20Retain%20your%20Best%20Software%20Developers%20and%20Programmers&amp;bodytext=%0D%0A%20It%20is%20not%20exactly%20news%20that%20programmers%20love%20to%20quit%20their%20job.%20It%20is%20an%20industry-wide%20obsession.%20The%20annual%20turnover%20rate%20for%20the%20High-Tech%20industry%20in%202008%20is%20a%20little%20bit%20above%2020%25%20%282%20out%20of%2010%20employees%20quit%20every%20year%29.%20A%20typical%20programmer%20o" 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%2F2010%2F09%2F26%2Fon-the-high-turnover-rate-of-software-developers-or-how-to-retain-your-best-software-developers-and-programmers%2F&amp;title=On%20the%20High%20Turnover%20Rate%20of%20Software%20Developers%20or%20How%20to%20Retain%20your%20Best%20Software%20Developers%20and%20Programmers" 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%2F2010%2F09%2F26%2Fon-the-high-turnover-rate-of-software-developers-or-how-to-retain-your-best-software-developers-and-programmers%2F&amp;title=On%20the%20High%20Turnover%20Rate%20of%20Software%20Developers%20or%20How%20to%20Retain%20your%20Best%20Software%20Developers%20and%20Programmers&amp;notes=%0D%0A%20It%20is%20not%20exactly%20news%20that%20programmers%20love%20to%20quit%20their%20job.%20It%20is%20an%20industry-wide%20obsession.%20The%20annual%20turnover%20rate%20for%20the%20High-Tech%20industry%20in%202008%20is%20a%20little%20bit%20above%2020%25%20%282%20out%20of%2010%20employees%20quit%20every%20year%29.%20A%20typical%20programmer%20o" 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=On%20the%20High%20Turnover%20Rate%20of%20Software%20Developers%20or%20How%20to%20Retain%20your%20Best%20Software%20Developers%20and%20Programmers%20-%20http%3A%2F%2Fblog.ianuy.com%2F2010%2F09%2F26%2Fon-the-high-turnover-rate-of-software-developers-or-how-to-retain-your-best-software-developers-and-programmers%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=On%20the%20High%20Turnover%20Rate%20of%20Software%20Developers%20or%20How%20to%20Retain%20your%20Best%20Software%20Developers%20and%20Programmers&amp;url=http%3A%2F%2Fblog.ianuy.com%2F2010%2F09%2F26%2Fon-the-high-turnover-rate-of-software-developers-or-how-to-retain-your-best-software-developers-and-programmers%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%2F2010%2F09%2F26%2Fon-the-high-turnover-rate-of-software-developers-or-how-to-retain-your-best-software-developers-and-programmers%2F&amp;t=On%20the%20High%20Turnover%20Rate%20of%20Software%20Developers%20or%20How%20to%20Retain%20your%20Best%20Software%20Developers%20and%20Programmers" 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%2F2010%2F09%2F26%2Fon-the-high-turnover-rate-of-software-developers-or-how-to-retain-your-best-software-developers-and-programmers%2F&amp;t=On%20the%20High%20Turnover%20Rate%20of%20Software%20Developers%20or%20How%20to%20Retain%20your%20Best%20Software%20Developers%20and%20Programmers" 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%2F2010%2F09%2F26%2Fon-the-high-turnover-rate-of-software-developers-or-how-to-retain-your-best-software-developers-and-programmers%2F&amp;title=On%20the%20High%20Turnover%20Rate%20of%20Software%20Developers%20or%20How%20to%20Retain%20your%20Best%20Software%20Developers%20and%20Programmers&amp;annotation=%0D%0A%20It%20is%20not%20exactly%20news%20that%20programmers%20love%20to%20quit%20their%20job.%20It%20is%20an%20industry-wide%20obsession.%20The%20annual%20turnover%20rate%20for%20the%20High-Tech%20industry%20in%202008%20is%20a%20little%20bit%20above%2020%25%20%282%20out%20of%2010%20employees%20quit%20every%20year%29.%20A%20typical%20programmer%20o" 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%2F2010%2F09%2F26%2Fon-the-high-turnover-rate-of-software-developers-or-how-to-retain-your-best-software-developers-and-programmers%2F&amp;title=On%20the%20High%20Turnover%20Rate%20of%20Software%20Developers%20or%20How%20to%20Retain%20your%20Best%20Software%20Developers%20and%20Programmers" 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/2010/09/26/on-the-high-turnover-rate-of-software-developers-or-how-to-retain-your-best-software-developers-and-programmers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Laziness, Impatience and Hubris or How to download Work Item attachments programatically using TFS SDK</title>
		<link>http://blog.ianuy.com/2010/01/24/laziness-impatience-and-hubris-or-how-to-download-work-item-attachments-programatically-using-tfs-sdk/</link>
		<comments>http://blog.ianuy.com/2010/01/24/laziness-impatience-and-hubris-or-how-to-download-work-item-attachments-programatically-using-tfs-sdk/#comments</comments>
		<pubDate>Sun, 24 Jan 2010 10:50:48 +0000</pubDate>
		<dc:creator>Ian Uy</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[TFS SDK]]></category>

		<guid isPermaLink="false">http://blog.ianuy.com/?p=562</guid>
		<description><![CDATA[Larry Wall, the creator of the infamous Perl programming language, has once said that the greatest virtues of a good programmer are Laziness, Impatience and Hubris. To not mislead the lazy &#8220;computer science&#8221; students, allow me to define each virtues:

Laziness &#8212; The quality that makes you go to great effort to reduce overall energy expenditure. [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_563" class="wp-caption aligncenter" style="width: 235px"><a href="http://blog.ianuy.com/wp-content/uploads/2010/01/larry_wall_haz_dem.JPG"><img class="size-medium wp-image-563" title="larry_wall_haz_dem" src="http://blog.ianuy.com/wp-content/uploads/2010/01/larry_wall_haz_dem-225x300.jpg" alt="Larry Wall haz dem" width="225" height="300" /></a><p class="wp-caption-text">Larry Wall haz dem</p></div>
<p><a title="Larry Wall" href="http://en.wikipedia.org/wiki/Larry_Wall" target="_blank">Larry Wall</a>, the creator of the infamous <a title="Perl" href="http://en.wikipedia.org/wiki/Perl" target="_blank">Perl programming language</a>, has once said that the greatest virtues of a good programmer are <a title="Don't you believe me?" href="http://en.wikipedia.org/wiki/Larry_Wall#Virtues_of_a_programmer" target="_blank">Laziness, Impatience and Hubris</a>. To not mislead the lazy &#8220;computer science&#8221; students, allow me to define each virtues:</p>
<ol>
<li><strong>Laziness</strong> &#8212; The quality that makes you go to great effort to reduce overall energy expenditure. It makes you write labor-saving programs that other people will find useful, and document what you wrote so you don&#8217;t have to answer so many questions about it. Hence, the first great virtue of a programmer. See also impatience and hubris.</li>
<li><strong>Impatience </strong>&#8211; The anger you feel when the computer is being lazy. This makes you write  programs that don&#8217;t just react to your needs, but actually anticipate  them. Or at least pretend to. Hence, the second great virtue of a  programmer. See also laziness and hubris.</li>
<li><strong>Hubris </strong>&#8211; Excessive pride. Also the quality that makes you write (and maintain) programs that other  people won&#8217;t want to say bad things about. Hence, the third great  virtue of a programmer. See also laziness and impatience.</li>
</ol>
<p>A few days ago, a tester at our company filled a track that contained multiple attachments (Screenshots, Error Logs, etc) to assist the developers on their investigation. As we are using <a title="TFS?" href="http://en.wikipedia.org/wiki/Team_Foundation_Server" target="_blank">Microsoft&#8217;s Team Foundation System</a> for source control and bug tracking, the most obvious way to get these attachments is through TFS Web Access; Frankly speaking, this is the <strong>only</strong> &#8220;official&#8221; way to access the track (bug report) on our company.</p>
<div id="attachment_564" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.ianuy.com/wp-content/uploads/2010/01/TFSWA.png"><img class="size-medium wp-image-564" title="TFSWA" src="http://blog.ianuy.com/wp-content/uploads/2010/01/TFSWA-300x217.png" alt="The TFS Web Access homepage UI" width="300" height="217" /></a><p class="wp-caption-text">The TFS Web Access homepage UI</p></div>
<p>I don&#8217;t know if its a lack of feature or what, but there is no way in TFS Web Access to download multiple attachments at once. Additionally, when downloading attachments that contains a space on their filename, TFS Web Access will automatically concatenate the filename and that will remove the file&#8217;s extension (EG: <em>Screenshot of the bug.jpg</em> will be renamed to <em>Screenshot</em>)&#8230; You still need to manually rename the file with the proper extension to open it. And because I&#8217;m lazy, I don&#8217;t want <span style="text-decoration: underline;">to log-in to TFS Web Access, type in the track ID, click on the attachments tab, click on the file(s) I want to download, browse for the location where to save the file, create a new folder for the track, click save, minimize my browser, open the download location and (unzip the attachment, it its zipped, which normally is)</span> to just view a single screenshot.</p>
<p>Since I am a big believer of Wall&#8217;s three virtues, I created a tool that will automate those boring and repetitive tasks for me (and allow me to download *all* attachments from a work item + workaround the &#8220;spacing&#8221; bug). The tool is called <strong>WIF </strong>or Work Item Fetcher and it is currently in Closed-Limited Beta.</p>
<p>At first, I thought about parsing the web pages to download the attachments using HTML Sanitizers and Regular Expressions but then I remembered that only <a title="Parsing Html The Cthulhu Way" href="http://www.codinghorror.com/blog/archives/001311.html" target="_blank">Chuck Norris can parse HTML using regular expressions</a>! So I searched the web and found out about the <a title="TFS SDK" href="http://msdn.microsoft.com/en-us/library/bb130146%28VS.80%29.aspx" target="_blank">TFS SDK</a>! Go .NET! Go Laziness! Okay, enough chit-chat, the rest of the post will be dedicated to discussing how to use the TFS API to download attachments from TFS. <img src='http://blog.ianuy.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':-D' class='wp-smiley' /> </p>
<p><span id="more-562"></span></p>
<h1><span style="text-decoration: underline;">Step 1: Acquiring the needed libraries</span></h1>
<p>To be honest, I don&#8217;t really know where to download the DLLs. I&#8217;ve searched and found nothing. What I did was I referenced the DLLs located at <span style="text-decoration: underline;">C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies</span>\. The DLLs should be available after you download and install <a title="Get it here!" href="http://www.microsoft.com/downloads/details.aspx?FamilyId=46473C2A-BB85-4461-BB27-4792A5DEF222&amp;displaylang=en" target="_blank">Team Explorer for Visual Studio 2005</a>. For our purposes, you should reference the following DLLs:</p>
<ul>
<li>Microsoft.TeamFoundation.DLL</li>
<li>Microsoft.TeamFoundation.Client.DLL</li>
<li>Microsoft.TeamFoundation.WorkItemTracking.Client.DLL</li>
</ul>
<p>You must then add the needed declarations like so:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">using</span> <span style="color: #008080;">Microsoft.TeamFoundation</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">Microsoft.TeamFoundation.Client</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">Microsoft.TeamFoundation.WorkItemTracking.Client</span><span style="color: #008000;">;</span></pre></div></div>

<p>Compile your project to check. <img src='http://blog.ianuy.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  Remember to always compile your project after each step.</p>
<h1><span style="text-decoration: underline;">Step 2: Connecting to your TFS server</span></h1>
<p>If you want to do <em>anything</em> with your TFS SDK, the first thing that you should do is to connect to your TFS server. Connecting is straight-forward, but a little tricky if you need to provide your network credentials. First, lets assume that the program will run on a machine that is connected to the domain with the proper credentials (AKA straight-forward way):</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">const</span> <span style="color: #FF0000;">string</span> TFSServer <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;http://mytfsserver:8090&quot;</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF;">using</span> <span style="color: #000000;">&#40;</span>TeamFoundationServer tfsConn <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> TeamFoundationServer<span style="color: #000000;">&#40;</span>TFSServer<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #0600FF;">try</span>
	<span style="color: #000000;">&#123;</span>
		tfsConn.<span style="color: #0000FF;">EnsureAuthenticated</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
	<span style="color: #000000;">&#125;</span>
	<span style="color: #0600FF;">catch</span> <span style="color: #000000;">&#40;</span>Exception ex<span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		MessageBox.<span style="color: #0000FF;">Show</span><span style="color: #000000;">&#40;</span>ex.<span style="color: #0000FF;">Message</span>, <span style="color: #666666;">&quot;Cannot connect to TFS Server!&quot;</span>, MessageBoxButtons.<span style="color: #0000FF;">OK</span>, MessageBoxIcon.<span style="color: #0000FF;">Error</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>A call to <strong>EnsureAuthenticated();</strong> is needed to check if your connection is properly authenticated. If not, the method will throw an exception.</p>
<p>How about if you need to manually provide login credentials or your machine is not joined to a domain? Just use the NetCredential object from <strong>System.Net</strong> to pass your credentials:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">const</span> <span style="color: #FF0000;">string</span> TFSServer <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;http://mytfsserver:8090&quot;</span><span style="color: #008000;">;</span>
&nbsp;
NetworkCredential netCred <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> NetworkCredential<span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Username&quot;</span>, <span style="color: #666666;">&quot;Password&quot;</span>, <span style="color: #666666;">&quot;Domain&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF;">using</span> <span style="color: #000000;">&#40;</span>TeamFoundationServer tfsConn <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> TeamFoundationServer<span style="color: #000000;">&#40;</span>TFSServer, netCred<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #0600FF;">try</span>
	<span style="color: #000000;">&#123;</span>
		tfsConn.<span style="color: #0000FF;">EnsureAuthenticated</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
	<span style="color: #000000;">&#125;</span>
	<span style="color: #0600FF;">catch</span> <span style="color: #000000;">&#40;</span>Exception ex<span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		MessageBox.<span style="color: #0000FF;">Show</span><span style="color: #000000;">&#40;</span>ex.<span style="color: #0000FF;">Message</span>, <span style="color: #666666;">&quot;Cannot connect to TFS Server!&quot;</span>, MessageBoxButtons.<span style="color: #0000FF;">OK</span>, MessageBoxIcon.<span style="color: #0000FF;">Error</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<h1><span style="text-decoration: underline;">Step 3: Acquire the Work Item</span></h1>
<p>Now that we&#8217;re good and connected to TFS, our next task is to acquire the Work Item from TFS. First, we&#8217;ll need to acquire the WorkItemStore service from TFS by calling the <strong>GetService</strong> method:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">WorkItemStore wis <span style="color: #008000;">=</span> <span style="color: #000000;">&#40;</span>WorkItemStore<span style="color: #000000;">&#41;</span>tfsServer.<span style="color: #0000FF;">GetService</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">typeof</span><span style="color: #000000;">&#40;</span>WorkItemStore<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span></pre></div></div>

<p>Then, we&#8217;ll get the Work Item by invoking the <strong>GetWorkItem </strong>method:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">WorkItem wi <span style="color: #008000;">=</span> wis.<span style="color: #0000FF;">GetWorkItem</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">1000</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">//Where 1000 is the Work Item ID</span></pre></div></div>

<p>Now, your code should look something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">const</span> <span style="color: #FF0000;">string</span> TFSServer <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;http://mytfsserver:8090&quot;</span><span style="color: #008000;">;</span>
&nbsp;
NetworkCredential netCred <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> NetworkCredential<span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Username&quot;</span>, <span style="color: #666666;">&quot;Password&quot;</span>, <span style="color: #666666;">&quot;Domain&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF;">using</span> <span style="color: #000000;">&#40;</span>TeamFoundationServer tfsConn <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> TeamFoundationServer<span style="color: #000000;">&#40;</span>TFSServer, netCred<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #0600FF;">try</span>
	<span style="color: #000000;">&#123;</span>
		tfsConn.<span style="color: #0000FF;">EnsureAuthenticated</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
                WorkItemStore wis <span style="color: #008000;">=</span> <span style="color: #000000;">&#40;</span>WorkItemStore<span style="color: #000000;">&#41;</span>tfsServer.<span style="color: #0000FF;">GetService</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">typeof</span><span style="color: #000000;">&#40;</span>WorkItemStore<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
                WorkItem wi <span style="color: #008000;">=</span> wis.<span style="color: #0000FF;">GetWorkItem</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">1000</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">//Where 1000 is the Work Item ID</span>
	<span style="color: #000000;">&#125;</span>
	<span style="color: #0600FF;">catch</span> <span style="color: #000000;">&#40;</span>Exception ex<span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		MessageBox.<span style="color: #0000FF;">Show</span><span style="color: #000000;">&#40;</span>ex.<span style="color: #0000FF;">Message</span>, <span style="color: #666666;">&quot;Something has gone wrong!&quot;</span>, MessageBoxButtons.<span style="color: #0000FF;">OK</span>, MessageBoxIcon.<span style="color: #0000FF;">Error</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<h1><span style="text-decoration: underline;">Step 4: Get the attachments&#8217; URI</span></h1>
<p>After acquiring the Work Item, we can now directly iterate through the attachment collection to access its attachment&#8217;s URI:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">foreach</span><span style="color: #000000;">&#40;</span>Attachment attachment <span style="color: #0600FF;">in</span> wi.<span style="color: #0000FF;">Attachments</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #FF0000;">string</span> FileName <span style="color: #008000;">=</span> attachment.<span style="color: #0000FF;">Name</span><span style="color: #008000;">;</span>
	<span style="color: #FF0000;">string</span> attachmentURI <span style="color: #008000;">=</span> attachment.<span style="color: #0000FF;">Uri</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Cool huh? Just like that! Your entire code should look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">const</span> <span style="color: #FF0000;">string</span> TFSServer <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;http://mytfsserver:8090&quot;</span><span style="color: #008000;">;</span>
&nbsp;
NetworkCredential netCred <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> NetworkCredential<span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Username&quot;</span>, <span style="color: #666666;">&quot;Password&quot;</span>, <span style="color: #666666;">&quot;Domain&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF;">using</span> <span style="color: #000000;">&#40;</span>TeamFoundationServer tfsConn <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> TeamFoundationServer<span style="color: #000000;">&#40;</span>TFSServer, netCred<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #0600FF;">try</span>
	<span style="color: #000000;">&#123;</span>
		tfsConn.<span style="color: #0000FF;">EnsureAuthenticated</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
                WorkItemStore wis <span style="color: #008000;">=</span> <span style="color: #000000;">&#40;</span>WorkItemStore<span style="color: #000000;">&#41;</span>tfsServer.<span style="color: #0000FF;">GetService</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">typeof</span><span style="color: #000000;">&#40;</span>WorkItemStore<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
                WorkItem wi <span style="color: #008000;">=</span> wis.<span style="color: #0000FF;">GetWorkItem</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">1000</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">//Where 1000 is the Work Item ID</span>
&nbsp;
		<span style="color: #0600FF;">foreach</span><span style="color: #000000;">&#40;</span>Attachment attachment <span style="color: #0600FF;">in</span> wi.<span style="color: #0000FF;">Attachments</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #FF0000;">string</span> FileName <span style="color: #008000;">=</span> attachment.<span style="color: #0000FF;">Name</span><span style="color: #008000;">;</span>
			<span style="color: #FF0000;">string</span> attachmentURI <span style="color: #008000;">=</span> attachment.<span style="color: #0000FF;">Uri</span><span style="color: #008000;">;</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #000000;">&#125;</span>
	<span style="color: #0600FF;">catch</span> <span style="color: #000000;">&#40;</span>Exception ex<span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		MessageBox.<span style="color: #0000FF;">Show</span><span style="color: #000000;">&#40;</span>ex.<span style="color: #0000FF;">Message</span>, <span style="color: #666666;">&quot;Something has gone wrong!&quot;</span>, MessageBoxButtons.<span style="color: #0000FF;">OK</span>, MessageBoxIcon.<span style="color: #0000FF;">Error</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<h1><span style="text-decoration: underline;">Step 5: Downloading the attachments</span></h1>
<p>And now that we have the attachment&#8217;s URI, all there is left to do is to download it. Thankfully, .NET provided us with the WebClient class that simplifies the downloading:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">using</span> <span style="color: #000000;">&#40;</span>WebClient wClient <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> WebClient<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	wClient.<span style="color: #0000FF;">Credentials</span> <span style="color: #008000;">=</span> netCred<span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">//Provide your network credentials.</span>
	wClient.<span style="color: #0000FF;">DownloadFile</span><span style="color: #000000;">&#40;</span>attachment.<span style="color: #0000FF;">Uri</span>, Path.<span style="color: #0000FF;">Combine</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">@&quot;C:&quot;</span>, attachment.<span style="color: #0000FF;">Name</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>That&#8217;s it! You&#8217;re done. <img src='http://blog.ianuy.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  The completed code should look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">using</span> <span style="color: #000000;">&#40;</span>TeamFoundationServer tfsConn <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> TeamFoundationServer<span style="color: #000000;">&#40;</span>TFSServer, netCred<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #0600FF;">try</span>
	<span style="color: #000000;">&#123;</span>
		tfsConn.<span style="color: #0000FF;">EnsureAuthenticated</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
                WorkItemStore wis <span style="color: #008000;">=</span> <span style="color: #000000;">&#40;</span>WorkItemStore<span style="color: #000000;">&#41;</span>tfsServer.<span style="color: #0000FF;">GetService</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">typeof</span><span style="color: #000000;">&#40;</span>WorkItemStore<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
                WorkItem wi <span style="color: #008000;">=</span> wis.<span style="color: #0000FF;">GetWorkItem</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">1000</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">//Where 1000 is the Work Item ID</span>
&nbsp;
		<span style="color: #0600FF;">foreach</span><span style="color: #000000;">&#40;</span>Attachment attachment <span style="color: #0600FF;">in</span> wi.<span style="color: #0000FF;">Attachments</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #FF0000;">string</span> FileName <span style="color: #008000;">=</span> attachment.<span style="color: #0000FF;">Name</span><span style="color: #008000;">;</span>
			<span style="color: #FF0000;">string</span> attachmentURI <span style="color: #008000;">=</span> attachment.<span style="color: #0000FF;">Uri</span><span style="color: #008000;">;</span>
&nbsp;
			<span style="color: #0600FF;">using</span> <span style="color: #000000;">&#40;</span>WebClient wClient <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> WebClient<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				wClient.<span style="color: #0000FF;">Credentials</span> <span style="color: #008000;">=</span> netCred<span style="color: #008000;">;</span>
				wClient.<span style="color: #0000FF;">DownloadFile</span><span style="color: #000000;">&#40;</span>attachmentURI, Path.<span style="color: #0000FF;">Combine</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">@&quot;C:&quot;</span>, FileName<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #000000;">&#125;</span>
	<span style="color: #0600FF;">catch</span> <span style="color: #000000;">&#40;</span>Exception ex<span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		MessageBox.<span style="color: #0000FF;">Show</span><span style="color: #000000;">&#40;</span>ex.<span style="color: #0000FF;">Message</span>, <span style="color: #666666;">&quot;Something has gone wrong!&quot;</span>, MessageBoxButtons.<span style="color: #0000FF;">OK</span>, MessageBoxIcon.<span style="color: #0000FF;">Error</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<h1><span style="text-decoration: underline;">Step 6: Optional Improvements</span></h1>
<p>The code above is the minimum required to have a fully functional attachment downloader for TFS. There are a couple of things that you can do to improve your program:</p>
<ul>
<li>Automatically create a directory for each Work Item. This way, you will have an organized local storage of the attachments.</li>
<li>Instead of using the DownloadFile method to download your file, you can use the <a title="MSDN" href="http://msdn.microsoft.com/en-us/library/system.net.webclient.downloadfileasync.aspx" target="_blank">DownloadFileAsync </a>method to download the file asynchronously. DownloadFileAsync is non-thread blocking. This call will also allow you to listen to EventHandlers for the download progress.</li>
<li>After the download, you can check if the file is a zip file (by using <a title="MSDN" href="http://msdn.microsoft.com/en-us/library/system.io.path.getextension.aspx" target="_blank">Path.GetExtension</a>), and if it is, you can use <a title="SharpZipLib" href="http://www.icsharpcode.net/OpenSource/SharpZipLib/" target="_blank">SharpZipLib</a> to automatically unzip the package.</li>
<li>Sometimes, instead of providing the Incident number, your users will provide the Incident Fix number. Its good to anticipate that and provide a way to resolve the Incident Number from the Incident Fix. To do that, first check if your user provided an Incident Fix by calling <strong>wi.Fields.GetById(25).Value.ToString() == &#8220;Incident Fix&#8221;</strong> then if yes, you can get the Incident Number by calling <strong>int ParentID = (int)wi.Fields.GetById(10120).Value</strong>. <em>Thank you Impatience!</em></li>
</ul>
<p>I can&#8217;t really share my program with you guys (you know all of that &#8220;corporate&#8221; legal mumbo-jumbo). But here&#8217;s the screenshot:</p>
<div id="attachment_594" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.ianuy.com/wp-content/uploads/2010/01/WIF.png"><img class="size-medium wp-image-594" title="WIF" src="http://blog.ianuy.com/wp-content/uploads/2010/01/WIF-300x247.png" alt="Work Item Fetcher @ TFS" width="300" height="247" /></a><p class="wp-caption-text">Work Item Fetcher @ TFS</p></div>
<p>Thank you Laziness for making me go to great effort to reduce the total effort and time needed to download attachments from TFS. Thank you for making me write labor-saving programs that other people will hopefully find useful.</p>
<p>Thank you Impatience for pissing me off when I am manually downloading and renaming attachments one by one. Thank you too for making me angry when my initial prototype failed when I gave it an Incident Fix number rather than an Incident number.</p>
<p>And, as always, thank you Hubris! <img src='http://blog.ianuy.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  (People around me knows exactly why!)</p>



Share and Enjoy:


	<a rel="nofollow" href="mailto:?subject=Laziness%2C%20Impatience%20and%20Hubris%20or%20How%20to%20download%20Work%20Item%20attachments%20programatically%20using%20TFS%20SDK&amp;body=http%3A%2F%2Fblog.ianuy.com%2F2010%2F01%2F24%2Flaziness-impatience-and-hubris-or-how-to-download-work-item-attachments-programatically-using-tfs-sdk%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%2F2010%2F01%2F24%2Flaziness-impatience-and-hubris-or-how-to-download-work-item-attachments-programatically-using-tfs-sdk%2F&amp;title=Laziness%2C%20Impatience%20and%20Hubris%20or%20How%20to%20download%20Work%20Item%20attachments%20programatically%20using%20TFS%20SDK&amp;bodytext=%0A%0D%0ALarry%20Wall%2C%20the%20creator%20of%20the%20infamous%20Perl%20programming%20language%2C%20has%20once%20said%20that%20the%20greatest%20virtues%20of%20a%20good%20programmer%20are%20Laziness%2C%20Impatience%20and%20Hubris.%20To%20not%20mislead%20the%20lazy%20%22computer%20science%22%20students%2C%20allow%20me%20to%20define%20each%20virtu" 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%2F2010%2F01%2F24%2Flaziness-impatience-and-hubris-or-how-to-download-work-item-attachments-programatically-using-tfs-sdk%2F&amp;title=Laziness%2C%20Impatience%20and%20Hubris%20or%20How%20to%20download%20Work%20Item%20attachments%20programatically%20using%20TFS%20SDK" 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%2F2010%2F01%2F24%2Flaziness-impatience-and-hubris-or-how-to-download-work-item-attachments-programatically-using-tfs-sdk%2F&amp;title=Laziness%2C%20Impatience%20and%20Hubris%20or%20How%20to%20download%20Work%20Item%20attachments%20programatically%20using%20TFS%20SDK&amp;notes=%0A%0D%0ALarry%20Wall%2C%20the%20creator%20of%20the%20infamous%20Perl%20programming%20language%2C%20has%20once%20said%20that%20the%20greatest%20virtues%20of%20a%20good%20programmer%20are%20Laziness%2C%20Impatience%20and%20Hubris.%20To%20not%20mislead%20the%20lazy%20%22computer%20science%22%20students%2C%20allow%20me%20to%20define%20each%20virtu" 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=Laziness%2C%20Impatience%20and%20Hubris%20or%20How%20to%20download%20Work%20Item%20attachments%20programatically%20using%20TFS%20SDK%20-%20http%3A%2F%2Fblog.ianuy.com%2F2010%2F01%2F24%2Flaziness-impatience-and-hubris-or-how-to-download-work-item-attachments-programatically-using-tfs-sdk%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=Laziness%2C%20Impatience%20and%20Hubris%20or%20How%20to%20download%20Work%20Item%20attachments%20programatically%20using%20TFS%20SDK&amp;url=http%3A%2F%2Fblog.ianuy.com%2F2010%2F01%2F24%2Flaziness-impatience-and-hubris-or-how-to-download-work-item-attachments-programatically-using-tfs-sdk%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%2F2010%2F01%2F24%2Flaziness-impatience-and-hubris-or-how-to-download-work-item-attachments-programatically-using-tfs-sdk%2F&amp;t=Laziness%2C%20Impatience%20and%20Hubris%20or%20How%20to%20download%20Work%20Item%20attachments%20programatically%20using%20TFS%20SDK" 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%2F2010%2F01%2F24%2Flaziness-impatience-and-hubris-or-how-to-download-work-item-attachments-programatically-using-tfs-sdk%2F&amp;t=Laziness%2C%20Impatience%20and%20Hubris%20or%20How%20to%20download%20Work%20Item%20attachments%20programatically%20using%20TFS%20SDK" 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%2F2010%2F01%2F24%2Flaziness-impatience-and-hubris-or-how-to-download-work-item-attachments-programatically-using-tfs-sdk%2F&amp;title=Laziness%2C%20Impatience%20and%20Hubris%20or%20How%20to%20download%20Work%20Item%20attachments%20programatically%20using%20TFS%20SDK&amp;annotation=%0A%0D%0ALarry%20Wall%2C%20the%20creator%20of%20the%20infamous%20Perl%20programming%20language%2C%20has%20once%20said%20that%20the%20greatest%20virtues%20of%20a%20good%20programmer%20are%20Laziness%2C%20Impatience%20and%20Hubris.%20To%20not%20mislead%20the%20lazy%20%22computer%20science%22%20students%2C%20allow%20me%20to%20define%20each%20virtu" 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%2F2010%2F01%2F24%2Flaziness-impatience-and-hubris-or-how-to-download-work-item-attachments-programatically-using-tfs-sdk%2F&amp;title=Laziness%2C%20Impatience%20and%20Hubris%20or%20How%20to%20download%20Work%20Item%20attachments%20programatically%20using%20TFS%20SDK" 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/2010/01/24/laziness-impatience-and-hubris-or-how-to-download-work-item-attachments-programatically-using-tfs-sdk/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Ordinary Programmers vs Great Hackers</title>
		<link>http://blog.ianuy.com/2009/09/17/ordinary-programmers-vs-great-hackers/</link>
		<comments>http://blog.ianuy.com/2009/09/17/ordinary-programmers-vs-great-hackers/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 16:54:29 +0000</pubDate>
		<dc:creator>Ian Uy</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Passion]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.ianuy.com/?p=526</guid>
		<description><![CDATA[I love Paul Graham. The guy speaks my mind. Although I don&#8217;t agree with all of his ideas (E.G. Java programmers are stupid. PERIOD.), most of his ideas are golden. For those of weak hearts (and sensitive ego), please proceed with care.  
The essay that will follow, entitled Great Hackers, basically compliments the main [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_527" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.ianuy.com/wp-content/uploads/2009/09/Paul_Graham_on_Hacking.jpg"><img class="size-medium wp-image-527" title="Paul_Graham_on_Hacking" src="http://blog.ianuy.com/wp-content/uploads/2009/09/Paul_Graham_on_Hacking-300x225.jpg" alt="Paul Graham (Author of Hackers and Painters)" width="300" height="225" /></a><p class="wp-caption-text">Paul Graham (Author of Hackers and Painters)</p></div>
<p>I love <a href="http://www.paulgraham.com/" target="_blank"><strong>Paul Graham</strong></a>. The guy speaks my mind. Although I don&#8217;t agree with all of his ideas (E.G. Java programmers are stupid. PERIOD.), most of his ideas are golden. For those of weak hearts (and sensitive ego), please proceed with care. <img src='http://blog.ianuy.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>The essay that will follow, entitled <strong>Great Hackers</strong>, basically compliments the main idea of my <a title="High Salary is Killing the Software Industry " href="http://blog.ianuy.com/2009/09/14/high-salary-is-killing-the-software-industry/" target="_blank">previous post</a> which is &#8220;<em>To do something well you have to<span> </span><a href="http://www.paulgraham.com/love.html">love</a><span> </span>it.</em>&#8221;</p>
<p>Some quotable quotes from this essay:</p>
<p><em>&#8220;Ordinary programmers write code to pay the bills. Great hackers think of it as something they do for fun, and which they&#8217;re delighted to find people will pay them for.&#8221;</em></p>
<p><em>&#8220;Hackers like to work for people with high standards. But it&#8217;s not enough just to be exacting. You have to insist on the right things. Which usually means that you have to be a hacker yourself. I&#8217;ve seen occasional articles about how to manage programmers. Really there should be two articles: one about what to do if you are yourself a programmer, and one about what to do if you&#8217;re not. And the second could probably be condensed into two words: give up.&#8221;</em></p>
<p><em>&#8220;The distinguishing feature of nasty little problems is that you don&#8217;t learn anything from them. Working on nasty little problems makes you stupid. Good hackers avoid it for the same reason models avoid cheeseburgers.&#8221;</em></p>
<p><em>&#8220;I&#8217;ve found that people who are great at something are not so much convinced of their own greatness as mystified at why everyone else seems so incompetent.&#8221;</em></p>
<p><em>&#8220;The key to being a good hacker may be to work on what you like. When I think about the great hackers I know, one thing they have in common is the extreme difficulty of making them work on anything they don&#8217;t want to. I don&#8217;t know if this is cause or effect; it may be both.&#8221;</em></p>
<p><em>&#8220;One difference I&#8217;ve noticed between great hackers and smart people in general is that hackers are more politically incorrect. And I can see why political incorrectness would be a useful quality in programming. Programs are very complex and, at least in the hands of good programmers, very fluid. In such situations it&#8217;s helpful to have a habit of questioning assumptions.&#8221;</em></p>
<p style="text-align: center;"><strong>AND NOW, THE ESSAY</strong></p>
<p style="text-align: center;"><strong><span id="more-526"></span></strong></p>
<h1 style="text-align: center;"><strong><span style="text-decoration: underline;">Great Hackers</span><br />
</strong></h1>
<p style="text-align: left;"><span style="font-family: verdana; font-size: 16px;"><strong>Edisons</strong></span></p>
<p>There&#8217;s no controversy about which idea is most controversial: the suggestion that variation in wealth might not be as big a problem as we think.</p>
<p>I didn&#8217;t say in the <a title="Hackers and Painters E-Book" href="http://books.google.com/books?id=IezOirt2n-gC&amp;printsec=frontcover&amp;dq=hackers+and+painters&amp;hl=tl&amp;source=gbs_summary_s&amp;cad=0#v=onepage&amp;q=&amp;f=false" target="_blank">book</a> that variation in wealth was in itself a good thing. I said in some situations it might be a sign of good things. A throbbing headache is not a good thing, but it can be a sign of a good thing&#8211; for example, that you&#8217;re recovering consciousness after being hit on the head.</p>
<p>Variation in wealth can be a sign of variation in productivity. (In a society of one, they&#8217;re identical.) And<em> that</em><span> </span>is almost certainly a good thing: if your society has no variation in productivity, it&#8217;s probably not because everyone is Thomas Edison. It&#8217;s probably because you have no Thomas Edisons.</p>
<p>In a low-tech society you don&#8217;t see much variation in productivity. If you have a tribe of nomads collecting sticks for a fire, how much more productive is the best stick gatherer going to be than the worst? A factor of two? Whereas when you hand people a complex tool like a computer, the variation in what they can do with it is enormous.</p>
<p>That&#8217;s not a new idea. Fred Brooks wrote about it in 1974, and the study he quoted was published in 1968. But I think he underestimated the variation between programmers. He wrote about productivity in lines of code: the best programmers can solve a given problem in a tenth the time. But what if the problem isn&#8217;t given? In programming, as in many fields, the hard part isn&#8217;t solving problems, but deciding what problems to solve. Imagination is hard to measure, but in practice it dominates the kind of productivity that&#8217;s measured in lines of code.</p>
<p>Productivity varies in any field, but there are few in which it varies so much. The variation between programmers is so great that it becomes a difference in kind. I don&#8217;t think this is something intrinsic to programming, though. In every field, technology magnifies differences in productivity. I think what&#8217;s happening in programming is just that we have a lot of technological leverage. But in every field the lever is getting longer, so the variation we see is something that more and more fields will see as time goes on. And the success of companies, and countries, will depend increasingly on how they deal with it.</p>
<p>If variation in productivity increases with technology, then the contribution of the most productive individuals will not only be disproportionately large, but will actually grow with time. When you reach the point where 90% of a group&#8217;s output is created by 1% of its members, you lose big if something (whether Viking raids, or central planning) drags their productivity down to the average.</p>
<p>If we want to get the most out of them, we need to understand these especially productive people. What motivates them? What do they need to do their jobs? How do you recognize them? How do you get them to come and work for you? And then of course there&#8217;s the question, how do you become one?</p>
<p><strong>More than Money</strong></p>
<p>I know a handful of super-hackers, so I sat down and thought about what they have in common. Their defining quality is probably that they really love to program. Ordinary programmers write code to pay the bills. Great hackers think of it as something they do for fun, and which they&#8217;re delighted to find people will pay them for.</p>
<p>Great programmers are sometimes said to be indifferent to money. This isn&#8217;t quite true. It is true that all they really care about is doing interesting work. But if you make enough money, you get to work on whatever you want, and for that reason hackers<span> </span><em>are</em><span> </span>attracted by the idea of making really large amounts of money. But as long as they still have to show up for work every day, they care more about what they do there than how much they get paid for it.</p>
<p>Economically, this is a fact of the greatest importance, because it means you don&#8217;t have to pay great hackers anything like what they&#8217;re worth. A great programmer might be ten or a hundred times as productive as an ordinary one, but he&#8217;ll consider himself lucky to get paid three times as much. As I&#8217;ll explain later, this is partly because great hackers don&#8217;t know how good they are. But it&#8217;s also because money is not the main thing they want.</p>
<p>What do hackers want? Like all craftsmen, hackers like good tools. In fact, that&#8217;s an understatement. Good hackers find it unbearable to use bad tools. They&#8217;ll simply refuse to work on projects with the wrong infrastructure.</p>
<p>At a startup I once worked for, one of the things pinned up on our bulletin board was an ad from IBM. It was a picture of an AS400, and the headline read, I think, &#8220;hackers despise it.&#8221; [1]</p>
<p>When you decide what infrastructure to use for a project, you&#8217;re not just making a technical decision. You&#8217;re also making a social decision, and this may be the more important of the two. For example, if your company wants to write some software, it might seem a prudent choice to write it in Java. But when you choose a language, you&#8217;re also choosing a community. The programmers you&#8217;ll be able to hire to work on a Java project won&#8217;t be as<span> </span><a href="http://www.paulgraham.com/pypar.html">smart</a><span> </span>as the ones you could get to work on a project written in Python. And the quality of your hackers probably matters more than the language you choose. Though, frankly, the fact that good hackers prefer Python to Java should tell you something about the relative merits of those languages.</p>
<p>Business types prefer the most popular languages because they view languages as standards. They don&#8217;t want to bet the company on Betamax. The thing about languages, though, is that they&#8217;re not just standards. If you have to move bits over a network, by all means use TCP/IP. But a programming language isn&#8217;t just a format. A programming language is a medium of expression.</p>
<p>I&#8217;ve read that Java has just overtaken Cobol as the most popular language. As a standard, you couldn&#8217;t wish for more. But as a medium of expression, you could do a lot better. Of all the great programmers I can think of, I know of only one who would voluntarily program in Java. And of all the great programmers I can think of who don&#8217;t work for Sun, on Java, I know of zero.</p>
<p>Great hackers also generally insist on using open source software. Not just because it&#8217;s better, but because it gives them more control. Good hackers insist on control. This is part of what makes them good hackers: when something&#8217;s broken, they need to fix it. You want them to feel this way about the software they&#8217;re writing for you. You shouldn&#8217;t be surprised when they feel the same way about the operating system.</p>
<p>A couple years ago a venture capitalist friend told me about a new startup he was involved with. It sounded promising. But the next time I talked to him, he said they&#8217;d decided to build their software on Windows NT, and had just hired a very experienced NT developer to be their chief technical officer. When I heard this, I thought, these guys are doomed. One, the CTO couldn&#8217;t be a first rate hacker, because to become an eminent NT developer he would have had to use NT voluntarily, multiple times, and I couldn&#8217;t imagine a great hacker doing that; and two, even if he was good, he&#8217;d have a hard time hiring anyone good to work for him if the project had to be built on NT. [2]</p>
<p><strong>The Final Frontier</strong></p>
<p>After software, the most important tool to a hacker is probably his office. Big companies think the function of office space is to express rank. But hackers use their offices for more than that: they use their office as a place to think in. And if you&#8217;re a technology company, their thoughts are your product. So making hackers work in a noisy, distracting environment is like having a paint factory where the air is full of soot.</p>
<p>The cartoon strip Dilbert has a lot to say about cubicles, and with good reason. All the hackers I know despise them. The mere prospect of being interrupted is enough to prevent hackers from working on hard problems. If you want to get real work done in an office with cubicles, you have two options: work at home, or come in early or late or on a weekend, when no one else is there. Don&#8217;t companies realize this is a sign that something is broken? An office environment is supposed to be something that<em>helps</em><span> </span>you work, not something you work despite.</p>
<p>Companies like Cisco are proud that everyone there has a cubicle, even the CEO. But they&#8217;re not so advanced as they think; obviously they still view office space as a badge of rank. Note too that Cisco is famous for doing very little product development in house. They get new technology by buying the startups that created it&#8211; where presumably the hackers did have somewhere quiet to work.</p>
<p>One big company that understands what hackers need is Microsoft. I once saw a recruiting ad for Microsoft with a big picture of a door. Work for us, the premise was, and we&#8217;ll give you a place to work where you can actually get work done. And you know, Microsoft is remarkable among big companies in that they are able to develop software in house. Not well, perhaps, but well enough.</p>
<p>If companies want hackers to be productive, they should look at what they do at home. At home, hackers can arrange things themselves so they can get the most done. And when they work at home, hackers don&#8217;t work in noisy, open spaces; they work in rooms with doors. They work in cosy, neighborhoody places with people around and somewhere to walk when they need to mull something over, instead of in glass boxes set in acres of parking lots. They have a sofa they can take a nap on when they feel tired, instead of sitting in a coma at their desk, pretending to work. There&#8217;s no crew of people with vacuum cleaners that roars through every evening during the prime hacking hours. There are no meetings or, God forbid, corporate retreats or team-building exercises. And when you look at what they&#8217;re doing on that computer, you&#8217;ll find it reinforces what I said earlier about tools. They may have to use Java and Windows at work, but at home, where they can choose for themselves, you&#8217;re more likely to find them using Perl and Linux.</p>
<p>Indeed, these statistics about Cobol or Java being the most popular language can be misleading. What we ought to look at, if we want to know what tools are best, is what hackers choose when they can choose freely&#8211; that is, in projects of their own. When you ask that question, you find that open source operating systems already have a dominant market share, and the number one language is probably Perl.</p>
<p><strong>Interesting</strong></p>
<p>Along with good tools, hackers want interesting projects. What makes a project interesting? Well, obviously overtly sexy applications like stealth planes or special effects software would be interesting to work on. But any application can be interesting if it poses novel technical challenges. So it&#8217;s hard to predict which problems hackers will like, because some become interesting only when the people working on them discover a new kind of solution. Before ITA (who wrote the software inside Orbitz), the people working on airline fare searches probably thought it was one of the most boring applications imaginable. But ITA made it interesting by<span> </span><a href="http://www.paulgraham.com/carl.html">redefining</a><span> </span>the problem in a more ambitious way.</p>
<p>I think the same thing happened at Google. When Google was founded, the conventional wisdom among the so-called portals was that search was boring and unimportant. But the guys at Google didn&#8217;t think search was boring, and that&#8217;s why they do it so well.</p>
<p>This is an area where managers can make a difference. Like a parent saying to a child, I bet you can&#8217;t clean up your whole room in ten minutes, a good manager can sometimes redefine a problem as a more interesting one. Steve Jobs seems to be particularly good at this, in part simply by having high standards. There were a lot of small, inexpensive computers before the Mac. He redefined the problem as: make one that&#8217;s beautiful. And that probably drove the developers harder than any carrot or stick could.</p>
<p>They certainly delivered. When the Mac first appeared, you didn&#8217;t even have to turn it on to know it would be good; you could tell from the case. A few weeks ago I was walking along the street in Cambridge, and in someone&#8217;s trash I saw what appeared to be a Mac carrying case. I looked inside, and there was a Mac SE. I carried it home and plugged it in, and it booted. The happy Macintosh face, and then the finder. My God, it was so simple. It was just like &#8230; Google.</p>
<p>Hackers like to work for people with high standards. But it&#8217;s not enough just to be exacting. You have to insist on the right things. Which usually means that you have to be a hacker yourself. I&#8217;ve seen occasional articles about how to manage programmers. Really there should be two articles: one about what to do if you are yourself a programmer, and one about what to do if you&#8217;re not. And the second could probably be condensed into two words: give up.</p>
<p>The problem is not so much the day to day management. Really good hackers are practically self-managing. The problem is, if you&#8217;re not a hacker, you can&#8217;t tell who the good hackers are. A similar problem explains why American cars are so ugly. I call it the<span> </span><em>design paradox.</em><span> </span>You might think that you could make your products beautiful just by hiring a great designer to design them. But if you yourself don&#8217;t have good<span> </span><a href="http://www.paulgraham.com/taste.html">taste</a>, how are you going to recognize a good designer? By definition you can&#8217;t tell from his portfolio. And you can&#8217;t go by the awards he&#8217;s won or the jobs he&#8217;s had, because in design, as in most fields, those tend to be driven by fashion and schmoozing, with actual ability a distant third. There&#8217;s no way around it: you can&#8217;t manage a process intended to produce beautiful things without knowing what beautiful is. American cars are ugly because American car companies are run by people with bad taste.</p>
<p>Many people in this country think of taste as something elusive, or even frivolous. It is neither. To drive design, a manager must be the most demanding user of a company&#8217;s products. And if you have really good taste, you can, as Steve Jobs does, make satisfying you the kind of problem that good people like to work on.</p>
<p><strong>Nasty Little Problems</strong></p>
<p>It&#8217;s pretty easy to say what kinds of problems are not interesting: those where instead of solving a few big, clear, problems, you have to solve a lot of nasty little ones. One of the worst kinds of projects is writing an interface to a piece of software that&#8217;s full of bugs. Another is when you have to customize something for an individual client&#8217;s complex and ill-defined needs. To hackers these kinds of projects are the death of a thousand cuts.</p>
<p>The distinguishing feature of nasty little problems is that you don&#8217;t learn anything from them. Writing a compiler is interesting because it teaches you what a compiler is. But writing an interface to a buggy piece of software doesn&#8217;t teach you anything, because the bugs are random. [3] So it&#8217;s not just fastidiousness that makes good hackers avoid nasty little problems. It&#8217;s more a question of self-preservation. Working on nasty little problems makes you stupid. Good hackers avoid it for the same reason models avoid cheeseburgers.</p>
<p>Of course some problems inherently have this character. And because of supply and demand, they pay especially well. So a company that found a way to get great hackers to work on tedious problems would be very successful. How would you do it?</p>
<p>One place this happens is in startups. At our startup we had Robert Morris working as a system administrator. That&#8217;s like having the Rolling Stones play at a bar mitzvah. You can&#8217;t hire that kind of talent. But people will do any amount of drudgery for companies of which they&#8217;re the founders. [4]</p>
<p>Bigger companies solve the problem by partitioning the company. They get smart people to work for them by establishing a separate R&amp;D department where employees don&#8217;t have to work directly on customers&#8217; nasty little problems. [5] In this model, the research department functions like a mine. They produce new ideas; maybe the rest of the company will be able to use them.</p>
<p>You may not have to go to this extreme.<span> </span><a href="http://www.paulgraham.com/progbot.html">Bottom-up programming</a><span> </span>suggests another way to partition the company: have the smart people work as toolmakers. If your company makes software to do x, have one group that builds tools for writing software of that type, and another that uses these tools to write the applications. This way you might be able to get smart people to write 99% of your code, but still keep them almost as insulated from users as they would be in a traditional research department. The toolmakers would have users, but they&#8217;d only be the company&#8217;s own developers. [6]</p>
<p>If Microsoft used this approach, their software wouldn&#8217;t be so full of security holes, because the less smart people writing the actual applications wouldn&#8217;t be doing low-level stuff like allocating memory. Instead of writing Word directly in C, they&#8217;d be plugging together big Lego blocks of Word-language. (Duplo, I believe, is the technical term.)</p>
<p><strong>Clumping</strong></p>
<p>Along with interesting problems, what good hackers like is other good hackers. Great hackers tend to clump together&#8211; sometimes spectacularly so, as at Xerox Parc. So you won&#8217;t attract good hackers in linear proportion to how good an environment you create for them. The tendency to clump means it&#8217;s more like the square of the environment. So it&#8217;s winner take all. At any given time, there are only about ten or twenty places where hackers most want to work, and if you aren&#8217;t one of them, you won&#8217;t just have fewer great hackers, you&#8217;ll have zero.</p>
<p>Having great hackers is not, by itself, enough to make a company successful. It works well for Google and ITA, which are two of the hot spots right now, but it didn&#8217;t help Thinking Machines or Xerox. Sun had a good run for a while, but their business model is a down elevator. In that situation, even the best hackers can&#8217;t save you.</p>
<p>I think, though, that all other things being equal, a company that can attract great hackers will have a huge advantage. There are people who would disagree with this. When we were making the rounds of venture capital firms in the 1990s, several told us that software companies didn&#8217;t win by writing great software, but through brand, and dominating channels, and doing the right deals.</p>
<p>They really seemed to believe this, and I think I know why. I think what a lot of VCs are looking for, at least unconsciously, is the next Microsoft. And of course if Microsoft is your model, you shouldn&#8217;t be looking for companies that hope to win by writing great software. But VCs are mistaken to look for the next Microsoft, because no startup can be the next Microsoft unless some other company is prepared to bend over at just the right moment and be the next IBM.</p>
<p>It&#8217;s a mistake to use Microsoft as a model, because their whole culture derives from that one lucky break. Microsoft is a bad data point. If you throw them out, you find that good products do tend to win in the market. What VCs should be looking for is the next Apple, or the next Google.</p>
<p>I think Bill Gates knows this. What worries him about Google is not the power of their brand, but the fact that they have better hackers. [7]</p>
<p><strong>Recognition</strong></p>
<p>So who are the great hackers? How do you know when you meet one? That turns out to be very hard. Even hackers can&#8217;t tell. I&#8217;m pretty sure now that my friend Trevor Blackwell is a great hacker. You may have read on Slashdot how he made his<span> </span><a href="http://www.tlb.org/scooter.html">own Segway</a>. The remarkable thing about this project was that he wrote all the software in one day (in Python, incidentally).</p>
<p>For Trevor, that&#8217;s par for the course. But when I first met him, I thought he was a complete idiot. He was standing in Robert Morris&#8217;s office babbling at him about something or other, and I remember standing behind him making frantic gestures at Robert to shoo this nut out of his office so we could go to lunch. Robert says he misjudged Trevor at first too. Apparently when Robert first met him, Trevor had just begun a new scheme that involved writing down everything about every aspect of his life on a stack of index cards, which he carried with him everywhere. He&#8217;d also just arrived from Canada, and had a strong Canadian accent and a mullet.</p>
<p>The problem is compounded by the fact that hackers, despite their reputation for social obliviousness, sometimes put a good deal of effort into seeming smart. When I was in grad school I used to hang around the MIT AI Lab occasionally. It was kind of intimidating at first. Everyone there spoke so fast. But after a while I learned the trick of speaking fast. You don&#8217;t have to think any faster; just use twice as many words to say everything.<span> </span></p>
<p>With this amount of noise in the signal, it&#8217;s hard to tell good hackers when you meet them. I can&#8217;t tell, even now. You also can&#8217;t tell from their resumes. It seems like the only way to judge a hacker is to work with him on something.</p>
<p>And this is the reason that high-tech areas only happen around universities. The active ingredient here is not so much the professors as the students. Startups grow up around universities because universities bring together promising young people and make them work on the same projects. The smart ones learn who the other smart ones are, and together they cook up new projects of their own.</p>
<p>Because you can&#8217;t tell a great hacker except by working with him, hackers themselves can&#8217;t tell how good they are. This is true to a degree in most fields. I&#8217;ve found that people who are great at something are not so much convinced of their own greatness as mystified at why everyone else seems so incompetent.<span> </span></p>
<p>But it&#8217;s particularly hard for hackers to know how good they are, because it&#8217;s hard to compare their work. This is easier in most other fields. In the hundred meters, you know in 10 seconds who&#8217;s fastest. Even in math there seems to be a general consensus about which problems are hard to solve, and what constitutes a good solution. But hacking is like writing. Who can say which of two novels is better? Certainly not the authors.</p>
<p>With hackers, at least, other hackers can tell. That&#8217;s because, unlike novelists, hackers collaborate on projects. When you get to hit a few difficult problems over the net at someone, you learn pretty quickly how hard they hit them back. But hackers can&#8217;t watch themselves at work. So if you ask a great hacker how good he is, he&#8217;s almost certain to reply, I don&#8217;t know. He&#8217;s not just being modest. He really doesn&#8217;t know.</p>
<p>And none of us know, except about people we&#8217;ve actually worked with. Which puts us in a weird situation: we don&#8217;t know who our heroes should be. The hackers who become famous tend to become famous by random accidents of PR. Occasionally I need to give an example of a great hacker, and I never know who to use. The first names that come to mind always tend to be people I know personally, but it seems lame to use them. So, I think, maybe I should say Richard Stallman, or Linus Torvalds, or Alan Kay, or someone famous like that. But I have no idea if these guys are great hackers. I&#8217;ve never worked with them on anything.</p>
<p>If there is a Michael Jordan of hacking, no one knows, including him.</p>
<p><strong>Cultivation</strong></p>
<p>Finally, the question the hackers have all been wondering about: how do you become a great hacker? I don&#8217;t know if it&#8217;s possible to make yourself into one. But it&#8217;s certainly possible to do things that make you stupid, and if you can make yourself stupid, you can probably make yourself smart too.</p>
<p>The key to being a good hacker may be to work on what you like. When I think about the great hackers I know, one thing they have in common is the extreme<span> </span><a href="http://www.paulgraham.com/procrastination.html">difficulty</a><span> </span>of making them work on anything they don&#8217;t want to. I don&#8217;t know if this is cause or effect; it may be both.</p>
<p>To do something well you have to<span> </span><a href="http://www.paulgraham.com/love.html">love</a><span> </span>it. So to the extent you can preserve hacking as something you love, you&#8217;re likely to do it well. Try to keep the sense of wonder you had about programming at age 14. If you&#8217;re worried that your current job is rotting your brain, it probably is.</p>
<p>The best hackers tend to be smart, of course, but that&#8217;s true in a lot of fields. Is there some quality that&#8217;s unique to hackers? I asked some friends, and the number one thing they mentioned was curiosity. I&#8217;d always supposed that all smart people were curious&#8211; that curiosity was simply the first derivative of knowledge. But apparently hackers are particularly curious, especially about how things work. That makes sense, because programs are in effect giant descriptions of how things work.</p>
<p>Several friends mentioned hackers&#8217; ability to concentrate&#8211; their ability, as one put it, to &#8220;tune out everything outside their own heads.&#8221; I&#8217;ve certainly noticed this. And I&#8217;ve heard several hackers say that after drinking even half a beer they can&#8217;t program at all. So maybe hacking does require some special ability to focus. Perhaps great hackers can load a large amount of context into their head, so that when they look at a line of code, they see not just that line but the whole program around it. John McPhee wrote that Bill Bradley&#8217;s success as a basketball player was due partly to his extraordinary peripheral vision. &#8220;Perfect&#8221; eyesight means about 47 degrees of vertical peripheral vision. Bill Bradley had 70; he could see the basket when he was looking at the floor. Maybe great hackers have some similar inborn ability. (I cheat by using a very<span> </span><a href="http://www.paulgraham.com/power.html">dense</a>language, which shrinks the court.)</p>
<p>This could explain the disconnect over cubicles. Maybe the people in charge of facilities, not having any concentration to shatter, have no idea that working in a cubicle feels to a hacker like having one&#8217;s brain in a blender. (Whereas Bill, if the rumors of autism are true, knows all too well.)</p>
<p>One difference I&#8217;ve noticed between great hackers and smart people in general is that hackers are more<span> </span><a href="http://www.paulgraham.com/say.html">politically incorrect</a>. To the extent there is a secret handshake among good hackers, it&#8217;s when they know one another well enough to express opinions that would get them stoned to death by the general public. And I can see why political incorrectness would be a useful quality in programming. Programs are very complex and, at least in the hands of good programmers, very fluid. In such situations it&#8217;s helpful to have a habit of questioning assumptions.</p>
<p>Can you cultivate these qualities? I don&#8217;t know. But you can at least not repress them. So here is my best shot at a recipe. If it is possible to make yourself into a great hacker, the way to do it may be to make the following deal with yourself: you never have to work on boring projects (unless your family will starve otherwise), and in return, you&#8217;ll never allow yourself to do a half-assed job. All the great hackers I know seem to have made that deal, though perhaps none of them had any choice in the matter.</p>
<p><strong>Notes</strong></p>
<p>[1] In fairness, I have to say that IBM makes decent hardware. I wrote this on an IBM laptop.</p>
<p>[2] They did turn out to be doomed. They shut down a few months later.</p>
<p>[3] I think this is what people mean when they talk about the &#8220;meaning of life.&#8221; On the face of it, this seems an odd idea. Life isn&#8217;t an expression; how could it have meaning? But it can have a quality that feels a lot like meaning. In a project like a compiler, you have to solve a lot of problems, but the problems all fall into a pattern, as in a signal. Whereas when the problems you have to solve are random, they seem like noise.</p>
<p>[4] Einstein at one point worked designing refrigerators. (He had equity.)</p>
<p>[5] It&#8217;s hard to say exactly what constitutes research in the computer world, but as a first approximation, it&#8217;s software that doesn&#8217;t have users.</p>
<p>I don&#8217;t think it&#8217;s publication that makes the best hackers want to work in research departments. I think it&#8217;s mainly not having to have a three hour meeting with a product manager about problems integrating the Korean version of Word 13.27 with the talking paperclip.</p>
<p>[6] Something similar has been happening for a long time in the construction industry. When you had a house built a couple hundred years ago, the local builders built everything in it. But increasingly what builders do is assemble components designed and manufactured by someone else. This has, like the arrival of desktop publishing, given people the freedom to experiment in disastrous ways, but it is certainly more efficient.</p>
<p>[7] Google is much more dangerous to Microsoft than Netscape was. Probably more dangerous than any other company has ever been. Not least because they&#8217;re determined to fight. On their job listing page, they say that one of their &#8220;core values&#8221; is &#8220;Don&#8217;t be evil.&#8221; From a company selling soybean oil or mining equipment, such a statement would merely be eccentric. But I think all of us in the computer world recognize who that is a declaration of war on.</p>
<p style="text-align: left;"><span style="font-family: verdana; font-size: 16px;">From: </span><a href="http://www.paulgraham.com/gh.html">http://www.paulgraham.com/gh.html</a></p>



Share and Enjoy:


	<a rel="nofollow" href="mailto:?subject=Ordinary%20Programmers%20vs%20Great%20Hackers&amp;body=http%3A%2F%2Fblog.ianuy.com%2F2009%2F09%2F17%2Fordinary-programmers-vs-great-hackers%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%2F09%2F17%2Fordinary-programmers-vs-great-hackers%2F&amp;title=Ordinary%20Programmers%20vs%20Great%20Hackers&amp;bodytext=%0A%0D%0AI%20love%20Paul%20Graham.%20The%20guy%20speaks%20my%20mind.%20Although%20I%20don%27t%20agree%20with%20all%20of%20his%20ideas%20%28E.G.%20Java%20programmers%20are%20stupid.%20PERIOD.%29%2C%20most%20of%20his%20ideas%20are%20golden.%20For%20those%20of%20weak%20hearts%20%28and%20sensitive%20ego%29%2C%20please%20proceed%20with%20care.%20%3A-%29%0D%0A%0D%0AThe%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%2F09%2F17%2Fordinary-programmers-vs-great-hackers%2F&amp;title=Ordinary%20Programmers%20vs%20Great%20Hackers" 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%2F09%2F17%2Fordinary-programmers-vs-great-hackers%2F&amp;title=Ordinary%20Programmers%20vs%20Great%20Hackers&amp;notes=%0A%0D%0AI%20love%20Paul%20Graham.%20The%20guy%20speaks%20my%20mind.%20Although%20I%20don%27t%20agree%20with%20all%20of%20his%20ideas%20%28E.G.%20Java%20programmers%20are%20stupid.%20PERIOD.%29%2C%20most%20of%20his%20ideas%20are%20golden.%20For%20those%20of%20weak%20hearts%20%28and%20sensitive%20ego%29%2C%20please%20proceed%20with%20care.%20%3A-%29%0D%0A%0D%0AThe%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=Ordinary%20Programmers%20vs%20Great%20Hackers%20-%20http%3A%2F%2Fblog.ianuy.com%2F2009%2F09%2F17%2Fordinary-programmers-vs-great-hackers%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=Ordinary%20Programmers%20vs%20Great%20Hackers&amp;url=http%3A%2F%2Fblog.ianuy.com%2F2009%2F09%2F17%2Fordinary-programmers-vs-great-hackers%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%2F09%2F17%2Fordinary-programmers-vs-great-hackers%2F&amp;t=Ordinary%20Programmers%20vs%20Great%20Hackers" 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%2F09%2F17%2Fordinary-programmers-vs-great-hackers%2F&amp;t=Ordinary%20Programmers%20vs%20Great%20Hackers" 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%2F09%2F17%2Fordinary-programmers-vs-great-hackers%2F&amp;title=Ordinary%20Programmers%20vs%20Great%20Hackers&amp;annotation=%0A%0D%0AI%20love%20Paul%20Graham.%20The%20guy%20speaks%20my%20mind.%20Although%20I%20don%27t%20agree%20with%20all%20of%20his%20ideas%20%28E.G.%20Java%20programmers%20are%20stupid.%20PERIOD.%29%2C%20most%20of%20his%20ideas%20are%20golden.%20For%20those%20of%20weak%20hearts%20%28and%20sensitive%20ego%29%2C%20please%20proceed%20with%20care.%20%3A-%29%0D%0A%0D%0AThe%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%2F09%2F17%2Fordinary-programmers-vs-great-hackers%2F&amp;title=Ordinary%20Programmers%20vs%20Great%20Hackers" 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/09/17/ordinary-programmers-vs-great-hackers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ASP.NET 1.X to ASP.NET 2.0 Migration Postback Problem</title>
		<link>http://blog.ianuy.com/2009/05/17/aspnet-1x-to-aspnet-20-migration-postback-problem/</link>
		<comments>http://blog.ianuy.com/2009/05/17/aspnet-1x-to-aspnet-20-migration-postback-problem/#comments</comments>
		<pubDate>Sun, 17 May 2009 15:40:17 +0000</pubDate>
		<dc:creator>Ian Uy</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Job]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.ianuy.com/?p=316</guid>
		<description><![CDATA[If you&#8217;ve read my previous blog post, I talked about some of the problems encountered while migrating some of our web applications from .NET 1.1 to .NET 2.0. Well, those products are now handed off to the Test Department for their routine torture.
Just a couple of days after the hand-off (Hand-off to Test or HOTT), [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_317" class="wp-caption aligncenter" style="width: 237px"><a href="http://blog.ianuy.com/wp-content/uploads/2009/05/7259_bird_cartoon.gif"><img class="size-medium wp-image-317" title="ASP.NET Migration Problem" src="http://blog.ianuy.com/wp-content/uploads/2009/05/7259_bird_cartoon-227x300.gif" alt="ASP.NET Migration Problem" width="227" height="300" /></a><p class="wp-caption-text">ASP.NET Migration Problem</p></div>
<p>If you&#8217;ve read my <a title="Migration: Why Developers Hate Microsoft or Why Developers Hate Vista or My First Encounter how Microsoft can Break your Software " 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 post</a>, I talked about some of the problems encountered while migrating some of our web applications from .NET 1.1 to .NET 2.0. Well, those products are now handed off to the Test Department for their routine torture.</p>
<p>Just a couple of days after the hand-off (Hand-off to Test or HOTT), the tester who is testing the product filed two (2) Tracks (Incident/Bug/Problem). Since I am the only developer working on the product, all of the tracks will automatically be assigned to me. The said tracks that were filed have the same &#8220;type&#8221; of problem.</p>
<blockquote><p>When browsing for a file (Backup File / File Upload), the value of the Textbox would change back to its default value when the page re-loads.</p></blockquote>
<p><span id="more-316"></span></p>
<p>The web application that I am supporting was originally written in .NET 1.1 using Visual Studio 2003. To migrate it to .NET 2.0, we converted the solutions to VS2005. Aside from some<a title="Migration: Why Developers Hate Microsoft or Why Developers Hate Vista or My First Encounter how Microsoft can Break your Software " 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"> minor problems like RESX incompatibility and broken Calendar Controls</a>, the Web Application worked &#8212; I thought it did.</p>
<p>We have a <em>Backup Restoration Page<strong> </strong></em>to allow the user to restore the web application in-case of Armageddon-like circumstances. The said page basically contain 3 components:</p>
<ol>
<li>A <strong>Read-Only </strong>Textbox that holds the path of the <strong>Backup File</strong> . This Textbox has a default value of <span style="text-decoration: underline;">C:\Backups\Backup.bak</span></li>
<li>A Browse button that will launch a custom page that will allow the user to browse for the <strong>Backup File</strong>. The value selected there will be posted-back to the <em>Backup Restoration Page.</em></li>
<li>A &#8220;Restore&#8221; button to start the restoration process.</li>
</ol>
<p>When I tried to repro (reproduce) the bug on my Virtual Machine setup, I was able to verify that the path of the Backup File is losing its value on postback. To put it more precisely, the Textbox is not retaining the correct path since it is changing back to its default value on postback.</p>
<p>After hours of debugging, I was no where close in determining the cause of the problem. So I did a quick search on Google and found out that this is a common problem during migration from ASP.NET 1.1 to ASP.NET 2.0.</p>
<p>The problem is that Microsoft changed the behavior of read-only textboxes on ASP.NET 2.0.</p>
<blockquote><p>ASP.NET 2.0 had a design change by which a control if marked with its ReadOnly property as true, would ignore client side changes and would lose the same across postback. So if you tried modifying the text box value or add a value to the text box using Javascript you wouldnt be able to retireve the value in the code behind or simply the value will be lost across postback.</p></blockquote>
<p><span style="color: #000000;"><span id="ctl00_ContentPlaceHolder1_lblDescription">This behaviour is by design in ASP.NET 2.0 and it has been designed with the idea that a ReadOnly TextBox shouldnt be modified in the client side by a malicious code.</span></span></p>
<p><span style="color: #000000;"><br />
Microsoft has a point. What&#8217;s the point of using a Textbox if you&#8217;re going to set it to Read-Only? Why not use a Label instead?</span></p>
<p>Fortunately, we have three simple <strong>workarounds</strong> for this problem.</p>
<ol>
<li>Use a Label instead of a Read-Only Textbox. (Heard of Borders?)</li>
<li>Set the Read-Only property of the Textbox to <em>FALSE </em>(If you don&#8217;t really need the Read-Only Property)</li>
<li>But if you are really insisting of using a Read-Only Textbox, then we need to &#8220;fool&#8221; ASP.NET that the Textbox is not Read-Only even if it is.</li>
</ol>
<p>To &#8220;fool&#8221; ASP.NET, you need to set the Read-Only property of the Textbox to <span style="color: #0000ff;">FALSE</span> during design time (Using the Property Pane) then <strong>set it to Read-Only on Page Load during runtime</strong>. <strong>You CANNOT use Textbox1.ReadOnly = true. </strong>You need to set the read-only attribute using the Attribute.Add() method.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">// This is part of the C# code-behind file.</span>
<span style="color: #0600FF;">protected</span> <span style="color: #0600FF;">void</span> Page_Load<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">object</span> sender, EventArgs e<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
     TextBox1.<span style="color: #0000FF;">Attributes</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;readonly&quot;</span>, <span style="color: #666666;">&quot;readonly&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>That will solve your postback problems. <img src='http://blog.ianuy.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>References:</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.textbox.readonly.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.textbox.readonly.aspx</a></li>
<li><a href="http://www.dotnetspider.com/resources/3120-ASP-NET--TextBox-Ready-Only-losing-client-side-changes-values-across-postback.aspx" target="_blank">http://www.dotnetspider.com/resources/3120-ASP-NET&#8211;TextBox-Ready-Only-losing-client-side-changes-values-across-postback.aspx</a></li>
<li><a href="http://stackoverflow.com/questions/856838/migration-asp-net-1-1-to-asp-net-2-0-broken-postback" target="_blank">http://stackoverflow.com/questions/856838/migration-asp-net-1-1-to-asp-net-2-0-broken-postback</a></li>
</ul>



Share and Enjoy:


	<a rel="nofollow" href="mailto:?subject=ASP.NET%201.X%20to%20ASP.NET%202.0%20Migration%20Postback%20Problem&amp;body=http%3A%2F%2Fblog.ianuy.com%2F2009%2F05%2F17%2Faspnet-1x-to-aspnet-20-migration-postback-problem%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%2F05%2F17%2Faspnet-1x-to-aspnet-20-migration-postback-problem%2F&amp;title=ASP.NET%201.X%20to%20ASP.NET%202.0%20Migration%20Postback%20Problem&amp;bodytext=%0A%0D%0AIf%20you%27ve%20read%20my%20previous%20blog%20post%2C%20I%20talked%20about%20some%20of%20the%20problems%20encountered%20while%20migrating%20some%20of%20our%20web%20applications%20from%20.NET%201.1%20to%20.NET%202.0.%20Well%2C%20those%20products%20are%20now%20handed%20off%20to%20the%20Test%20Department%20for%20their%20routine%20torture." 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%2F05%2F17%2Faspnet-1x-to-aspnet-20-migration-postback-problem%2F&amp;title=ASP.NET%201.X%20to%20ASP.NET%202.0%20Migration%20Postback%20Problem" 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%2F05%2F17%2Faspnet-1x-to-aspnet-20-migration-postback-problem%2F&amp;title=ASP.NET%201.X%20to%20ASP.NET%202.0%20Migration%20Postback%20Problem&amp;notes=%0A%0D%0AIf%20you%27ve%20read%20my%20previous%20blog%20post%2C%20I%20talked%20about%20some%20of%20the%20problems%20encountered%20while%20migrating%20some%20of%20our%20web%20applications%20from%20.NET%201.1%20to%20.NET%202.0.%20Well%2C%20those%20products%20are%20now%20handed%20off%20to%20the%20Test%20Department%20for%20their%20routine%20torture." 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=ASP.NET%201.X%20to%20ASP.NET%202.0%20Migration%20Postback%20Problem%20-%20http%3A%2F%2Fblog.ianuy.com%2F2009%2F05%2F17%2Faspnet-1x-to-aspnet-20-migration-postback-problem%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=ASP.NET%201.X%20to%20ASP.NET%202.0%20Migration%20Postback%20Problem&amp;url=http%3A%2F%2Fblog.ianuy.com%2F2009%2F05%2F17%2Faspnet-1x-to-aspnet-20-migration-postback-problem%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%2F05%2F17%2Faspnet-1x-to-aspnet-20-migration-postback-problem%2F&amp;t=ASP.NET%201.X%20to%20ASP.NET%202.0%20Migration%20Postback%20Problem" 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%2F05%2F17%2Faspnet-1x-to-aspnet-20-migration-postback-problem%2F&amp;t=ASP.NET%201.X%20to%20ASP.NET%202.0%20Migration%20Postback%20Problem" 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%2F05%2F17%2Faspnet-1x-to-aspnet-20-migration-postback-problem%2F&amp;title=ASP.NET%201.X%20to%20ASP.NET%202.0%20Migration%20Postback%20Problem&amp;annotation=%0A%0D%0AIf%20you%27ve%20read%20my%20previous%20blog%20post%2C%20I%20talked%20about%20some%20of%20the%20problems%20encountered%20while%20migrating%20some%20of%20our%20web%20applications%20from%20.NET%201.1%20to%20.NET%202.0.%20Well%2C%20those%20products%20are%20now%20handed%20off%20to%20the%20Test%20Department%20for%20their%20routine%20torture." 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%2F05%2F17%2Faspnet-1x-to-aspnet-20-migration-postback-problem%2F&amp;title=ASP.NET%201.X%20to%20ASP.NET%202.0%20Migration%20Postback%20Problem" 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/05/17/aspnet-1x-to-aspnet-20-migration-postback-problem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Migration: Why Developers Hate Microsoft or Why Developers Hate Vista or My First Encounter how Microsoft can Break your Software</title>
		<link>http://blog.ianuy.com/2009/05/10/migration-why-developers-hate-microsoft-or-my-first-encounter-how-microsoft-can-break-your-software/</link>
		<comments>http://blog.ianuy.com/2009/05/10/migration-why-developers-hate-microsoft-or-my-first-encounter-how-microsoft-can-break-your-software/#comments</comments>
		<pubDate>Sun, 10 May 2009 14:13:29 +0000</pubDate>
		<dc:creator>Ian Uy</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Job]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://blog.ianuy.com/?p=262</guid>
		<description><![CDATA[In my previous blog post, I&#8217;ve mentioned that I&#8217;m working on a project to migrate an entire product line to Vista. What I meant by that is that I am responsible for making sure that our current product will run properly on Windows Vista. To guarantee that it is indeed Running Properly it should behave [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_263" class="wp-caption aligncenter" style="width: 546px"><a href="http://blog.ianuy.com/wp-content/uploads/2009/05/windowsvistalogo.jpg"><img class="size-full wp-image-263" title="Windows Vista Compatible Logo" src="http://blog.ianuy.com/wp-content/uploads/2009/05/windowsvistalogo.jpg" alt="Do you know how much Programmer's Blood it cost to put this tiny sticker in a Software Box?" width="536" height="262" /></a><p class="wp-caption-text">Do you know how much Programmer&#39;s Blood it cost to put this tiny sticker in a Software Box?</p></div>
<p>In my <a title="Coding Horror 01: Readability vs Efficiency " href="http://blog.ianuy.com/2009/04/26/coding-horror-01-readability-vs-efficiency/" target="_blank">previous blog post</a>, I&#8217;ve mentioned that I&#8217;m working on a project to migrate an entire product line to Vista. What I meant by that is that I am responsible for making sure that our current product will run properly on Windows Vista. To guarantee that it is indeed <em>Running Properly</em> it should behave *exactly* like it behaves in Windows XP.  In simple terms, my entire job security is riding on making our products compatible with Microsoft&#8217;s failed attempt at a MAC-ish Operating System and with Microsoft&#8217;s successful attempt (a first in their history) to make their operating system <strong>NOT</strong> backward compatible with older applications. So much for <a title="Raymond Chen's Blog" href="http://blogs.msdn.com/oldnewthing/" target="_blank">Raymond Chen</a>&#8217;s camp <a title="How Microsoft Lost the API War" href="http://joelonsoftware.com/articles/APIWar.html" target="_blank">undying obsession with backward compatibility</a>.</p>
<p>This products that I&#8217;m talking about are a set of Web Applications written in ASP.NET version 1.1. This web applications are as old as Windows XP. <img src='http://blog.ianuy.com/wp-includes/images/smilies/icon_lol.gif' alt=':lol:' class='wp-smiley' />  I checked its File Modification History in our TFS repository and the last time that anyone have touched its code base is in 2005 &#8212; and that&#8217;s just for a minor code modification to fix a bug. I believe this apps were written way way back in 2004 &#8212; when I was in Third Year High School! <img src='http://blog.ianuy.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>To make this products compatible with Vista, there are a couple of steps that had to be done. I&#8217;ll enumerate each steps and what it takes to accomplish them.</p>
<p><span id="more-262"></span></p>
<h3>.NET Upgrade (.NET 1.1 to .NET 2.0)</h3>
<p>Windows Vista comes pre-installed with .NET 2.0 (and .NET 3.0). Our products are running on .NET 1.1. One approach that most people will suggest is to just install .NET 1.1 on Windows Vista and everything will be perfect. Right? WRONG. Firstly, .NET 1.1 has already reached its end-of-life. Microsoft pulled support for .NET 1.1 last October 14, 2008. Although it was extended, its a sign that this technology is <em>old enough</em> to be replaced. Secondly, installing .NET 1.1 on a Vista machine is not as <a href="http://geekycoder.wordpress.com/2007/10/08/installing-microsoft-net-11-framework-on-windows-vista-without-tears/" target="_blank">easy</a> <a href="http://www.mydigitallife.info/2007/12/27/install-microsoft-net-framework-11-on-windows-vista-fix-regsvcsexe-fails-error/" target="_blank">as</a> <a href="http://searchwindevelopment.techtarget.com/tip/0,289483,sid8_gci1237467,00.html" target="_blank">you</a> <a href="http://www.sharpdeveloper.net/content/archive/2008/10/07/setup-aspnet-11-on-vista.aspx" target="_blank">think</a>. No, we are not lazy programmers, we just don&#8217;t want to introduce unnecessary complications to the system. We are, by the way, <a title="Coding Horror 01: Readability vs Efficiency " href="http://blog.ianuy.com/2009/04/26/coding-horror-01-readability-vs-efficiency/" target="_blank">Software Developers</a>.</p>
<div id="attachment_270" class="wp-caption aligncenter" style="width: 224px"><a href="http://blog.ianuy.com/wp-content/uploads/2009/05/lazy-programmers.jpg"><img class="size-medium wp-image-270" title="Lazy Programmers" src="http://blog.ianuy.com/wp-content/uploads/2009/05/lazy-programmers-214x300.jpg" alt="Those Lazy Programmers" width="214" height="300" /></a><p class="wp-caption-text">Those Lazy Programmers</p></div>
<p>So the approach we took is to upgrade our Visual Studio 2003 solutions to Visual Studio 2005 solutions. This, in turn, will &#8220;force&#8221; the web application to use .NET 2.0. You might say, &#8220;How hard could it be? Visual Studio 2005 can convert old solutions automatically using its <em>Upgrade Wizard. </em>All you have to do is click next!, You lazy programmer!&#8221;. That&#8217;s correct. Upgrading the solution is no problem. Converting every file to .NET 2.0 compliant code <em>is</em>.</p>
<p>We encountered two conversion problems. The first one is relatively simple to fix. It&#8217;s a problem where the old .NET 1.1 Resource files (*.resx) were not converted to the .NET 2.0 resource files. The two resource file formats are different (the .NET 2.0 have a *.designer.cs component) and in very rare cases, the .NET 1.1 *resx files won&#8217;t work in .NET 2.0. This problem is very hard to catch since the incompatible *.resx files won&#8217;t throw a compile error. The strings just won&#8217;t be detected. But once found it was relatively easy to fix. After a day of investigation, we found out that the XML format for the resource files changed in .NET 2.0. As a simple hack (fix), we manually changed the &lt;string&gt; parameters of each .NET 1.1 strings to match the .NET 2.0 &lt;string&gt; parameters.</p>
<p>The second problem is harder to find and much much harder to fix. The problem is related to ASP.NET&#8217;s datetime picker control.</p>
<div id="attachment_274" class="wp-caption aligncenter" style="width: 282px"><a href="http://blog.ianuy.com/wp-content/uploads/2009/05/workingaspnet.jpg"><img class="size-full wp-image-274" title="ASP.NET 1.1 Calendar Control" src="http://blog.ianuy.com/wp-content/uploads/2009/05/workingaspnet.jpg" alt="Our Calendar Control before upgrading to .NET 2.0" width="272" height="214" /></a><p class="wp-caption-text">Our Calendar Control before upgrading to .NET 2.0</p></div>
<p>On our previous version running .NET 1.1, there is no problem with the datetime picker. But when we installed the .NET 2.0 version, the calendar objects are all over the place.</p>
<div id="attachment_275" class="wp-caption aligncenter" style="width: 1034px"><a href="http://blog.ianuy.com/wp-content/uploads/2009/05/brokencontrol.jpg"><img class="size-large wp-image-275" title="Broken ASP.NET Calendar Control" src="http://blog.ianuy.com/wp-content/uploads/2009/05/brokencontrol-1024x211.jpg" alt="Broken ASP.NET Calendar Control" width="1024" height="211" /></a><p class="wp-caption-text">The Migrated .NET 2.0 Calendar Control</p></div>
<p style="text-align: left;">Two days of investigation later, we found out that the previous developer made this custom Calendar control by inheriting from .NET 1.1&#8217;s System.Web.Controls. During pre-render, he reads the rendered Calendar Control&#8217;s HTML and then does something funny with it. What he wanted to achieve is to replace the &#8220;Month&#8221; from the Calendar header (gray part) with a drop down box that contains a list of the months. So what he did is he &#8220;catch&#8221; the HTML stream from the Calendar Control and perform a String.Replace on it!</p>
<p style="text-align: left;">
<div id="attachment_278" class="wp-caption aligncenter" style="width: 586px"><a href="http://blog.ianuy.com/wp-content/uploads/2009/05/design.jpg"><img class="size-full wp-image-278" title="Design Goal" src="http://blog.ianuy.com/wp-content/uploads/2009/05/design.jpg" alt="His Design Goal" width="576" height="207" /></a><p class="wp-caption-text">His Design Goal</p></div>
<p style="text-align: left;">The actual String.Replace command is something like this:</p>
<p style="text-align: left;">

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">//szHTML = Get current HTML stream</span>
<span style="color: #008080; font-style: italic;">//szCurrentMonth = Get current month from HTML</span>
szHTML.<span style="color: #0000FF;">Replace</span><span style="color: #000000;">&#40;</span>szCurrentMonth, <span style="color: #666666;">&quot;
&lt;select&gt;&lt;option value=&quot;</span>January<span style="color: #666666;">&quot;&gt;January&lt;/option&gt;
       &lt;option value=&quot;</span>February<span style="color: #666666;">&quot;&gt;February&lt;/option&gt;
       &lt;option value=&quot;</span>March<span style="color: #666666;">&quot;&gt;March&lt;/option&gt;
       &lt;option value=&quot;</span>April<span style="color: #666666;">&quot;&gt;April&lt;/option&gt;
       &lt;option value=&quot;</span>May<span style="color: #666666;">&quot;&gt;May&lt;/option&gt;
       &lt;option value=&quot;</span>June<span style="color: #666666;">&quot;&gt;June&lt;/option&gt;
       &lt;option value=&quot;</span>July<span style="color: #666666;">&quot;&gt;July&lt;/option&gt;
       &lt;option value=&quot;</span>August<span style="color: #666666;">&quot;&gt;August&lt;/option&gt;
       &lt;option value=&quot;</span>September<span style="color: #666666;">&quot;&gt;September&lt;/option&gt;
       &lt;option value=&quot;</span>October<span style="color: #666666;">&quot;&gt;October&lt;/option&gt;
       &lt;option value=&quot;</span>November<span style="color: #666666;">&quot;&gt;November&lt;/option&gt;
       &lt;option value=&quot;</span>December<span style="color: #666666;">&quot;&gt;December&lt;/option&gt;
&lt;/select&gt;
&nbsp;
&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span></pre></div></div>

<p>It worked fine before the migration, but somehow we broke it during migration to .NET 2.0. A further investigation of the &#8220;emitted&#8221; HTML stream from the .NET 2.0 control shows this:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;table style=&quot;border-style: solid; border-width: 1px; border-collapse: collapse;&quot; title=&quot;Calendar&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;background-color: Silver;&quot; colspan=&quot;7&quot;&gt;
&lt;table style=&quot;width: 100%; border-collapse: collapse;&quot; border=&quot;0&quot; cellspacing=&quot;0&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 15%;&quot;&gt;&lt;a style=&quot;color: Black;&quot; title=&quot;Go to the previous month&quot; href=&quot;javascript:__doPostBack('ctl01','V3378')&quot;&gt;&amp;lt;&lt;/a&gt;&lt;/td&gt;
&lt;!-- THIS WILL BE THE PART THAT WILL BE REPLACED BY A DROP DOWN BOX --&gt;
&lt;td style=&quot;width: 70%;&quot; align=&quot;center&quot;&gt;May 2009&lt;/td&gt;
&lt;td style=&quot;width: 15%;&quot; align=&quot;right&quot;&gt;&lt;a style=&quot;color: Black;&quot; title=&quot;Go to the next month&quot; href=&quot;javascript:__doPostBack('ctl01','V3439')&quot;&gt;&amp;gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;th align=&quot;center&quot; scope=&quot;col&quot;&gt;Sun&lt;/th&gt;
&lt;th align=&quot;center&quot; scope=&quot;col&quot;&gt;Mon&lt;/th&gt;
&lt;th align=&quot;center&quot; scope=&quot;col&quot;&gt;Tue&lt;/th&gt;
&lt;th align=&quot;center&quot; scope=&quot;col&quot;&gt;Wed&lt;/th&gt;
&lt;th align=&quot;center&quot; scope=&quot;col&quot;&gt;Thu&lt;/th&gt;
&lt;th align=&quot;center&quot; scope=&quot;col&quot;&gt;Fri&lt;/th&gt;
&lt;th align=&quot;center&quot; scope=&quot;col&quot;&gt;Sat&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 14%;&quot; align=&quot;center&quot;&gt;&lt;a style=&quot;color: black;&quot; title=&quot;April 26&quot; href=&quot;javascript:__doPostBack('ctl01','3403')&quot;&gt;26&lt;/a&gt;&lt;/td&gt;
&lt;td style=&quot;width: 14%;&quot; align=&quot;center&quot;&gt;&lt;a style=&quot;color: Black;&quot; title=&quot;April 27&quot; href=&quot;javascript:__doPostBack('ctl01','3404')&quot;&gt;27&lt;/a&gt;&lt;/td&gt;
&lt;td style=&quot;width: 14%;&quot; align=&quot;center&quot;&gt;&lt;a style=&quot;color: Black;&quot; title=&quot;April 28&quot; href=&quot;javascript:__doPostBack('ctl01','3405')&quot;&gt;28&lt;/a&gt;&lt;/td&gt;
&lt;td style=&quot;width: 14%;&quot; align=&quot;center&quot;&gt;&lt;a style=&quot;color: Black;&quot; title=&quot;April 29&quot; href=&quot;javascript:__doPostBack('ctl01','3406')&quot;&gt;29&lt;/a&gt;&lt;/td&gt;
&lt;td style=&quot;width: 14%;&quot; align=&quot;center&quot;&gt;&lt;a style=&quot;color: Black;&quot; title=&quot;April 30&quot; href=&quot;javascript:__doPostBack('ctl01','3407')&quot;&gt;30&lt;/a&gt;&lt;/td&gt;
&lt;!-- THE TITLE ATTRIBUTE WAS ALSO REPLACED ACCIDENTALLY --&gt;
&lt;td style=&quot;width: 14%;&quot; align=&quot;center&quot;&gt;&lt;a style=&quot;color: Black;&quot; title=&quot;May 01&quot; href=&quot;javascript:__doPostBack('ctl01','3408')&quot;&gt;1&lt;/a&gt;&lt;/td&gt;
&lt;td style=&quot;width: 14%;&quot; align=&quot;center&quot;&gt;&lt;a style=&quot;color: Black;&quot; title=&quot;May 02&quot; href=&quot;javascript:__doPostBack('ctl01','3409')&quot;&gt;2&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
.....&lt;/tbody&gt;&lt;/table&gt;</pre></div></div>

<p>A comparison with the &#8220;emitted&#8221; .NET 1.1 control shows this:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;table style=&quot;border-style: solid; border-width: 1px; border-collapse: collapse;&quot; title=&quot;Calendar&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;background-color: Silver;&quot; colspan=&quot;7&quot;&gt;
&lt;table style=&quot;width: 100%; border-collapse: collapse;&quot; border=&quot;0&quot; cellspacing=&quot;0&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 15%;&quot;&gt;&lt;a style=&quot;color: Black;&quot; title=&quot;Go to the previous month&quot; href=&quot;javascript:__doPostBack('ctl01','V3378')&quot;&gt;&amp;lt;&lt;/a&gt;&lt;/td&gt;
&lt;!-- THIS WILL BE THE PART THAT WILL BE REPLACED BY A DROP DOWN BOX --&gt;
&lt;td style=&quot;width: 70%;&quot; align=&quot;center&quot;&gt;May 2009&lt;/td&gt;
&lt;td style=&quot;width: 15%;&quot; align=&quot;right&quot;&gt;&lt;a style=&quot;color: Black;&quot; title=&quot;Go to the next month&quot; href=&quot;javascript:__doPostBack('ctl01','V3439')&quot;&gt;&amp;gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;th align=&quot;center&quot; scope=&quot;col&quot;&gt;Sun&lt;/th&gt;
&lt;th align=&quot;center&quot; scope=&quot;col&quot;&gt;Mon&lt;/th&gt;
&lt;th align=&quot;center&quot; scope=&quot;col&quot;&gt;Tue&lt;/th&gt;
&lt;th align=&quot;center&quot; scope=&quot;col&quot;&gt;Wed&lt;/th&gt;
&lt;th align=&quot;center&quot; scope=&quot;col&quot;&gt;Thu&lt;/th&gt;
&lt;th align=&quot;center&quot; scope=&quot;col&quot;&gt;Fri&lt;/th&gt;
&lt;th align=&quot;center&quot; scope=&quot;col&quot;&gt;Sat&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 14%;&quot; align=&quot;center&quot;&gt;&lt;a style=&quot;color: black;&quot; href=&quot;javascript:__doPostBack('ctl01','3403')&quot;&gt;26&lt;/a&gt;&lt;/td&gt;
&lt;td style=&quot;width: 14%;&quot; align=&quot;center&quot;&gt;&lt;a style=&quot;color: Black;&quot; href=&quot;javascript:__doPostBack('ctl01','3404')&quot;&gt;27&lt;/a&gt;&lt;/td&gt;
&lt;td style=&quot;width: 14%;&quot; align=&quot;center&quot;&gt;&lt;a style=&quot;color: Black;&quot; href=&quot;javascript:__doPostBack('ctl01','3405')&quot;&gt;28&lt;/a&gt;&lt;/td&gt;
&lt;td style=&quot;width: 14%;&quot; align=&quot;center&quot;&gt;&lt;a style=&quot;color: Black;&quot; href=&quot;javascript:__doPostBack('ctl01','3406')&quot;&gt;29&lt;/a&gt;&lt;/td&gt;
&lt;td style=&quot;width: 14%;&quot; align=&quot;center&quot;&gt;&lt;a style=&quot;color: Black;&quot; href=&quot;javascript:__doPostBack('ctl01','3407')&quot;&gt;30&lt;/a&gt;&lt;/td&gt;
&lt;td style=&quot;width: 14%;&quot; align=&quot;center&quot;&gt;&lt;a style=&quot;color: Black;&quot; href=&quot;javascript:__doPostBack('ctl01','3408')&quot;&gt;1&lt;/a&gt;&lt;/td&gt;
&lt;td style=&quot;width: 14%;&quot; align=&quot;center&quot;&gt;&lt;a style=&quot;color: Black;&quot; href=&quot;javascript:__doPostBack('ctl01','3409')&quot;&gt;2&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
.....&lt;/tbody&gt;&lt;/table&gt;</pre></div></div>

<p>Executing the String.Replace command in the .NET 1.1 code will produce the proper output. However, Microsoft decided to <em>upgrade</em> the Calendar control in .NET 2.0 by adding a <strong>tooltip</strong> for each date!</p>
<div id="attachment_287" class="wp-caption aligncenter" style="width: 282px"><a href="http://blog.ianuy.com/wp-content/uploads/2009/05/tooltip1.jpg"><img class="size-full wp-image-287" title="Tool Tip in .NET 2.0" src="http://blog.ianuy.com/wp-content/uploads/2009/05/tooltip1.jpg" alt="Tool Tip in .NET 2.0" width="272" height="216" /></a><p class="wp-caption-text">Tool Tip in .NET 2.0</p></div>
<p>Since the String.Replace has no <em>checking</em> (this is not REGEX afterall), it also replaced the &#8220;Month&#8221; in the tooltip with the drop down box (&lt;select&gt; command), thus generating the broken control shown above. This is not, in anyway, the fault of the original developer. Can you anticipate what will Microsoft do?</p>
<p><strong>This is my first encounter on how Microsoft can break your products. <img src='http://blog.ianuy.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /><br />
</strong></p>
<h3>MSDE to Microsoft SQL Server 2005 Express</h3>
<p>Our web applications were written before the release of SQL Server 2005 Express. The only *free* choice back then is Microsoft SQL Server Desktop Engine, a free scaled-down version of Microsoft SQL Server 2000. Since the support for MSDE officially ended last April 8, 2008, we are then forced to upgrade to Microsoft SQL Server 2005 express.</p>
<p>Our previous MSDE setup runs on <strong>default instance</strong>. In migrating to SQL Server 2005, we run the risk of &#8220;conflicting&#8221; with our other products that runs on <strong>default instance</strong> of SQL 2005. So the decision was made to migrate from <strong>default instance </strong>to <strong>named instance</strong>.</p>
<p>Migrating to SQL Server 2005 Express is straightforward at first look. The first and the most obvious thing to do is to modify the installer (InstallShield) so that it will install SQL 2005 instead of MSDE.  To compensate with the instance problem, the second thing to do is to modify each and every <strong>connection string</strong> in the entire app to point to the proper named instance. Making sure that each and every connection string in your entire app has been changed is a monumental task&#8230; especially if different version of connection strings were used. After that, you also need to modify the Service Query String so that it will point to the proper SQL Service ($MSSQLSERVER to $Instance_Name). There are also minor modifications here and there, but its not worth the mention.</p>
<p>After three days of manual modification, we got to the point where we were able to install the product. We tested it and everything seems to work fine. We then got to the part where are going to test for the database backup. Lo and behold, it failed. But no error message was given. We looked for the bug for an entire day but our search proved futile. We called it a day and went home. The next day, my brilliant manager excitedly told us the problem.</p>
<blockquote>
<h3 style="text-align: center;">Microsoft SQL Server 2005 Express does not have SQL Server Agent.</h3>
</blockquote>
<p>Our backup routine uses SQL Server Agent. When a user request for a backup, the SQL Server will &#8220;schedule&#8221; that backup request and the SQL Server Agent will &#8220;execute&#8221; the request when the schedule parameter is met.</p>
<p>Simply put, No SQL Server Agent, No Backup.</p>
<p>We have three solutions to the problem:</p>
<ol>
<li>Ship the product with Microsoft SQL Server 2005 standard or enterprise edition (Instead of the Express edition)</li>
<li>Remove the &#8220;scheduled&#8221; backup. Instead, just provide a &#8220;one shot&#8221; backup</li>
<li>Create our own custom &#8220;Backup Scheduler&#8221; using Windows Task Scheduler</li>
</ol>
<p>We talked to the marketing folks and they eliminated option 1 because, according to them, we can&#8217;t make our customer pay for something that was free before. Option 2 was eliminated due to the simple fact that we can&#8217;t ship an upgraded version of our product with downgraded features (But this was actually done to one of the product that had missed its deadline). So Option 3 was our only choice.</p>
<p>The plan in creating Option 3 is simple. Create a &#8220;scheduled task&#8221; using <strong>schtasks.exe </strong>that will invoke <strong>sqlcmd.exe</strong> that will invoke the <strong>sql command</strong> to invoke the <strong>stored procedure</strong> that was doing the backups. The <strong>schtasks</strong> will then be invoked by the ASP.NET page using Process.Start();. So I created a wrapper class that will simplify this process. The class was created in 2 hours and I had it running and compiled to the ASP.NET page in just 3 hours. <strong>BUT IT DIDN&#8217;T WORK.</strong></p>
<p>Further investigation revealed that IIS 6.0 has a different security model than IIS 5.1 (which XP uses). Spawning a process from within IIS 6.0 will have a credential of NETWORK SERVICE. Yes, we can impersonate since we are using Windows Authentication, but it won&#8217;t work unless we force the user to type-in the credentials again. Which is bad in a usability point of view.</p>
<p>The workaround was to put the scheduler on a Windows Service that will then be run with proper credentials. The problem then was the communication between the ASP.NET page and the Windows Service. How will the Service know when to invoke the backup? Our solution is a little crude but simple. We did it old-skul UNIX style! The ASP.NET page will create a &#8220;marker&#8221; file in a certain, defined location. The Windows Service will then monitor that location&#8230; waiting for the &#8220;marker&#8221; file. If the marker file is found, the service will then invoke the backup procedure. <img src='http://blog.ianuy.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Fortunately for us, all the data needed for the backup is in the database, so we don&#8217;t need to pass anything between the ASP.NET page and the Service. <img src='http://blog.ianuy.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  We could have used sockets or mutex, but its overkill for our purpose.</p>
<p><strong>This</strong> are just the major steps that had to be done in order to make our web applications compatible with Windows Vista. There are a couple of minor steps that also needs attention like the IIS 5.1 to IIS 7.0 migration and the new Vista Security Model.</p>
<p>The next time you see the &#8220;Vista Compatible&#8221; sticker on a Software Box, think of the programmers who nearly died in making your software run on a &#8220;cuter&#8221; operating system.</p>
<h2>Windows 7, we are ready! <img src='http://blog.ianuy.com/wp-includes/images/smilies/icon_lol.gif' alt=':lol:' class='wp-smiley' /> </h2>



Share and Enjoy:


	<a rel="nofollow" href="mailto:?subject=Migration%3A%20Why%20Developers%20Hate%20Microsoft%20or%20Why%20Developers%20Hate%20Vista%20or%20My%20First%20Encounter%20how%20Microsoft%20can%20Break%20your%20Software&amp;body=http%3A%2F%2Fblog.ianuy.com%2F2009%2F05%2F10%2Fmigration-why-developers-hate-microsoft-or-my-first-encounter-how-microsoft-can-break-your-software%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%2F05%2F10%2Fmigration-why-developers-hate-microsoft-or-my-first-encounter-how-microsoft-can-break-your-software%2F&amp;title=Migration%3A%20Why%20Developers%20Hate%20Microsoft%20or%20Why%20Developers%20Hate%20Vista%20or%20My%20First%20Encounter%20how%20Microsoft%20can%20Break%20your%20Software&amp;bodytext=%0A%0D%0AIn%20my%20previous%20blog%20post%2C%20I%27ve%20mentioned%20that%20I%27m%20working%20on%20a%20project%20to%20migrate%20an%20entire%20product%20line%20to%20Vista.%20What%20I%20meant%20by%20that%20is%20that%20I%20am%20responsible%20for%20making%20sure%20that%20our%20current%20product%20will%20run%20properly%20on%20Windows%20Vista.%20To%20guaran" 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%2F05%2F10%2Fmigration-why-developers-hate-microsoft-or-my-first-encounter-how-microsoft-can-break-your-software%2F&amp;title=Migration%3A%20Why%20Developers%20Hate%20Microsoft%20or%20Why%20Developers%20Hate%20Vista%20or%20My%20First%20Encounter%20how%20Microsoft%20can%20Break%20your%20Software" 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%2F05%2F10%2Fmigration-why-developers-hate-microsoft-or-my-first-encounter-how-microsoft-can-break-your-software%2F&amp;title=Migration%3A%20Why%20Developers%20Hate%20Microsoft%20or%20Why%20Developers%20Hate%20Vista%20or%20My%20First%20Encounter%20how%20Microsoft%20can%20Break%20your%20Software&amp;notes=%0A%0D%0AIn%20my%20previous%20blog%20post%2C%20I%27ve%20mentioned%20that%20I%27m%20working%20on%20a%20project%20to%20migrate%20an%20entire%20product%20line%20to%20Vista.%20What%20I%20meant%20by%20that%20is%20that%20I%20am%20responsible%20for%20making%20sure%20that%20our%20current%20product%20will%20run%20properly%20on%20Windows%20Vista.%20To%20guaran" 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=Migration%3A%20Why%20Developers%20Hate%20Microsoft%20or%20Why%20Developers%20Hate%20Vista%20or%20My%20First%20Encounter%20how%20Microsoft%20can%20Break%20your%20Software%20-%20http%3A%2F%2Fblog.ianuy.com%2F2009%2F05%2F10%2Fmigration-why-developers-hate-microsoft-or-my-first-encounter-how-microsoft-can-break-your-software%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=Migration%3A%20Why%20Developers%20Hate%20Microsoft%20or%20Why%20Developers%20Hate%20Vista%20or%20My%20First%20Encounter%20how%20Microsoft%20can%20Break%20your%20Software&amp;url=http%3A%2F%2Fblog.ianuy.com%2F2009%2F05%2F10%2Fmigration-why-developers-hate-microsoft-or-my-first-encounter-how-microsoft-can-break-your-software%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%2F05%2F10%2Fmigration-why-developers-hate-microsoft-or-my-first-encounter-how-microsoft-can-break-your-software%2F&amp;t=Migration%3A%20Why%20Developers%20Hate%20Microsoft%20or%20Why%20Developers%20Hate%20Vista%20or%20My%20First%20Encounter%20how%20Microsoft%20can%20Break%20your%20Software" 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%2F05%2F10%2Fmigration-why-developers-hate-microsoft-or-my-first-encounter-how-microsoft-can-break-your-software%2F&amp;t=Migration%3A%20Why%20Developers%20Hate%20Microsoft%20or%20Why%20Developers%20Hate%20Vista%20or%20My%20First%20Encounter%20how%20Microsoft%20can%20Break%20your%20Software" 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%2F05%2F10%2Fmigration-why-developers-hate-microsoft-or-my-first-encounter-how-microsoft-can-break-your-software%2F&amp;title=Migration%3A%20Why%20Developers%20Hate%20Microsoft%20or%20Why%20Developers%20Hate%20Vista%20or%20My%20First%20Encounter%20how%20Microsoft%20can%20Break%20your%20Software&amp;annotation=%0A%0D%0AIn%20my%20previous%20blog%20post%2C%20I%27ve%20mentioned%20that%20I%27m%20working%20on%20a%20project%20to%20migrate%20an%20entire%20product%20line%20to%20Vista.%20What%20I%20meant%20by%20that%20is%20that%20I%20am%20responsible%20for%20making%20sure%20that%20our%20current%20product%20will%20run%20properly%20on%20Windows%20Vista.%20To%20guaran" 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%2F05%2F10%2Fmigration-why-developers-hate-microsoft-or-my-first-encounter-how-microsoft-can-break-your-software%2F&amp;title=Migration%3A%20Why%20Developers%20Hate%20Microsoft%20or%20Why%20Developers%20Hate%20Vista%20or%20My%20First%20Encounter%20how%20Microsoft%20can%20Break%20your%20Software" 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/05/10/migration-why-developers-hate-microsoft-or-my-first-encounter-how-microsoft-can-break-your-software/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>What are your Programming Milestones?</title>
		<link>http://blog.ianuy.com/2009/05/01/what-are-your-programming-milestones/</link>
		<comments>http://blog.ianuy.com/2009/05/01/what-are-your-programming-milestones/#comments</comments>
		<pubDate>Fri, 01 May 2009 14:35:40 +0000</pubDate>
		<dc:creator>Ian Uy</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Reminiscing about Technology]]></category>

		<guid isPermaLink="false">http://blog.ianuy.com/?p=223</guid>
		<description><![CDATA[
While having dinner with my teammates at the Shangri-La Plaza, we had a nostalgic conversation about our adventures in technology, particularly in programming. Just a bunch of geeks talking about geeky stuffs on a Friday night.  
According to our Project Lead, he started his programming adventure by writing programs in BASIC on an Intel [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><a href="http://blog.ianuy.com/wp-content/uploads/2009/05/thumb_canonicalmilestones.jpg"><img class="aligncenter size-medium wp-image-224" title="Milestones" src="http://blog.ianuy.com/wp-content/uploads/2009/05/thumb_canonicalmilestones-300x230.jpg" alt="thumb_canonicalmilestones" width="300" height="230" /></a></p>
<p>While having dinner with my teammates at the <a title="Sharila Mall" href="http://www.shangrila-plaza.com/" target="_blank">Shangri-La Plaza</a>, we had a nostalgic conversation about our adventures in technology, particularly in programming. Just a bunch of geeks talking about geeky stuffs on a Friday night. <img src='http://blog.ianuy.com/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> </p>
<p>According to our Project Lead, he started his programming adventure by writing programs in BASIC on <del datetime="2009-05-04T16:33:38+00:00">an Intel 486 computer</del> a <a href="http://www.old-computers.com/museum/computer.asp?c=172">Sharp MZ80 Series (2 Mhz and 24KB of RAM)</a>. He also mentioned that he had once used a cassette tape to store his programs. He is <em>that</em> old (80+ years old in Programmer Years). <img src='http://blog.ianuy.com/wp-includes/images/smilies/icon_lol.gif' alt=':lol:' class='wp-smiley' />  Another teammate told me that his programming adventure started when he first discovered Visual Basic. For me, my programming adventure began when my <a title="His Twitter Account" href="http://twitter.com/lawrencekin02" target="_blank">elementary professor</a> taught us Web Development (as in HTML) way way back in 1999. 1999 was the time when having an E-Mail account can get you laid <img src='http://blog.ianuy.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  . *I know, HTML is not programming! STOP BOTHERING ME*</p>
<p><a href="http://blog.ianuy.com/wp-content/uploads/2009/05/490423135_a7e8e7b8fa.jpg"><img class="aligncenter size-medium wp-image-229" title="HTML is NOT Programming" src="http://blog.ianuy.com/wp-content/uploads/2009/05/490423135_a7e8e7b8fa-252x300.jpg" alt="HTML is NOT Programming" width="252" height="300" /></a></p>
<p>After sometime reminiscing the days of Web 1.0, Visual Basic 4, Dial-Up Internet, mIRC, Hacked Unix Shell Accounts, Hacked AOL accounts and the Borland Turbo C Compilers, I suddenly brought up the topic of <strong>programming milestones</strong> &#8212; Those important events in your programming life that marks an important transformation. Those paradigm-shifting events that changed your geeky life forever. What&#8217;s interesting with this conversation is that everyone in the table can relate to each others milestones, its like everyone have the same programming milestones. Maybe all programmers have the same set of programming milestones? Like in life (as in real life), where we consider both College Graduation and Marriage as milestones.</p>
<p><span id="more-223"></span></p>
<p>Anyway, here are my programming milestones so far (Sorted by Date):</p>
<h3>1. Arrays (1999)</h3>
<p><a href="http://blog.ianuy.com/wp-content/uploads/2009/05/array2d.gif"><img class="aligncenter size-medium wp-image-232" title="Arrays" src="http://blog.ianuy.com/wp-content/uploads/2009/05/array2d-300x230.gif" alt="Arrays" width="300" height="230" /></a></p>
<p>I&#8217;ve <a href="http://blog.ianuy.com/about/" target="_blank">previously</a> mentioned that my first ever <em>functional</em> program is a tiny tool that can be used to help determine the winner(s) of a <em>Millionaire&#8217;s Game</em> (A Monopoly-like game). I made that tool because, most often than not, the players participating in the game will just agree that noone should win because they are just too lazy to &#8220;compute&#8221; for the winner.</p>
<p>I made that program in C using Borland&#8217;s Turbo C Compiler (TC.EXE) back in 1999. Back then, all I know are Console I/O (printf,scanf), IF Statements and FOR Loops! So its safe to say that I don&#8217;t know that Arrays even exists. Here&#8217;s how my program in C looked like:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include &lt;stdio.h&gt;</span>
&nbsp;
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #993333;">char</span> Player1<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">100</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> Player2<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">100</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> Player3<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">100</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> Player4<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">100</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> Player5<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">100</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #993333;">int</span> P1Score<span style="color: #339933;">,</span> P2Score<span style="color: #339933;">,</span> P3Score<span style="color: #339933;">,</span> P4Score<span style="color: #339933;">,</span> P5Score<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Enter the name of Player 1: &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	scanf<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%s&quot;</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>Player1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Enter the name of Player 2: &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	scanf<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%s&quot;</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>Player2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Enter the name of Player 3: &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	scanf<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%s&quot;</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>Player3<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Enter the name of Player 4: &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	scanf<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%s&quot;</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>Player4<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Enter the name of Player 5: &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	scanf<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%s&quot;</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>Player5<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//... You Get The Point!</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>I don&#8217;t even have an inkling that <em>char Player1[100]</em> is an array. <img src='http://blog.ianuy.com/wp-includes/images/smilies/icon_lol.gif' alt=':lol:' class='wp-smiley' />  I just know that Player1[100] is a <strong>variable</strong> that can store 100 characters. That&#8217;s it! But anyway, I was limited to copy-pasting similar block of codes to accomodate for each player. Even the computation logic was copy-pasted.</p>
<p>You can tell how happy I was when I learned of arrays. <img src='http://blog.ianuy.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h3>2. Graphical User Interfaces &#8211; Visual Basic 6.0 (2001)</h3>
<p><a href="http://blog.ianuy.com/wp-content/uploads/2009/05/visualbasic6enterprise.jpg"><img class="aligncenter size-medium wp-image-240" title="visualbasic6enterprise" src="http://blog.ianuy.com/wp-content/uploads/2009/05/visualbasic6enterprise-300x230.jpg" alt="visualbasic6enterprise" width="300" height="230" /></a></p>
<p>From 1999-2001, I have probably made five programs in C. Not all of them worked but some of them did &#8211; like my <strong>Hindu Arabic to Roman Numeral Converter</strong> and my poor attempt to simulate <a title="SM Chain of Malls" href="http://www.smprime.com/" target="_blank">SM</a>&#8217;s POS System. My first POS System have a pseudo-GUI. The &#8220;graphical objects&#8221; are made up of ASCII characters like all DOS-based programs and like most DOS-based programs, its barely usable.</p>
<p>When my High School Computer Professor showed me Visual Basic 6.0 in early 2001, all I can think about is this:</p>
<blockquote>
<p style="text-align: center;">&#8220;Oh Shoot! Now I can make my program look like the *real* thing and sell them on the Internet and then I&#8217;ll be as rich as Bill Gates!&#8221;</p>
</blockquote>
<p>Kidding aside, going from Terminal-based (Console) program to Windows Application is one of the greatest milestones in my programming life. Having your mom use your user-friendly POS system for your little business is very very rewarding. <img src='http://blog.ianuy.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h3>3. Filestream &#8211; Writing and Reading Files (2002)</h3>
<p><a href="http://blog.ianuy.com/wp-content/uploads/2009/05/ch09.png"><img class="aligncenter size-medium wp-image-245" title="ch09" src="http://blog.ianuy.com/wp-content/uploads/2009/05/ch09-300x271.png" alt="ch09" width="300" height="271" /></a>When my professor in High School taught me Visual Basic 6.0 and Graphical User Interfaces, I thought then that making your program look like the *real* thing is just the same as making your program *real*. Real as in functional. But it isn&#8217;t the same. Let&#8217;s face it, if your program can&#8217;t persist data, it is close to <strong>useless</strong>. So my dreams of becoming as rich as Bill Gates were suddenly crushed, at least <em>temporarily</em>.</p>
<p>Year 2002 was that magnificent year when I was able to force my mom into upgrading our old and broken home computer. I can still remember the *shiny* new specs of that computer:</p>
<ul>
<li>AMD K6-2 500 MHZ</li>
<li>Seagate 20 GB HDD (IDE, 5400 RPM)</li>
<li>ECX Motherboard (Can&#8217;t remember the exact model)</li>
<li>128MB SDRAM PC100/133</li>
<li><span style="color: #ff0000;">Connectix 56K Dial-Up PCI Win Modem</span></li>
</ul>
<p><span style="color: #000000;">That was the biggest and most important investment my mom made: A DIAL-UP MODEM! It was the very first time that I had unlimited (Unlimited Dial-Up Prepaid Card) access to the internet, at home.</span> That was also the first time that  I had access to almost unlimited amounts of low-resolution P*rn images! <img src='http://blog.ianuy.com/wp-includes/images/smilies/icon_lol.gif' alt=':lol:' class='wp-smiley' />  Also, and most imporantly, that was the first time that I had access to the vast quantity of knowledge available in the Internet.</p>
<p>I can still remember that fateful summer day. I was making a simple tic-tac-toe game in Visual Basic 6.0, the game logic are all done and the game is already 100% fully functional. I gave the game to my brother to try it out and he asked me if there is a Top-Score list in my program. It made me think. How can I persist data even after the program was closed? Fortunately, the internet was there to help me out.</p>
<p>After a couple of hours searching and asking in the Forums, someone told me that I should write the data in a File and read it everytime the program is launched.</p>
<p>For the very first time in my entire programming life, I was able to persist data in a file! After 4 years of just working inside the RAM, I can now write stuffs on my Harddisk! A whole new universe of possibility was unlocked. I was so excited! Hundreds of idea came rushing into me. Suddenly I want to make my own Integrated Library System (OPAC), Sales and Inventory System, Dictionary and hundreds of different programs!</p>
<p>Now I really believe that I can make my program look and feel like the *real* thing. My dream of becoming as rich as Bill Gates is back on track! <img src='http://blog.ianuy.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><strong>Those</strong> are the three most important programming milestones in my programming life. There are also others but they are not as enlightening as the those three. The other milestones in my programming life happened when I discovered the following:</p>
<ul>
<li>Pointers</li>
<li>Relational Databases (Microsoft SQL Server)</li>
<li>Serialization (Marshalling)</li>
<li>Socket Programming</li>
<li>Cloud Computing (Web Services)</li>
<li>.NET Framework</li>
</ul>
<p>Also, another milestone. Today was the very first day that I celebrated our National Labor Day (May 1). It is funny that I celebrated Labor Day by coming to work. <img src='http://blog.ianuy.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>Happy Labors Day Everyone!</p>



Share and Enjoy:


	<a rel="nofollow" href="mailto:?subject=What%20are%20your%20Programming%20Milestones%3F&amp;body=http%3A%2F%2Fblog.ianuy.com%2F2009%2F05%2F01%2Fwhat-are-your-programming-milestones%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%2F05%2F01%2Fwhat-are-your-programming-milestones%2F&amp;title=What%20are%20your%20Programming%20Milestones%3F&amp;bodytext=%0D%0A%0D%0AWhile%20having%20dinner%20with%20my%20teammates%20at%20the%20Shangri-La%20Plaza%2C%20we%20had%20a%20nostalgic%20conversation%20about%20our%20adventures%20in%20technology%2C%20particularly%20in%20programming.%20Just%20a%20bunch%20of%20geeks%20talking%20about%20geeky%20stuffs%20on%20a%20Friday%20night.%20%3Ao%0D%0A%0D%0AAccording%20to" 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%2F05%2F01%2Fwhat-are-your-programming-milestones%2F&amp;title=What%20are%20your%20Programming%20Milestones%3F" 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%2F05%2F01%2Fwhat-are-your-programming-milestones%2F&amp;title=What%20are%20your%20Programming%20Milestones%3F&amp;notes=%0D%0A%0D%0AWhile%20having%20dinner%20with%20my%20teammates%20at%20the%20Shangri-La%20Plaza%2C%20we%20had%20a%20nostalgic%20conversation%20about%20our%20adventures%20in%20technology%2C%20particularly%20in%20programming.%20Just%20a%20bunch%20of%20geeks%20talking%20about%20geeky%20stuffs%20on%20a%20Friday%20night.%20%3Ao%0D%0A%0D%0AAccording%20to" 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=What%20are%20your%20Programming%20Milestones%3F%20-%20http%3A%2F%2Fblog.ianuy.com%2F2009%2F05%2F01%2Fwhat-are-your-programming-milestones%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=What%20are%20your%20Programming%20Milestones%3F&amp;url=http%3A%2F%2Fblog.ianuy.com%2F2009%2F05%2F01%2Fwhat-are-your-programming-milestones%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%2F05%2F01%2Fwhat-are-your-programming-milestones%2F&amp;t=What%20are%20your%20Programming%20Milestones%3F" 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%2F05%2F01%2Fwhat-are-your-programming-milestones%2F&amp;t=What%20are%20your%20Programming%20Milestones%3F" 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%2F05%2F01%2Fwhat-are-your-programming-milestones%2F&amp;title=What%20are%20your%20Programming%20Milestones%3F&amp;annotation=%0D%0A%0D%0AWhile%20having%20dinner%20with%20my%20teammates%20at%20the%20Shangri-La%20Plaza%2C%20we%20had%20a%20nostalgic%20conversation%20about%20our%20adventures%20in%20technology%2C%20particularly%20in%20programming.%20Just%20a%20bunch%20of%20geeks%20talking%20about%20geeky%20stuffs%20on%20a%20Friday%20night.%20%3Ao%0D%0A%0D%0AAccording%20to" 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%2F05%2F01%2Fwhat-are-your-programming-milestones%2F&amp;title=What%20are%20your%20Programming%20Milestones%3F" 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/05/01/what-are-your-programming-milestones/feed/</wfw:commentRss>
		<slash:comments>6</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>
		<item>
		<title>Transactions in C#</title>
		<link>http://blog.ianuy.com/2009/04/12/transactions-in-c/</link>
		<comments>http://blog.ianuy.com/2009/04/12/transactions-in-c/#comments</comments>
		<pubDate>Sun, 12 Apr 2009 11:00:19 +0000</pubDate>
		<dc:creator>Ian Uy</dc:creator>
				<category><![CDATA[Daily Logs]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.ianuy.com/?p=74</guid>
		<description><![CDATA[After spending almost 2 months at work without actually doing anything that barely resembles programming, I was finally sent to a training at an outsourced training company in Makati.
The training is about Windows Communication Framework or WCF &#8212; Microsoft&#8217;s answer to building Service-Oriented Architectures (SOA). Gone were the days of Web Services, more so, socket [...]]]></description>
			<content:encoded><![CDATA[<p><span style="font-size: small;">After spending almost 2 months at work without actually doing anything that barely resembles programming, I was finally sent to a training at an outsourced training company in Makati.</span></p>
<p><span style="font-size: small;">The training is about Windows Communication Framework or WC</span><span style="font-size: small;">F &#8212; Microsoft&#8217;s answer to building Service-Oriented Architectures (SOA). Go</span><span style="font-size: small;">ne were the days of Web Services, more so, socket programming! It&#8217;s all abstracted now. Yay for lame programmers! <img src='http://blog.ianuy.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </span></p>
<p><span style="font-size: small;">But anyway, the training was GREAT! I was able to learn the ins and outs of WCF. But what&#8217;s interesting is that I learned a new &#8220;way&#8221; to do <span style="font-weight: bold;">rollbacks</span> <span style="font-style: italic;">automatically! </span>It&#8217;s called&#8230;</span></p>
<div style="text-align: center;"><span style="font-weight: bold;"><span style="font-size: large;">TRANSACTIONS!<br />
</span></span><span class="insertedphoto"><img class="alignmiddleb" src="http://images.ianuy.multiply.com/image/1/photos/upload/300x300/Sber4AoKCDIAAE0IzR01/transactions.gif?et=VjPQJF%2CZslrtB7dlRy4D6w&amp;nmid=0" border="0" alt="" /></span></div>
<div style="text-align: left;"><span class="insertedphoto"><br />
</span></div>
<div style="text-align: left;"><span class="insertedphoto"><span id="more-74"></span><br />
</span></div>
<div style="text-align: center;">
<div style="text-align: left;"><span style="font-size: small;">But what&#8217;s more interesting is that Transactions is not really part of the WCF nor the.NET 3.5. It&#8217;s an existing feature from .NET 1.1! <img src='http://blog.ianuy.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> )</span><span style="font-size: small;">So what&#8217;s Transactions? Well, its really hard to explain so I&#8217;ll just present a scenario on how and where you can use Transactions.</span><br />
<span style="font-size: small;"><br />
Let&#8217;s say that you have a <span style="font-weight: bold;">Point of Sales </span>(POS) system</span><span style="font-size: small;"> that have 2 tables namely <span style="font-weight: bold;">Inventory</span> table and <span style="font-weight: bold;">Sales</span> table. And you have a method called </span><span style="font-size: small;"><span style="font-weight: bold;">CustomerBuysStuff(int ItemID)</span>. The said method will be called if a customer buys new stuff (obviously)&#8230; so the implementation would be something like:</span></p>
<ol>
<li><span style="font-size: small;">Deduct 1 unit from the Inventory table using the ItemID</span></li>
<li><span style="font-size: small;">Add 1 unit from the Sales table using the ItemID</span></li>
</ol>
<p><span style="font-size: small;">This means that this particular method must execute <span style="font-weight: bold;">two (2)</span> SQL statements and both of them must SUCCEED or you will have a decrepancy on your data. If you can remember from your Database Management Course, you have studied a concept called <span style="font-weight: bold;">ACID</span>. This scenerio represents the <span style="font-weight: bold;">A </span>in <span style="font-weight: bold;">ACID</span> &#8212; <span style="font-weight: bold;">Atomic Operations</span>. In our case, this means that &#8220;<span style="font-style: italic;">All statements in a group must execute, or no statement in a group must execute.</span> &#8220;</span></p>
<p>Frequently in a database application you come across a situation where you need to execute two or more SQL commands in such a way that if any one of <span style="font-size: small;">the statements fails, then no other statement will be able to change the database.</span></p>
<p>I&#8217;ll try to demonstrate Transactions using <span style="text-decoration: underline;">REAL<span style="font-weight: bold;"><span style="font-weight: bold;"><span style="text-decoration: underline;"> </span></span></span></span>code (Click the image to enlarge):</p>
<p><a href="http://ianuy.multiply.com/photos/hi-res/upload/SbexswoKCDIAAHsKDVg1"><img class="aligncenter" style="border: 0pt none;" src="http://images.ianuy.multiply.com/image/1/photos/upload/300x300/SbexswoKCDIAAHsKDVg1/WithoutRollBack.jpg?et=nykBq0UPSIArV6iOHBNBdQ&amp;nmid=0" border="0" alt="" width="300" height="101" /></a><br />
<span style="font-size: small;"><a href="http://ianuy.multiply.com/photos/hi-res/upload/SbexswoKCDIAAHsKDVg1"></a>Let&#8217;s call the code snippet as &#8220;No Rollback&#8221;. This assumes that you are 101% sure that <span style="font-weight: bold;">both </span>operation will succeed that you did not even bother to write a rollback method if ever one of the two fails. This is a very <span style="font-weight: bold;">bad practice</span> in the real world because it will create a discrepancy in your data that cannot be traced &#8212; and worst, debugged.</span><a href="http://ianuy.multiply.com/photos/hi-res/upload/SbexswoKCDIAAHsKDVg1"></a><span style="font-size: small;"><a href="http://ianuy.multiply.com/photos/hi-res/upload/SbexswoKCDIAAHsKDVg1"></a><a href="http://ianuy.multiply.com/photos/hi-res/upload/SbexswoKCDIAAHsKDVg1"></a></span></p>
<p><a href="http://ianuy.multiply.com/photos/hi-res/upload/SbexswoKCDIAAHsKDVg1"></a><a href="http://ianuy.multiply.com/photos/hi-res/upload/SbezQAoKCDIAACm6Esc1"><img class="aligncenter" style="border: 0pt none;" src="http://images.ianuy.multiply.com/image/1/photos/upload/300x300/SbezQAoKCDIAACm6Esc1/WithRollback.jpg?et=Xf5pp3ZA9nui55Zx0%2CXvlA&amp;nmid=0" border="0" alt="" width="300" height="215" /></a><a href="http://ianuy.multiply.com/photos/hi-res/upload/SbexswoKCDIAAHsKDVg1"></a><span style="font-size: small;">The above code snippet is called &#8220;With Rollback&#8221;, because in this code snippet, when the <span style="font-style: italic;">second</span></span> <span style="font-size: small;">command fails, you cared enough to rollback the changes made by the first command. This is how I did it in the college days </span><span style="font-size: small;">when I&#8217;m too lazy to use Stored Procedures (and TRANS/COMMIT) and I&#8217;m too stupid to not have researched about</span> <span style="font-size: small;"><span style="font-weight: bold;">Transactions!</span> Oh the dark ages. Mind you, this method is not 100% fool-proof. What will happen if your rollback command also failed? Discrepancy!<br />
</span><br />
<span style="font-size: small;"><a href="http://ianuy.multiply.com/photos/hi-res/upload/Sbe1JQoKCDIAAFK1F6s1"><img class="aligncenter" style="border: 0pt none;" src="http://images.ianuy.multiply.com/image/1/photos/upload/300x300/Sbe1JQoKCDIAAFK1F6s1/Transaction.JPG?et=9AF9BeWpv6MAobJJkH1wAw&amp;nmid=0" border="0" alt="" width="300" height="136" /></a>Now, let&#8217;s call this code snippet &#8220;Almighty </span><span style="font-size: small;">Transaction&#8221;. In the above code, there is no extra method or SQL command to invoke to do the rollback when the pre-requisite part of your code fails. And oh, there&#8217;s also no extra code to detect an exception or an error. It just magically knows that something awful had happened and it will just magically rollback <span style="font-weight: bold;">ALL </span>the changes that happened before the error. Like, <span style="font-weight: bold;">MAGICALLY!</span> Isn&#8217;t it freakin great?!</span><br />
<span style="font-size: small;"><br />
Also, this will work on ANYTHING (Not only on Database Related Stuffs). During my thesis days, I have to write a method to perform rollbacks when my encryption/decyption algorithm fails. It took me a whole week and lots of messy code to make it work perfectly. If only I have the knowledge of Transactions then, it could have just taken me 5 minutes. DAMN!</span><a href="http://ianuy.multiply.com/photos/hi-res/upload/Sbe6agoKCDIAAGzOrvo1"><img class="aligncenter" style="border: 0pt none;" src="http://images.ianuy.multiply.com/image/1/photos/upload/300x300/Sbe6agoKCDIAAGzOrvo1/training.gif?et=aGkVA17rxVHNfn3%2BboFfVg&amp;nmid=0" border="0" alt="" width="241" height="300" /></a><span style="font-size: small;"><br />
So yeah&#8230; I love these TRAININGS (Have 6 more to go for this year)! You can learn lots of <span style="text-decoration: underline;">useful</span> stuffs in a very short span of time (Like 3 days). They will even give you a certificate that is <span style="font-weight: bold;">signed by Billy-G </span>himself! Haha! Another additional line in my Resume.</span></p>
<p>What&#8217;s great about the training company that my company chose is that they are <span style="font-weight: bold;">official Microsoft Partners&#8230; </span>This means that I can take the official WCF Online Test and if I pass, I will then be a <span style="font-weight: bold;">&#8220;Certified&#8221;</span> MCP (Microsoft Certified Professional)!</p>
<p><span style="font-weight: bold;">Remember&#8230;</span></p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">TransactionScope AtomicScope <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> TransactionScope<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #0600FF;">using</span><span style="color: #000000;">&#40;</span>AtomicScope<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
<span style="color: #008080; font-style: italic;">//ATOMIC OPERATIONS</span>
AtomicScope.<span style="color: #0000FF;">Complete</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

</div>
</div>



Share and Enjoy:


	<a rel="nofollow" href="mailto:?subject=Transactions%20in%20C%23&amp;body=http%3A%2F%2Fblog.ianuy.com%2F2009%2F04%2F12%2Ftransactions-in-c%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%2F12%2Ftransactions-in-c%2F&amp;title=Transactions%20in%20C%23&amp;bodytext=After%20spending%20almost%202%20months%20at%20work%20without%20actually%20doing%20anything%20that%20barely%20resembles%20programming%2C%20I%20was%20finally%20sent%20to%20a%20training%20at%20an%20outsourced%20training%20company%20in%20Makati.%0D%0A%0D%0AThe%20training%20is%20about%20Windows%20Communication%20Framework%20or%20WCF%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%2F12%2Ftransactions-in-c%2F&amp;title=Transactions%20in%20C%23" 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%2F12%2Ftransactions-in-c%2F&amp;title=Transactions%20in%20C%23&amp;notes=After%20spending%20almost%202%20months%20at%20work%20without%20actually%20doing%20anything%20that%20barely%20resembles%20programming%2C%20I%20was%20finally%20sent%20to%20a%20training%20at%20an%20outsourced%20training%20company%20in%20Makati.%0D%0A%0D%0AThe%20training%20is%20about%20Windows%20Communication%20Framework%20or%20WCF%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=Transactions%20in%20C%23%20-%20http%3A%2F%2Fblog.ianuy.com%2F2009%2F04%2F12%2Ftransactions-in-c%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=Transactions%20in%20C%23&amp;url=http%3A%2F%2Fblog.ianuy.com%2F2009%2F04%2F12%2Ftransactions-in-c%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%2F12%2Ftransactions-in-c%2F&amp;t=Transactions%20in%20C%23" 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%2F12%2Ftransactions-in-c%2F&amp;t=Transactions%20in%20C%23" 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%2F12%2Ftransactions-in-c%2F&amp;title=Transactions%20in%20C%23&amp;annotation=After%20spending%20almost%202%20months%20at%20work%20without%20actually%20doing%20anything%20that%20barely%20resembles%20programming%2C%20I%20was%20finally%20sent%20to%20a%20training%20at%20an%20outsourced%20training%20company%20in%20Makati.%0D%0A%0D%0AThe%20training%20is%20about%20Windows%20Communication%20Framework%20or%20WCF%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%2F12%2Ftransactions-in-c%2F&amp;title=Transactions%20in%20C%23" 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/12/transactions-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

