<?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>winJade &#187; dev fail</title>
	<atom:link href="http://winjade.net/tag/dev-fail/feed/" rel="self" type="application/rss+xml" />
	<link>http://winjade.net</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Sun, 27 Jun 2010 23:47:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Terms of Service issues with Zune HD (and a fix)</title>
		<link>http://winjade.net/2009/09/zune-tos-sign-in-issues/</link>
		<comments>http://winjade.net/2009/09/zune-tos-sign-in-issues/#comments</comments>
		<pubDate>Tue, 15 Sep 2009 14:46:03 +0000</pubDate>
		<dc:creator>Bryant Zadegan</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Tips/Tricks/Hacks]]></category>
		<category><![CDATA[bright idea]]></category>
		<category><![CDATA[dev fail]]></category>
		<category><![CDATA[FIX]]></category>
		<category><![CDATA[Zune]]></category>
		<category><![CDATA[Zune 4.0]]></category>
		<category><![CDATA[Zune HD]]></category>

		<guid isPermaLink="false">http://www.aeroxp.org/2009/09/zune-tos-sign-in-issues/</guid>
		<description><![CDATA[Just to clarify: this is a selective issue; the scope of this issue isn’t known, but not everyone is seeing this problem. The fix is outlined after the jump for the issue listed below for those of you experiencing it.
In the wonderful world of Zune, all the Zune teamsters, Zune coders, Zune pushers, and Zune [...]]]></description>
			<content:encoded><![CDATA[<p><em>Just to clarify: this is a selective issue; the scope of this issue isn’t known, but not everyone is seeing this problem. The fix is outlined after the jump for the issue listed below for those of you experiencing it.</em></p>
<p>In the wonderful world of Zune, all the Zune teamsters, Zune coders, Zune pushers, and Zune lovers are busy celebrating the launch of the Zune HD. That’s not to say there aren’t any snags with which to deal. Case in point: I came across this wonderful screen when I tried to sign into my account under Zune 4.0 for the first time:</p>
<p><a href="http://winjade.net/wp-content/uploads/2009/09/zuneterms1.png" target="_blank"><img style="border-bottom: 0px; border-left: 0px; margin: 10px 10px 10px 20px; display: inline; border-top: 0px; border-right: 0px" title="zuneterms1" border="0" alt="zuneterms1" src="http://winjade.net/wp-content/uploads/2009/09/zuneterms1-thumb.png" width="524" height="402" /></a></p>
<p> “Great, there’s no terms to which I must agree. I’ll just go ahead and click Accept,” <em>(the result of which you can see after the jump)</em></p>
<p> <span id="more-1207"></span>
<p><a href="http://winjade.net/wp-content/uploads/2009/09/zuneterms2.png" target="_blank"><img style="border-bottom: 0px; border-left: 0px; margin: 10px 10px 10px 20px; display: inline; border-top: 0px; border-right: 0px" title="zuneterms2" border="0" alt="zuneterms2" src="http://winjade.net/wp-content/uploads/2009/09/zuneterms2-thumb.png" width="524" height="403" /></a> </p>
<p>“<em>Crap.”</em></p>
<p>I’ll chalk it up to quick thinking on behalf of Michael Gillet (@<a href="http://twitter.com/Gilly2468" target="_blank">Gilly2468</a>) for <a href="http://twitter.com/Gilly2468/status/4005185647" target="_blank">coming up with the bright idea</a> of signing in online and accepting the terms there. If you’re one of the few people who, for whatever reason, aren’t able to sign into the Zune account for which you may have paid, try signing in via Zune.net and accepting the new terms there (you’ll see your account edit screen when you sign in, which is where you’ll do this). Once you’re done, you can sign back in via the Zune software and <em>voila</em>, life is good again.</p>
]]></content:encoded>
			<wfw:commentRss>http://winjade.net/2009/09/zune-tos-sign-in-issues/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>What not to do with UX design</title>
		<link>http://winjade.net/2009/08/what-not-to-do-with-ux-design/</link>
		<comments>http://winjade.net/2009/08/what-not-to-do-with-ux-design/#comments</comments>
		<pubDate>Tue, 25 Aug 2009 16:01:58 +0000</pubDate>
		<dc:creator>Bryant Zadegan</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Tips/Tricks/Hacks]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[annoying]]></category>
		<category><![CDATA[dev fail]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[not awesome]]></category>
		<category><![CDATA[rude]]></category>
		<category><![CDATA[Sun Microsystems]]></category>
		<category><![CDATA[UAC]]></category>

		<guid isPermaLink="false">http://www.aeroxp.org/2009/08/what-not-to-do-with-ux-design/</guid>
		<description><![CDATA[Once upon a time, a Microsoft employee said that UAC was designed to annoy people, thus encouraging people (and systems administrators) to bug application developers and get those developers to fix their use of resources in Windows. Well, it seems that one company actually went backwards, making its application more annoying than it used to [...]]]></description>
			<content:encoded><![CDATA[<p><img style="border-bottom: 0px; border-left: 0px; margin: 10px auto; display: block; float: none; border-top: 0px; border-right: 0px" title="Java Automatic Update consent prompt" border="0" alt="Java Automatic Update consent prompt" src="http://winjade.net/wp-content/uploads/2009/08/javastupid.png" width="500" height="238" />Once upon a time, a Microsoft employee said that UAC was designed to annoy people, thus encouraging people (and systems administrators) to bug application developers and get those developers to fix their use of resources in Windows. Well, it seems that one company actually went <em>backwards</em>, making its application more annoying than it used to be.</p>
<p>Of course, I’m talking about Java.</p>
<p>I figured I would turn Java into an example of what <em>not</em> to do when designing something for Windows before uninstalling it. Since Sun Microsystems clearly has no idea how to develop for Windows Vista, I’m going to direct them to <a href="http://msdn.microsoft.com/en-us/library/aa905330.aspx" target="_blank">this wonderful page</a>.</p>
<p>I highlighted the single switch present in the command which indicates the problem: “-auto”. <strong>UAC prompts should never be automatically launched without informing the user prior to launching one.</strong> It’s very plain and very simple, and when developers start writing applications which throw consent prompts without any obvious reason as to why, they’re clearly doing something wrong.</p>
<p>Worse yet, Java Automatic Update decides to tell me <em>after I click Cancel</em> that it wants to update.</p>
<p><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="Java Update bubble" border="0" alt="Java Update bubble" src="http://winjade.net/wp-content/uploads/2009/08/javastupid2.png" width="296" height="268" /> </p>
<p>This bubble should be thrown first, <em>followed by</em> launching the consent prompt should the user decide to update. Doing it the other way around is <em>mindblowingly stupid. </em>It’s not exactly an easy thing to screw up, either, so I’m chalking this one up either to developers not knowing what they’re doing or developers testing UAC out for the heck of it to see how many people obey random UAC prompts.</p>
<p>If you’re seeing this, I <strong>highly</strong> encourage you to click Cancel. Better yet, go ahead and uninstall Java. That’s what I did.</p>
<p>Now if you’ll excuse me, I’ll be going off to celebrate my birthday away from random UAC prompts.</p>
]]></content:encoded>
			<wfw:commentRss>http://winjade.net/2009/08/what-not-to-do-with-ux-design/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>WPF Magnifier Scaling kinda returns from the dead?</title>
		<link>http://winjade.net/2009/02/wpf-magnifier-scaling-kinda-returns-from-the-dead/</link>
		<comments>http://winjade.net/2009/02/wpf-magnifier-scaling-kinda-returns-from-the-dead/#comments</comments>
		<pubDate>Sat, 21 Feb 2009 16:39:53 +0000</pubDate>
		<dc:creator>Bryant Zadegan</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[blu]]></category>
		<category><![CDATA[dev fail]]></category>
		<category><![CDATA[Developers]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[vectors]]></category>
		<category><![CDATA[What went wrong?]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://www.aeroxp.org/?p=897</guid>
		<description><![CDATA[
This post was originally supposed to be about why blu is faster with WPF, hence the tweet in the image, but after some digging, an equally unusual happening supplanted my original purpose for this post. If you decide to download blu, feel free to follow me as well; blu is a fine application if you [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://winjade.net/wp-content/uploads/2009/02/blucomparoalpha.png" target="_blank"><img style="border-right: 0px; border-top: 0px; display: block; float: none; margin-left: auto; border-left: 0px; margin-right: auto; border-bottom: 0px" title="blucomparo-alpha" src="http://winjade.net/wp-content/uploads/2009/02/blucomparoalpha-thumb.png" border="0" alt="blucomparo-alpha" width="640" height="417" /></a></p>
<p><em>This post was originally supposed to be about why <a href="http://thirteen23.com/experiences/desktop/blu/#" target="_blank">blu</a> is faster with WPF, hence the tweet in the image, but after some digging, an equally unusual happening supplanted my original purpose for this post. If you decide to download blu, <a href="http://twitter.com/conhopper" target="_blank">feel free to follow me as well</a>; blu is a fine application if you don’t mind the occasional <a title="Blu crash" href="http://winjade.net/wp-content/uploads/2009/02/blu-not-responding-3.png" target="_blank">random crashing</a>.</em></p>
<p>When Vista was being developed, the ability to magnify WPF vector graphics was included as an accessibility feature: vectors scaled in the magnifier on a WPF app would be easier to see and read, thus making this feature highly beneficial for those with diminishing sight. However, down the road, the WPF guys decided to scratch this feature in SP1.</p>
<p>Now, before I start, it’s best to know what vector graphics are. Outside the usual jokes about vectors thrown around during the Longhorn days when Aero Diamond managed to be a very persistent rumor, not many people actually understand the benefits of vector graphics over raster images (or, for that matter, what a vector graphic <em>even is</em>).</p>
<ul>
<li><strong>Raster images</strong> are built pixel-by-pixel stacked like brickwork to generate an image. Because of this, raster images aren’t any good once you start zooming in and seeing the individual pixels. Generally, raster images are great for photographs simply because there’s far too much detail to be captured through points and lines, which brings us to vectors.</li>
<li><strong>Vector graphics</strong>, on the other hand, are built using a series of points connected together by way of instructions for various types of lines. Along with fill, effect, and other instructions generally used to make things look pretty, that’s really all a vector graphic is. Because of this, vector graphics are great for web graphics and other computer-generated things which don’t require photographic precision (Corporate logos are a great example).  Thanks to the fact that vector graphics are rendered upon request, they’re infinitely scalable; all you’re doing when scaling a vector graphic is scaling the math behind the scenes.</li>
</ul>
<p>Here’s the thing: <a href="http://blogs.msdn.com/greg_schechter/archive/2008/05/12/gpu-accelerated-custom-effects-for-wpf.aspx#8501940" target="_blank">this feature was supposedly nixed from Vista SP1</a>, but before I found out about this, I tried scaling blu in the magnifier. The text <em>scaled just fine</em>, while the rest of the app did not (though this second bit could just be due to how blu was designed). I tested this out in Windows 7 and found that vector scaling in the magnifier was <a title="Windows 7 Zoom Fail" href="http://winjade.net/wp-content/uploads/2009/02/zoomfail1.png" target="_blank">also kept out of Windows 7</a>, as you can see by the fact that the text in blu is not magnified in Windows 7&#8217;s magnifier.</p>
<p>Well, if you take a look at the leading image at the top of this post, you’ll clearly see that vector scaling works in Vista SP1 at least with text (the unmagnified app is to the left).</p>
<p>Anyone have any ideas? I should note that I <strong>am</strong> on Vista SP1, and I do have .net 3.5 installed.</p>
]]></content:encoded>
			<wfw:commentRss>http://winjade.net/2009/02/wpf-magnifier-scaling-kinda-returns-from-the-dead/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>A lesson on infinite loops</title>
		<link>http://winjade.net/2009/01/lesson-on-infinite-loops/</link>
		<comments>http://winjade.net/2009/01/lesson-on-infinite-loops/#comments</comments>
		<pubDate>Sat, 03 Jan 2009 20:57:35 +0000</pubDate>
		<dc:creator>Bryant Zadegan</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[dev fail]]></category>
		<category><![CDATA[in depth]]></category>
		<category><![CDATA[Infinite Loop]]></category>
		<category><![CDATA[Zune 30]]></category>

		<guid isPermaLink="false">http://www.aeroxp.org/?p=756</guid>
		<description><![CDATA[
pre {
    font-size: medium;
    }

&#160;
&#160;
Yesterday, I took a look at the varying perspectives taken with regards to the Zune 30 debacle. Today, I’ll take a look at what exactly led the Zune 30s to freeze. If you’d like to see the code for the entire driver, click here.
Below the [...]]]></description>
			<content:encoded><![CDATA[<style  TYPE="text/css">
pre {
    font-size: medium;
    }
</style>
<p>&#160;<img style="border-top-width: 0px; border-left-width: 0px; float: none; border-bottom-width: 0px; margin-left: auto; margin-right: auto; display: block; border-right-width: 0px" title="quality assurance baby" border="0" alt="quality assurance baby" src="http://winjade.net/wp-content/uploads/2009/01/qualityassurancebaby1.png" width="640" height="480" /></p>
<p>&#160;</p>
<p>Yesterday, <a href="http://www.aeroxp.org/2009/01/zune-30-bug-overinflated/" target="_blank">I took a look</a> at the varying perspectives taken with regards to the Zune 30 debacle. Today, I’ll take a look at what exactly led the Zune 30s to freeze. If you’d like to see the code for the entire driver, <a href="http://pastie.org/349916">click here</a>.</p>
<p>Below the fold lies a sufficiently sized code sample with everything you’ll need to understand what happened with the Zune 30 bug.</p>
<p><script type="text/javascript">
digg_url = 'http://www.aeroxp.org/2009/01/lesson-on-infinite-loops/';
</script><br />
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script> </p>
<p> <span id="more-756"></span>
</p>
<p>Relevant code is non-gray code:</p>
<blockquote><pre><font color="#ff00ff"><font color="#000000">#</font>define</font> <font color="#000080">ORIGINYEAR</font> <font color="#ff0000">1980</font> <font color="#000000">
<font color="#008000">BOOL</font> ConvertDays(<font color="#008000">UINT32</font> days<font color="#808080">, SYSTEMTIME* lpTime</font>)
{
    <font color="#008000">int</font> <font color="#808080">dayofweek, month,</font> year;
    <font color="#808080">UINT8 *month_tab;</font>

    <font color="#808080">//Calculate current day of the week
    dayofweek = GetDayOfWeek(days);</font>

    year = <font color="#000080">ORIGINYEAR</font>;

    <font color="#800000">while</font> (days &gt; <font color="#ff0000">365</font>)
    {
        <font color="#800000">if</font> (IsLeapYear(year))
        {
            <font color="#800000">if</font> (days &gt; <font color="#ff0000">366</font>)
            {
                days -= <font color="#ff0000">366</font>;
                year += <font color="#ff0000">1</font>;
            }
        }
        <font color="#800000">else</font>
        {
            days -= <font color="#ff0000">365</font>;
            year += <font color="#ff0000">1</font>;
        }
    }

<font color="#808080">    // Determine whether it is a leap year
    month_tab = (UINT8 *)((IsLeapYear(year))? monthtable_leap : monthtable);

    for (month=0; month&lt;12; month++)
    {
        if (days &lt;= month_tab[month])
            break;
        days -= month_tab[month];
    }

    month += 1;

    lpTime-&gt;wDay = days;
    lpTime-&gt;wDayOfWeek = dayofweek;
    lpTime-&gt;wMonth = month;
    lpTime-&gt;wYear = year;

    return TRUE;
</font>}</font></pre>
</blockquote>
<p>So what’s the purpose of the while loop? To put it simply, it’s designed to get the number of years from the number of days since 1980 as well as a remainder of days out of the current year. Well, let’s look at how the code plays out in my confusingly simple <em>While Loop in Plain English™</em>. Keep in mind that you’re <em>never </em>supposed to retry the loop without committing some sort of action which will ultimately exit the loop:</p>
<ol>
<li>year is set to ORIGINYEAR. Since ORIGINYEAR is 1980, any addition to year is added on top of 1980. This is fine because the hardware is passing the number of days since January 1, 1980. </li>
<li>Is the number of days greater than 365? If so, proceed. Otherwise, skip to number 6. </li>
<li>Is the current year a leap year? If so, proceed. Otherwise, subtract 365 from the number of days, add 1 to the number of years, and skip to number 5. </li>
<li>Is the number of days greater than 366? If so, subtract 366 from the number of days, add 1 to the number of years, and proceed. </li>
<li>retry number 2. </li>
<li>…</li>
<li>Profit? </li>
</ol>
<p>The problem lies in the fact that there is one case which can never escape the loop. If it’s a leap year, the number 366 will stay within the loop forever because 366 will never be greater than 366, but 366 will also always be greater than 365. 366 days will pass through, in our Plain English While Loop, without having any action committed upon it.</p>
<p>There’s a very quick solution to this: Since 366 is a valid remainder of days in a leap year (December 31 is the 366th day in a leap year), 366 can technically exit the loop without any problems. All we need to do is add a way to exit the loop when the number of days is 366. Let’s see how things go with this new breakpoint:</p>
<ol>
<li>year is set to ORIGINYEAR. Since ORIGINYEAR is 1980, any addition to year is added on top of 1980. This is fine because the hardware is passing the number of days since January 1, 1980. </li>
<li>Is the number of days greater than 365? If so, proceed. Otherwise, skip to number 6. </li>
<li>Is the current year a leap year? If so, proceed. Otherwise, subtract 365 from the number of days, add 1 to the number of years, and skip to number 5. </li>
<li>Is the number of days greater than 366? If so, subtract 366 from the number of days, add 1 to the number of years, and proceed. Otherwise, skip to number 6. </li>
<li>retry number 2. </li>
<li>…</li>
<li>Profit!</li>
</ol>
<p>Thanks to the break (represented by “Otherwise, skip to number 6”), 366 days can escape the loop properly. This would lead to the end result for December 31, 2008 being years == 2008 and days == 366.</p>
<p>This is what the break would look in the while loop:</p>
<blockquote>
<pre><font color="#000000">    <font color="#800000">while</font> (days &gt; <font color="#ff0000">365</font>)
    {
        <font color="#800000">if</font> (IsLeapYear(year))
        {
            <font color="#800000">if</font> (days &gt; <font color="#ff0000">366</font>)
            {
                days -= <font color="#ff0000">366</font>;
                year += <font color="#ff0000">1</font>;
            }
            <font color="#800000">else</font>
            {
                <font color="#800000">break;</font>
            }
        }
        <font color="#800000">else</font>
        {
            days -= <font color="#ff0000">365</font>;
            year += <font color="#ff0000">1</font>;
        }
    }
</font></pre>
</blockquote>
<p>Clarifying one quick thing: A number of people on outlets such as Digg suggested that changing “<font color="#800000">if</font> (days &gt; <font color="#ff0000">366</font>)” to “<font color="#800000">if</font> (days &gt;= <font color="#ff0000">366</font>)”:</p>
<p><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; display: inline; border-right-width: 0px" title="QAdigg" border="0" alt="QAdigg" src="http://winjade.net/wp-content/uploads/2009/01/qadigg.png" width="660" height="158" /></p>
<p>The problem with doing this is that the end result, upon hitting “<font color="#800000">if</font> (days &gt;= <font color="#ff0000">366</font>)” with the value 366, one would end up with the year going up by one and the operation “<font color="#ff0000">366 –</font>= <font color="#ff0000">366</font>” playing out. End result: December 31 of the leap year is suddenly January 0 of the following year.</p>
<p>&#160;</p>
<p><strong>Extra credit:</strong> This loop can be fixed such that the loop’s condition is based on the year’s status as a leap year. The change needed is simple:</p>
<blockquote>
<pre><font color="#000000">    <font color="#800000">while</font> (days &gt; (IsLeapYear(year) ? <font color="#ff0000">366</font> : <font color="#ff0000">365</font>))
    <font color="#008080">//The above line basically says “Is it a leap year? Check days against 366.
    //Otherwise, check it against 365”</font>
    {
        <font color="#800000">if</font> (IsLeapYear(year))
        {
            days -= <font color="#ff0000">366</font>;
            year += <font color="#ff0000">1</font>;
            <font color="#008080">/*You’ll notice we no longer need a break. The loop condition now
             *checks the days properly. Because the loop properly checks
             *whether days is greater than 365 or 366, the second days &gt; 366
             *check is no longer needed. */</font>
        }
        <font color="#800000">else</font>
        {
            days -= <font color="#ff0000">365</font>;
            year += <font color="#ff0000">1</font>;
        }
    }
</font></pre>
</blockquote>
<p>&#160;</p>
<p>However, if this change is made, IsLeapYear() is now being called twice. This is inefficient, especially on small devices (like the devices which would be using this driver). In order to reduce the number of times IsLeapYear() is being called, it would be best to store the value of IsLeapYear() in a variable.</p>
<blockquote>
<pre><font color="#000000">    <font color="#008000">int</font> leap = IsLeapYear(year);
    <font color="#008080">//leap is determined before the loop begins.
    //In this case, it would be true (1980 is a leap year)</font>
    <font color="#800000">while</font> (days &gt; (leap ? <font color="#ff0000">366</font> : <font color="#ff0000">365</font>))
    {
        <font color="#800000">if</font> (leap)
        {
            days -= <font color="#ff0000">366</font>;
            year += <font color="#ff0000">1</font>;
        }
        <font color="#800000">else</font>
        {
            days -= <font color="#ff0000">365</font>;
            year += <font color="#ff0000">1</font>;
        }
        leap = IsLeapYear(year);
        <font color="#008080">//leap is determined again now that the year has changed.</font>
    }
</font></pre>
</blockquote>
<p>This can actually be reduced even further. If you look at how the if/else statement is operating, you can see that it’s basically saying “If it’s a leap year, subtract 366. Otherwise, subtract 365,” which is similar to the while loop’s condition!</p>
<blockquote>
<pre><font color="#000000">    <font color="#008000">int</font> leap = IsLeapYear(year);
    <font color="#800000">while</font> (days &gt; (leap ? <font color="#ff0000">366</font> : <font color="#ff0000">365</font>))
    {
        days -= (leap ? <font color="#ff0000">366</font> : <font color="#ff0000">365</font>);
        <font color="#008080">//days is equal to days - 366 if it's a leap year,
        //                 days - 365 if it isn't.</font>
        year += <font color="#ff0000">1</font>;
        leap = IsLeapYear(year);
    }
</font></pre>
</blockquote>
<p>If you wanted to reduce the number of times (leap ? <font color="#ff0000">366</font> : <font color="#ff0000">365</font>) is checked, you could do this instead:</p>
<blockquote>
<pre><font color="#000000">    <font color="#008000">int</font> daysThisYear = (IsLeapYear(year) ? <font color="#ff0000">366</font> : <font color="#ff0000">365</font>);
    <font color="#008080">//The number of days in the current year is now calculated instead. </font>
    <font color="#800000">while</font> (days &gt; daysThisYear)
    {
        days -= daysThisYear;
        year += <font color="#ff0000">1</font>;
        daysThisYear = (IsLeapYear(year) ? <font color="#ff0000">366</font> : <font color="#ff0000">365</font>);
    }
</font></pre>
</blockquote>
<p>It’s questionable whether or not this code is any better than the original solution with the break, but this would be the “proper” way to do it (instead of using an arbitrary break in your code). It’s also easier to understand if you know C.</p>
<p>The irony in all of this is that this specific driver is used in multiple Windows CE devices, not just the Zune. This is why quality assurance is so necessary.</p>
<p><strong>There are three morals here: </strong></p>
<ol>
<li><strong>Test every condition which could happen in every single loop in your code </strong>(though, as Matt Boehm points out in the comments, this might be a <a href = "http://www.aeroxp.org/2009/01/lesson-on-infinite-loops/#comment-831">tad bit hard</a>). </li>
<li><strong>Don’t visit Digg for programming advice. What you’ll hear is questionable at best</strong> </li>
<li><strong>Make your code easy to read for other developers.</strong> </li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://winjade.net/2009/01/lesson-on-infinite-loops/feed/</wfw:commentRss>
		<slash:comments>157</slash:comments>
		</item>
		<item>
		<title>The Zune 30 bug was overinflated</title>
		<link>http://winjade.net/2009/01/zune-30-bug-overinflated/</link>
		<comments>http://winjade.net/2009/01/zune-30-bug-overinflated/#comments</comments>
		<pubDate>Fri, 02 Jan 2009 23:13:45 +0000</pubDate>
		<dc:creator>Bryant Zadegan</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[dev fail]]></category>
		<category><![CDATA[Infinite Loop]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Press Fail]]></category>
		<category><![CDATA[Zune]]></category>
		<category><![CDATA[Zune 30]]></category>

		<guid isPermaLink="false">http://www.aeroxp.org/2009/01/zune-30-bug-overinflated/</guid>
		<description><![CDATA[(My sincerest apologies; this post was unpublished due to a database error. The issue has since been fixed.
This is a shout-out to all Zune 30 owners who remained patient. 
This is to you, the faithful owner of a Zune 30, who didn&#8217;t buckle under stress and kept a keen eye on Microsoft, waiting for a [...]]]></description>
			<content:encoded><![CDATA[<p><img style="border-top-width: 0px; border-left-width: 0px; float: none; border-bottom-width: 0px; margin-left: auto; margin-right: auto; display: block; border-right-width: 0px" title="Zune Logo" border="0" alt="Zune Logo" src="http://winjade.net/wp-content/uploads/2009/01/zunelogo.png" width="446" height="360" /><br /><em>(My sincerest apologies; this post was unpublished due to a database error. The issue has since been fixed.</em></p>
<p>This is a shout-out to all Zune 30 owners who remained patient. </p>
<p>This is to you, the faithful owner of a Zune 30, who didn&#8217;t buckle under stress and kept a keen eye on Microsoft, waiting for a solution. </p>
<p>This is to you, the discount shopper who picked up a Zune 30 and didn&#8217;t want to lose faith in your hardware. </p>
<p>Low and behold, Microsoft dug deep to find out the problem and, within minutes of finding out exactly what it was, pushed out an answer and a solution that <em>didn&#8217;t</em> void your warranty (thanks, Gizmodo). There&#8217;s a reason for why I&#8217;m bringing all of this up. July of 2008 saw <a href="http://www.betanews.com/article/Activation_problems_delay_sales_during_iPhone_3G_premiere/1215779644">cataclysmic</a> <a href="http://blogs.zdnet.com/Apple/?p=1972">server</a> <a href="http://www.engadget.com/2008/07/11/itunes-activation-servers-go-down-iphone-3g-customers-being-sen/">failure</a> when a vast majority of all newly-purchased iPhone 3G units tried activating at nearly the same time, leaving both new iPhone 3Gs and some iPhone Gen 1 units dead in the water until the activation servers came back online. Poor planning led to the creation of a load-intolerant system on AT&amp;T&#8217;s side (though the blame hardly belongs to them, given that Apple mandated this system in the first place). However, people weren&#8217;t infuriated by Apple&#8217;s ineptitude here. They were complacent and merely went with whatever explanation was fed to them. Meanwhile, a sizable majority of people who stuck with their own platforms of choice decided <em>not</em> to point and jeer. </p>
<p>Fast forward to December 31, 2008, and <a href="http://community.winsupersite.com/blogs/paul/archive/2008/12/31/zune-30s-succumb-to-software-glitch.aspx">every</a> <a href="http://blogs.zdnet.com/microsoft/?p=1784">Zune 30</a> <a href="http://www.msnbc.msn.com/id/28449091/">device</a> <a href="http://blog.seattlepi.nwsource.com/microsoft/archives/158313.asp">freezes</a> due to a bug in a driver from Freescale Semiconductor in this while loop (<a href="http://pastie.org/349916">between lines 259 and 274</a>): </p>
<blockquote><pre>    while (days &gt; 365)
    {
        if (IsLeapYear(year))
        {
            if (days &gt; 366)
            {
                days -= 366;
                year += 1;
            }
        }
        else
        {
            days -= 365;
            year += 1;
        }
    }</pre>
</blockquote>
<p><em>(protip: day 366 triggers an infinite loop. To see the context of the code, check out the pastie link above, or just <a href="http://pastie.org/349916">click here</a>. You can see a breakdown of how this could&#8217;ve been handled <a href = "http://www.aeroxp.org/2009/01/lesson-on-infinite-loops/">here</a>)</em>&#160; </p>
<p>What happened? Every Apple-loyal iPhone, iPod, and Mac owner threw a fit even though none of them actually owned a Zune 30 (You can&#8217;t run a Zune 30&#8230; or any Zune, for that matter, on a Mac). Thanks in part to the additional sensationalism promoted by gadget bloggers and, subsequently, news outlets the world over, a problem with a Zune model sold only in North America suddenly became a &quot;Worldwide Zune Outage.&quot; </p>
<p>This is the difference between the Social and the Kingdom of Apple. Those with Zunes held out patiently and were rewarded with verbose output by Microsoft, whereas Apple simply vaguely alluded to some other company being the source of their problems (or were otherwise mute for a long period of time) whenever something on Apple&#8217;s side went wrong. </p>
<p>Thank you, Zune 30 owners, for living up to the hype of the Social. I&#8217;m now quite proud to be an owner of a Zune myself.</p>
]]></content:encoded>
			<wfw:commentRss>http://winjade.net/2009/01/zune-30-bug-overinflated/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
	</channel>
</rss>
