Joe White’s Blog

Life, .NET, and Cats


Whiskey Tango Foxtrot

We’ve been refactoring some legacy code over the past few days, and we’ve found a couple of amusing snippets. They were written by programmers who no longer work here, so we can poke fun at them.

Here’s an interesting bit from 1998:

try
  // do some stuff
except
  raise;
  ShowMessage('Duplicate ID: ' + IntToStr(NewID) + #13 +
    'TableName: ' + tblNewRow.TableName );
  tblNewRow.Cancel;
end;

So we’ll cancel the append even if the re-raise fails, and execution falls through to the line after the raise. I can honestly say that this bit of resource-protection code never would have occurred to me.

A co-worker found another gem yesterday. This one also dates back to 1998 (though written by a different programmer):

Query.Locate(Query.FieldByName('ID').FieldName, ID, []);

So we call FieldByName, which searches for, and returns, the field whose FieldName is ‘ID’… and then we read that field’s FieldName. Brilliant, no?

I’m sad to say, though, that these coding gems are no longer in our code base. Somehow, they got lost during some code cleanup. I can’t tell you how much that distresses me.

2 Responses to “Whiskey Tango Foxtrot”

  1. m00kie Says:

    ok, nerd

  2. SPring-8 Says:

    Hey, it’s late

    im in Japan on a synchrotron and every 3 minutes I have to take a reading, like now …

    So in the time (sorry about the interrupt)

    in between i’m doing a little surfing

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


Joe White's Blog copyright © 2004-2008. Portions of the site layout use Yahoo! YUI Reset, Fonts, and Grids.
Proudly powered by WordPress. Entries (RSS) and Comments (RSS).