• unregistered person (unregistered) in reply to unregistered person
    Nagesh:
    public class StringSplit {
      public static void main(String args[]) throws Exception{
        String testString = "Real-How-To";
        System.out.println(
            java.util.Arrays.toString(
            testString.split("-")
        ));
    
    // output : [Real, How, To]
    }
    

    }

    mroot really needs to attend one short course in java. java is most user friendly REAL PROGRAMMING language. of course everyone think VB6 is most user friendly but keep in mind I use term "REAL" here. there are sevreal java course available online. i think he can contact me if he cannot google.

    Sure, Java's a "most user friendly REAL PROGRAMMING language" compared to... say... Python?

    Same code:

        print "Real-how-to".split('-')

  • DrewE (no relation to Drew) (unregistered) in reply to Drew
    Drew:
    Couldn't you just instanciate an array with the rs.size() and put them in without having to deal with a list?

    String[] toBeReturned = new String[rs.size()]; for (int i = 0; rs.next(); i++) { toBeReturned[i] = rs.getString("email"); }

    That would work if ResultSet had a size() method. Alas, it doesn't (assuming this is Java, as it appears to be), presumably because there's no guarantee that the underlying database has determined how many results there are before it can start providing some to you.

    Stuffing the results into an ArrayList or similar would work pretty nicely.

  • (cs) in reply to Anonymous
    Anonymous:
    What the hell... oh, hi Nagesh. How's the cow worshipping going today?
    wtf dude... get a brain.
  • C-Octothorpe (unregistered) in reply to DrewE (no relation to Drew)
    DrewE (no relation to Drew):
    Drew:
    Couldn't you just instanciate an array with the rs.size() and put them in without having to deal with a list?

    String[] toBeReturned = new String[rs.size()]; for (int i = 0; rs.next(); i++) { toBeReturned[i] = rs.getString("email"); }

    That would work if ResultSet had a size() method. Alas, it doesn't (assuming this is Java, as it appears to be), presumably because there's no guarantee that the underlying database has determined how many results there are before it can start providing some to you.

    Stuffing the results into an ArrayList or similar would work pretty nicely.

    Or in the .Net world, just use yield return (pretty cool because you can stream the items back to the caller while still reading from the reader). This assumes you don't CARE how many items there is in the collection, and often times, you don't...

    Is there an equivalent in Java of the yield return?

  • C-Octothorpe (unregistered) in reply to toshir0
    toshir0:
    Anonymous:
    What the hell... oh, hi Nagesh. How's the cow worshipping going today?
    wtf dude... get a brain.

    Relax, it's probably his sock puppet... Which is funny because it's probably frits or boogs sock puppet, which makes it a sock puppet of a sock puppet.

  • (cs) in reply to C-Octothorpe

    what does yield do?

  • (cs) in reply to C-Octothorpe
    C-Octothorpe:
    DrewE (no relation to Drew):
    Drew:
    Couldn't you just instanciate an array with the rs.size() and put them in without having to deal with a list?

    String[] toBeReturned = new String[rs.size()]; for (int i = 0; rs.next(); i++) { toBeReturned[i] = rs.getString("email"); }

    That would work if ResultSet had a size() method. Alas, it doesn't (assuming this is Java, as it appears to be), presumably because there's no guarantee that the underlying database has determined how many results there are before it can start providing some to you.

    Stuffing the results into an ArrayList or similar would work pretty nicely.

    Or in the .Net world, just use yield return (pretty cool because you can stream the items back to the caller while still reading from the reader). This assumes you don't CARE how many items there is in the collection, and often times, you don't...

    Is there an equivalent in Java of the yield return?

    read this http://jimblackler.net/blog/?p=61

  • Just sayin' (unregistered) in reply to unregistered person
    unregistered person:
    Nagesh:
    public class StringSplit {
      public static void main(String args[]) throws Exception{
        String testString = "Real-How-To";
        System.out.println(
            java.util.Arrays.toString(
            testString.split("-")
        ));
    
    // output : [Real, How, To]
    }
    

    }

    mroot really needs to attend one short course in java. java is most user friendly REAL PROGRAMMING language. of course everyone think VB6 is most user friendly but keep in mind I use term "REAL" here. there are sevreal java course available online. i think he can contact me if he cannot google.

    Sure, Java's a "most user friendly REAL PROGRAMMING language" compared to... say... Python?

    Same code:

        print "Real-how-to".split('-')

    I like Python, but once a project gets above 3 members and ~7K lines, unless I've been able to very carefully select the other 2 programmers, I'd much rather the project be in Java (even if that does make it 12K lines instead).

    The tooling is nicer, and although this can be mitigated by writing proper automated unit tests, it is much easier to debug problems in unfamiliar code.

  • Just another coder (unregistered)

    Not surprised. The state of competence has more than 1 to 40 variance and examples of the lack of basic comprehension of the cause and effect relations in programs are common.

    Reminds me of a bugfix, one programmer made. There was a function call missing from a piece of code, and that programmer was instructed to add the function call there. So that programmer copy-pasted the function call from the corresponding header file to the indicated place, compiled the code. As it compiled that programmer checked the code in and signed the fix done.

    Only problem was, that the copy-pasted code remained a declaration (that was C code) so no actual function call, of course, took place.

    Another programmer had learned to initialize C-strings like

    char text[] = { 'T', 'e', 'x', 't', '\0' };

    instead of

    char text[] = "Text";

    in an university level programming course.

  • (cs) in reply to Just sayin'
    Just sayin':
    I like Python, but once a project gets above 3 members and ~7K lines, unless I've been able to very carefully select the other 2 programmers, I'd much rather the project be in Java (even if that does make it 12K lines instead).

    The tooling is nicer, and although this can be mitigated by writing proper automated unit tests, it is much easier to debug problems in unfamiliar code.

    Amen, brother! I've seen first-hand the results of writing a large (in absolute terms, just medium-to-small, but large for Python) system in Python. Even with very strong programmers and strong naming conventions, the lack of automatic checks to prevent the compiler accepting code that passed in the wrong kind of object was a real killer once the project complexity reached a certain level.

  • Boris Vladamir (unregistered) in reply to Nagesh
    Nagesh:
    What would you know of best vodka, drinker of horse-piss?
    Saying "best vodka" is like saying "best cut of beef." Sometime you want T-bone, sometime you want burger, sometime you want filet minon, sometime you want rump roast.

    My mouth watering now. Time to go out and murder cow.

  • (cs) in reply to Just sayin'
    Just sayin':
    unregistered person:
    Nagesh:
    public class StringSplit {
      public static void main(String args[]) throws Exception{
        String testString = "Real-How-To";
        System.out.println(
            java.util.Arrays.toString(
            testString.split("-")
        ));
    
    // output : [Real, How, To]
    }
    

    }

    mroot really needs to attend one short course in java. java is most user friendly REAL PROGRAMMING language. of course everyone think VB6 is most user friendly but keep in mind I use term "REAL" here. there are sevreal java course available online. i think he can contact me if he cannot google.

    Sure, Java's a "most user friendly REAL PROGRAMMING language" compared to... say... Python?

    Same code:

        print "Real-how-to".split('-')

    I like Python, but once a project gets above 3 members and ~7K lines, unless I've been able to very carefully select the other 2 programmers, I'd much rather the project be in Java (even if that does make it 12K lines instead).

    The tooling is nicer, and although this can be mitigated by writing proper automated unit tests, it is much easier to debug problems in unfamiliar code.

    Agreed++

  • Just sayin' (unregistered) in reply to Just another coder
    Just another coder:
    Not surprised. The state of competence has more than 1 to 40 variance and examples of the lack of basic comprehension of the cause and effect relations in programs are common.

    Reminds me of a bugfix, one programmer made. There was a function call missing from a piece of code, and that programmer was instructed to add the function call there. So that programmer copy-pasted the function call from the corresponding header file to the indicated place, compiled the code. As it compiled that programmer checked the code in and signed the fix done.

    Only problem was, that the copy-pasted code remained a declaration (that was C code) so no actual function call, of course, took place.

    Another programmer had learned to initialize C-strings like

    char text[] = { 'T', 'e', 'x', 't', '\0' };

    instead of

    char text[] = "Text";

    in an university level programming course.

    I think showing students the

    char text[] = { 'T', 'e', 'x', 't', '\0' };

    version makes sense, as it makes it obvious exactly what is going on... but yeah I'd show them both at once and say use the quoted string one, but here's what's going on behind the scenes

    Captcha: commoveo ... comb over in Italian?

  • sam (unregistered)

    What IM was that? Automatic detection and formatting of source code? I'd like that.

  • Anonymous Coward (unregistered)

    TRWTF is not using "Linq to Shortcut Guy"

  • (cs)

    mroot (10:03 AM): Got a problem for ya... mroot (10:03 AM): Any idea how I can parse a string of email addresses like this: [email protected]@[email protected]? mroot (10:04 AM): I need them separated in an array. I was thining of looking for .net, .com, etc. boog (10:05 AM): Sure, that might work. mroot (10:05 AM): Is there a web service to do that? boog (10:06 AM): There might be. See if you can find one, and let me know if you do. mroot (11:18 AM): Okay. What if there was a comma between the addresses? For example, [email protected],[email protected],[email protected]. mroot (11:19 AM): That should be easy to put in an array? boog (11:22 AM): Couldn't find a web service? Hmm... wait, where did those commas come from? mroot (11:24 AM): I just copy/pasted them from debug console. That's what my string has. boog (11:25 AM): Oh, I see, they make it easier to read. Good thinking! So if there's no web service already, you should write your own. It can start out by removing the commas, then search on .net, .com, etc.! Think you can pull it off? mroot (11:25 AM): Sure, no problem... boog: (11:25 AM): Excellent.

    On the plus side, he'd never ask for my help again.

  • (cs) in reply to boog
    boog:
    mroot (10:03 AM): Got a problem for ya... mroot (10:03 AM): Any idea how I can parse a string of email addresses like this: [email protected]@[email protected]? mroot (10:04 AM): I need them separated in an array. I was thining of looking for .net, .com, etc. boog (10:05 AM): Sure, that might work. mroot (10:05 AM): Is there a web service to do that? boog (10:06 AM): There might be. See if you can find one, and let me know if you do. mroot (11:18 AM): Okay. What if there was a comma between the addresses? For example, [email protected],[email protected],[email protected]. mroot (11:19 AM): That should be easy to put in an array? boog (11:22 AM): Couldn't find a web service? Hmm... wait, where did those commas come from? mroot (11:24 AM): I just copy/pasted them from debug console. That's what my string has. boog (11:25 AM): Oh, I see, they make it easier to read. Good thinking! So if there's no web service already, you should write your own. It can start out by removing the commas, then search on .net, .com, etc.! Think you can pull it off? mroot (11:25 AM): Sure, no problem... boog: (11:25 AM): Excellent.

    On the plus side, he'd never ask for my help again.

    booger, That will never work. Mister Oot will simply ask you to write the webservice. <smiles>

  • (cs) in reply to boog
    boog (defective copy):
    I'm pretty sure I would have strangled someone and got thrown in prison before I became a seasoned developer.
    Not a problem, my dimwitted duplicator - you can still be a seasoned developer. You just need to know your options.
  • Just sayin' (unregistered) in reply to Nagesh
    Nagesh:
    Just sayin':
    unregistered person:
    Nagesh:
    public class StringSplit {
      public static void main(String args[]) throws Exception{
        String testString = "Real-How-To";
        System.out.println(
            java.util.Arrays.toString(
            testString.split("-")
        ));
    
    // output : [Real, How, To]
    }
    

    }

    mroot really needs to attend one short course in java. java is most user friendly REAL PROGRAMMING language. of course everyone think VB6 is most user friendly but keep in mind I use term "REAL" here. there are sevreal java course available online. i think he can contact me if he cannot google.

    Sure, Java's a "most user friendly REAL PROGRAMMING language" compared to... say... Python?

    Same code:

        print "Real-how-to".split('-')

    I like Python, but once a project gets above 3 members and ~7K lines, unless I've been able to very carefully select the other 2 programmers, I'd much rather the project be in Java (even if that does make it 12K lines instead).

    The tooling is nicer, and although this can be mitigated by writing proper automated unit tests, it is much easier to debug problems in unfamiliar code.

    Agreed++

    Great... now no one will listen to my actually reasonable point, thanks Nagesh ;-) . And btw, that python segment isn't the "exact same code" ... it's closer to this

    public class SplitStuff {
      static {
        System.out.println(
            java.util.Arrays.toString("Real-how-to".split("-")
        ));
      };
    }
    

    Yes, if I was writing a quick script to split strings, I'd choose python or ruby. Since they are often considered scripting languages they do have nicer string manipulation abilities, but let's look at what is actually doing the work here:

        System.out.println(
            java.util.Arrays.toString("Real-how-to".split("-")
        ));
    

    vs print "Real-how-to".split('-')

    Yes longer, but not too unreasonable, and after a year or so of object oriented programming it shouldn't seem any more complicated

    PS: elif python? really? saving three characters is so important that we need to use an abbreviation that should have died out in the 70's?

  • Ditto (unregistered)

    [sarcasm] Why wouldn't they just loop through each possible combination of the list, and send a test email to each one .. then just record which ones bounce, and viola ... you have your email list!! Easy ... [/sarcasm]

  • (cs) in reply to Nagesh
    Nagesh:
    ...java is most user friendly REAL PROGRAMMING language. ... keep in mind I use term "REAL" here.
    You're so funny. And what crazy hair too!
  • Someone who can't be bothered to login from work (unregistered)

    You mean conversations like that aren't normal? I have them everyday at work. Although I work for a small company (< 10 people) and I'm the only actual developer; my manager is actually a DBA trying to teach himself how to program in C#

    I miss working with C and C++

  • Racialista (unregistered) in reply to toshir0
    toshir0:
    Anonymous:
    What the hell... oh, hi Nagesh. How's the cow worshipping going today?
    wtf dude... get a brain.
    Oh oh oh, don't tell me, I know this one - he's being racist!!!!! But wait, 80% of Indians genuinely consider the cow to be sacred. So for one, it ain't racist if it's true; and for two, how does a sensitive little pussy like you survive on the Internet?
  • jackowackoslacko (unregistered)

    I think you're all stupid LOL.

  • Your Name (unregistered) in reply to Just sayin'
    Just sayin':
    PS: elif python? really? saving three characters is so important that we need to use an abbreviation that should have died out in the 70's?

    I think it's there to make the parser less complex, actually, although I could be wrong; it's been a while since I was elbow-deep into CPython's guts.

  • F (unregistered) in reply to itsmo
    itsmo:
    Warren:
    I can shortcut the entire comments thread:

    brainless first-posts people who haven't got the joke or feel sorry for the wtf-creator people calling shenanigans people who insist upon slightly different solutions people who argue about the slightly different solutions people who say it would all be easier in another language / OS / etc.

    You forgot people who comment on the comments.

    Really? People do that? Here?

  • Splitter (unregistered)

    I have split your email addresses. Pray I don't split them further.

  • (cs)

    Love the python fanboy whose hardest coding problem was probably scraping HTML off of a website.

    re: TFA, I'm very suspicious of this. The if-statement means he'll only get the first result of the query each time the method is called, so it'd be impossible to get different email addresses without some manipulation of the database between calls.

    Also, no call to rs.close()? Article is obviously BS.

    Addendum:

    boog:
    mroot (10:03 AM): Got a problem for ya... mroot (10:03 AM): Any idea how I can parse a string of email addresses like this: [email protected]@[email protected]? mroot (10:04 AM): I need them separated in an array. I was thining of looking for .net, .com, etc. boog (10:05 AM): Sure, that might work. mroot (10:05 AM): Is there a web service to do that? boog (10:06 AM): There might be. See if you can find one, and let me know if you do. mroot (11:18 AM): Okay. What if there was a comma between the addresses? For example, [email protected],[email protected],[email protected]. mroot (11:19 AM): That should be easy to put in an array? boog (11:22 AM): Couldn't find a web service? Hmm... wait, where did those commas come from? mroot (11:24 AM): I just copy/pasted them from debug console. That's what my string has. boog (11:25 AM): Oh, I see, they make it easier to read. Good thinking! So if there's no web service already, you should write your own. It can start out by removing the commas, then search on .net, .com, etc.! Think you can pull it off? mroot (11:25 AM): Sure, no problem... boog: (11:25 AM): Excellent.

    On the plus side, he'd never ask for my help again.

    You messed up your name in the last line of the instant message. The extra : ruined it.

  • F (unregistered) in reply to Just another coder
    Just another coder:
    Not surprised. The state of competence has more than 1 to 40 variance and examples of the lack of basic comprehension of the cause and effect relations in programs are common.

    ...

    Another programmer had learned to initialize C-strings like

    char text[] = { 'T', 'e', 'x', 't', '\0' };

    instead of

    char text[] = "Text";

    in an university level programming course.

    Perhaps they were using a compiler hacked together by the course lecturer, which barfed on the "" syntax. After all, syntactic sugar is for wimps.

  • random internet wanker (unregistered) in reply to Derp

    The person's job is programming. As in, understanding the basic structures of the language they are working with to make stuff that does other useful stuff and possibly occasionally solves problems, instead of introducing more.

    The fact that they are using a loop to create a string out of individual email addresses, and cannot figure out how to parse individual emails out of their newly-created string, qualifies as a major WTF regardless of the language in question or anyone's individual level of patience.

    Or do yu beleeve that an editer doesn't need to no grammer, speling, and vocabalery well, as qualifikations to doing there job and properly ern their paychek?

    Seriously. Your comment is the real WTF.

  • Whiskey (unregistered) in reply to Racialista
    Racialista:
    toshir0:
    Anonymous:
    What the hell... oh, hi Nagesh. How's the cow worshipping going today?
    wtf dude... get a brain.
    Oh oh oh, don't tell me, I know this one - he's being racist!!!!! But wait, 80% of Indians genuinely consider the cow to be sacred. So for one, it ain't racist if it's true; and for two, how does a sensitive little pussy like you survive on the Internet?

    I'm amazed...

  • Toc the elder (unregistered) in reply to Power Troll
    Power Troll:
    Love the python fanboy whose hardest coding problem was probably scraping HTML off of a website.

    re: TFA, I'm very suspicious of this. The if-statement means he'll only get the first result of the query each time the method is called, so it'd be impossible to get different email addresses without some manipulation of the database between calls. ...

    Wow, I just skimmed over it assuming it must be a while... obviously I need another coffee today

  • (cs) in reply to ubersoldat
    ubersoldat:
    Nothing better than a junior with superiority complex. You know what kid? Keep doing things right, you won't escalate the business ladder.

    Nothing better - or worse - than being the junior who's always correct. Been there, done that.

    Nick:
    am i missing something, shouldn't the code be:

    while(rs.Next()){ //code here }

    or it will only print one thing?

    Yep, I noticed that too... faulty code sample makes me think made-up WTF.

  • Colin (unregistered)

    Interestingly enough, Mozilla maintains a text file of TLDs here. There's even an atom feed of updates to it.

  • C-Octothorpe (unregistered) in reply to Power Troll
    Power Troll:
    Love the python fanboy whose hardest coding problem was probably scraping HTML off of a website.

    re: TFA, I'm very suspicious of this. The if-statement means he'll only get the first result of the query each time the method is called, so it'd be impossible to get different email addresses without some manipulation of the database between calls.

    Also, no call to rs.close()? Article is obviously BS.

    Addendum:

    boog:
    mroot (10:03 AM): Got a problem for ya... mroot (10:03 AM): Any idea how I can parse a string of email addresses like this: [email protected]@[email protected]? mroot (10:04 AM): I need them separated in an array. I was thining of looking for .net, .com, etc. boog (10:05 AM): Sure, that might work. mroot (10:05 AM): Is there a web service to do that? boog (10:06 AM): There might be. See if you can find one, and let me know if you do. mroot (11:18 AM): Okay. What if there was a comma between the addresses? For example, [email protected],[email protected],[email protected]. mroot (11:19 AM): That should be easy to put in an array? boog (11:22 AM): Couldn't find a web service? Hmm... wait, where did those commas come from? mroot (11:24 AM): I just copy/pasted them from debug console. That's what my string has. boog (11:25 AM): Oh, I see, they make it easier to read. Good thinking! So if there's no web service already, you should write your own. It can start out by removing the commas, then search on .net, .com, etc.! Think you can pull it off? mroot (11:25 AM): Sure, no problem... boog: (11:25 AM): Excellent.

    On the plus side, he'd never ask for my help again.

    You messed up your name in the last line of the instant message. The extra : ruined it.

    Oh wow, you've got OCD too?

    Honestly, who the hell notices something like that, and furthermore, who the hell pays such close attention to boogs comments!? :)

  • (cs) in reply to ubersoldat
    ubersoldat:
    Nothing better than a junior with superiority complex.
    But this junior IS superior. For him to think otherwise would technically be a delusion.
  • (cs) in reply to C-Octothorpe
    C-Octothorpe:
    Power Troll:
    Love the python fanboy whose hardest coding problem was probably scraping HTML off of a website.

    re: TFA, I'm very suspicious of this. The if-statement means he'll only get the first result of the query each time the method is called, so it'd be impossible to get different email addresses without some manipulation of the database between calls.

    Also, no call to rs.close()? Article is obviously BS.

    Addendum:

    boog:
    mroot (10:03 AM): Got a problem for ya... mroot (10:03 AM): Any idea how I can parse a string of email addresses like this: [email protected]@[email protected]? mroot (10:04 AM): I need them separated in an array. I was thining of looking for .net, .com, etc. boog (10:05 AM): Sure, that might work. mroot (10:05 AM): Is there a web service to do that? boog (10:06 AM): There might be. See if you can find one, and let me know if you do. mroot (11:18 AM): Okay. What if there was a comma between the addresses? For example, [email protected],[email protected],[email protected]. mroot (11:19 AM): That should be easy to put in an array? boog (11:22 AM): Couldn't find a web service? Hmm... wait, where did those commas come from? mroot (11:24 AM): I just copy/pasted them from debug console. That's what my string has. boog (11:25 AM): Oh, I see, they make it easier to read. Good thinking! So if there's no web service already, you should write your own. It can start out by removing the commas, then search on .net, .com, etc.! Think you can pull it off? mroot (11:25 AM): Sure, no problem... boog: (11:25 AM): Excellent.

    On the plus side, he'd never ask for my help again.

    You messed up your name in the last line of the instant message. The extra : ruined it.

    Oh wow, you've got OCD too?

    Honestly, who the hell notices something like that, and furthermore, who the hell pays such close attention to boogs comments!? :)

    YHBT. YHL. HAND.

  • (cs) in reply to EmperorOfCanada
    EmperorOfCanada:
    I am repeatedly shocked by the number of programmers who can't program. I once tried to explain Associative arrays to two programmers who had graduated from Waterloo. I used every synonym and semi synonym that I could come up with: Key value pairs, hashes, thing where you put in a string and it stores and retrieves a value, etc. They both sat there and looked at me blankly. So then I had to give a tutorial on the whole concept with them leaving the meeting thinking that I had made my code unnecessarily complex and could have just used a bunch of arrays and sorted/searched through them. But my favorite programmers are the one tool programmers; especially if the tool is obscure such as the Natural language or Adabas.
    LIKE!!!!
  • Ken B. (unregistered) in reply to tehR
    tehR:
    Derp:
    It just dawned on me that the only things that make these "WTFs" is the level of impatience or frustration the "victim" gains in each story.

    Most of us can probably laugh and live with little derpy moments like this.

    Apparently, though, folks like jbanic need to "regain their cool" frist. Maybe the short fuse is the difference between a good job and a bad one.

    Agreed. From a technical perspective nothing in the supplied code was particularly WTFy. Story reduces to a guy who has existing code but wants it to do a bit more, yet doesn't know right off the bat (the horror!) how to get it done.

    Junior dbag, in his infinite wisdom, feels time spent helping a colleague learn something new is an absolute waste of his own life and so has to sign off of AIM in order to cool off and a void a heart attack.

    Classy.

    What you're forgetting is that this is not a "one off" thing. "jbanic" is dealing with stuff like this day in and day out. "mroot" already he knows he wants the list as an array. And, rather than simply putting things into the array, he decides to go the "let's mangle the list into one big mess, and then try to unmangle it later" route. And, of course, when asking for help, tells the person who can help him that all he has is the mangled set of things in a single string.

    Captcha: appellatio... The real reason Eve got kicked out of Eden.

  • (cs) in reply to DrewE (no relation to Drew)
    DrewE (no relation to Drew):
    Drew:
    Couldn't you just instanciate an array with the rs.size() and put them in without having to deal with a list?

    String[] toBeReturned = new String[rs.size()]; for (int i = 0; rs.next(); i++) { toBeReturned[i] = rs.getString("email"); }

    That would work if ResultSet had a size() method. Alas, it doesn't (assuming this is Java, as it appears to be), presumably because there's no guarantee that the underlying database has determined how many results there are before it can start providing some to you.

    Stuffing the results into an ArrayList or similar would work pretty nicely.

    The count methods on recordset classes are only accurate once the entire set has been iterated.

  • (cs) in reply to Nagesh
    Nagesh:
    Just sayin':
    unregistered person:
    Nagesh:
    public class StringSplit {
      public static void main(String args[]) throws Exception{
        String testString = "Real-How-To";
        System.out.println(
            java.util.Arrays.toString(
            testString.split("-")
        ));
    
    // output : [Real, How, To]
    }
    

    }

    mroot really needs to attend one short course in java. java is most user friendly REAL PROGRAMMING language. of course everyone think VB6 is most user friendly but keep in mind I use term "REAL" here. there are sevreal java course available online. i think he can contact me if he cannot google.

    Sure, Java's a "most user friendly REAL PROGRAMMING language" compared to... say... Python?

    Same code:

        print "Real-how-to".split('-')

    I like Python, but once a project gets above 3 members and ~7K lines, unless I've been able to very carefully select the other 2 programmers, I'd much rather the project be in Java (even if that does make it 12K lines instead).

    The tooling is nicer, and although this can be mitigated by writing proper automated unit tests, it is much easier to debug problems in unfamiliar code.

    Agreed++

    Still confident in your opinion, Just Sayin?

  • Ken B. (unregistered) in reply to Haero
    Haero:
           PreparedStatement ps  = connection.prepareStatement("SELECT * FROM email_contact");
           ResultSet rs = ps.executeQuery();
           System.out.print("<email_list>\n");
           while (rs.next()) {
                String email = rs.getString("email");
                System.out.print("<email>"+email+"</email>\n");
           }
           System.out.print("</email_list>\n");
    
    I like this one better, many interfaces can already grab this as an array.
    FTFY.
  • C-Octothorpe (unregistered) in reply to hoodaticus
    hoodaticus:
    C-Octothorpe:
    Power Troll:
    Love the python fanboy whose hardest coding problem was probably scraping HTML off of a website.

    re: TFA, I'm very suspicious of this. The if-statement means he'll only get the first result of the query each time the method is called, so it'd be impossible to get different email addresses without some manipulation of the database between calls.

    Also, no call to rs.close()? Article is obviously BS.

    Addendum:

    boog:
    mroot (10:03 AM): Got a problem for ya... mroot (10:03 AM): Any idea how I can parse a string of email addresses like this: [email protected]@[email protected]? mroot (10:04 AM): I need them separated in an array. I was thining of looking for .net, .com, etc. boog (10:05 AM): Sure, that might work. mroot (10:05 AM): Is there a web service to do that? boog (10:06 AM): There might be. See if you can find one, and let me know if you do. mroot (11:18 AM): Okay. What if there was a comma between the addresses? For example, [email protected],[email protected],[email protected]. mroot (11:19 AM): That should be easy to put in an array? boog (11:22 AM): Couldn't find a web service? Hmm... wait, where did those commas come from? mroot (11:24 AM): I just copy/pasted them from debug console. That's what my string has. boog (11:25 AM): Oh, I see, they make it easier to read. Good thinking! So if there's no web service already, you should write your own. It can start out by removing the commas, then search on .net, .com, etc.! Think you can pull it off? mroot (11:25 AM): Sure, no problem... boog: (11:25 AM): Excellent.

    On the plus side, he'd never ask for my help again.

    You messed up your name in the last line of the instant message. The extra : ruined it.

    Oh wow, you've got OCD too?

    Honestly, who the hell notices something like that, and furthermore, who the hell pays such close attention to boogs comments!? :)

    YHBT. YHL. HAND.

    Good god, please don't make that a meme...

    Do a bert glanstron, or a paula bean, but for the love of all that is good, don't let that be a meme on this site...

  • Jules Winnfield (unregistered) in reply to Warren
    Warren:
    I can shortcut the entire comments thread

    I see what you did there. LOL

  • Phong (unregistered) in reply to frist?

    Seriously? Logging off fuming and needing to cool off after 30 seconds of questions from a newbie? That's the real WTF here.

  • (cs) in reply to C-Octothorpe
    C-Octothorpe:
    Good god, please don't make that a meme...

    Do a bert glanstron, or a paula bean, but for the love of all that is good, don't let that be a meme on this site...

    It's so completely retarded, I felt I just had to make fun of it through repetition. But I agree - it sucks too much to continue repeating.

  • Ken B. (unregistered) in reply to DrewE (no relation to Drew)
    DrewE (no relation to Drew):
    Drew:
    Couldn't you just instanciate an array with the rs.size() and put them in without having to deal with a list? ...
    That would work if ResultSet had a size() method. Alas, it doesn't (assuming this is Java, as it appears to be), presumably because there's no guarantee that the underlying database has determined how many results there are before it can start providing some to you.
    Well, the obvious solution to that is to simply execute this first:
    SELECT count(*) as NumberOfRows FROM email_contact
    Why, no, I've never heard of this "race condition" thing of which you speak. Why do you ask?
  • C-Octothorpe (unregistered) in reply to Phong
    Phong:
    Seriously? Logging off fuming and needing to cool off after 30 seconds of questions from a newbie? That's the *real* WTF here.

    That troll attempt has already been done... Please try and keep up.

  • (cs) in reply to Phong
    Phong:
    Seriously? Logging off fuming and needing to cool off after 30 seconds of questions from a newbie? That's the *real* WTF here.
    It was a senior dev; the guy answering him was the newbie.

    The real WTF is reading comprehension or the lack thereof.

  • Phong (unregistered) in reply to Ken B.
    Ken B.:
    tehR:
    Derp:
    It just dawned on me that the only things that make these "WTFs" is the level of impatience or frustration the "victim" gains in each story.

    Most of us can probably laugh and live with little derpy moments like this.

    Apparently, though, folks like jbanic need to "regain their cool" frist. Maybe the short fuse is the difference between a good job and a bad one.

    Agreed. From a technical perspective nothing in the supplied code was particularly WTFy. Story reduces to a guy who has existing code but wants it to do a bit more, yet doesn't know right off the bat (the horror!) how to get it done.

    Junior dbag, in his infinite wisdom, feels time spent helping a colleague learn something new is an absolute waste of his own life and so has to sign off of AIM in order to cool off and a void a heart attack.

    Classy.

    What you're forgetting is that this is not a "one off" thing. "jbanic" is dealing with stuff like this day in and day out. "mroot" already he knows he wants the list as an array. And, rather than simply putting things into the array, he decides to go the "let's mangle the list into one big mess, and then try to unmangle it later" route. And, of course, when asking for help, tells the person who can help him that all he has is the mangled set of things in a single string.

    Yeah, well, adding the fact that it's the end of his world is completely unnecessary and should be left out unless you want to add the entire context every time. It detracts from the actual story, especially when the story isn't noteworthy to begin with.

Leave a comment on “The Shortcut Guy”

Log In or post as a guest

Replying to comment #:

« Return to Article