• Kluge Doctor (unregistered)

    Comment for Current Article //Comment for Tomorrow's Article //Comment for Day After Tomorrow's Article //Comment for Two Days After Tommorow's Article //Comment for Three Days After Tomorrow's Article

  • Anonymous coward (unregistered)

    At least he's using paramter binding.

  • Martin (unregistered)

    I totaly agree. Loops and arrays are bad. Any good programs uses goto statements and hard coded variables like that! Anyone have to agree to that:P

  • (cs) in reply to Kluge Doctor
    Kluge Doctor:
    Comment for Current Article //Comment for Tomorrow's Article //Comment for Day After Tomorrow's Article //Comment for Two Days After Tommorow's Article //Comment for Three Days After Tomorrow's Article

    I vote this one as a FEATURED comment. {Alex, are you there? }

  • (cs)

    Ugh. As a user of SQL Server Reporting Services, this is extremely painful to look at. I've made some convoluted reports, but nothing this moronic.

  • NO no NO! (unregistered)

    This is great. From now on no Loops or Arrays you morons! They are out dated and produce to little KLOC.

    Btw. this Jed defeinitely learned from the other Jed. It would be hilarious to watch those guys discuss their programming techniques. Like a Titanic movie for geeks!

  • (cs)

    Alex,

    I enjoy the newish highlighted comments feature. Sometimes I don't have time to wade through 100+ comments, and it's nice to have quick access to a few of the best.

    But it seems that you or whoever does the highlighting stops after the first couple hours of posting. I often look back the next day to check on comments added overnight and none of them are ever highlighted.

    Could you please do something so that the best late-posted comments get attention too?

    AlpineR

  • atkretsch (unregistered)

    My heart was racing there for a second until he said "just kidding." Simon, you prankster!

  • bushel (unregistered) in reply to Kluge Doctor

    Response to current comment. //Response to retort //Counter-argument to reply to response //Interim summary of discussion //Reply to tangential response

  • (cs) in reply to Martin

    TRWTF is that Simon didn't use SSDS to find all the places that he would need to uncomment, then he could have owned his data

  • (cs) in reply to NO no NO!
    NO no NO!:
    This is great. From now on no Loops or Arrays you morons! They are out dated and produce too little KLOC.

    Quite right. Get with modern coding practices. There's nothing an array and loop can do that you can't do with XML and exceptions, and a little imagination.

    --Rank

  • (cs)

    Rather than write a software loop, put yourself in a realtime loop. Very efficient.

  • jamie (unregistered) in reply to bushel
    bushel:
    Response to current comment. //Response to retort //Counter-argument to reply to response //Interim summary of discussion //Reply to tangential response

    followed by.....

    This is not a WTF //yes it is //it is a little //this is not a WTF //repeat and rinse

  • Joaquin (unregistered)

    I don't see the problem. You guys are always saying that using where is faster! :)

    And yes, the :) means I'm not serious.

  • David (unregistered)

    I can understand Jed.

    In a world where applications are full of overhead, doing things like retrieving data using SQL (interpreted on the server! just imagine the wasted cycles!) over TCP/IP (with all that extra bandwidth being wasted in headers!), etc. Jed just wanted to save cycles where he had control: his source code!

    // just kidding! why is he unrolling the loop? that used to work great when we had like 64kB of memory cache, but today??? FFS...

  • JM (unregistered) in reply to David
    David:
    In a world where applications are full of overhead, doing things like retrieving data using SQL (interpreted on the server! just imagine the wasted cycles!) over TCP/IP (with all that extra bandwidth being wasted in headers!), etc. Jed just wanted to save cycles where he had control: his source code!

    And now imagine Don LaFontaine narrating that.

    In a world... Sped-up footage of New York traffic

    where applications are full of overhead... server room with tape drives spinning

    Jed just wanted to save cycles where he had control... Jed behind his computer

    His SOURCE CODE. Camera rotates to screen, zoom in and fade

    This summer... flash 'W'

    Programming is about to get... flash 'T'

    SERIOUS. flash 'F'

  • (cs)

    Ha! I'd watch that movie.

    I can't see anything in the original code about months being commented out, was that just left out of the shown code snippet?

  • (cs)

    The real WTF is using a DB instead of flat files.

    Flat files take up less room.

  • (cs) in reply to JM
    JM:
    And now imagine Don LaFontaine narrating that.

    In a world... Sped-up footage of New York traffic

    where applications are full of overhead... server room with tape drives spinning

    Jed just wanted to save cycles where he had control... Jed behind his computer

    His SOURCE CODE. Camera rotates to screen, zoom in and fade

    This summer... flash 'W'

    Programming is about to get... flash 'T'

    SERIOUS. flash 'F'

    That's just...wow...you win for best post ever.

  • Enterprise Code (unregistered) in reply to Anonymous coward
    Anonymous coward:
    At least he's using paramter binding.
    Alas, the getTotals() function was a total disappointment. Shouldn't that have been
    if(companyCode.equals("Company1") && month == 1 && year == 2003)
       rows[] = dbConn.exec("select * from COMPANY_TRANS "
          "where companyCode = 'Company1' "
          "and month = 1 and year = 2003");
    if(companyCode.equals("Company1") && month == 2 && year == 2003)
       rows[] = dbConn.exec("select * from COMPANY_TRANS "
          "where companyCode = 'Company1' "
          "and month = 2 and year = 2003");
    if(companyCode.equals("Company1") && month == 3 && year == 2003)
       rows[] = dbConn.exec("select * from COMPANY_TRANS "
          "where companyCode = 'Company1' "
          "and month = 3 and year = 2003");
    
  • (cs) in reply to JM
    JM:
    And now imagine Don LaFontaine narrating that.

    In a world... Sped-up footage of New York traffic

    where applications are full of overhead... server room with tape drives spinning

    Jed just wanted to save cycles where he had control... Jed behind his computer

    His SOURCE CODE. Camera rotates to screen, zoom in and fade

    This summer... flash 'W'

    Programming is about to get... flash 'T'

    SERIOUS. flash 'F'

    Thread over, go home.

  • Southern (unregistered)

    No loop for you!

  • SomeCoder (unregistered) in reply to taylonr
    taylonr:
    JM:
    And now imagine Don LaFontaine narrating that.

    In a world... Sped-up footage of New York traffic

    where applications are full of overhead... server room with tape drives spinning

    Jed just wanted to save cycles where he had control... Jed behind his computer

    His SOURCE CODE. Camera rotates to screen, zoom in and fade

    This summer... flash 'W'

    Programming is about to get... flash 'T'

    SERIOUS. flash 'F'

    Thread over, go home.

    It's true, I don't think we can do any better than this. The bar is just too high now :)

  • (cs) in reply to SomeCoder

    JM is now REQUIRED to create a mock-trailer for this film. I suggest editing footage from Hackers.

  • (cs)

    My first programming class in high school, the instructor forced us to write a little program to track four salesmen without using arrays.

    No, he wasn't a "Jed". The point was to pound into everyone (most of these people had no prior prgramming experience) how useful arrays are. I'd say it was a success.

  • Mike (unregistered) in reply to Martin

    WTF?

    Why is nobody commenting on the fact that he retrieves all rows just to get row counts? getTotals is not adding to the data, it's overwritting the rows[] variable every time, just so he can get rows.length. As well, he's using "" so he retrieves all columns. Effectively downloading the entire table instead of using COUNT().

    Wow. When does it hit that there might be a better way?

  • (cs)

    Now, listen to a story 'bout a man named Jed A poor programmer, whose code was seldom read Seems one day he was avoidin' some loops Leaving our Simon to say, "What the boop?"

    Eff, that is. Bad code, hurts to see.

    Next thing you, Jed don't need to care Boss-man say, "Get away from there! Off the computer, is where you ought to be!" And Simon sent the tale to the Daily.

    WTF, that is. Coding n00bs, error shots.

  • (cs)

    I know we've said it before, but.

    How do these people get jobs? How do they hold them?

  • (cs) in reply to Raedwald
    Raedwald:
    I know we've said it before, but.

    How do these people get jobs? How do they hold them?

    By finding and staying with companies whose managers care exclusively about deadlines being met and features implemented no matter what, and that employees work exclusively towards these goals rather than creating problems for the managers by asking questions or pointing out bad practices.

  • Mikael Bergkvist (unregistered)

    How the hell does people like that get hired? Is the employer really THAT desperate?

  • Mikael Bergkvist (unregistered)

    Oh.. maybe by reading the preceding post..

  • Anonymous (unregistered)

    out( "" + (iCompany1Nov2003 + iCompany2Nov2003 + ... + iCompany7Nov2003 "" );

    hmm, wouldn't this caused compilation error?

  • (cs) in reply to stationary
    stationary:
    Now, listen to a story 'bout a man named Jed A poor programmer, whose code was seldom read Seems one day he was avoidin' some loops Leaving our Simon to say, "What the boop?"

    Eff, that is. Bad code, hurts to see.

    Next thing you, Jed don't need to care Boss-man say, "Get away from there! Off the computer, is where you ought to be!" And Simon sent the tale to the Daily.

    WTF, that is. Coding n00bs, error shots.

    LOL

  • Dean (unregistered)

    Now that's productivity! Just look at all that code!

  • Andrew (unregistered) in reply to David
    David:
    I can understand Jed.

    In a world where applications are full of overhead, doing things like retrieving data using SQL (interpreted on the server! just imagine the wasted cycles!) over TCP/IP (with all that extra bandwidth being wasted in headers!), etc. Jed just wanted to save cycles where he had control: his source code!

    // just kidding! why is he unrolling the loop? that used to work great when we had like 64kB of memory cache, but today??? FFS...

    Actually, unrolling such a loop was more expensive when there was only 64kB of memory cache. Only a few iterations, or certain nesting should get unrolled, even today. Processor speed, at 5Mhz or less, was what slowed down loops.

    I think programmers today try to be too clever. They should write code to the strengths of the system, e.g. SQL fetches sets in a loop, not to some peculiar (or false) optimization.

  • Jesse (unregistered)

    any relation to Jed Clampett?

  • k (unregistered)

    I thought the title of the article was "Jedi Code", and was expecting some sort of "These aren't the variables you're looking for" reference.

  • cdzerg (unregistered) in reply to Kluge Doctor

    iCdzerg01 ..... iCdzerg02 ..... iCdzerg03 ..... iCdzerg04 ..... iCdzerg05 ..... iCdzerg06 ..... iCdzerg07 ..... iCdzerg08 ..... iCdzerg09 ..... iCdzerg10 ..... iCdzerg11 ..... iCdzerg12 ..... iCdzerg13 ..... iCdzerg14 ..... iCdzerg15 ..... iCdzerg16 ..... iCdzerg17 ..... iCdzerg18 ..... iCdzerg19 ..... iCdzerg20 .....

  • <Maybe Anon?> (unregistered) in reply to k
    k:
    I thought the title of the article was "Jedi Code", and was expecting some sort of "These aren't the variables you're looking for" reference.
  • JUST ANOTHER WTF (unregistered)

    I don't see the problem... he just unrolled the loops for optimization

  • Chuck (unregistered)

    I know at least one possible motivation for writing code like this. I knew a guy who would love to write this kind of tedious crap just so he wouldn't have to think very hard and it would keep him occupied for days. And yes he had a four-year BS in Computer Science, unbelievable.

  • Bobby (unregistered) in reply to Mike
    Mike:
    Wow. When does it hit that there might be a better way?
    Apparently when the page takes 8 minutes to load!
  • (cs) in reply to <Maybe Anon?>
    <Maybe Anon?>:
    k:
    I thought the title of the article was "Jedi Code", and was expecting some sort of "These aren't the variables you're looking for" reference.
    Okey dokey.

    Stormtrooper: Let me download teh codez. Obi-Wan -- with a small wave of his hand: You don't need to download teh codez. Stormtrooper: We don't need to download teh codez. Obi-Wan: This isn't the regexp you're looking for. Stormtrooper: This isn't the regexp we're looking for. Obi-Wan: He can go about his BizTalk. Stormtrooper: You can go about your BizTalk. Obi-Wan: Add SQL and Stir. Stormtrooper: Add SQL ... Add SQL.

    Luckily, in episode 7, the whole thing is rewritten in Elvish -- a far more appropriate dysfunctional language.

  • shazam (unregistered)

    The Real WTF(tm) here is that the poster didn't tell his manager "I think I can fix it and make it run 20% faster if you give me 2 weeks to work on it". He could then write the loop, make it run a million percent faster, browse the web for 2 weeks, and greatly exceed his goals and score a nice bonus.

  • iMalc (unregistered)

    Clearly someone had told him that conditional branches were slow and should be avoided at ABSOLUTELY ALL costs!

  • Ikasinuk (unregistered) in reply to k
    k:
    I thought the title of the article was "Jedi Code", and was expecting some sort of "These aren't the variables you're looking for" reference.
    Whew, I'm not the only one.
  • cam (unregistered)

    Hey, to all you future wtf'ers, I really appreciate how he explained how he fixed the problem. as a cs student its nice to know what not to do!

  • SuperC142 (unregistered)

    This could only have been better if you subsequently discovered a (looping) program he wrote to generate the source code.

  • Jed the third (unregistered)

    Ok, don't panic people when I say that I completely agree with Jed. Basic idea behind his solution is the generation of report in such a way that what-you-see-is-what-you-get. For every value you need to see in your summary report there is a corresponding c++ line that like this:

    out( "<td>" + getTotals("Company1",11,2003) + "</td>" );
    

    Next step is making it easy to read. We introduce new language extension - variable named like so iCompany1Nov2003, is not really a variable, but a function call to getTotals() that is executed like so: getTotals("Company1",11,2003). This language extension is of course only theoretical, becase it can be simulated with careful book keeping - every time compiler complains about "failed call" to a "function" like iCompany1Nov2003 we go into our Pending_Language_Extensions.h and manually add this "function" to the rest of them:

    iCompany1Nov2003 = getTotals(con, "Company1", 11, 2003);
    iCompany2Nov2003 = getTotals(con, "Company2", 11, 2003);
    iCompany3Nov2003 = getTotals(con, "Company3", 11, 2003);
    iCompany4Nov2003 = getTotals(con, "Company4", 11, 2003);
    ...
    

    This way we don't need to worry about actually implementing new language feature, and supporting it for all those complaining lamers :)

  • Prove that you're not a robot (unregistered) in reply to Mike

    Why is nobody commenting on the fact that he retrieves all rows just to get row counts?

    I rewrote the report to use a simple GROUP BY query

    There you go

Leave a comment on “Jed Code”

Log In or post as a guest

Replying to comment #:

« Return to Article