This version of the site is now archived. See the next iteration at v4.chriskrycho.com.
Topic: “worst practices”

Four more anti-patterns

Another set of absolutely lovely gems we found this week: an empty for, the almost-impossible if, continue just because, and source that doesn’t match the executable. Oh my!

The empty for

I’d seen this before, but we found it again while trying to diagnose an (unrelated) infinite loop bug in our source (more on that below): Read on, intrepid explorer →

Two (absurd) anti-patterns

A pair of anti-patterns I’ve run into recently in my software development work, both of which are absolutely awful, though in completely different (and quite distinct) ways. I thought I’d share The Empty If and Wash, Rinse, Repeat, just so the world can share a bit of my pain. Read on, intrepid explorer →

Something you should never do, but which did provide some hilarity for us today:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
if (idate < 65535)
  {
    CTime itime = CTime::GetCurrentTime();
      iyear = itime.GetYear();
        imonth = itime.GetMonth();
          idate = itime.GetDay();
            icurdate = (iyear - 2005)*512+12800 + (imonth*32 +1) + idate;
              if(icurdate > tdate)
                {
                  sprintf(str, "Key Expired");
                    MessageBoxEx(m_hWnd, str, "Error", MB_OK,LANG_ENGLISH);
                      exit(-1);
                    }
                  }

The whole 1500-line module was written up that way. Why? We have no idea. It’s better now. Less funny, but better.