• Ben (unregistered) in reply to JPhi
    JPhi:
    Ben:
    Wait a second.. Isn't that wrong anyway? private static boolean isNotAllXs( String s ) { StringBuffer test = new StringBuffer( s.trim() ); boolean retVal = false; for ( int i = 0; i < test.length(); i++ ) { if ( test.charAt( i ) != 'X' ) { retVal = true; } } return retVal; }

    Wouldn't that mean that a String s which ends with an X would return false too? (which means that it's all Xes) so isNotAllXs("ASDFX"); would return false, just as isNotAllXs("XX[...]XXXX"); Sorry if i'm wrong about that.

    If you're trolling, then way to go, but otherwise, yes, you are wrong about that. retVal is initialized to false, and as soon as any one character is NOT AN X, it is set to true. No where in the code does retVal get set back to false if there is an X. The only WTF is that the code should look more like this:

    private static boolean isNotAllXs( String s )
    {
       StringBuffer test = new StringBuffer( s.trim() );
    
       for ( int i = 0; i < test.length(); i++ )
       {
          if ( test.charAt( i ) != 'X' )
          {
             return true;
          }
       }
          return false;
    }
    

    That way as soon as a non-X is found, the comparison is done instead of checking a bunch of chars that don't matter anymore...

    Not trolling at all (but as said just some seconds ago):

    If test.charAt( i ) is not an X, retval is set to true indeed. so if the first character (test.charAt(0)) is not an X, retval is being set correctls. But the loop continues for the whole string length (e.g. ASDFX) For each character of the string, the check is being done. Which means, that after the last check (the X), retval will be set to false, which will be returned, since i < test.length() does not apply any more.

    About your solution: That's better, since the loop breaks and true is returned, as soon as a single letter in the string is not an X.

  • Ben (unregistered)

    Gosh.. now i saw it. Sorry guys. (have been looking onto code too much today i guess)

  • (cs) in reply to Ben
    Ben:
    Ben:
    Wait a second.. Isn't that wrong anyway? private static boolean isNotAllXs( String s ) { StringBuffer test = new StringBuffer( s.trim() ); boolean retVal = false; for ( int i = 0; i < test.length(); i++ ) { if ( test.charAt( i ) != 'X' ) { retVal = true; } } return retVal; }
    ... But the loop continues for the whole string length (e.g. ASDFX) For each character of the string, the check is being done. Which means, that after the last check (the X), retval will be set to false, which will be returned, since i < test.length() does not apply any more.
    OK, now you *HAVE* to be trolling. Either that or you have special superhuman vision that can see assignment statements that aren't even present in the code! Well done you!

    Append: ah, must've cross posted. I completely understand the too tired to read code thing...

  • Wretch (unregistered)

    I suppose separating the words on different rows like that would allow you to link each first letter of each word to the acronym. That way you could create output like "IBM (INTERNATIONAL BUSINESS MACHINES CORPORATION)", that would otherwise be difficult if it was stored as a single string. The whole delimiter thing is crap though.

  • (cs) in reply to Voodoo Coder
    Voodoo Coder:
    rbonvall:
    The codez will fail for the AXMD (Association of XXX Movie Directors).

    A workaround for this would be to check whether the delimiter has an even ABBR_IDX.

    It wouldn't fail on AXMD. Take a closer look at it...it actually works pretty well for to check for an all-x string. Even if the last character were X it would work fine...

    1. Yeah it would... It would split the acronym into separate strings: "Association of" and "Movie Directors"

    A sweet work around would be to write a function which acronymizes the returned string and checks it against the original acronym to make sure they match.

    1. Also, while it does seem to correctly check for all X's, keep in mind that it's not "correct". At the very least, it should break from the loop as soon as it finds any non-X character.

    2. You can't check the ID for evenness because when you get to the first acronym that doesn't have any delimiters, then the following acronym will start in an even row, and its XXX's will be in odd rows.

  • (cs) in reply to JPhi
    JPhi:
    Ben:
    Wait a second.. Isn't that wrong anyway? ...

    If you're trolling, then way to go, but otherwise, yes, you are wrong about that. retVal is initialized to false, and as soon as any one character is NOT AN X, it is set to true. No where in the code does retVal get set back to false if there is an X. The only WTF is that the code should look more like this:

    private static boolean isNotAllXs( String s )
    {
       StringBuffer test = new StringBuffer( s.trim() );
       for ( int i = 0; i < test.length(); i++ )
       {
          if ( test.charAt( i ) != 'X' )
          {
             return true;
          }
       }
          return false;
    }
    

    That way as soon as a non-X is found, the comparison is done instead of checking a bunch of chars that don't matter anymore...

    Don't forget about empty strings! Still, I like a lot potential abuse of the method name:

    if (false == isNotAllXs(someValue)) ...
    
  • annymouse (unregistered) in reply to Wretch

    mebbe they wanted to be able to look up any acronym a particular word participates in.

    the delimiter thing surely is a wtf, though.

    it would, however, be interesting for the author or someone else to explain how the table design violates any particular normal form.

  • (cs) in reply to zolf
    zolf:
    Still, I like a lot potential abuse of the method name:
    if (false == isNotAllXs(someValue)) ...
    
    Because comparing boolean variables / return values to boolean literals in if statements is never a WTF in itself... *sigh*
  • (cs) in reply to annymouse
    annymouse:
    mebbe they wanted to be able to look up any acronym a particular word participates in.
    Because "WHERE ABBR_TXT LIKE '%INPUT%'" is *such* a pain...
  • (cs) in reply to Nath3an
    Nath3an:
    The real WTF is that IBM, LA, WCAB and WTF are not acronyms. They are abbreviations.

    An acronym is an acrostic name. For example:

    International Business Machines

    or

    Workers Compensation Appeal Board

    An abbreviation is a shortened version of a word. For example:

    St. (instead of Saint, or Street) Dr. (instead of Doctor, or Drive) Fla. (instead of Florida) abbr. (instead of abbreviation)

  • (cs) in reply to Donal

    I would love to see what this guy would have come up with if someone had asked him for something like "Hey, you've got that AJAX stands for 'Asynchronous JavaScript and XML' but we need to know if the acronym contains an acronym, and if so, what it stands for."

  • Crabs (unregistered) in reply to annymouse
    mebbe they wanted to be able to look up any acronym a particular word participates in.

    so you store it sanely and use LIKE '% FOO %'.

    it would, however, be interesting for the author or someone else to explain how the table design violates any particular normal form.

    It doesn't break any normal form, because as far as I can tell there are no non-trivial functional dependencies. A table with no functional dependencies is basically useless.

  • (cs) in reply to Mhendren
    Mhendren:
    Nath3an:
    The real WTF is that IBM, LA, WCAB and WTF are not acronyms. They are abbreviations.

    An acronym is an acrostic name. For example:

    International Business Machines

    or

    Workers Compensation Appeal Board

    An abbreviation is a shortened version of a word. For example:

    St. (instead of Saint, or Street) Dr. (instead of Doctor, or Drive) Fla. (instead of Florida) abbr. (instead of abbreviation)

    actually, everything you put is an abbreviation. acronyms are a type of abbreviation, as are initialisms. Nath3an is correct. Acronyms are pronounced as words, like AJAX, SCUBA and RADAR. Initialisms have there letters pronounced, like IBM, WWW.

  • AF (unregistered) in reply to Mhendren
    Mhendren:
    Nath3an:
    The real WTF is that IBM, LA, WCAB and WTF are not acronyms. They are abbreviations.

    An acronym is an acrostic name. For example: <snip> An abbreviation is a shortened version of a word. For example:

    <snip>
    If you want to be fussy about it (and I don't, but here goes), IBM is an initialisation because it doesn't form a word, and all the examples are abbreviations because they shorten the original word or phrase.
  • Eric (unregistered) in reply to Nath3an
    Nath3an:
    The real WTF is that IBM, LA, WCAB and WTF are not acronyms. They are abbreviations.
    Well, let's see!

    Acronym: A word formed from the initial letters of a multi-word name.

    I'm afraid I must disagree.

  • Todo: register username (unregistered) in reply to method1
    method1:
    GalacticCowboy:
    What do you call a man with no arms or legs, floating in the ocean?

    Bob

    HIS NAME WAS ROBERT PALSEN! HIS NAME WAS ROBERT PALSEN! HIS NAME WAS ROBERT PALSEN!

  • Eric (unregistered) in reply to campkev
    campkev:
    Mhendren:
    Nath3an:
    The real WTF is that IBM, LA, WCAB and WTF are not acronyms. They are abbreviations.

    An acronym is an acrostic name. For example:

    International Business Machines

    or

    Workers Compensation Appeal Board

    An abbreviation is a shortened version of a word. For example:

    St. (instead of Saint, or Street) Dr. (instead of Doctor, or Drive) Fla. (instead of Florida) abbr. (instead of abbreviation)

    actually, everything you put is an abbreviation. acronyms are a type of abbreviation, as are initialisms. Nath3an is correct. Acronyms are pronounced as words, like AJAX, SCUBA and RADAR. Initialisms have there letters pronounced, like IBM, WWW.

    The dispute rages on!

  • Niels (unregistered)

    Apparently the author of isNotAllXs( ... ) failed to notice that they may just as well have checked if the ABBR_IDX is an odd or even value. ;)

  • annymouse (unregistered) in reply to JimM
    JimM:
    annymouse:
    mebbe they wanted to be able to look up any acronym a particular word participates in.
    Because "WHERE ABBR_TXT LIKE '%INPUT%'" is *such* a pain...

    and scales sooooo well, since it's an expression that can't use an index...

  • (cs) in reply to Eric
    Eric:
    Nath3an:
    The real WTF is that IBM, LA, WCAB and WTF are not acronyms. They are abbreviations.
    Well, let's see!

    Acronym: A word formed from the initial letters of a multi-word name.

    I'm afraid I must disagree.

    the debate is whethere IBM qualifies as a word, since it isn't pronounced like a word, like SCUBA and RADAR are

  • Anonymous (unregistered) in reply to campkev
    campkev:
    Eric:
    Nath3an:
    The real WTF is that IBM, LA, WCAB and WTF are not acronyms. They are abbreviations.
    Well, let's see!

    Acronym: A word formed from the initial letters of a multi-word name.

    I'm afraid I must disagree.

    the debate is whethere IBM qualifies as a word, since it isn't pronounced like a word, like SCUBA and RADAR are

    As Eric pointed out earlier, there are better men than us arguing about this. So maybe we should just stick to arguing about IT.

  • (cs) in reply to JimM
    JimM:
    Maybe the person who p[ut the Xx30 line in weas actually just completing a normal row of Data Entry. How do we know that the original, business defined meaning of LA wasn't "Los Angeles XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"?

    OK, I'll give you that would be a WTF in itself, but who knows...

    If you could do me a favor and stop trying to communicate at people, that would be great, m'kay?

  • Zach Bora (unregistered)

    Why not juste replace X and x in the string and then check to see if it's different than "" ? I don't know how fast that would be but maybe it's faster?

  • (cs)

    They used 30 X's so when the computer is looking through the table it won't lose it's place.

  • (cs) in reply to Anonymous
    Anonymous:
    campkev:
    Eric:
    Nath3an:
    The real WTF is that IBM, LA, WCAB and WTF are not acronyms. They are abbreviations.
    Well, let's see!

    Acronym: A word formed from the initial letters of a multi-word name.

    I'm afraid I must disagree.

    the debate is whethere IBM qualifies as a word, since it isn't pronounced like a word, like SCUBA and RADAR are

    As Eric pointed out earlier, there are better men than us arguing about this. So maybe we should just stick to arguing about IT.

    It's important to argue the usage of words, because there already adequate words for describing abbreviations and initialisations, and I for one would like to keep acronym true to its linguistic roots (akron [point or tip], onyma [name]).

    If people are going to say damn fool things like "IBM" is a word (how the hell do you pronounce that? Ibbum? Ibeem?) then the argument will carry on!

  • Mike (unregistered) in reply to wee
    wee:
    JimM:
    Maybe the person who p[ut the Xx30 line in weas actually just completing a normal row of Data Entry. How do we know that the original, business defined meaning of LA wasn't "Los Angeles XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"?

    OK, I'll give you that would be a WTF in itself, but who knows...

    If you could do me a favor and stop trying to communicate at people, that would be great, m'kay?

    Feel free to communicate at me Jim my friend, because I'm not an asshole.
  • Al (unregistered)

    Why is "abbreviation" such a long word?

  • Nobody (unregistered)

    Its amazing that people will go to the trouble to correct other people here and manage to be wrong themselves. Pointing out that other people are wrong is apparently more important than being right yourself.

    It is not an acronym unless you pronounce it like a word and not a series of letters. So for example:

    UN is an abbreviation NATO is an acronym

    IBM is an abbreviation SCUBA is an acronym

  • (cs) in reply to JimM
    JimM:
    annymouse:
    mebbe they wanted to be able to look up any acronym a particular word participates in.
    Because "WHERE ABBR_TXT LIKE '%INPUT%'" is *such* a pain...

    That's not indexable in the same way that this guy's design is. I believe that would result in a full table scan.

    Some of the DBMS (like mysql) have pretty good text indexers built in, but there's no standard -- maybe this guy was trying to stay platform-agnostic.

    Zach Bora:
    Why not juste replace X and x in the string and then check to see if it's different than "" ? I don't know how fast that would be but maybe it's faster?

    It would be fewer lines of code, but it would obviously be much slower. Or were you kidding?

    http://www.joelonsoftware.com/articles/fog0000000319.html

  • (cs) in reply to Ben
    Ben:
    Gosh.. now i saw it. Sorry guys. (have been looking onto code too much today i guess)
    <trump>You're fired.</trump>
  • Bob (unregistered) in reply to Scott
    Scott:
    Testing each character one by one to see whether it is an "X" or not might seem odd at first until you realize that's how the machine code does it anyway.

    By explicitly calling out the logic you make it more obvious to future readers what's going on, and you also provide opportunities for the compiler to optimize.

    Nice try. The real WTF is that no one took the bait.

  • The Wanderer (unregistered) in reply to Quango
    Quango:
    The real WTF:

    "At Chris N.'s employer, they needed the ability to look up acronyms' meanings"

    It's called Google.

    Actually, I think it's called VERA.

  • Weps (unregistered)

    if the guy didn't know how to insert a space then the design isn't that bad.

  • (cs)

    We here at 30X Corp. would like to become a client, just to destroy your database.

  • IMSoP (unregistered) in reply to Mr B
    Mr B:
    It's important to argue the usage of words, because there already adequate words for describing abbreviations and initialisations, and I for one would like to keep acronym true to its linguistic roots (akron [point or tip], onyma [name]).

    If people are going to say damn fool things like "IBM" is a word (how the hell do you pronounce that? Ibbum? Ibeem?) then the argument will carry on!

    Why does something need to a) be pronounceable to be a word? b) be a word to be a "name"? c) need to be a "name" itself to be "true to [the word's] linguistic roots", rather than simply composed of the "tips" of many existing "names"?

    Note that I consider these questions largely hypothetical, since the actual point of language is not to adhere to some pseudo-etymological logic, but to communicate. Many people are quite happy to use "acronym" to cover both pronouncable and non-pronouncable words of this type (pronouncable by whom, anyway?), and wouldn't recognise any extra information in being told something was in fact an "initialism" instead.

    Incidentally, I wonder if it's a sign of the relative rarity of the word "initialism" that you mis-typed it as "initialisation"? (More likely you've just been coding too many constructors today, but it's an unfortunate mistake.)

  • Harrow (unregistered) in reply to Niels
    Niels:
    Apparently the author of isNotAllXs( ... ) failed to notice that they may just as well have checked if the ABBR_IDX is an odd or even value. ;)
    There is no requirement or guarantee that distinct ABBR_IDX values are contiguous. They could all be, e.g., even.

    -Harrow.

  • (cs) in reply to Voodoo Coder
    Voodoo Coder:
    Not one to buy into that whole normalization thing, he created a table like the following:

    You obviously aren't familiar with -2nd Normal Form.

    I was about to point out that this had nothing to do with <blah> and then spied the negative sign. Subtle and well done sir, you did make the coffee come out my nose.

  • Alex (unregistered) in reply to Voodoo Coder

    I think the real question is, why use 2nd normal form and not 3rd given today's database management systems such as SQL? There's also 1st normal form, as well as 4th, but there's a very good business reason we all mostly use 3rd and if someone doesn't know that reason, we say they don't know normalization as well as they should.

  • (cs) in reply to Bob
    Bob:
    Scott:
    Testing each character one by one to see whether it is an "X" or not might seem odd at first until you realize that's how the machine code does it anyway.

    By explicitly calling out the logic you make it more obvious to future readers what's going on, and you also provide opportunities for the compiler to optimize.

    Nice try. The real WTF is that no one took the bait.

    I have to admit that I was tempted, if only to point out that you couldn't have an abbreviation where one of the parts consisted of purely X's (say you'd like TXF to mean The X Files). But you're right, this was pure flame bait.

    I do admire the reasonable sounding insanity of the justification paragraph: by explicitly ... It sounds so wonderful, it just has to be true...

  • Dirk Diggler (unregistered) in reply to Alex
    Alex:
    I think the real question is, why use 2nd normal form and not 3rd given today's database management systems such as SQL? There's also 1st normal form, as well as 4th, but there's a very good business reason we all mostly use 3rd and if someone doesn't know that reason, we say they don't know normalization as well as they should.
    What's the Normalization level where letters are in one table words are in another, sentences are in a third and full comments in a fourth?
  • (cs) in reply to campkev
    campkev:
    Eric:
    Nath3an:
    The real WTF is that IBM, LA, WCAB and WTF are not acronyms. They are abbreviations.
    Well, let's see!

    Acronym: A word formed from the initial letters of a multi-word name.

    I'm afraid I must disagree.

    the debate is whethere IBM qualifies as a word, since it isn't pronounced like a word, like SCUBA and RADAR are

    You can't pronounce IBM? You can communicate verbally I assume. I mean it is pretty simple to pronounce. It has three syllables.

  • The Pig Go (unregistered) in reply to Mr B
    Mr B:
    Anonymous:
    campkev:
    Eric:
    Nath3an:
    The real WTF is that IBM, LA, WCAB and WTF are not acronyms. They are abbreviations.
    Well, let's see!

    Acronym: A word formed from the initial letters of a multi-word name.

    I'm afraid I must disagree.

    the debate is whethere IBM qualifies as a word, since it isn't pronounced like a word, like SCUBA and RADAR are

    As Eric pointed out earlier, there are better men than us arguing about this. So maybe we should just stick to arguing about IT.

    It's important to argue the usage of words, because there already adequate words for describing abbreviations and initialisations, and I for one would like to keep acronym true to its linguistic roots (akron [point or tip], onyma [name]).

    If people are going to say damn fool things like "IBM" is a word (how the hell do you pronounce that? Ibbum? Ibeem?) then the argument will carry on!

    NO QUACK

  • (cs) in reply to Mhendren
    Mhendren:
    campkev:
    Eric:
    Nath3an:
    The real WTF is that IBM, LA, WCAB and WTF are not acronyms. They are abbreviations.
    Well, let's see!

    Acronym: A word formed from the initial letters of a multi-word name.

    I'm afraid I must disagree.

    the debate is whethere IBM qualifies as a word, since it isn't pronounced like a word, like SCUBA and RADAR are

    You can't pronounce IBM? You can communicate verbally I assume. I mean it is pretty simple to pronounce. It has three syllables.

    You can't read? I didn't say I couldn't pronounce it, I said it isn't pronounced like a word. When you see the word "can" do you say "see-ay-en" or "kan"?

  • loamaxe (unregistered) in reply to Dirk Diggler
    Dirk Diggler:
    Alex:
    I think the real question is, why use 2nd normal form and not 3rd given today's database management systems such as SQL? There's also 1st normal form, as well as 4th, but there's a very good business reason we all mostly use 3rd and if someone doesn't know that reason, we say they don't know normalization as well as they should.
    What's the Normalization level where letters are in one table words are in another, sentences are in a third and full comments in a fourth?

    That would be -TDWTF Normal Form

  • pants (unregistered)

    I'm still confused as to the part where he needed a database of acronyms.

  • christian (unregistered)

    That database design makes me want to hurt someone. Badly.

  • moshbox (unregistered) in reply to pants
    pants:
    I'm still confused as to the part where he needed a database of acronyms.

    Probably worked in an IBM shop. Back in my Operator days we had a 4" binder dedicated to internal & customer abbreviations. AFAIK, its still up there...

  • DivineGod (unregistered) in reply to Dirk Diggler

    level crazy and the database would consist of these tables:

    Bits: BitID - PK Value - int (if we invent crazy bits)

    Characters: CharID - PK UnicodeName - string Size - int

    CharacterBits: BitID - FK CharID - FK

    Words: WordID - PK WordDefinition : string

    WordCharacters: WordID - FK CharID - FK

    Sentences: SentenceID - PK SentenceDelimiter - CharID FK (delimiter to put at the end)

    SentenceWords: WordID - FK SentenceID - FK

    Paragraps: ParagraphID - PK

    ParagraphSentences: ParagraphID - FK SentenceID - FK

    Chapter: IThinkYouGetTheID : PK etc. etc. ad nauseam.

  • (cs) in reply to campkev
    campkev:
    Mhendren:
    campkev:

    the debate is whethere IBM qualifies as a word, since it isn't pronounced like a word, like SCUBA and RADAR are

    <lame joke>

    You can't read? I didn't say I couldn't pronounce it, I said it isn't pronounced like a word. When you see the word "can" do you say "see-ay-en" or "kan"?

    You can sort-of italicize "like a word" all you like.

    The pronunciation of a word, depends on the word. How do you pronounce pneumatic, knife, or epitome? Using your qualifications none of these are pronounced like the word they spell. The English language (all dialects) has no pretense that the collection of letters you have in the spelling of a word affect the pronunciation of that word. They just weight the possibilities of pronunciation.

    I am merely stating that just because some words are pronounced as their constituent letters, does not mean they are not pronounced like a word. From a certain point of view that is, I can obviously see where you were going with that, and chose to explore an alternative side with minor, admittedly lame, humor not intending to be injurious or otherwise untoward you in any manner.

  • mcwyrm (unregistered) in reply to Mhendren
    campkev:
    You can't read? I didn't say I couldn't pronounce it, I said it isn't pronounced like a word. When you see the word "can" do you say "see-ay-en" or "kan"?
    It seems you have trouble with the spelling, not the pronunciation. That's progress, of a sort.
    Mhendren:
    Using your qualifications none of these are pronounced like the word they spell.
    Not sure what to make of this, but I suspect you're gesturing at the science of phonetics.

    At any rate, just because campkev doesn't like the way it's spelled doesn't mean it isn't a word.

Leave a comment on “Thirty X's”

Log In or post as a guest

Replying to comment #:

« Return to Article