- 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(first).InnerText.Replace("first", "");
Admin
The wonders of temporary variables. I mean it's 20 seconds to make this readable and much better performing.
Admin
isPolicy || !jePolica sounds slavic, maybe || !nieMaPolicy ;-) is missing
Admin
Where's the bit that increments the value of index? Doesn't this produce an infinite loop?
Remy: It's reasonable to assume that index gets incremented in the commented out section- the submitter didn't provide that.
Admin
I think it means "is shelf".
Admin
I don't see any regexes here. Just some regular String.Replace(). Still pretty awful though. On the other hand, I don't see that much to improve. Yes, the cloning is a WTF, but the rest... without knowing the requirements there's not much else to optimize. You might shuffle things around for a little bit more readability, but that's pretty much it.
Admin
The beauty of JS; Replace is both string replace as well as regex replace :p https://www.w3schools.com/jsref/jsref_replace.asp
Admin
If there's that much in a while clause then there is something wrong with the code. There should be a way to clean it up
Admin
"je polica" means "is policy." Really.
Admin
This needs a bit more context to say if it's a WTF or sensible use of just-good-enough code. It really depends on whether this is code that will run occasionally or all the time: if it takes half a second longer to compile a report once a month, it's not worth even two minutes to optimise it for performance, let alone paying a proper developer to do it right instead of an intern to do it OK.
Admin
There's always two of me just replacing around.
Admin
What's the fuzz about cost of evaluating the statements, like "the body of the loop is cheaper to evaluate than the loop condition"? So what?
This seems to be a simple "do { move to next thing } while ( there are more things && it's not the thing we're looking for )". That's an OK pattern, even if the conditional is more complex than the body. Granted, the conditional itself is WTF, but the rest?
Admin
This code was programmed in a copy-and-paste style. The developer saved himself 2 or 3 seconds and every reader needs additional 15 seconds, just to decide "there are more things && it's not the thing we're looking for" (Quotation of commenter Alex). That's the real WTF. Because code is written once, but read many times (average 10). Commenter Vilx thinks there is not much to optimize instead of reformatting code. That's wrong. So to clean-up you should write a single method that you call with different parameters instead of copy-pasting code, like: function isPolicy(xpathPolicyNo, policyNumberSystem) { return nodeList.Item(index).CloneNode(true).SelectSingleNode(xpathPolicyNo, XmlNsMngr).InnerText.Replace("\n", "").Replace("\t", "").Replace("\r", "") == policyNumberSystem; }
Admin
I'm still waiting for the flame war around singular "they".
Admin
The real WTF is:
"XmlNodeList nodeList = ..."
Nothing good ever followed that in my experience.
Admin
Anneke can actually be both "Annie" and "Arnie". Perhaps the author didn't deem it worthwhile to ask the submitter for clarification.
Admin
Of course, it's obviously a calque of "IsPolicy" above. In Serbo-Croatian, maybe in Slovenian.