- 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
Comment(); Comment(); Comment(); Comment(); Comment(); Comment(); Comment(); Comment();
Admin
notFrist(); notFrist(); notFrist(); notFrist(); notFrist(); notFrist(); notFrist(); notFrist();
Admin
It's so obious he shall have writed ;
for(i=0;i++;i<8) { activate(); }
so we have a better readability maintenance is easy (want 50 activate just change the number)
for (i=0;i++;i<100) { comment(); }
Admin
Without knowing what Activate() does how would I know this is a legitimate WTF?
Admin
Ah yeah I see the WFT is that those should be inside an infinite loop. Pfft Amatures.
CAPTCHA Test: inhibeo - the brand-name for the pill that helps curb overly extroverted behavior.
Admin
You were slow today Alex; I just had someone look for the cornify link and didn't realize I was talking about YESTERDAY's WTF.
Admin
sad, but I read this in a Dalek voice...
captcha: eros. Not something often seen in connection with Daleks.
Admin
http://msdn.microsoft.com/en-us/library/system.windows.forms.form.activate.aspx
Activates the form and gives it focus:
Activating a form brings it to the front if this is the active application, or it flashes the window caption if this is not the active application. The form must be visible for this method to have any effect. To determine the active form in an application, use the ActiveForm property or the ActiveMdiChild property if your forms are in a Multiple-document interface (MDI) application.
Admin
Is WPF the new WTF?
Admin
QFT, where is the code for the Activate() function?
Admin
Here's a better version:
for (int i = 0; i < 8; ++i) { Activate(); }
Or maybe he manually unrolled the loop for an optimization.
Admin
I think I feel a song coming on! http://www.youtube.com/watch?v=xv85NLeuAzk
Ahh... good times.
Admin
This source code is like an early 90s techno lyric.
Admin
Exterminate(); Exterminate(); Exterminate(); Exterminate(); Exterminate(); Exterminate();
Admin
Are you sure it's not Window.Activate: http://msdn.microsoft.com/en-us/library/system.windows.window.activate.aspx?
Admin
Clearly the WTF is WPF. GDI and WinForms don't have this issue.
Admin
Activate() is just a wrapper. the unwrapped code is
Developers(); Developers(); Developers(); Developers(); Developers(); Developers();
Admin
"btn_Export_Click" strikes me as being the name of a function within a Form, so I doubt it.
Admin
WTF powers Activate():!
Admin
Take a look at the eventargs type (RoutedEventArgs). That's WPF not Winforms.
Admin
So what does the Activate() method actually do?
Perhaps it cause the app to sleep for a period of time, allowing other process to run in the meantime... Let's just hope processes that this app relies on don't take longer...
(No, I don't want to be first or frist!)
Admin
Method calls are like drinking and violence. If using a little works, then using a lot by extension must be better. I'm just disappointed they didn't wrap activate() in a speedup loop.
Admin
Those calls to Activate() should be called in a while(true) loop concurrently in another thread, making sure to invoke the actual call on the UI thread, of course.
Admin
Is this somehow related to Magic Flutes ?
Admin
Gah, and the article itself even said it was WPF.
Admin
He just wanted to make it clear that he wants it to activate right now. Just like when you approach a crosswalk or elevator, you press the button several times to make it respond sooner.
Admin
ACTIVATE GOT DAMN IT
Admin
You have to substitute "Activate" with "Engage" and read it again in Picard's voice...
Admin
I'm so sick of seeing code implementing the wrong technology for the right solution!
Speed up your code, responsive UI and great UX, on multi-core CPU's; The right solutions is this:
Admin
Under the category of code smells, repeated calls to activate, redraw, set focus, etc. would be the "smell of fear."
Oh, and 1,890 lines of code for a single screen -- I don't think that's really unusual for WPF, from what little I've done with it so far. WPF has the smell of job security.
Admin
Just make sure you deactivate crossthread exceptions...
Admin
Admin
I must defend WPF. It's actually really awesome once you get the hang of it (and the MVVM pattern). The developer who created this WTF obviously did not get the hang of it.
Admin
Story has eight '!'s in title and joke has eight Activates.
HAH
Admin
fixed:
try { Activate(); Activate(); Activate(); Activate(); Activate(); Activate(); Activate(); Activate(); Activate(); } catch (Exception e) { Activate(); Activate(); Activate(); Activate(); Activate(); Activate(); Activate(); Activate(); Activate(); }
Admin
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.
Admin
It's the WonderTwins application! Try using
PowersActivate();
Admin
Please be sparing his good name from abuse further.
Admin
I do a lot of WPF development, and I love the framework. However, progress bars, and updates to the UI in general are handled a little bit differently than your standard windows form.
There's not really a simple "Refresh the UI" call you can make. If you're going to perform a task substantial enough for a progress bar, you're expected to run it an another thread. Trying to perform a task and update the UI at the same time, on the UI thread, is very frustrating (because you're not supposed to).
I respect that this guy had the patience and clarity to deliver a compilable "'eff you" to the framework, instead of just smashing his keyboard.
Admin
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.
Admin
Repeated function calls, the best there is. When you absolutely, positively, got to Activate(); every motherfucking form in the app, accept no substitutes.
Admin
Is this just an "interesting" way to make the window flash in an irritating manner?
Admin
I've seen stuff like this happen with TFS automatic merges. You merge from a dev / feature branch to Main then back to a dev branch at some later date. Sometimes TFS freaks out and duplicates the change.
Admin
FTFY
Admin
Sigh, it amazes me how many people get caught on this common mistake. It should be:
try { Activate(); Activate(); Activate(); Activate(); Activate(); Activate(); Activate(); Activate(); Activate(); } catch (Exception e) { Activate(); Activate(); Activate(); Activate(); Activate(); Activate(); Activate(); Activate(); Activate(); }
finally { Activate(); Activate(); Activate(); Activate(); Activate(); Activate(); Activate(); Activate(); Activate(); }
Admin
Yes this is silly. Anyone who doesn't put their Activate() calls in a for-loop doesn't know what they're doing.
Admin
Sigh, it amazes me how many people still don't know that an exception can be thrown in a finally block as well...
Admin
Perhaps he was just trying to answer the age-old question "if there are only seven items on the form, how can you activate?"
Admin
?!
Admin
Understatement.
In addition to placing program logic in an event handler, they queued background work directly to the dispatcher, and that background work mixes UI access with program logic.
It's hard to fathom the situation that resulted in this code. Even if the programmer^H^H^H^H^H^H perpetrator was drunk and high at the same time, the code shouldn't be that bad.