| « Prev | Page 1 | Page 2 | Next » |
|
Confusing naming, you say? Isn't it obvious that removeNumeric() is supposed to remove everything _except_ numeric chars? :)
|
|
I'm no VB developer, but I doubt very much that the last one will even work. NumStriper != NumStripper.
|
|
This is not a WTF. When you have a shared function library, you will always have repeated functions, or functions that are really similar but take in account a different range or type of input.
This will always happen. |
|
Also 2nd one won't work. outStr != outString
|
Re: Third Time's a Charm
2007-03-22 09:28
•
by
RON
(unregistered)
|
Fail. |
Presuming they're typos, but if not, oh the fun of ensuring that there's no option explicit in sight! (OTOH I forget whether classic asp is vb6 or vbscript; the latter has no declarations at all in a classic invitation to shoot yourself in the foot. Repeatedly.) |
Re: Third Time's a Charm
2007-03-22 09:41
•
by
Sgt. Preston
(unregistered)
|
Classic ASP uses VBScript, which has very loose run time typing and implicit variable declaration. Quick and easy to write and quick and easy to screw up if you're not careful. |
|
This is great!
In fact, this is just the way the PHP functions were developped! It’s the "it doesn’t exist, just add it to the language" school of language definition at it’s finest expression!!! Captcha: "poindexter". WTF???? |
Re: Third Time's a Charm
2007-03-22 09:47
•
by
Sgt. Preston
(unregistered)
|
Rather like the English language, except that in English, we don't care whether a we already have eighteen ways to say something; we'll add a nineteenth and call it cool. And we don't care whether the expression we invent already exists with an unrelated meaning; we'll just give it another one. Sort of spoken language overloading run amok. |
Re: Third Time's a Charm
2007-03-22 09:52
•
by
Blame
(unregistered)
|
Spot on, Ron. |
|
Eat it VB. Java pwnage:
public String stripNumbersFromString(String s) { return s.replaceAll("\D", ""); } |
|
Sorry, but I don't see how this is a WTF at all. Something to read, shrug and move on, certainly wouldn't make me think "WTF" :)
|
|
It wouldn't be a WTF discussion without someone coming to the defense of the WTF. So, I'll offer the following.
At least the first function, "OnlyNumber", has a tolerably meaningful name and actually does what it appears to claim. It uses the bizarrely named variable "sNonNum" for the string of numeric characters, but that's inside the 'black box'. As for including a whole library of community developed functions in every script on the Web site, well... WTF indeed! Peer review, weeding, and thorough documentation could still make it a handy resource. |
Re: Third Time's a Charm
2007-03-22 10:00
•
by
blah
(unregistered)
|
|
Thats obvious. its actually NumStriper <> NumStripper
|
Re: Third Time's a Charm
2007-03-22 10:05
•
by
Luke Dawson
(unregistered)
|
Ah, well that's OK then. |
Re: Third Time's a Charm
2007-03-22 10:05
•
by
Will
(unregistered)
|
Hey, at least it wasn't NunStripper... |
|
I actually love the name of the second one: removeNumeric().
So that's supposed to remove all numbers in the string. And of course, the code do the exact contrary (well, the code doesn't work, unless this is a typo from our master poster). I guess there is a meta-function somewhere which is called removeNameSecmantics() (or addNameSemantics(), depending on the programmers way of thinking). The captcha says it all: muhahaha. |
Wow! VB supports regular expressions too. |
|
i like that they have such good naming conventions though
sStr, inString, str nice... |
|
I like the way all three of them will turn, e.g. "a1b2c" into "12"...
|
Re: Third Time's a Charm
2007-03-22 10:13
•
by
etr
(unregistered)
|
Yeah, and you can do the same thing (roughly) in PHP, or Javascript, or any language with regex capability... Is there no regex in VB? Why would anyone use that language?.... That's a real WTF... :P |
Re: Third Time's a Charm
2007-03-22 10:15
•
by
EmmanuelD
(unregistered)
|
If it's not a WTF, then it's because there's only 3 of them. You must have many more code repetitions to make this kind of "quite normal behavior" a WTF. For my part, I can't consider this kind of issue to be a WTF unless there are at least 31 of them (and that's because I'm 31. In 4 years, this maximum repetition number should increase). |
While a library often contains similar/related functionality (different but similar ways of pouring database results into a language-native format, for example), a library with exact copies of functionality is in dire need of cleanup. This WTF is a WTF indeed, because it displays the utter mental blindness with which their library is treated. |
Re: Third Time's a Charm
2007-03-22 10:16
•
by
EmmanuelD
(unregistered)
|
Yeah! They look like similar functions! |
Re: Third Time's a Charm
2007-03-22 10:19
•
by
Sgt. Preston
(unregistered)
|
Isn't it interesting how quick people are to slam Visual Basic, VBScript, and VN.NET without (a) knowing the differences among them or (b) knowing the features and capabilities of the languages. What we saw in this WTF was VBScript. All three of the VB-related languages support regular expressions. http://msdn2.microsoft.com/en-us/library/ms974570.aspx |
Re: Third Time's a Charm
2007-03-22 10:20
•
by
Sgt. Preston
(unregistered)
|
|
Pardon my typo. "VN.NET" of course should have been "VB.NET".
|
|
NumStriper()?
How do you add 'stripes' to a number? |
Re: Third Time's a Charm
2007-03-22 10:50
•
by
I Hate 1st TN Bank
(unregistered)
|
|
Aren't regular expressions available in just about every language under the sun? This is not a problem with VB (although I would never use it over C# or JavaScript), it is a problem with the one(s) behind the keyboard. Unfortunately, we can't put monkeys in space, that's why there's still so many in front of computers...
|
|
OnlyNumber only returned numbers. Perhaps that is what was wanted, but some numbers have a decimal component that wouldn't be honoured.
As for the glorious WTFy way Microsoft decided to implement RegExp in VBScript:
|
Re: Third Time's a Charm
2007-03-22 11:00
•
by
etr
(unregistered)
|
Ouch! |
Turn on every other bit? |
It's perfectly cromulent code, which imbiggens the functionality of the language. |
Re: Third Time's a Charm
2007-03-22 11:17
•
by
Reaver
(unregistered)
|
Maybe it has something to do with the Webserver's RAID configuration? Nah, probably the same thing that makes "developpers" play "Rouges" in fantasy games. Or the disappointment felt when one discovers that there are only "stripers" at the nightclub. Cheers! |
VB does have its share of WTFs, like finishing out the function with functionName = value rather than using the return statement like everyone else. Small typos like we see in the sample above will result in a returned value of a zero-length string. Yippee. And although it is possible to create a RegEx object in VB, I wouldn't recommend it if you have to do it more than a couple times. It's incredibly slow to instantiate. Not that VB is known for its speed, but don't slow it down any more than you have to. If you're dealing with fairly short strings, just loop through it with Mid(), save the RegEx stuff for when it would be worthwhile. |
|
I moved onto a 750kloc project once, and found 7 functions which operated on the same container type, all called "remove_duplicates" (with minor changes / namespace hiding).
Catchpa : Bling - Programming's glamorous you know. |
|
Having been forced to use ASP in the past, I defied convention and used Javascript as the language instead of VBScript because of the nightmarish state of VBScript. Also making sure to always explicitly declare and explicit type conversion was extremely helpful as well.
Even so, I also had to resort to (albeit much shorter) a custom defined "library" for dealing with the bizarre XML RPC I was forced to use for communication with our CRM system (that drives the website). |
Wow, you're cool. Function stripNumbersFromString(ByVal s)\d matches numeric characters. \D matches non-numeric characters. |
Re: Third Time's a Charm
2007-03-22 11:55
•
by
Will
(unregistered)
|
According to the article, the submitter was looking for a function to return the numeric characters out of a string. So, what is wanted is to replace non-numeric characters with "". \D would be correct. |
Yes, but the GGP comment was a new function with a new function name. I fixed the pattern to match what the function name said it was doing. Ever hear of the saying "say what you mean and mean what you say"? |
Re: Third Time's a Charm
2007-03-22 12:00
•
by
PC Paul
(unregistered)
|
Why would I want to stripe a Nun? |
Re: Third Time's a Charm
2007-03-22 12:05
•
by
Will Perdikakis
(unregistered)
|
The problem is, you can not just go to the library and determine the best function for the job and delete the other two because there may be some remote code that uses this library. You will break that code. This problem is inherent in user editable function libraries. Just like the possibility of errant code getting in there. Just like possibility of bad information getting on Wikipedia. And to all those one-word replies to the original post, please explain what you disagree with. |
|
Don't you get it? "RemoveNumeric" removes the numeric characters... and returns them! Get it? Huh? Huh???
Wow, tough crowd. |
Re: Third Time's a Charm
2007-03-22 12:13
•
by
Jimmy
(unregistered)
|
I concellate. It's a snaff way of bedroggling. |
|
NumStriper? does it paint the numbers with stripes?
Captcha: xevious - You know I dont' speak Spanish! |
Re: Third Time's a Charm
2007-03-22 12:20
•
by
Paul
(unregistered)
|
|
If you want to strip the numbers from the string, you use \D. You fixed it backwards.
|
Well, apparently two of the three basically do nothing. In the remote likelihood that they are used anywhere, I suspect that a simple refactoring to no-op would be an improvement. In the more general case, a refactoring of all but one function such that they are implemented in terms of the remaining (useful?) one is obviously the way to go. This makes the lives of future developers significantly less likely to end in That Postal Moment. As to the one-word replies, I think the authors are implying that they would not wish to work alongside someone with your refreshingly cavalier attitude to sensible codebase maintenance. This is most unfair of them. If they look around their place of work, I have no doubt they'll find plenty of other ninnies who are equally adept at making their lives miserable. |
Re: Third Time's a Charm
2007-03-22 12:30
•
by
Phyzz
(unregistered)
|
Helped out by the fact that English is a ridiculously loosely typed language. What were they thinking. Theres even the word "verbed" for implicit conversion of noun type objects to a verb object. Which is itself verbed noun. What a WTF. :D |
Re: Third Time's a Charm
2007-03-22 12:33
•
by
Will
(unregistered)
|
The name "stripNumbersFromString" is a little ambiguous. It could mean "strip the numbers from the string and give the string back to me" or "strip the numbers from the string and give the numbers back to me." |
Re: Third Time's a Charm
2007-03-22 12:39
•
by
Paul
(unregistered)
|
|
"strip" is synonymous with "discard". You don't want back what you discard.
|
Re: Third Time's a Charm
2007-03-22 12:44
•
by
Andrew
(unregistered)
|
To send her to prison. |
| « Prev | Page 1 | Page 2 | Next » |