- 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
It's still shorter than the complete email regex...
Admin
frist! Okay, I have a very similar procedure, but it's nowhere near that complicated. but if it works, it works.
Admin
Holy Shit! How did I get beaten!
Third FIST!
Admin
Oh yeah. Reminds me of the time I found&removed a 300 line strong method that was supposed to check if the difference between a given date and "now" exceeds 18 years (an enterprisey java "are you over 18?" check)
Admin
You gol-danged whipper-snapper kids and your uppity "methods" should shut up and learn the REAL way to code, like we did back in the day! Ha, "split", you're just begging for trouble by letting some fancy LIBRARY routine do the work for you, ya slacker! How do you know it will work right unless you write the code yourself?? Huh?? Got no answer for that, do you, Mister Smarty-Pants!
Admin
I was thinking, hey I know the guy who wrote this but then I realized it was missing his trademark ... if (doneCur == true)
Admin
How zen.
Admin
Sure, it's a WTF. I'm not gonna say it's not a WTF.
But these modern day compiler libraries are so incredibly large, it's impossible to know, and understand, and be able to use, every single call that's included. It would take years, if not decades, for a programmer to get to know all the ins and outs of a given library. And then in the end, when he knows everything, he'll find that his knowledge is outdated and there are newer versions of the libraries with different functionalities.
So the best you can aspire to is to learn a decent subset of the calls at your disposal, and to use those to the best of your abilities.
If, at every routine I'm writing, I were to think, hey, maybe there's an API call somewhere that does the same thing; why don't I just launch a quick internet search and spend the afternoon surfing across msdn.microsoft.com, my programs would take much longer to write, even if they would end up marginally smaller.
Admin
Yeah right, cause string.Split() is an obscure, rarely-used method.
Admin
Shouldn't that be:
return emails.Split(new char[]{' ','\t',',',';',':'});
Admin
The reason you would do this is:
Admin
This is typical of Java mistraining:
Admin
He that is good with a hammer tends to think everything is a nail.
Admin
Speed up loop?
Admin
Ok, that's more readable.
Admin
Comment<string> comment = new Comment<string>(1);
Admin
The what?
Admin
You know, those two-letter words that nobody likes to see on TV. Like... I guess.... uu in this case?
Admin
I have no idea, but I sure gonna use this one from now on.
Admin
To the man who only has a hammer, everything he encounters begins to look like a nail.
Admin
Get off my lawn!!
Admin
stoopid
Admin
Or:
return emails.Split(" \t,;:".ToCharArray());
Admin
The argument for Split is params char[] so the call from the article is correct and the easiest to use.
Admin
Admin
It's a funny thing.
When I was a very young kid and having just learned the basics of English, got adopted into an American family, I spent weeks reading dictionaries from cover to cover so I could have a better understanding of the language.
Yet there are professional programmers who learn the syntax of a language but don't bother furthering their understanding of all the functions and objects available for that language.
strange.
Admin
Or you could just type emails.'Ctrl-Space'
Admin
" \t,;:".ToCharArray() would return [' ','','t',',',';',':']
The original is more readable and is less typing; what's not to like (unless you're a Complicator, of course)?
Admin
Yes, but is your work thread-safe??
Admin
FYI to all the java programmers providing solutions, the method is
and not and on top of that it doesn't take character array as an argument.Admin
So how many of the 540,000 words in the English language do you know?
Did you know that the "acnestis" is the part of the back that's impossible to scratch?
No? I didn't either until I looked it up - but I managed before by saying "that bit just behind my shoulder blades that I can't scratch". OK it was a bit long winded, but in many ways it's easier to communicate with people the long-winded way, rather than using an obscure word which you'd probably end up having to explain the meaning of anyway.
:)
Admin
Maybe so, but string.Split() is the nose on your face, not the acnestis on your back :)
Admin
i could be wrong, but i don't think, that "List<string> list = new List<string>(1);" would compile at all... List is an Interface and thus is not instantiable.
Admin
I'm pretty sure this is C# code, not Java.
I don't know C# - can you really call a function that takes a Char[] by passing the chars as separate parameters?
How does it deal with this:
void func(Char[] foo); void func(Char a, Char b);
...
func('a', 'b');
Admin
Admin
Admin
It's C#, you can use List<string>, IList is the interface.
Admin
So are you saying that it's easier when you talk to people to say "Moses did that action that applied to an object creates several subparts of that object to the waters" instead of "Moses split the waters"?
Admin
A "decent subset" of the Java library should include String.split, or it is not "decent".
Learning all of the libraries for a language such as Java is not feasible; however, any developer should imho try to constantly expand the tools (i.e. the "decent subset of calls" ) at his disposal. If what you are trying to code seems like something that should be in a library, chances are it is in the library, but you just did not find it yet.
Admin
Except '\t' is a tab character.
I guess you could verbatim the string (@".."); but, string -> char[] is not the best way anyhow. I'm not going to hate-on splitting a string to char[] since it is useful in some cases. This is not one of those cases.
You sir, are The Complicator. "new char[] { ... }" is the way to go.
Admin
Wake up people...this is obviously C#, not Java! The uppercase method names should have given it away.
Admin
Tim: You cannot do that -- you must actually create an array.
Admin
in C#, if the signature is: func(params char[] foo); the params keyword allows you to invoke it by passing the chars as separate parameters, and you treat it as an array inside the function.
func('a','b'); will invoke the signature that explicitly matches your call, but func('a','b','c') will invoke the overload with the params keyword.
Admin
To the "programmers" who complain that the class libraries are too large for them to discover functions like String.Split ... nobody's asking you to memorize the entire class library, but every programmer SHOULD be familiar with the most fundamental classes in the library (such as Object, String, and the collections framework) and the methods that are available for these classes.
If you can't even be bothered to learn the methods for String (one of the most commonly used classes in the language), then why is your employer paying you again?
Admin
Because the employer charges the customer by the hour and/or lines of code?
Admin
No. I pretty sure you can't. Hence why it should be func(new char[]{....});
Admin
Well, at least its easy to write a test and refactor all those method by method until your done. It could be worse.
Admin
Which overload called is dependent upon how its invoked. func('a', 'b') will call the second. func(new char[]{'a', 'b'}) with call the first.
Admin
Admin
Must be amateur hour on TDWTF.
This is a rookie mistake, but also an understandable one. I'm going to guess the guy who wrote this came from a background full of languages with crap libraries, and so it didn't even occur to him that somebody might have solved his problem in advance.
Now if this guy was an experienced C# (is that it?) dev, then yeah, it becomes a WTF, though not a colossal one.
I was kind of hoping for this guy to be the Director of IT or something and mandate that all libraries have to be re-implemented internally because "Microsoft isn't any good."