• (cs) in reply to the CTO

    Of course, you just know that Activate() has side affects that a) write to the db, b) call out to some remote web service, c) move 9,000 files from directory a to b, then back to a, and at least 20 other unobvious tasks. That's why it's called multiple times.

    int n=1;
    
    void Activate() { n += 1; ... }
    
  • Doug (unregistered)

    add Activate() (which probably worked for a previous problem) repeatedly until it seems to work and go on to the next problem. It is easy to get into this pattern when required to muddle about in a soup of code you don't understand.

    You might call this a "test pattern". Keep testing till it passes the test due to unknown circumstances and call the last thing you did the solution.

  • (cs) in reply to Dalek
    Dalek:
    Exterminate(); Exterminate(); Exterminate(); Exterminate(); Exterminate(); Exterminate();

    That was my first thought too. However, in this particular case I'd say the catchphrase of the (alt-universe) Cybermen would be more appropriate: Delete! Delete! Delete! Delete! Delete! Delete! Delete! Delete!

  • guilty (unregistered)

    I have actually done that very thing in a small and scarcely used application written in AppleScript. Calling "activate" on an application object didn't always work as (when?) expected when there was a lot of CPU load. So it was either research the cause and then find a way to work around that (a couple of days of work down the pipe) or just paste "activate" several times (total amount of work: a few seconds). The WTF in that case would have been to burn several days to "correctly" fix a problem that could have been avoided with a quick and dirty hack.

  • (cs) in reply to snoofle
    snoofle:
    so...
    try {
        Activate(); ...
    } catch (Exception e) {
        Activate(); ....
    } finally {
      try {
          Activate(); ...
      } catch (Exception e2) {
        Activate(); ...
      } finally {
        try {
            ...
    
    ?!

    Allow me to explain: he was stating that the previous example of exception handling was wrong, and supplied his own (probably a joke) incorrect correction. I wanted to point out that exceptions can be thrown from both catch and finally blocks, and not just the try block. This is a very common mistake I've seen all too often when reviewing others, as well as my own code. You just assume that because you've taken care of wrapping VolatileMethodCall() in a try construct, that your call to HandleException (which writes to a DB log and sends an email) in the catch won't throw a new exception.

    The example you supplied is a rediculous logical extension of what I said. You have an exception, try to handle it gracefully (i.e. retry a DB call), and if that fails, bubble it up to the caller. My comment about "this should never happen" was a joke, and another example of what I see all to often in catch blocks that swallow exceptions.

  • Just a Commenter (unregistered) in reply to Siva
    Siva:
    Nagesh:
    This reminds me of state machine I develop at university for Master's thesis. Activeate call to be change state and new Activeate can be diferent funtionality.
    Friends, real Nagesh's funning to stop. Have you wondering why he not has posted some time? This is very sad situation: He take long struggle with dysentery and died of much diarrhea food poisioning. He has wife and 16 childs who are missing his provision and in bear feet on the streets.

    Please be sparing his good name from abuse further.

    The blacked words and thinking of the Nagesh character involved made me shoot hot coffee out of several orifices simultaneously.

  • (cs) in reply to Just a Commenter
    Just a Commenter:
    The blacked words and thinking of the Nagesh character involved made me shoot hot coffee out of several orifices simultaneously.

    I can understand the first 3 orifices, but anymore than that and you should probably see a doctor.

  • (cs) in reply to frits
    frits:
    Is WPF the new WTF?
    Yes, definitely. Even Microsoft seems to realize that now. Sure took them long enough...
  • Ken B. (unregistered) in reply to guilty
    guilty:
    I have actually done that very thing in a small and scarcely used application written in AppleScript. Calling "activate" on an application object didn't always work as (when?) expected when there was a lot of CPU load. So it was either research the cause and then find a way to work around that (a couple of days of work down the pipe) or just paste "activate" several times (total amount of work: a few seconds). The WTF in that case would have been to burn several days to "correctly" fix a problem that could have been avoided with a quick and dirty hack.
    So, under light loads, one call suffices. Under "a lot of CPU load", you needed several calls to make it "work".

    Who's to say that under "really heavy CPU load", the code still wouldn't "work", even with your "fix" in place?

  • Just a Commenter (unregistered) in reply to C-Octothorpe
    C-Octothorpe:
    Just a Commenter:
    The blacked words and thinking of the Nagesh character involved made me shoot hot coffee out of several orifices simultaneously.

    I can understand the first 3 orifices, but anymore than that and you should probably see a doctor.

    Last time I checked, "several" means "3".

  • Ramsey (unregistered)

    Badgers(); Badgers(); Badgers(); Badgers(); Badgers(); Badgers(); Badgers(); Badgers(); Badgers(); Badgers(); Badgers(mushroom, mushroom);

  • (cs) in reply to Just a Commenter
    Just a Commenter:
    C-Octothorpe:
    Just a Commenter:
    The blacked words and thinking of the Nagesh character involved made me shoot hot coffee out of several orifices simultaneously.

    I can understand the first 3 orifices, but anymore than that and you should probably see a doctor.

    Last time I checked, "several" means "3".

    Um, several means more than two, no? In any case I was joking, but do feel free to be pedantic; everyone is listening.

  • eVil (unregistered) in reply to Rollin you
    Rollin you:
    Is this somehow related to Magic Flutes ?

    Shame the Magic Flute was one of Mozarts... I guess accuracy of placing opera into appropriate classical periods isn't an XKCD forté.

  • Doozerboy (unregistered) in reply to Ramsey
    Ramsey:
    Badgers(); Badgers(); Badgers(); Badgers(); Badgers(); Badgers(); Badgers(); Badgers(); Badgers(); Badgers(); Badgers(mushroom, mushroom);

    +1000

  • Doozerboy (unregistered) in reply to Doozerboy
    Doozerboy:
    Ramsey:
    Badgers(); Badgers(); Badgers(); Badgers(); Badgers(); Badgers(); Badgers(); Badgers(); Badgers(); Badgers(); Badgers(mushroom, mushroom);

    +1000

    Snaaaaaaaaaaaaaake()

  • Troll Food #2 (unregistered) in reply to C-Octothorpe
    C-Octothorpe:
    Just a Commenter:
    C-Octothorpe:
    Just a Commenter:
    The blacked words and thinking of the Nagesh character involved made me shoot hot coffee out of several orifices simultaneously.

    I can understand the first 3 orifices, but anymore than that and you should probably see a doctor.

    Last time I checked, "several" means "3".

    Um, several means more than two, no? In any case I was joking, but do feel free to be pedantic; everyone is listening.

    This is what the internet told me:

    1. Being of a number more than two or three but not many.

    I think the word you're looking for is "many". Or in "Just a Commenter"'s case, "three".

  • Bob (unregistered) in reply to Yohann
    Yohann:
    It's so obious he shall have writed ;

    for(i=0;i++;i<8) { activate(); }

    Come on, here at TDWTF we follow best practices; namely the FOR-CASE paradigm:
    for (i = 0; i < 8; i++) {
       switch (i) {
         case 0: activate(); break;
         case 1: activate(); break;
         case 2: activate(); break;
         case 3: activate(); break;
         case 4: activate(); break;
         case 5: activate(); break;
         case 6: activate(); break;
         case 7: activate(); break;
         default: activate();
       }
    }
  • Jerry (unregistered)
    // automatic compensation for CPU load
    until (Activated()) {
      Activate();
    }
  • (cs) in reply to snoofle
    snoofle:
    so...
    try {
        Activate(); ...
    } catch (Exception e) {
        Activate(); ....
    } finally {
      try {
          Activate(); ...
      } catch (Exception e2) {
        Activate(); ...
      } finally {
        try {
            ...
    
    ?!
    No...
    void SafeActivate() {
        try {
            Activate(); ...
        } catch (Exception e) {
            SafeActivate();
        } finally {
            try {
                SafeActivate();
            } catch (StackOverflowException e) {
                // Oh crap!
            }
        }
    }
  • Ishtar (unregistered)

    It probably firing a weapon is. More times try, better lucky.

  • (cs) in reply to Mason Wheeler
    Mason Wheeler:
    frits:
    Is WPF the new WTF?
    Yes, definitely. Even Microsoft seems to realize that now. Sure took them long enough...
    WPF is actually an amzingly powerful framework, and much faster to develop in than WinForms given a few conditions:
    1. You can actually understand threading and understand that WPF basically forces a multi-threaded scenerio on you.
    2. You realize that much of your time in WinForms is not the initial layout and code it up, but the visual clean up an maintenence to give the app a good feel to it. First draft seems to take me slightly longer on WPF, but I have made up for it in no time with an app that has a good feel to it, and is easily modified to add new content without completely changing everyhting
    3. Don't use the built-in GUI designer for drag-and-drop like you do for WinForms. Treat it more like HTML development and realize what you wouldn't drag-and-drop for a web page, do not do for a WPF application.

    Yes, there is a learning curve, but if you thing of it being alot more like ASP.NET and less like WinForms in the interface part of it, it minimizes the learning curve.

    I think people just get scared off by WPF mainly because of poor tutorials (that just want to show off every feature possible) and simply there is a lot more at your finger tips. For me, having Databinding that actually works properly and minimizes my coding efforts is a huge plus.

  • (cs)

    I can really picture in my head the person while writing this code.

    "I said ACTIVATE God Damn It!!! I will make you Activate if I have to sit here and call you all day!"

  • (cs) in reply to The Bytemaster
    The Bytemaster:
    Mason Wheeler:
    frits:
    Is WPF the new WTF?
    Yes, definitely. Even Microsoft seems to realize that now. Sure took them long enough...
    WPF is actually an amzingly powerful framework, and much faster to develop in than WinForms given a few conditions:
    1. You can actually understand threading and understand that WPF basically forces a multi-threaded scenerio on you.
    2. You realize that much of your time in WinForms is not the initial layout and code it up, but the visual clean up an maintenence to give the app a good feel to it. First draft seems to take me slightly longer on WPF, but I have made up for it in no time with an app that has a good feel to it, and is easily modified to add new content without completely changing everyhting
    3. Don't use the built-in GUI designer for drag-and-drop like you do for WinForms. Treat it more like HTML development and realize what you wouldn't drag-and-drop for a web page, do not do for a WPF application.

    Yes, there is a learning curve, but if you thing of it being alot more like ASP.NET and less like WinForms in the interface part of it, it minimizes the learning curve.

    I think people just get scared off by WPF mainly because of poor tutorials (that just want to show off every feature possible) and simply there is a lot more at your finger tips. For me, having Databinding that actually works properly and minimizes my coding efforts is a huge plus.

    It is powerful, unfortunately it's on the way out (IMO). SL and WPF are converging technologies that share a lot in common. With SL's ability to run out of browser, I really don't see any reason to even keep WPF alive...

    Slightly off topic: I even recall reading an article recently that said MS will completely do away with .Net soon and go completely HTML5 and JS. I'm sure that can't be true though considering how many developers and clients/partners that would alienate, not to mention the at least two-dozen web applications written in .Net. <ducks>

  • Mark (unregistered)

    Can just do it in 2 line but really properly:

    system.GodMode = True; Activate();

  • (cs) in reply to C-Octothorpe
    C-Octothorpe:
    Just a Commenter:
    ...made me shoot hot coffee out of several orifices simultaneously.
    I can understand the first 3 orifices...
    You can? Then apparently you aren't sorting alphabetically.
  • (cs)

    Duff's Activation

    register n = (count + 7) / 8;      /* count > 0 assumed */
    
      switch (count % 8)
      {
      case 0:        do {  Activate();
      case 7:              Activate();
      case 6:              Activate();
      case 5:              Activate();
      case 4:              Activate();
      case 3:              Activate();
      case 2:              Activate();
      case 1:              Activate();
                         } while (--n > 0);
      }
    
  • Just a Commenter (unregistered) in reply to boog
    boog:
    C-Octothorpe:
    Just a Commenter:
    ...made me shoot hot coffee out of several orifices simultaneously.
    I can understand the first 3 orifices...
    You can? Then apparently you aren't sorting alphabetically.
    The second "Just a Commenter" is apparently trolling: I did intend to imply more than three, which I thought was great double entandre for the original post which mentioned diarrhea as well as (looking back on it now) more kids than most people expect to pop out of themselves.
  • Gunslinger (unregistered) in reply to Just a Commenter
    Just a Commenter:
    C-Octothorpe:
    Just a Commenter:
    The blacked words and thinking of the Nagesh character involved made me shoot hot coffee out of several orifices simultaneously.

    I can understand the first 3 orifices, but anymore than that and you should probably see a doctor.

    Last time I checked, "several" means "3".

    Nope, couple is 2, coupla or few is 3, several is 4 or more.

  • gs (unregistered)

    Seems weird, indeed, at first glance... But as an experienced (5+ years) WPF developer, I admit I feel some empathy for the author of these desperate lines...

    MSDN Docs: "Window.Activate: Attempts to bring the window to the foreground and activates it."

    Actual behaviour: Mostly nothing.

    For me, those lines of code just reflect something like the following, fully understandable thoughts of a frustrated developer:

    "Activate. [...] Activate. [...] Activate! [...] Hello?! I said 'Activate!' [...] Helloo?!! WPF, .NET, Microsoft, anybody out there? I said 'Activate', okay? WhyTF is that window not being activated? You want me to say it in Chinese, or Hindi or what??!! ACTIVAAAATE!!! <sobbing> <banging head on the keyboard> :'( Aaaaaargh!!!! :( :("

    // Captcha: dignissim. I'm just dignissim what it might mean.

  • rfoxmich (unregistered) in reply to Yohann

    No, that's terribly unmaintainable (as well as wrong):

    for (i = 0; i < ACTIVATE_COUNT; i++) { Activate(); }

    As well as:

    for (i =0; i < LARGE_NUMBER_OF_COMMENTS; i++) { Comment(); }

    Even better, since we can see this pattern (multiple consecutive calls to Activate()) appearing in several places in the same function it needs to be factored out:

    multiActivate(INITIAL_ACTIVATE_COUNT);

  • rfoxmich (unregistered) in reply to Siva

    Looked at this and was thinking he had $50M ($50,000,000) he wanted me to launder through the U.S. for a small % of the amount.

  • Rollin you (unregistered) in reply to Gunslinger
    Gunslinger:
    Just a Commenter:
    C-Octothorpe:
    Just a Commenter:
    The blacked words and thinking of the Nagesh character involved made me shoot hot coffee out of several orifices simultaneously.

    I can understand the first 3 orifices, but anymore than that and you should probably see a doctor.

    Last time I checked, "several" means "3".

    Nope, couple is 2, coupla or few is 3, several is 4 or more.

    This is a couple

  • daqq (unregistered)

    I don't understand why is he complicating thing in this manner... why not just create another thread would contain only

    while(true)Activate();

    ?

  • Why bother (unregistered)

    TRWTF is that an enterprise architect is doing such low-level code audits.

  • (cs) in reply to gs
    gs:
    Seems weird, indeed, at first glance... But as an experienced (5+ years) WPF developer, I admit I feel some empathy for the author of these desperate lines...

    MSDN Docs: "Window.Activate: Attempts to bring the window to the foreground and activates it."

    Actual behaviour: Mostly nothing.

    For me, those lines of code just reflect something like the following, fully understandable thoughts of a frustrated developer:

    "Activate. [...] Activate. [...] Activate! [...] Hello?! I said 'Activate!' [...] Helloo?!! WPF, .NET, Microsoft, anybody out there? I said 'Activate', okay? WhyTF is that window not being activated? You want me to say it in Chinese, or Hindi or what??!! ACTIVAAAATE!!! <sobbing> <banging head on the keyboard> :'( Aaaaaargh!!!! :( :("

    // Captcha: dignissim. I'm just dignissim what it might mean.

    I figured someone with 5+ years of WPF experience would notice that it hasn't been around for even 5 years yet... Hmm...

  • (cs) in reply to boog
    boog:
    C-Octothorpe:
    Just a Commenter:
    ...made me shoot hot coffee out of several orifices simultaneously.
    I can understand the first 3 orifices...
    You can? Then apparently you aren't sorting alphabetically.

    Now that made me shoot hot coffee from all my orifices, plus a new one!

  • Calli Arcale (unregistered) in reply to Dalek
    Dalek:
    Exterminate(); Exterminate(); Exterminate(); Exterminate(); Exterminate(); Exterminate();

    Ah, good, so I wasn't the only person to think of Daleks when reading the title.

    "ACT-I-VATE!"

  • The Great Lobachevsky (unregistered) in reply to C-Octothorpe
    C-Octothorpe:
    boog:
    C-Octothorpe:
    Just a Commenter:
    ...made me shoot hot coffee out of several orifices simultaneously.
    I can understand the first 3 orifices...
    You can? Then apparently you aren't sorting alphabetically.

    Now that made me shoot hot coffee from all my orifices, plus a new one!

    What? If not yours, then someone elses? That seems rather cruel...

  • publiclurker (unregistered) in reply to Sarah Jane Smith

    "Not something often seen in connection with Daleks."

    You've obviously never seen "Abducted by the Daleks"

  • (cs)

    Computer will obey! Activate! Activate!

  • ted (unregistered) in reply to guilty
    guilty:
    The WTF in that case would have been to do it in a way that avoids long term, unforeseen consequences that could waste hours and hours instead of taking what will end up taking less time to do it correctly now.

    Alternatively, we could just hire more competent and experienced developers who won't take weeks to figure out simple problems, like it would you, by your own admission.

    You are what is so wrong with everything.

  • Shinobu (unregistered)

    I've written code like this, and since that was also interfacing an MS object model, I can sympathise. It went essentially like this:   do   {       x.enable();       sleep(100);   } while(!x.enabled()); Often it didn't loop, sometimes it would loop twice and rarely a handful of times. Remove the loop, and the program would crash on a method call that required x to be enabled.

  • (cs) in reply to Sarah Jane Smith
    Sarah Jane Smith:
    sad, but I read this in a Dalek voice...

    captcha: eros. Not something often seen in connection with Daleks.

    Oh drat, I was just about to do the "Activate! Activate!" joke myself.

  • (cs) in reply to C-Octothorpe
    C-Octothorpe:
    a flaming pineapple:
    fixed:

    try { Activate(); Activate(); Activate(); Activate(); Activate(); Activate(); Activate(); Activate(); Activate(); } catch (Exception e) { try { Activate(); Activate(); Activate(); Activate(); Activate(); Activate(); Activate(); Activate(); Activate(); } catch{ /* This should never happen. */ } }

    FTFY

    FTFTFYFY

  • (cs) in reply to guilty
    guilty:
    I have actually done that very thing in a small and scarcely used application written in AppleScript. Calling "activate" on an application object didn't always work as (when?) expected when there was a lot of CPU load. So it was either research the cause and then find a way to work around that (a couple of days of work down the pipe) or just paste "activate" several times (total amount of work: a few seconds). The WTF in that case would have been to burn several days to "correctly" fix a problem that could have been avoided with a quick and dirty hack.
    I think I'm beginning to understand why the application was scarcely used...
  • (cs) in reply to Siva
    Siva:
    Nagesh:
    This reminds me of state machine I develop at university for Master's thesis. Activeate call to be change state and new Activeate can be diferent funtionality.
    Friends, real Nagesh's funning to stop. Have you wondering why he not has posted some time? This is very sad situation: He take long struggle with dysentery and died of much diarrhea food poisioning. He has wife and 16 childs who are missing his provision and in bear feet on the streets.

    Please be sparing his good name from abuse further.

    Oh no, don't tell me he went to a convention and ate hotel food? Silly boy.

  • (cs) in reply to C-Octothorpe

    Ok, so the official release of .NET 3.0 was in November 2006, not quite 5 years... the beta and preview releases were arround a long time before that.

  • (cs) in reply to C-Octothorpe
    C-Octothorpe:
    I figured someone with 5+ years of WPF experience would notice that it hasn't been around for even 5 years yet... Hmm...
    Ok, so the official release of .NET 3.0 was in November 2006, not quite 5 years... the beta and preview releases were arround a long time before that.
  • (cs) in reply to boog
    boog:
    I think this code could be cited as justification for an established peer review process. It doesn't have to be formal; it could just be a handful of programmers sitting down at lunch to glance through the code, discuss important methods, offer suggestions, and generally make sure it's not doing anything completely idiotic in plain sight.

    I can't imagine this code surviving a peer review unless all the reviewers are total nitwits like the author.

    Oh come on, get real, there were eight peers of the programmer who put this together. "You need an Activate()," said the first. "Yes, you need an Activate()," said the second. "You know what's missing here, an Activate()," said the third.

    You can probably guess where this is going so I'll offer up the continuation as an exercise for the student.

  • (cs) in reply to The Bytemaster
    The Bytemaster:
    C-Octothorpe:
    I figured someone with 5+ years of WPF experience would notice that it hasn't been around for even 5 years yet... Hmm...
    Ok, so the official release of .NET 3.0 was in November 2006, not quite 5 years... the beta and preview releases were arround a long time before that.

    Sorry, knee-jerk reaction to people telling me in interviews they have a solid 15+ years of .Net experience, or when .Net 4 just came out, apparently they had been using it for 2+ years... oh really?

    Off topic: Depending on my mood/schedule, I'll either end the interview there (lying is a big character flaw IMO), or give them enough rope to hang themselves with (I love teaching people to never lie in an interview).

Leave a comment on “Activate!!!!!!!!”

Log In or post as a guest

Replying to comment #:

« Return to Article