- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
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.
Admin
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.
Admin
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!
Admin
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.
Admin
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.
Admin
Admin
I can understand the first 3 orifices, but anymore than that and you should probably see a doctor.
Admin
Admin
Who's to say that under "really heavy CPU load", the code still wouldn't "work", even with your "fix" in place?
Admin
Admin
Badgers(); Badgers(); Badgers(); Badgers(); Badgers(); Badgers(); Badgers(); Badgers(); Badgers(); Badgers(); Badgers(mushroom, mushroom);
Admin
Um, several means more than two, no? In any case I was joking, but do feel free to be pedantic; everyone is listening.
Admin
Shame the Magic Flute was one of Mozarts... I guess accuracy of placing opera into appropriate classical periods isn't an XKCD forté.
Admin
+1000
Admin
Snaaaaaaaaaaaaaake()
Admin
This is what the internet told me:
I think the word you're looking for is "many". Or in "Just a Commenter"'s case, "three".
Admin
Admin
Admin
Admin
It probably firing a weapon is. More times try, better lucky.
Admin
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.
Admin
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!"
Admin
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>
Admin
Can just do it in 2 line but really properly:
system.GodMode = True; Activate();
Admin
Admin
Duff's Activation
Admin
Admin
Nope, couple is 2, coupla or few is 3, several is 4 or more.
Admin
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.
Admin
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);
Admin
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.
Admin
This is a couple
Admin
I don't understand why is he complicating thing in this manner... why not just create another thread would contain only
?
Admin
TRWTF is that an enterprise architect is doing such low-level code audits.
Admin
I figured someone with 5+ years of WPF experience would notice that it hasn't been around for even 5 years yet... Hmm...
Admin
Now that made me shoot hot coffee from all my orifices, plus a new one!
Admin
Ah, good, so I wasn't the only person to think of Daleks when reading the title.
"ACT-I-VATE!"
Admin
What? If not yours, then someone elses? That seems rather cruel...
Admin
"Not something often seen in connection with Daleks."
You've obviously never seen "Abducted by the Daleks"
Admin
Computer will obey! Activate! Activate!
Admin
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.
Admin
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.
Admin
Oh drat, I was just about to do the "Activate! Activate!" joke myself.
Admin
FTFTFYFY
Admin
Admin
Oh no, don't tell me he went to a convention and ate hotel food? Silly boy.
Admin
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.
Admin
Admin
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.
Admin
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).