Submitted for your (Dis)approval



  • class DataFileFilter implements FileNameFilter {
    public boolean accept(File f, String name) {
    return name.endsWith(".dat");
    }
    }

    .
    .
    .

    private int sleeptime = 5000;

    .
    .
    .

    public void processFile() {

    Map dataItem;

    File dataInputDir = new File(dataInputDirectoryName);

    FileFilter filter = new DataFileFilter();

    String[] fileArray = dataInputDir.list(filter);

    for (int i = 0; i < fileArray.length; i++) {
    if (!(fileArray[x].charAt[0] == '.')) {
    try {
    fileReader = new FileReader(dataFileDirectory + File.separator + fileArray[x]);
    } catch (Exception e) {
    error = true;
    system.err.println("DataReader: Unable to create file reader for ...");
    System.err.println(dataFileDirectory + File.separator + fileArray[x]);
    }

      if(dataType.equals("DATAFORMAT1") {
        try {
          reader = new DataFormat2Reader(fileReader, formatFileName, properties);
        catch (Exception e) {
          error = true;
          System.err.println("DataReader: Unable to create DataFormat2Reader...");
          e.printStackTrace();
        }
      } else { 
        try {
          reader = new DataFormat1Reader(fileReader, formatFileName);
        catch (Exception e) {
          error = true;
          System.err.println("DataReader: Unable to create DataFormat1Reader...");
          e.printStackTrace();
        }
      }
    
      startDate = new java.util.Date();
    
      if (dataItem != null) {
        dataItem.clear();
      }
    
      try { 
        dataItem = reader.readDataItem();
    
        if (dataItem == null || dataItem.size() &lt; 10) {
          done = true;
        }   
    
      } catch (Exception e) {
        error = true;
        System.err.println("DataReader: Error reading dataItem...");
        e.printStackTrace();
        done = true;
      }
    
      while (!done &amp;&amp; shutdown == false) {
    
        if (buffer.getSize() &gt; 1000) {
          System.err.println("DataReader: Buffer has more than 1000 waiting... Going to sleep...");
          while (buffer.size() &gt; 250) {
            try {
              Thread.sleep(sleeptime);
            } catch (Exception e) {
              System.err.println("DataReader: Error going to sleep...");
            }
          }
        }
    
        dataItemCounter++;
    
        try { 
          nextDataItem = reader.readDataItem();
          if (nextDataItem == null || nextDataItem.size() &lt; 10) {
            done = true;
          }
          reader.close();
        } catch (Exception e) {
          error = true;
          e.printStackTrace();
          done = true;
        }
    
        if (!done) {
          realDataItem = DataItem.getDataItem(dataItem);
        
          if (realDataItem != null) {
            dataItemSaveCounter++;
          }
    
          if (!done) {
            buffer.put(realDataItem);
          }
    
        } else {
          realDataItem = DataItem.getDataItem(dataItem);
    
          if (dataItem != null) {
            dataItemSaveCounter++;
          }
          if (!error) {
            buffer.put(realDataItem);
          }
        }
    

    .
    .
    .

    There's some even wackier stuff that I omitted which was caching vectors of DataItems using an "arrayHeap" apparently because they were so expensive to create ... although, I can't see where more than one is ever created.



  • That made me feel rather uneasy what with the missing type information for…

    dataInputDirectoryName
    dataInputDir
    fileReader
    error
    startDate
    dataItem
    done
    buffer
    dataItemCounter
    nextDataItem
    realDataItem
    dataItemSaveCounter



  • @pinkduck said:

    That made me feel rather uneasy what with the missing type information for…

    String dataInputDirectoryName
    File dataInputDir (in OP)
    BufferedReader fileReader
    boolean error
    java.util.Date startDate (context in OP)
    Map dataItem (in OP)
    boolean done
    DataItemBuffer (extends Vector) buffer  (yes, untyped; predates generics)
    int dataItemCounter
    DataItem nextDataItem
    DataItem realDataItem
    int dataItemSaveCounter

    I thought most could be gleaned from context in the OP ... Most are instance variables.

    One of my favorite bits is if (!done && shutdown == false)



  • tldr, will come back later,  but this amuses me:

    @zelmak said:

    system.err.println("DataReader: Unable to create file reader for ...");

    System.err.println(dataFileDirectory + File.separator + fileArray[x]);

     

     

    elipsis and 1 tick delay for extra suspension before actually finding out what exactly failed




  • The major problem I see is that all exceptions are essentially eaten -- error messages are written, but the control flow keeps going on.

    TRWTF is having to to put so much more thought into fixing code than the author took in writing it. Your company would be better off if you could somehow discourage this guy from writing any more code, or at least slow him down. Maybe you could pay a thug to break his fingers.



  • I like how the code uses DataFormat1Reader to read everything except when dataType is actually "DATAFORMAT1", which is when it switches to DataFormat2Reader...



  • @SEMI-HYBRID code said:

    tldr, will come back later,  but this amuses me:

    @zelmak said:

    system.err.println("DataReader: Unable to create file reader for ...");

    System.err.println(dataFileDirectory + File.separator + fileArray[x]);

     

     

    elipsis and 1 tick delay for extra suspension before actually finding out what exactly failed

    I've reached the point where any indication of progress in a UI causes me to experience a moment of rage. Fuck anyone who uses the present progressive tense in a UI too... you're not "cancelling" my print job. You either did cancel it, or, more likely, you didn't.



  • @bridget99 said:

    I've reached the point where any indication of progress in a UI causes me to experience a moment of rage.

    Of course. It is much more relaxing to have a non-responsive GUI that may or may not indicate that the application has frozen during a long-running task. It keeps the mind busy with questions such as: when should I kill this? what if it's doing something and I'm just being impatient? did I lock the door when I left home this morning?.

    Also that design solves the problem of dealing with multiple threads. One thread to rule them all.



  • @Speakerphone Dude said:

    @bridget99 said:
    I've reached the point where any indication of progress in a UI causes me to experience a moment of rage.

    Of course. It is much more relaxing to have a non-responsive GUI that may or may not indicate that the application has frozen during a long-running task. It keeps the mind busy with questions such as: when should I kill this? what if it's doing something and I'm just being impatient? did I lock the door when I left home this morning?.

    Also that design solves the problem of dealing with multiple threads. One thread to rule them all.

    Yes! Finally someone gets it! The only part you missed is that you don't just throw up a non-responsive GUI during long-running tasks. You have to show a giant "topmost" window over the entire primary display, to prevent the user (and his computer) from wasting limited brainpower on other tasks. This window consists solely of a tiled company logo bitmap with "Please Wait..." superimposed on top. This is how most of my latest applications work. The single-thread thing, the topmost banner, etc. are all parts of our official company architecture!



  • @bridget99 said:

    @Speakerphone Dude said:
    @bridget99 said:
    I've reached the point where any indication of progress in a UI causes me to experience a moment of rage.

    Of course. It is much more relaxing to have a non-responsive GUI that may or may not indicate that the application has frozen during a long-running task. It keeps the mind busy with questions such as: when should I kill this? what if it's doing something and I'm just being impatient? did I lock the door when I left home this morning?.

    Also that design solves the problem of dealing with multiple threads. One thread to rule them all.

    Yes! Finally someone gets it! The only part you missed is that you don't just throw up a non-responsive GUI during long-running tasks. You have to show a giant "topmost" window over the entire primary display, to prevent the user (and his computer) from wasting limited brainpower on other tasks. This window consists solely of a tiled company logo bitmap with "Please Wait..." superimposed on top. This is how most of my latest applications work. The single-thread thing, the topmost banner, etc. are all parts of our official company architecture!

    WOW. And here I thought your software couldn't possibly be any more user hostile. Also, that you couldn't be any worse at recognizing Speakerphone's sarcasm.



  • @bridget99 said:

    The only part you missed is that you don't just throw up a non-responsive GUI during long-running tasks. You have to show a giant "topmost" window over the entire primary display, to prevent the user (and his computer) from wasting limited brainpower on other tasks.

    Rookie mistake. Topmost (aka z0) is pointless if the window is not system modal - your whole architecture can be bypassed with ALT-TAB. Also I suspect that such a flawed model does not disable the CTRL-ALT-DEL shortcut (which may or may not be achieved on Windows 7 by faking the screensaver like in the good ol' days - haven't tried). Anyways this definitely could not pass C2 compliance (no resource isolation) but don't give up, it's up there with the Acrobat Reader splash screen that brings up more plugins than Glade's test centers.



  • @Speakerphone Dude said:

    @bridget99 said:
    The only part you missed is that you don't just throw up a non-responsive GUI during long-running tasks. You have to show a giant "topmost" window over the entire primary display, to prevent the user (and his computer) from wasting limited brainpower on other tasks.

    Rookie mistake. Topmost (aka z0) is pointless if the window is not system modal - your whole architecture can be bypassed with ALT-TAB. Also I suspect that such a flawed model does not disable the CTRL-ALT-DEL shortcut (which may or may not be achieved on Windows 7 by faking the screensaver like in the good ol' days - haven't tried). Anyways this definitely could not pass C2 compliance (no resource isolation) but don't give up, it's up there with the Acrobat Reader splash screen that brings up more plugins than Glade's test centers.

    Whatever I'm doing, Alt+Tab doesn't circumvent it. I've tested that. Ctrl+Alt+Del does circumvent my banner, and so does Ctrl+Shift+Esc (which brings up Task Manager). But this is by design.... if a long job hangs up or takes too long, the user needs to be able to kill it with Task Manager. I'm not trying to make some kind of banking system or kiosk, just reasonable client/server business software that's maintainable by mere mortals.



  • @bridget99 said:

    Whatever I'm doing, Alt+Tab doesn't circumvent it. I've tested that. Ctrl+Alt+Del does circumvent my banner, and so does Ctrl+Shift+Esc (which brings up Task Manager). But this is by design.... if a long job hangs up or takes too long, the user needs to be able to kill it with Task Manager. I'm not trying to make some kind of banking system or kiosk, just reasonable client/server business software that's maintainable by mere mortals.

    Jesus Fuck, Bridget. I know you're probably a troll and trolling and I'm biting but what the fucking hell, I hate you so much.

    WHAT IF THE USER SHUTS DOWN THE COMPUTER. WHAT THE FUCK DO YOU DO THEN YOU RETARD. It doesn't fucking matter if your splash screen "looks right". It doesn't fucking matter if alt-tab breaks it (and Speakerphone Dude: I hate you too for even bringing that up). What you are doing is BROKEN because it DOESN'T HANDLE A LOGOUT GRACEFULLY.



  • @blakeyrat said:

    WHAT IF THE USER SHUTS DOWN THE COMPUTER. WHAT THE FUCK DO YOU DO THEN YOU RETARD. It doesn't fucking matter if your splash screen "looks right". It doesn't fucking matter if alt-tab breaks it (and Speakerphone Dude: I hate you too for even bringing that up). What you are doing is BROKEN because it DOESN'T HANDLE A LOGOUT GRACEFULLY.

    Easy fix. You switch the Windows shell from Explorer.exe to CrappySplashScreen.exe. It's a simple value somewhere in HKLM in the registry. Reboot-proof because it comes back on every time, like herpes.



  • @bridget99 said:

    @Speakerphone Dude said:
    @bridget99 said:
    I've reached the point where any indication of progress in a UI causes me to experience a moment of rage.

    Of course. It is much more relaxing to have a non-responsive GUI that may or may not indicate that the application has frozen during a long-running task. It keeps the mind busy with questions such as: when should I kill this? what if it's doing something and I'm just being impatient? did I lock the door when I left home this morning?.

    Also that design solves the problem of dealing with multiple threads. One thread to rule them all.

    Yes! Finally someone gets it! The only part you missed is that you don't just throw up a non-responsive GUI during long-running tasks. You have to show a giant "topmost" window over the entire primary display, to prevent the user (and his computer) from wasting limited brainpower on other tasks. This window consists solely of a tiled company logo bitmap with "Please Wait..." superimposed on top. This is how most of my latest applications work. The single-thread thing, the topmost banner, etc. are all parts of our official company architecture!

     

    You two are playing a game of sarcastic-chicken, right? BECAUSE I CAN'T TELL.

     



  • @blakeyrat said:

    @bridget99 said:
    Whatever I'm doing, Alt+Tab doesn't circumvent it. I've tested that. Ctrl+Alt+Del does circumvent my banner, and so does Ctrl+Shift+Esc (which brings up Task Manager). But this is by design.... if a long job hangs up or takes too long, the user needs to be able to kill it with Task Manager. I'm not trying to make some kind of banking system or kiosk, just reasonable client/server business software that's maintainable by mere mortals.

    Jesus Fuck, Bridget. I know you're probably a troll and trolling and I'm biting but what the fucking hell, I hate you so much.

    WHAT IF THE USER SHUTS DOWN THE COMPUTER. WHAT THE FUCK DO YOU DO THEN YOU RETARD. It doesn't fucking matter if your splash screen "looks right". It doesn't fucking matter if alt-tab breaks it (and Speakerphone Dude: I hate you too for even bringing that up). What you are doing is BROKEN because it DOESN'T HANDLE A LOGOUT GRACEFULLY.

     

    And what if the program is being run in a VIRTUAL MACHINE?  Bridgettt, you need to go back and redesign your program so it can detect when it's running in a virtual machine, and then reach up into the next level. Then it needs to do host OS detection, and disable all interactions with the host OS so the program can't be shut down.

     You must make this check recursive, in case there's a VM installed inside a VM like in the second Matrix movie.

    If you don't do that, your program is a failing failure that fails. IT'S IN THE SPECS!

     



  • @Lorne Kates said:

    And what if the program is being run in a VIRTUAL MACHINE? Bridgettt, you need to go back and redesign your program so it can detect when it's running in a virtual machine, and then reach up into the next level. Then it needs to do host OS detection, and disable all interactions with the host OS so the program can't be shut down.

    What the fuck are you talking about. VMs save state when the host computer is being shut down. Are you being stupid on purpose so you can make the World's Worst Matrix Joke? Is that what you're doing?



  • @Lorne Kates said:

    You must make this check recursive, in case there's a VM installed inside a VM like in the second Matrix movie.

    One time a client was evaluating various systems automation products so I actually had to install ESX in a virtual machine. It worked. Call me The Architect.



  • @blakeyrat said:

    @Lorne Kates said:
    And what if the program is being run in a VIRTUAL MACHINE? Bridgettt, you need to go back and redesign your program so it can detect when it's running in a virtual machine, and then reach up into the next level. Then it needs to do host OS detection, and disable all interactions with the host OS so the program can't be shut down.

    What the fuck are you talking about. VMs save state when the host computer is being shut down.

     

    Yes, but then someone could boot the computer back up, change the saved state, and then restart the VM, and thus be allowed to make NONMODAL changes to Briiiidgett's application. NOT ALLOWED!

     



  • @blakeyrat said:

    @bridget99 said:
    Whatever I'm doing, Alt+Tab doesn't circumvent it. I've tested that. Ctrl+Alt+Del does circumvent my banner, and so does Ctrl+Shift+Esc (which brings up Task Manager). But this is by design.... if a long job hangs up or takes too long, the user needs to be able to kill it with Task Manager. I'm not trying to make some kind of banking system or kiosk, just reasonable client/server business software that's maintainable by mere mortals.

    Jesus Fuck, Bridget. I know you're probably a troll and trolling and I'm biting but what the fucking hell, I hate you so much.

    WHAT IF THE USER SHUTS DOWN THE COMPUTER. WHAT THE FUCK DO YOU DO THEN YOU RETARD. It doesn't fucking matter if your splash screen "looks right". It doesn't fucking matter if alt-tab breaks it (and Speakerphone Dude: I hate you too for even bringing that up). What you are doing is BROKEN because it DOESN'T HANDLE A LOGOUT GRACEFULLY.

    I'm not sure what you're getting at. If a user logs out during a long-running process, they log out during a long-running process. The result depends entirely on the nature of said process and whether or not it was designed to handle such a circumstance gracefully. What happens does not depend on the prettiness / ugliness of whatever progress bar or wait screen was being shown, nor does it depend on any use of parallelism in my front-end code.

    I'll also tell you that when someone tries to raise "what if?" questions with me in person, I usually use the scenario as the opportunity for a somewhat philosophical discussion about the sort of questions I can answer and those that I cannot, and how this distinction must be incorporated into the process by which the world dumps 99.784% of its technical needs into my lap.

    Think about such questions. "What if the user shuts down the computer?" How am I supposed to answer such a nonsensical query? It's too open-ended. If the user shuts down the computer, then electrons will exhibit a negative charge, Lent will last 40 days, and Ted Williams will be the last man to hit .400 for a whole Major League Baseball season. I'm not sure what you want out of me. "What if?" is the interrogative equivalent of grabbing me by my ankles during a robbery, and shaking me upside-down until even more money falls out. It's not a productive way to design software.



  • @bridget99 said:

    this distinction must be incorporated into the process by which the world dumps 99.784% of its technical needs into my lap

    Just had a psychic flash. You must be one of those people who drive Starbucks staff crazy by asking for a complex drink that requires grounding a special mix of beans, putting the whipped cream in the cup before the coffee, and adding "just a drop" of the least popular flavor they have (so they must go grab the bottle in the backstore).



  • @Speakerphone Dude said:

    @bridget99 said:

    this distinction must be incorporated into the process by which the world dumps 99.784% of its technical needs into my lap

    Just had a psychic flash. You must be one of those people who drive Starbucks staff crazy by asking for a complex drink that requires grounding a special mix of beans, putting the whipped cream in the cup before the coffee, and adding "just a drop" of the least popular flavor they have (so they must go grab the bottle in the backstore).

    I've honestly never been to Starbucks... remember, I'm living in a small, impoverished fishing village in French Polynesia now. But in general I don't ask for "substitutions" or give special instructions at restaurants. I just think that's obnoxious. If something comes with bean sprouts, I may order it and ask for the sprouts to be removed... that's just rational, in my opinion, like asking for your cocktail not to contain Hydrogen Peroxide. More likely, though, I'll just find something else to order or someplace else to eat.



  • @Speakerphone Dude said:

    Starbuck

    That is some sort of coffee shop, right? What is the deal with that? Is that an US thing? Some sort of fast food chain equivalent but just coffee?

    @bridget99 said:

    in general I don't ask for "substitutions" or give special instructions at restaurants.

    In my case I guess it depends on the restaurant, in some of the fancier ones I might do this.



  • @serguey123 said:

    @Speakerphone Dude said:
    Starbuck

    That is some sort of coffee shop, right? What is the deal with that? Is that an US thing? Some sort of fast food chain equivalent but just coffee?

    Yes, but a better analogy would be to Apple gadgets, in that they've managed to convince so many people that they have to always have a cup of coffee with them wherever they go. And what better way to manage that than by selling it in overpriced individual servings!?

    It's worse than going to a bar to drink alcohol. At least there, you're presumably going to hang out with friends or dance or something that you couldn't do in your house (for about 1/10th the cost of the drinks). But people get their coffee and then go to their office or wherever they would normally go. A tax on stupid people, basically.



  • @boomzilla said:

    A tax on stupid people, basically.

    Not stupid, just oblivious to the obvious alternative, presumably due to a mix of commercially-generated perceptions of cultural norms and a lack of exposure to that obvious alternative.

    ... I'm still working on my wife with this one :(



  • @Xyro said:

    @boomzilla said:
    A tax on stupid people, basically.

    Not stupid, just oblivious to the obvious alternative, presumably due to a mix of commercially-generated perceptions of cultural norms and a lack of exposure to that obvious alternative.

    ... I'm still working on my wife with this one :(

    Are yous talking 'bout Mikee Dees? Cause that's how I roll too, dag.



  • @Speakerphone Dude said:

    @Xyro said:
    @boomzilla said:
    A tax on stupid people, basically.

    Not stupid, just oblivious to the obvious alternative, presumably due to a mix of commercially-generated perceptions of cultural norms and a lack of exposure to that obvious alternative.

    ... I'm still working on my wife with this one :(

    Are yous talking 'bout Mikee Dees? Cause that's how I roll too, dag.

    If that's ganster slag for "making your own freaking coffee", then yeah.



  • @Xyro said:

    @Speakerphone Dude said:
    @Xyro said:
    @boomzilla said:
    A tax on stupid people, basically.

    Not stupid, just oblivious to the obvious alternative, presumably due to a mix of commercially-generated perceptions of cultural norms and a lack of exposure to that obvious alternative.

    ... I'm still working on my wife with this one :(

    Are yous talking 'bout Mikee Dees? Cause that's how I roll too, dag.

    If that's ganster slag for "making your own freaking coffee", then yeah.


    No, "making your own coffee" would be "homez madez" in Gangsta.



    Making it at home is actually still pretty expensive. We're talking about a stimulant cultivated in the Andes and brought in on a boat... it's never going to be as cheap as Kool-Aid.



  • @bridget99 said:

    Making it at home is actually still pretty expensive. We're talking about a stimulant cultivated in the Andes and brought in on a boat... it's never going to be as cheap as Kool-Aid.

    Of course, the key is to avoid "fair trade" nonsense. And Kool-Aid has sugar, so you're being raped by Uncle Sugar in order to keep growing sugar in places where we shouldn't be.



  • Also what is up with those big mugs of coffee? Is it diluted or something? In my country coffee is taken mostly black and in a very small cup.



  • @serguey123 said:

    In my country coffee is taken mostly black and in a very small cup.

    Just like your women?



  • @Speakerphone Dude said:

    @blakeyrat said:

    WHAT IF THE USER SHUTS DOWN THE COMPUTER. WHAT THE FUCK DO YOU DO THEN YOU RETARD. It doesn't fucking matter if your splash screen "looks right". It doesn't fucking matter if alt-tab breaks it (and Speakerphone Dude: I hate you too for even bringing that up). What you are doing is BROKEN because it DOESN'T HANDLE A LOGOUT GRACEFULLY.

    Easy fix. You switch the Windows shell from Explorer.exe to CrappySplashScreen.exe. It's a simple value somewhere in HKLM in the registry. Reboot-proof because it comes back on every time, like herpes.

     

     

    And now, what if the user brings some bootable media that fixes that registry hack???

     

    I bet that is the kind of question Microsoft had in mind when they came up with Secure Boot. I finally understand what it is good for.

     



  • @serguey123 said:

    Also what is up with those big mugs of coffee? Is it diluted or something? In my country coffee is taken mostly black and in a very small cup.
     

     

    Yep, it is diluted. It tastes as bad as it sounds.


Log in to reply
 

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