<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><atom:link rel="hub" href="http://tumblr.superfeedr.com/" xmlns:atom="http://www.w3.org/2005/Atom"/><description>A feed of interesting tidbits from IT, software engineering, business intelligence, and videogaming.</description><title>Programming Analytics</title><generator>Tumblr (3.0; @tedspence)</generator><link>http://tedspence.com/</link><item><title>Why did x86 never die?</title><description>&lt;p&gt;&lt;a href="http://www.itworld.com/print/346559" target="_blank"&gt;This article on ITWorld about potential x86 replacements&lt;/a&gt; proposes that the reason x86 remained superior is that it had established software and that the potential replacements lacked compilers.&lt;/p&gt;

&lt;p&gt;Balderdash.&lt;/p&gt;

&lt;p&gt;In addition to the potential replacements Intel offered, the market offered hundreds of other possible replacements to the x86, many with phenomenal compilers.  MIPS, PowerPC, DEC Alpha, and tons of others all offered excellent performance (I won&amp;#8217;t list SPARC because SPARC was in fact a terrible design and remains one to this day).&lt;/p&gt;

&lt;p&gt;What kept Intel&amp;#8217;s x86 line on top of the heap was Moore&amp;#8217;s law.  Throughout the 1990s, everyone always knew they could switch to a different chip and see a 50% performance increase immediately.  However, they also knew, by Moore&amp;#8217;s law, that they could wait six months and get a 50% performance increase by buying the latest Intel chip six months in the future.&lt;/p&gt;

&lt;p&gt;Even better, Intel kept playing a phenomenal game of catch-up.  Whatever feature competitive CPU architectures built, Intel built into the next version of x86.  The P6 CPU was, in fact, a very advanced RISC chip with a nifty-quick microcode decoder attached to the front of its pipeline.  So Intel&amp;#8217;s chips rapidly caught up the 50% performance gap.&lt;/p&gt;

&lt;p&gt;So everyone had two options: Buy a replacement platform now and rebuild your code, or wait six months and get equivalent performance with no rebuilding.  I know which choice I made back then.  &lt;/p&gt;

&lt;p&gt;Keep in mind that buying a replacement platform was often 10x more expensive, since none of the alternate CPUs available at the time had sufficient volume to keep prices down.  So if your choice was between buying a $10,000 DEC Alpha and buying a $3000 Pentium Pro with half the performance, &amp;#8230; you&amp;#8217;d buy a Pentium Pro, wait two years, and buy another one.&lt;/p&gt;

&lt;p&gt;Getting back to today - the reason Intel&amp;#8217;s x86 is finally threatened is because, due to Android smartphones, ARM chips now have sufficient production volume and performance demands.  Chipmakers are competing to create the highest performing ARM chips, and they&amp;#8217;re producing millions of them at a time, so they can afford to invest in performance boosts.&lt;/p&gt;

&lt;p&gt;Intel can keep reducing the power usage of x86 to compete, but this is a different type of challenge, and I honestly think x86 chips will not always dominate against ARM.&lt;/p&gt;</description><link>http://tedspence.com/post/44647091085</link><guid>http://tedspence.com/post/44647091085</guid><pubDate>Tue, 05 Mar 2013 15:29:00 -0500</pubDate></item><item><title>Programming is like building a house?</title><description>&lt;p&gt;I saw this article today which &lt;a href="http://www.wired.com.edgesuite.net/opinion/2013/01/code-bugs-programming-why-we-need-specs" target="_blank"&gt;compares programming to building a house&lt;/a&gt;.  It&amp;#8217;s a noble sentiment.&lt;/p&gt;

&lt;p&gt;However, one of the advantages of having (I can hardly believe it) 22 years of professional software development expertise is that I have seen trends like this come and go.  Every few years, this theme of &amp;#8220;Programming should be engineering!&amp;#8221; resurfaces.  And afterwards, even though some progress was made, all goes back to the way it was before, and the companies that do &amp;#8220;release-early, release-often&amp;#8221; win out over the companies that do rigorous design.&lt;/p&gt;

&lt;p&gt;Why is this?&lt;/p&gt;

&lt;p&gt;Programming is, unfortunately to say, not like engineering in the way we wish it was.  &lt;/p&gt;

&lt;p&gt;When you are designing a house, or designing a bridge, or any other gigantic physical work, you have complete knowledge of your materials available.  If you say that you wish this roof to be held up by two steel beams or by a wooden frame, you can look up the quality of the materials and know exactly how it works.&lt;/p&gt;

&lt;p&gt;When you are doing mechanical engineering, physically changing something has a known time and cost and often is impossible once a system is built.  In software engineering, changing a component is virtually costless.&lt;/p&gt;

&lt;p&gt;In programming, every detail is just as unique as the overall design of the application itself.  Every detail can suffer from the same problems that can cause the program as a whole to fail.&lt;/p&gt;

&lt;p&gt;I think it is much more fair to compare software to law.  A programmer is like a lawyer.  They have rules to follow and a flexible set of limits to push against.  But at every step of the way, the rules and the limits are subject to interpretation.  At every step of the way, the results of something you thought you understood can surprise you.&lt;/p&gt;</description><link>http://tedspence.com/post/42030312155</link><guid>http://tedspence.com/post/42030312155</guid><pubDate>Fri, 01 Feb 2013 12:20:00 -0500</pubDate></item><item><title>Managing Receivables</title><description>&lt;p&gt;Saw an interesting discussion on Slashdot today and thought I&amp;#8217;d share some of my personal experience about receivables.  I&amp;#8217;ve been involved with lots of startups and this is a common occurrence.&lt;/p&gt;

&lt;p&gt;Delayed payment is normal.  Large companies have very complex rules about how to make payments and how to process invoices.  You must be extremely persistent and gracious in order to get things resolved.  Each company will respond differently, but I encourage you to make use of some (if not all) of these following tactics:&lt;/p&gt;

&lt;p&gt;&lt;nl&gt;&lt;li&gt;Get a &amp;#8220;Master Vendor Agreement&amp;#8221; in place with the customer that states invoicing terms.  This contract may take months to negotiate and require guidance from a lawyer.  Once this is done, all of your projects should be addendums to this original master vendor agreement.  This reduces the amount of paperwork the large multinational company has to do to validate each of your invoices and speeds them up.&lt;/li&gt;&lt;br/&gt;&lt;li&gt;Provide both a discount for early payment and a penalty for late payment.  Annotate these discounts &amp;amp; payments on each invoice.  If you carefully track your effort, you can know how much it costs you to track long term overdue payments.  You can use this to determine how much of a discount you can offer for prompt payment.&lt;/li&gt;&lt;br/&gt;&lt;li&gt;Designate someone within your company as the &amp;#8220;Accounts Receivable&amp;#8221; person.  It is their job to contact each customer with an overdue payment once per month (or week).  They should very carefully take notes on all of their conversations and correspondence, but they _must_ be friendly and relaxed.  The goal is to establish a positive rapport with the &amp;#8220;accounts payable&amp;#8221; person on the other side.  It may take dozens of polite phonecalls to get routed to the correct person though, so you absolutely must be willing to put in the effort while not creating bad will.&lt;/li&gt;&lt;br/&gt;&lt;li&gt;Be gracious when payment is offered.  Many times, companies may refuse to pay late payment fees; you can simply say, &amp;#8220;I&amp;#8217;ll remove the late payment fee if you wire the money by tomorrow&amp;#8221;.&lt;/li&gt;&lt;br/&gt;&lt;li&gt;If desired, you can contact your bank to find out if they will finance your receivables.  Some banks will provide you with cash up front for a fee since they know how this process works.&lt;/li&gt;&lt;br/&gt;&lt;li&gt;Don&amp;#8217;t harass your point of contact until the invoice is more than a reasonable amount late.  Generally, in a big company, the person who signs the contract doesn&amp;#8217;t even know the person who actually pays the bill.  You want to avoid harassing your point of contact (who is usually your biggest fan) until you really need their help getting the bill paid.&lt;/li&gt;&lt;br/&gt;&lt;li&gt;Know your customers&amp;#8217; &amp;#8220;approval limits&amp;#8221;.  Generally, executives at a large company will have specific approval levels - for maybe $500 they can simply file an expense report; for $2500 they have to file one form with one signature, and for more than that they have to get approval from a VP level person.  If you can keep your projects small enough, you can bypass some of the challenges.&lt;/li&gt;&lt;br/&gt;&lt;li&gt;Once you&amp;#8217;ve read lots of advice on slashdot and picked a strategy, contact a lawyer before doing anything.  Most lawyers will be able to confirm whether your plans follow the law quickly.  It&amp;#8217;ll only cost you a small amount.&lt;/li&gt;&lt;br/&gt;&lt;/nl&gt;&lt;/p&gt;

&lt;p&gt;And finally, remember, &amp;#8220;managing receivables&amp;#8221; is part of the cost of doing business with large companies.  Factor it into your project costs.&lt;/p&gt;</description><link>http://tedspence.com/post/38087757948</link><guid>http://tedspence.com/post/38087757948</guid><pubDate>Sun, 16 Dec 2012 15:34:00 -0500</pubDate></item><item><title>Tinting Buttons in WPF</title><description>&lt;p&gt;While working on the UI of a WPF application, someone told me, &amp;#8220;If you&amp;#8217;re going to change the background color of the form, why not re-tint all the buttons to match it?&amp;#8221;&lt;/p&gt;

&lt;p&gt;So I thought I should write a tiny piece of code that takes as input a brush, lightens it by 50%, and assigns that to all controls of a certain type.  Here&amp;#8217;s how to do it:&lt;/p&gt;

&lt;pre&gt;
private void RecolorChildren(DependencyObject dep, System.Windows.Media.Brush b)
{
    for (int i = 0; i &amp;lt; VisualTreeHelper.GetChildrenCount(dep); i++) {
        DependencyObject child = VisualTreeHelper.GetChild(dep, i);
        if (child is System.Windows.Controls.Button) {
            System.Windows.Controls.Button button = child as System.Windows.Controls.Button;
            button.Background = b;
        } else if (child is System.Windows.Controls.ComboBox) {
            System.Windows.Controls.ComboBox cbx = child as System.Windows.Controls.ComboBox;
            cbx.Background = b;
        } else {
            RecolorChildren(child, b);
        }
    }
}
&lt;/pre&gt;

&lt;p&gt;To tint a brush:&lt;/p&gt;

&lt;pre&gt;
private static System.Windows.Media.Brush LightenBrush(System.Windows.Media.Brush b, int percent)
{
    SolidColorBrush scb = b as SolidColorBrush;
    System.Windows.Media.Color c2 = scb.Color;
    c2.B = (byte)(c2.B + ((double)(255 - c2.B) / 100.0 * percent));
    c2.G = (byte)(c2.G + ((double)(255 - c2.G) / 100.0 * percent));
    c2.R = (byte)(c2.R + ((double)(255 - c2.R) / 100.0 * percent));
    b = new SolidColorBrush(c2);
    return b;
}
&lt;/pre&gt;</description><link>http://tedspence.com/post/37367202896</link><guid>http://tedspence.com/post/37367202896</guid><pubDate>Thu, 06 Dec 2012 19:33:00 -0500</pubDate></item><item><title>AltDev Student Summit 2012</title><description>&lt;a href="http://www.youtube.com/watch?v=Hz3g8rkskDs"&gt;AltDev Student Summit 2012&lt;/a&gt;: &lt;p&gt;My presentation at the AltDev Student Summit was about what new graduates should expect from the games industry.  It’s a modified version of the presentation I gave to the San Diego State University ACM - &lt;a href="http://acm.sdsu.edu/" target="_blank"&gt;http://acm.sdsu.edu/&lt;/a&gt; - last month.&lt;/p&gt;

&lt;p&gt;This is a very light presentation with some interesting stories about the games industry.&lt;/p&gt;</description><link>http://tedspence.com/post/36007182912</link><guid>http://tedspence.com/post/36007182912</guid><pubDate>Sun, 18 Nov 2012 14:50:26 -0500</pubDate></item><item><title>New Article: Fix Your Pebbles</title><description>&lt;p&gt;Just recently published my latest article, this time about my programming philosophy.  This article talks about how I teach my team members to deliver results and apply their intelligence to problems.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.altdevblogaday.com/2012/10/21/fix-your-pebbles/" target="_blank"&gt;http://www.altdevblogaday.com/2012/10/21/fix-your-pebbles/&lt;/a&gt;&lt;/p&gt;</description><link>http://tedspence.com/post/34067086555</link><guid>http://tedspence.com/post/34067086555</guid><pubDate>Sun, 21 Oct 2012 20:31:01 -0400</pubDate></item><item><title>New Article: The Elements of Comment Style</title><description>&lt;p&gt;I wrote a new article for AltDevBlogADay regarding the &lt;a href="http://bit.ly/T64vIL" target="_blank"&gt;use of comments in programming&lt;/a&gt;.  I&amp;#8217;m rather happy with the way this article turned out; I find that the research and categorization I did when reading through my past work was quite useful in understanding how I use comments.  &lt;/p&gt;

&lt;p&gt;Hopefully all of you will find the article fun reading too!&lt;/p&gt;</description><link>http://tedspence.com/post/31891191746</link><guid>http://tedspence.com/post/31891191746</guid><pubDate>Wed, 19 Sep 2012 20:24:11 -0400</pubDate></item><item><title>SSIS</title><description>&lt;p&gt;Never before in the history of mankind have so many connection strings been erroneously reset by such a simple project.&lt;/p&gt;

&lt;p&gt;With apologies to Winston Churchill.&lt;/p&gt;</description><link>http://tedspence.com/post/30533483673</link><guid>http://tedspence.com/post/30533483673</guid><pubDate>Thu, 30 Aug 2012 15:13:09 -0400</pubDate></item><item><title>Open source database schema comparisons!</title><description>&lt;p&gt;I&amp;#8217;ve really missed my old Red Gate SQL Compare product - I&amp;#8217;ve been using it for years and it was a fantastic tool.  But for working on independent projects, I just didn&amp;#8217;t want to pay for a personal use license.  So that&amp;#8217;s why I&amp;#8217;m excited to find this project:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://code.google.com/p/sql-dbdiff/" target="_blank"&gt;http://code.google.com/p/sql-dbdiff/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Despite the awkward user interface, this program does appear to get a thorough database schema from a Microsoft SQL server, and it appears to be fully capable of doing a difference analysis and creating a changescript.  With a bit of cleanup, this program would be a fantastic replacement!&lt;/p&gt;

&lt;p&gt;As a note, it looks like it&amp;#8217;s a fork of this program:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://opendbiff.codeplex.com/" target="_blank"&gt;http://opendbiff.codeplex.com/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I&amp;#8217;ll need to do some more analysis to figure out which one is a more appealing start.  However, they both appear to have ended development sometime in 2010 - I wonder why?&lt;/p&gt;</description><link>http://tedspence.com/post/29898889744</link><guid>http://tedspence.com/post/29898889744</guid><pubDate>Tue, 21 Aug 2012 10:53:21 -0400</pubDate></item><item><title>Type Conversions!</title><description>&lt;p&gt;A far better way of writing &amp;#8220;string-to-type&amp;#8221; conversion is here:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.hanselman.com/blog/TypeConvertersTheresNotEnoughTypeDescripterGetConverterInTheWorld.aspx" target="_blank"&gt;http://www.hanselman.com/blog/TypeConvertersTheresNotEnoughTypeDescripterGetConverterInTheWorld.aspx&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here&amp;#8217;s the terrible thing about C# - it changes and grows so fast there&amp;#8217;s tons of fantastic stuff in it that often slips below the radar.  This is by far the best little type conversion kit I&amp;#8217;ve seen!&lt;/p&gt;</description><link>http://tedspence.com/post/29635397542</link><guid>http://tedspence.com/post/29635397542</guid><pubDate>Fri, 17 Aug 2012 15:09:56 -0400</pubDate></item><item><title>Automated SSIS Decompiler</title><description>&lt;p&gt;I&amp;#8217;ve started an open source project to create an &lt;a href="http://code.google.com/p/csharp-dessist/" target="_blank"&gt;Automated SSIS Decompiler&lt;/a&gt;.  This program is so far capable of reading in a DTSX package and writing, as output, a C# source code file and an accompanying configuration file.  I&amp;#8217;ll continue to develop this program as long as it helps me research my current administration / maintenance process; anyone who is interested in providing assistance will be welcome to join in!&lt;/p&gt;</description><link>http://tedspence.com/post/29389307054</link><guid>http://tedspence.com/post/29389307054</guid><pubDate>Tue, 14 Aug 2012 00:40:27 -0400</pubDate></item><item><title>SSIS is not a useful product.</title><description>&lt;p&gt;Read this article today while researching ways to migrate an SSIS package into a C# program.  It would really be neat if there was a way to programmatically convert an SSIS abomination into a readable, intelligible C# / .NET program.  Maybe that will be a useful project ;)&lt;/p&gt;

&lt;p&gt;&lt;a href="http://ayende.com/blog/2637/ssis-15-faults" target="_blank"&gt;http://ayende.com/blog/2637/ssis-15-faults&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So here&amp;#8217;s the thing: why is SSIS bad?  Honestly, when I used to use Data Transformation Services back in the late &amp;#8217;90s, there was nothing wrong with it.  DTS was a simple way to automate a complex, bulk data transformation process.  It was limited, but that was okay - because it had a specific function.  It imported and exported data to and from SQL server.&lt;/p&gt;

&lt;p&gt;Nowadays SSIS supports everything and the kitchen sink.  What used to be straightforward (Import -&amp;gt; Select source -&amp;gt; Select columns -&amp;gt; Go!) is now a massive undertaking.  I thought it was really neat how DTS had the ability to save a package so you could repeat it again in the future.  If I&amp;#8217;d have known that it would become this complex and impenetrable, I would have walked away.&lt;/p&gt;</description><link>http://tedspence.com/post/29157004837</link><guid>http://tedspence.com/post/29157004837</guid><pubDate>Fri, 10 Aug 2012 20:01:37 -0400</pubDate></item><item><title>Introduction to Regression Analysis</title><description>&lt;p&gt;I&amp;#8217;ve been teaching people how to use basic regression for a while now, and I finally wrote it all up as an article here:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.altdevblogaday.com/2012/08/10/business-analytics-with-regression/" target="_blank"&gt;http://www.altdevblogaday.com/2012/08/10/business-analytics-with-regression/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are lots of tools available that are far more complex than you&amp;#8217;d ever need, but fortunately there are open source tools that can really help you get started smoothly.  Good luck!&lt;/p&gt;</description><link>http://tedspence.com/post/29108607479</link><guid>http://tedspence.com/post/29108607479</guid><pubDate>Fri, 10 Aug 2012 01:50:54 -0400</pubDate></item><item><title>C# Command Line Wrapper Library</title><description>&lt;p&gt;So I got tired of writing and rewriting the same command line user interface over and over again.&lt;/p&gt;

&lt;p&gt;I have lots of programs that I write to be &amp;#8220;automatable&amp;#8221; - i.e. so that an operations team member can put it into a script and execute it, or schedule it, or batch it up.&lt;/p&gt;

&lt;p&gt;Rather than continue rewriting this stuff over and over, I wrote a library that accomplishes universal execution automation via reflection: &lt;/p&gt;

&lt;p&gt;&lt;a href="http://code.google.com/p/csharp-command-line-wrapper/" target="_blank"&gt;http://code.google.com/p/csharp-command-line-wrapper/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can view the code here, and drop it into your project at any time by copying and pasting this code:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://code.google.com/p/csharp-command-line-wrapper/source/browse/trunk/CommandWrapper/CommandWrapLib/CommandWrapLib.cs" target="_blank"&gt;http://code.google.com/p/csharp-command-line-wrapper/source/browse/trunk/CommandWrapper/CommandWrapLib/CommandWrapLib.cs&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It produces nice clean output and parses your variables on the command line.&lt;/p&gt;</description><link>http://tedspence.com/post/28992185981</link><guid>http://tedspence.com/post/28992185981</guid><pubDate>Wed, 08 Aug 2012 14:11:57 -0400</pubDate></item><item><title>JPL was able to snap a picture of Curiosity as it landed</title><description>&lt;p&gt;This is truly the coolest photo I&amp;#8217;ve seen in a while.  Nice camera work. ;)&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.nasa.gov/mission_pages/msl/news/msl20120806b.html" target="_blank"&gt;http://www.nasa.gov/mission_pages/msl/news/msl20120806b.html&lt;/a&gt;&lt;/p&gt;</description><link>http://tedspence.com/post/28856344243</link><guid>http://tedspence.com/post/28856344243</guid><pubDate>Mon, 06 Aug 2012 16:39:42 -0400</pubDate></item><item><title>C# Library for Automating VMWare</title><description>&lt;p&gt;This looks surprisingly useful!  Why not have an Amazon-style scripted toolset for deploying images to your internal cloud?&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.codeproject.com/Articles/31961/Automating-VMWare-Tasks-in-C-with-the-VIX-API" target="_blank"&gt;http://www.codeproject.com/Articles/31961/Automating-VMWare-Tasks-in-C-with-the-VIX-API&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This would have been fantastic back when we were deploying virtual GamePulse images every week.&lt;/p&gt;</description><link>http://tedspence.com/post/28851184165</link><guid>http://tedspence.com/post/28851184165</guid><pubDate>Mon, 06 Aug 2012 15:17:00 -0400</pubDate></item><item><title>QuickDraw Source Code</title><description>&lt;p&gt;Ever wonder how the Mac was possible?  Now you can actually download the 68000 assembly source code for Bill Atkinson&amp;#8217;s QuickDraw, one of the most impressive toolkits you never really thought about:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.computerhistory.org/highlights/macpaint/" target="_blank"&gt;http://www.computerhistory.org/highlights/macpaint/&lt;/a&gt;&lt;/p&gt;</description><link>http://tedspence.com/post/28145793896</link><guid>http://tedspence.com/post/28145793896</guid><pubDate>Fri, 27 Jul 2012 16:21:26 -0400</pubDate></item><item><title>Your Task "Inventory"</title><description>&lt;p&gt;Joel Spolsky wrote a cool article on the problems with letting your programming backlog get too big.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.joelonsoftware.com/items/2012/07/09.html" target="_blank"&gt;http://www.joelonsoftware.com/items/2012/07/09.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Over the past five years I suffered heavily from this.  There were always hundreds of bugs being reported; there we always years worth of backlog programming ideas in the queue.  At the time, I felt it was useful to have a massive backlog of ideas.  &lt;/p&gt;

&lt;p&gt;But of course, at the same time, we kept our programming velocity up:  We had a daily scrum process and we identified the most promising changes that could get into our codebase right now.  Because of that, we were able to deliver incredibly rapid change and keep our product at the top of the market even when we had fewer programmers than any of our competitors.&lt;/p&gt;

&lt;p&gt;I like to think of it as &amp;#8220;banking&amp;#8221; your changes.  Any code you write is ephemeral until it is launched.  As you work, you build up lots of potential improvements.  But if you don&amp;#8217;t deploy your code - &lt;a href="http://www.folklore.org/StoryView.py?story=Real_Artists_Ship.txt" target="_blank"&gt;real artists ship&lt;/a&gt; - your changes never benefit anyone.  We kept up our velocity by shipping all changesets that were ready, deploying code to live about once every three weeks.&lt;/p&gt;</description><link>http://tedspence.com/post/28134918317</link><guid>http://tedspence.com/post/28134918317</guid><pubDate>Fri, 27 Jul 2012 13:20:17 -0400</pubDate></item><item><title>About Year-Week Dates</title><description>&lt;p&gt;I did a lot of work in sales data processing. In America, sales data is reported monthly; and months are handled in one of two ways: either as a calendar month or as a NRF 4-5-4 calendar month, which is used to make year-over-year month comparisons consistent. Basically, the NRF calendar allows you to compare January 2011 to January 2012 in such a way that each month contains the same number of weekdays and weekend days.&lt;/p&gt;


&lt;p&gt;When I started working with European data, I was overjoyed to discover that European data was reported weekly. Even better, all the weeks appeared to start on Sunday. I could simply load data from all the European countries, who provided for each data point the year and week numbers. I wrote a tiny function in my code that took these two numbers and produced a date, and a separate function that did the opposite. Here&amp;#8217;s what they looked like:&lt;/p&gt;

&lt;pre&gt;
-- Determine the week number of this date
SELECT DATEPART(week, GETDATE())

-- Starting from January 1st, backtrack to Sunday; then add 29 weeks 
-- to get the start date for week 30
SELECT DATEADD(week, 29, 
    DATEADD(day, 
    1-(SELECT DATEPART(weekday, '2012-01-01')), '2012-01-01'))

&lt;/pre&gt;


&lt;p&gt;This worked great until I started receiving data from provider A which said &amp;#8220;Week 53 of 2008&amp;#8221; whereas the same data from provider B said &amp;#8220;Week 1 of 2009&amp;#8221;. All my carefully constructed logic blew up. Because these providers would not explain what algorithm they used to calculate their year-week numbers, I had to infer their logic from how their calendars changed. I wrote this post to hopefully explain to you the challenge involved in using year-week numbers; I&amp;#8217;m sorry it&amp;#8217;s not more helpful.&lt;/p&gt;


&lt;p&gt;Here are some of the definitions I have seen used:&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;Weeks start Sunday OR weeks start Monday.&lt;/li&gt;
&lt;li&gt;The first week that contains January 1st of year X is considered week 1 of year X OR the first week whose first day starts after January 1st of year X is considered week 1 of year X.&lt;/li&gt;
&lt;li&gt;In some cases, I&amp;#8217;ve worked with some data companies that worked on a &amp;#8220;balance of days&amp;#8221; principle, where the first week that has three or more days within year X is considered week 1 of year X.&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;With this in mind, you can determine year-week numbers in any way you want. Just remember that the numbers are not standardized unless you publish your definition of how you calculate year week numbers.&lt;/p&gt;</description><link>http://tedspence.com/post/28133756205</link><guid>http://tedspence.com/post/28133756205</guid><pubDate>Fri, 27 Jul 2012 12:59:00 -0400</pubDate></item><item><title>C# CSV Reader</title><description>&lt;p&gt;Code that reads data from comma-separated files is quite tricky.  Because most beginners simply split on the presence of a comma, and because this mostly works, it&amp;#8217;s easy to get started with CSV files - but actually quite hard to perfect them.  &lt;/p&gt;

&lt;p&gt;I wrote a library back in 2006 to parse these files, and have been modifying this for a long time.  I just realized it&amp;#8217;s really silly of me not to open source it.  So here goes:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://code.google.com/p/csharp-csv-reader/" target="_blank"&gt;https://code.google.com/p/csharp-csv-reader/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enjoy!&lt;/p&gt;</description><link>http://tedspence.com/post/28108622483</link><guid>http://tedspence.com/post/28108622483</guid><pubDate>Fri, 27 Jul 2012 01:05:59 -0400</pubDate></item></channel></rss>
