Wrong line of work


  • Discourse touched me in a no-no place

    So last week I did an arcane little conversion on an arcane and ancient project to comply with some new, arcane vendor requirements. This makes me the expert on doing this arcane conversion (and, if I weren't already already, would make me the expert and lead support on the arcane and ancient project).

    Today, I get handed the task to do the same conversion to a VASTLY arcane project that doesn't even have the slightest thing to do with what our department is supposed to be writing code to do - but somehow it originated with us so we own it. The problem is that, in the words of my team lead, the project was originally coded by someone who "was in the wrong line of work."

    Man wasn't kidding.

    I start digging in the database (of course there's no documentation. There's NEVER documentation in these parts) and discover a dozen tables with identical schemas which appear to be used as a sort of relay - data in one state of processing lives in each table, and gets deleted and reinserted to another one when it moves.

    So I need to find the procedures that move the data from table to table
    (because god knows they probably name each column explicitly, and I need
    to add a few). So I open a likely looking stored procedure and the first thing to jump out at me from the wall of FUGLY is this:

    @SQL = 'SELECT TOP 1 NULL FROM tblParts'

    [URL=http://imageshack.us/photo/my-images/216/khaaaaan.jpg/][IMG]http://img216.imageshack.us/img216/6649/khaaaaan.jpg[/IMG][/URL]



  • Isn't that the quickest way to tell if there are any rows?


  • Discourse touched me in a no-no place

    @Sutherlands said:

    Isn't that the quickest way to tell if there are any rows?

    Perhaps, but given that if the table is empty something has gone catastrophically wrong up-process and we need to crash spectacularly to alert the nearest innocent maintainer that some people aren't going to be getting their earth-shatteringly valuable shipments, it's both nonobvious to a maintainer and pointless. And the table is guaranteed (for certain, concurrency-be-damned values of guaranteed) to only contain records relevant to the current run (because of the aforementioned idiotic relay system), so a count(id) or whatever isn't going to hurt anything in comparison to the FIFTEEN HOURS of dick-around period built into the application (which runs on a schedule - one stage executes in the morning, nothing happens all day, and then another stage runs at night for no conceivable reason given the fact that both stages total like forty-five seconds of runtime with a worst-case input) it's the grandest premature optimization imaginable. ((((PARENTHESES!))))


  • Discourse touched me in a no-no place

    First, let me say this was pretty awesome.

    Second,

    @Weng said:

    So last week I did an arcane little conversion on an arcane and ancient project to comply with some new, arcane vendor requirements. This makes me the expert on doing this arcane conversion

    Yep, that's how it works. Ever notice, though, it only works for crap like this? You never get to be defaulted into the expert on something cool.

    @Weng said:

    @SQL = 'SELECT TOP 1 NULL FROM tblParts'


    QFT.


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.