• Dilbertino (unregistered)

    Paid per line?

  • Baboon (unregistered)

    Frist

    The real WTF is VB!

  • RedFox (unregistered)

    I guess they sort of went overboard with loop unrolling.

  • JasonA_ (unregistered)

    Created by someone who thought they were working in a DOS batch file?

  • Coffee Hound (unregistered) in reply to RedFox
    Function for renaming DATFIL.ZIP files and maintaining 30 versions
    So the problem is that they say they keep 30, but end up keeping 70, right? Wow, WTF indeed!
  • QJo (unregistered)

    Zippy, Bungle and Gawd ...

  • (cs)

    Did the author^W perpetrator of this code never think “there's got to be a better way”?

  • QJo (unregistered)

    Hang on thoug, you can't put this in a loop, it's impossible, you'd never be able to get it to work. Because the last entry copies from \old\DATFIL.ZIP to \old\DATFIL.001.ZIP and it wouldn't be worth putting a wasteful and difficult-to-maintain if statement to take care of just that one instance. And you'd never be able to write a reliable program to convert "002" to "001", and "003" to "002", you'd have to write a separate if statement for each one. No, far too hard, better to write each one separately then we all know where we are.

  • BlackBart (unregistered)

    I see it like this: V1 of the product had an 'evil loop' that just created a new backup. After a customer filled up their hard drive, they realized the evilness of unconstrained loops, and used the featured code as a solution.

    A side benefit is that the unrolled loop is super-optimized.

    I like how they copy to a new version instead of just renaming.

  • Nagesн (unregistered)

    Isn't this the exactly typo of problem link is supposed to be addressing?

  • Craig (unregistered)

    How do some "programmers" ever manage to get, and keep, their jobs.

  • (cs) in reply to BlackBart

    That's another optimization - renaming would be racy, there might be holes in the backup chain!

  • (cs)

    This whole industry is constantly promoting code reuse. Well here's the result.

  • Nagesh (unregistered)

    Tyr use to be regulare expresioning in Javas!

  • Chelloveck (unregistered)

    This algorithm runs in constant time. The best you could do with a loop is linear time. Last I heard, O(1) beats O(n). This implementation rocks!

  • 3rd Ferguson (unregistered)

    Looks like it was ported from shell script. Ported altogether too literally, which is TRWTF. I can see where you'd do this with just search/replace to fill in the syntax, but no way would that be faster to do than just to write it from scratch as a loop. WTF!

  • (cs) in reply to Chelloveck
    Chelloveck:
    This algorithm runs in constant time. The best you could do with a loop is linear time. Last I heard, O(1) beats O(n). This implementation *rocks*!
    O(2/10)
  • DonaldK (unregistered)

    My ice are bleeidink

    Th payne!

  • (cs)

    You know, you could've done

    Example code 68 [ ... SNIP ...] Example code 2 Example code 1

    And we'd have all understood what was [Snipped]

  • (cs)

    Don't you know the authors are paid per line of... article ?!

  • QJo (unregistered) in reply to steenbergh
    steenbergh:
    You know, you could've done

    Example code 68 [ ... SNIP ...] Example code 2 Example code 1

    And we'd have all understood what was [Snipped]

    Wish I was as clever as you to automatically know what's in between 68 and 2.

  • No Magic Numbers (unregistered)

    No magic numbers!

    Private Const ZERO_SEVEN_ZERO As String = "070" Private Const ZERO_SIX_NINE As String = "069"

    theSystem.runDOSCommand("if exist " _ & theSystem.ImportDir & "\old\DATFIL." & ZERO_SEVEN_ZERO & ".ZIP del " _ & theSystem.ImportDir & "\old\DATFIL." & ZERO_SEVEN_ZERO & ".ZIP /F") '//ADDED theSystem.runDOSCommand("copy " _ & theSystem.ImportDir & "\old\DATFIL." & ZERO_SIX_NINE ".ZIP " _ & theSystem.ImportDir & "\old\DATFIL." & ZERO_SEVEN_ZERO ".ZIP")

  • (cs) in reply to QJo
    QJo:
    steenbergh:
    You know, you could've done

    Example code 68 [ ... SNIP ...] Example code 2 Example code 1

    And we'd have all understood what was [Snipped]

    Wish I was as clever as you to automatically know what's in between 68 and 2.

    Because some of them could have been out of order or left out entirely, and that would have made the code less of a fail?

  • (cs) in reply to steenbergh
    steenbergh:
    You know, you could've done

    Example code 68 [ ... SNIP ...] Example code 2 Example code 1

    And we'd have all understood what was [Snipped]

    Exactly: it would have been much easier on the eyes, had Alex not posted the code in all its terrible entirety. But then the true horror of this code would have been lost in translation.

  • ಠ_ಠ (unregistered) in reply to Nagesh
    Nagesh:
    Tyr use to be regulare expresioning in Javas!

    uhh...what?

  • Friedrich (unregistered) in reply to dkf

    No, thinking is for loosers, programmers type faster ;-(

  • (cs)
    ' Running the commands to copy the DATFIL.ZIP to their OLD names!
    Hey, at least he's enthusiastic.
  • (cs) in reply to dkf
    dkf:
    Did the author^W perpetrator of this code never think “there's got to be a better way”?
    You'd be surprised how uncommon this is...
  • (cs) in reply to Craig
    Craig:
    How do some "programmers" ever manage to get, and keep, their jobs.
    They know more than their managers. Not that this is much of an accomplishment.
  • Jon (unregistered)

    The AARP called. Using "old" as a folder name is insensitive to the superannuated.

  • airdrik (unregistered) in reply to boog
    boog:
    steenbergh:
    You know, you could've done

    Example code 68 [ ... SNIP ...] Example code 2 Example code 1

    And we'd have all understood what was [Snipped]

    Exactly: it would have been much easier on the eyes, had Alex not posted the code in all its terrible entirety. But then the true horror of this code would have been lost in translation.

    FWIW, there is a line around example code 31 which says:

    '** END BLOCK ADDED [removed for privacy]

    TRWTF is no:

    '** BEGIN BLOCK ADDED [removed for privacy]

    Or is it that there was a block of code/comments there which was removed at some point (either from the original code base, automagically by some "privacy cleanup" process or because it was sensitive material and was removed when submitting to TDWTF)?

  • Chad (unregistered)

    I think he should get a promotion. I mean he wrote so much more code then necessary!

  • (cs) in reply to airdrik
    airdrik:
    boog:
    steenbergh:
    You know, you could've done

    Example code 68 [ ... SNIP ...] Example code 2 Example code 1

    And we'd have all understood what was [Snipped]

    Exactly: it would have been much easier on the eyes, had Alex not posted the code in all its terrible entirety. But then the true horror of this code would have been lost in translation.

    FWIW, there is a line around example code 31 which says:

    '** END BLOCK ADDED [removed for privacy]

    TRWTF is no:

    '** BEGIN BLOCK ADDED [removed for privacy]

    Or is it that there was a block of code/comments there which was removed at some point (either from the original code base, automagically by some "privacy cleanup" process or because it was sensitive material and was removed when submitting to TDWTF)?

    Good find, and it supports my comment: that additional nonsensical line of crap would have been left out, had the snippet been abbreviated as suggested.

  • Anon (unregistered) in reply to Jon
    Jon:
    The AARP called. Using "old" as a folder name is insensitive to the superannuated.

    Might I suggest "vintage"? Or "experienced"?

  • (cs) in reply to Anon
    Anon:
    Jon:
    The AARP called. Using "old" as a folder name is insensitive to the superannuated.

    Might I suggest "vintage"? Or "experienced"?

    AFAIK, experience only counts when you remember said experiences, no?

    slowly ducks

  • Still Water (unregistered)

    Aargh!

    Clearly whoever wrote this monstrosity thought that Ctrl-V, edit, and repeat... was quicker than writing some kind of loop...

  • (cs) in reply to Craig
    Craig:
    How do some "programmers" ever manage to get, and keep, their jobs.
    Programming is not house building: people can tell, to some extent, that a house is built like crap, or that a car is a piece of crap. But with software we're so used to "weird" glitches, that it's treated like magic and people don't care to understand what's going on. Thus people who have no job of doing any programming, do.

    The real problem is an issue of required deep societal change. Our society is a century behind times when it comes to understanding of everyday objects. Electronics and software pervade our lives, yet are pretty much treated like magic. The gap is not getting any narrower either, it seems.

    Hundreds of years ago, basic arithmetics and writing were done by educated people only. These days it's a skill that everyone is expected to have. We call it literacy. Time has come, too, that basic programming skills should be regarded the same way as writing and arithmetics. It's required to be a literate member of the society.

  • (cs)

    This is standard procedure on embedded systems where there is just a file system but no loops.

  • freeBSD (unregistered)

    At least their code meets standards by concatenating a string with '&'.

    Captcha: I came home today and my dog left a praesent on the floor.

  • freeBSD (unregistered) in reply to Chelloveck

    You're kidding right? right, good.

  • (cs)

    This is good code, if the system ever needs to be ported to an embedded system that does not support loops this person's job is already done. They will need to make a DOS to ENIAC converter first because they are using DOS specific commands.

  • VAXcat (unregistered)

    The real WTF is using an operating system without automatic file versioning. On VMS, you add an ACL that controls how many versions to keep - then you don't even have to think about it anymore....

  • Sectoid Dev (unregistered) in reply to dkf

    This reminds me of a game I started to write in 7th grade when I was first starting to learn programming. After about the third iteration of typing in nearly identical code, I stopped and wondered "is there a better way?". Sadly back in 1982, the math teacher knew nothing about programming, despite teaching the class, and I had to wait to learn about loops. I guess some people never did learn.

  • (cs)

    I just threw up in my mouth.

    In related news, Microsoft invented this product called SQL Server. Maybe these guys want to check that out sometime.

  • (cs) in reply to Chelloveck
    Chelloveck:
    This algorithm runs in constant time. The best you could do with a loop is linear time. Last I heard, O(1) beats O(n). This implementation *rocks*!
    Please tell me you're kidding so I don't have to kill you.
  • (cs) in reply to Chelloveck
    Chelloveck:
    This algorithm runs in constant time. The best you could do with a loop is linear time. Last I heard, O(1) beats O(n). This implementation *rocks*!
    Wow, you're getting more bites than I thought you would... Congrats!
  • iToad (unregistered) in reply to VAXcat
    VAXcat:
    The real WTF is using an operating system without automatic file versioning. On VMS, you add an ACL that controls how many versions to keep - then you don't even have to think about it anymore....

    or PURGE/KEEP=30 DATFIL.ZIP

    Damn, sometimes I really miss VMS...

  • (cs) in reply to Anon
    Anon:
    Jon:
    The AARP called. Using "old" as a folder name is insensitive to the superannuated.

    Might I suggest "vintage"? Or "experienced"?

    The only insensitive person here is the one thinking "old" is insulting.

    I don't think any blind person is actually happy to be called "visually impaired"... because blind, old or fat are not swear words you know ?

  • (cs) in reply to Chad
    Chad:
    I think he should get a promotion. I mean he wrote so much more code then necessary!
    Yes, a promotion is due for going the extra kloc.
  • Nagesh (unregistered) in reply to VAXcat
    VAXcat:
    The real WTF is using an operating system without automatic file versioning. On VMS, you add an ACL that controls how many versions to keep - then you don't even have to think about it anymore....
    I am thinking you sounding more retarded than coleague who only use Linux.

Leave a comment on “Loopless”

Log In or post as a guest

Replying to comment #:

« Return to Article