• foo AKA fooo (unregistered) in reply to Jeremy
    Jeremy:
    I use switches pretty sparingly myself, but it's amazing how many switches I see that are like that. Where, for some reason, a huge part of the population treat the default as if it's some kind of "it should never get here but just in case" fallback. It's one of those things I see so often that I can't help but think - wait, am I the one in the wrong there for using the default as an intentional "if not this specific stuff, do this"?

    No, it's the children who are wrong.

    They'd love to have a default branch in an if statement, just so they could write:

    if (cond)
      ...
    else
      ...
    default
      assert ("should never get here");
    
  • foo AKA fooo (unregistered) in reply to chubertdev
    chubertdev:
    So am I the only one thinking that the "Q requires U" comment was in jest, as in it would be something stupid that this person would do?
    Seems I'm getting to good at drive-by trooling ...
  • (cs) in reply to Cbuttius
    Cbuttius:
    The default case maybe covers the blank tile which can be used for any letter so it might be used for a vowel or for a consonant.

    When I play WWF, "QI" comes up very frequently. Especially with my opponent who just loves making 2 letter words. No not parallel ones, just puts down one letter to make a 2 letter word. Or 2 letters making such a word attaching one of them.

    I am also big fan of WWF. John Cena - The Champ is my favorite.

  • (cs) in reply to foo AKA fooo
    foo AKA fooo:
    chubertdev:
    So am I the only one thinking that the "Q requires U" comment was in jest, as in it would be something stupid that this person would do?
    Seems I'm getting to good at drive-by trooling ...

    I think we need to wait for a few dozen more people to weigh in on the situation.

  • (cs)

    And, of course, there is no case conversion. If this is indeed C#, lets hope the user enters everything in lower case.

  • Zog (unregistered) in reply to Matt Westwood

    Neither has 'catch' nor the unfortunate village of 'Ynysybwl' etc...don't get me started on the amazing Georgian language with with consonantal clusters either!

    ps: Actually Welsh has more vowel symbols than English: aeiouwy vs aeiou

  • (cs) in reply to Eh
    Eh:
    I am a new employee for a software company controlled by developers who regard comments and program verbosity as blasphemies. We use Python as the primary development language so pep8 is rigidly and sometimes fanatically adheared to. Almost nothing is commented or documented. Whenever I ask how something work, I get the reply 'just read the code newbie'.((etc))
    As the Agilistas say, "Change your organization... or change your organization." If you can.

    And ask to see their code during the interview.

  • DWalker (unregistered) in reply to Jeff Dege
    Jeff Dege:
    To comment on the actual subject - we've found that putting comments in the code isn't actually very useful, anymore, given our current tooling.

    Our commentary on the code is going into our version control software. And with a decent VCS, it's easy to identify all of the places in the source tree that were modified as a part of a specific change, or to identify which lines in a given file were part of which change.

    So, when I'm looking at a line and I don't understand it, I can easily find out which revision created that line, and what other changes, elsewhere in the code, were made at the same time. And the provides a context that a simple comment in the code cannot.

    Comments aren't there to tell you which revision created the line. They are there to tell you what the purpose (the logical purpose) of the code section is. You know, the business cases, what inputs are expected, what edge cases are being handled or not, and so on.

    When you write a program for the first time, you don't have a revision history. Where do you put comments like (I have done this a few times) "It may appear that optimization XYZ can help here, but in this case, you can't do that for reason ABC"? That doesn't belong in the revision history, it belongs in the code comments.

  • jfh (unregistered) in reply to chubertdev
    chubertdev:
    So am I the only one thinking that the "Q requires U" comment was in jest, as in it would be something stupid that this person would do?

    QED!

  • Kyle Huff (unregistered) in reply to Doozerboy
    Doozerboy:

    in c# it'd be something like

    var exists = myString.IndexOfAny(new []{'a','e','i','o','u'}) != -1;

    STRTOK DOES NOT WORK THAT WAY!

  • Kyle Huff (unregistered) in reply to Schol-R-LEA
    Schol-R-LEA:
    In C, one can (mis-)use strtok() to get the same effect:
        return (strtok(s, "aeiou") != NULL);
    

    It isn't what the function is meant for, but it will do the job. Seriously, how hard is that?

    I meant this one, of course.

  • Bruce Johnson (unregistered) in reply to win

    I have a chocolate lab (sitting at my feet as I type this). She has no problems coding (well, to be fair, having to use the shift key to get the curly brace is challenging, so she prefers to write in Visual Basic). But ask her to perform functional decomposition on even the most basic business process and all I get is her cocking her head at me and giving me a "you're kidding, right?" look.

  • Reductio Ad Ridiculousum (unregistered) in reply to Davio
    Davio:
    I refuse to accept that a word is an actual word if it doesn't contain at least one vowel.
    Hmm... that's an interesting idea.
  • OldPeter (unregistered)

    The question was, why would you want to search for vowels in a word? I had to, when it was just 1980, when I had to tinker my own word processor on my 8-bitter, and wanted to have some help for hyphenation. In that procedure, finding a vowel is your first step.

    But why only aeiou as vowels? That's missing a lot. In english, also y often serves as a vowel ("system"). In other languages, like my mother tongue german, there are a lot more: äöü. And please don't ignore accented vowels in french or italian (be aware that those umlaut dots before don't count as "accents").

  • Butthats 4Eva (unregistered)
    Now this isn't all bad. Because the developer (who is no longer with Roger's company)

    The "developer".

  • nameyour (unregistered)
    //this creates my "extraBool" which is a fantastic way of handling additional //logics so that as well as true & false, we can also have like no value string
    I think a part of my brain committed suicide after reading this.
  • (cs)

    Vowels, etc...

    What is needed is a marriage between Hawaiian (vowels, we got 'em) and Polish (buy me a vowel). One has a surplus, the other has a deficit. As for the program, it's terrible!!

  • q.kontinuum (unregistered) in reply to giammin
    I can't believe this is real
    Because it isn't. It's all strings, even the booleans.
  • q.kontinuum (unregistered) in reply to anon
    We just had a guy come (and go) that wouldn't even have been able to produce this.

    That doesn't mean much. I wouldn't have been able to twist my mind enough to produce that. Not enough hard drugs available on this planet.

  • cyborg (unregistered)

    I just want to know why everything that's already as string needs .ToString().

    Is that too much to ask?

  • (cs) in reply to Flabberghasted
    Flabberghasted:
    In Java this can be done in one line: org.apache.commons.lang.StringUtils.containsAny(theword, "aeiou");
    Or maybe you should read the JavaDocs a bit better, and simply use the standard Java library, instead of relying on some external dependency.

    theword.toLowerCase().matches( ".[aeiou]." )

    As for the special cases of 'y', simply do not certify this algorithm for use with Welsh. That should solve that.

  • QJo (unregistered) in reply to foo AKA fooo
    foo AKA fooo:
    Jeremy:
    I use switches pretty sparingly myself, but it's amazing how many switches I see that are like that. Where, for some reason, a huge part of the population treat the default as if it's some kind of "it should never get here but just in case" fallback. It's one of those things I see so often that I can't help but think - wait, am I the one in the wrong there for using the default as an intentional "if not this specific stuff, do this"?

    No, it's the children who are wrong.

    They'd love to have a default branch in an if statement, just so they could write:

    if (cond)
      ...
    else
      ...
    default
      assert ("should never get here");
    

    Many companies (sensibly, to my mind) make the specification in their code standards that all switch constructs have a default branch. If you must use switches, then it's a good habit to have.

    It can of course conveniently be used as a parameter range check: if your method / function / subroutine basically is a switch statement, then the "default" can conveniently be used as the sanity check on the input parameters.

    There are other advantages to this approach, whose cataloguing I will leave as an exercise for the student.

  • QJo (unregistered) in reply to Reductio Ad Ridiculousum
    Reductio Ad Ridiculousum:
    Davio:
    I refuse to accept that a word is an actual word if it doesn't contain at least one vowel.
    Hmm... that's an interesting idea.

    Russian has several words which are vowel-less: "в" and "с" come immediately to mind (pronounced "və" and "sə") respectively.

  • acko (unregistered)

    Everybody was so bussy reading comments, so this almost left unnoticed ...

    catch (Exception) { return "error unknown".ToString(); }

    Briliant xD

  • Pete (unregistered)

    This is an example of why unittesting is necessary in any language - so that at least you catch cases where a function does something completely different from your expectations

  • nizzle (unregistered) in reply to foo AKA fooo

    Of course, TRWTF in such a case would be an assertion on a string literal. Since the pointer isn't NULL, the code would keep happily chugging along!

    Although a language in which a default branch in an if-statement existed, the behaviour of assert() would probably be defined as such:

    #define assert(x) \
            if (!(rand() ^ (x))) exit(EXIT_FAILURE);
    
  • gnasher729 (unregistered) in reply to foo AKA fooo

    [quote user="foo AKA fooo"]They'd love to have a default branch in an if statement, just so they could write:

    if (cond)
      ...
    else
      ...
    default
      assert ("should never get here");
    
    [/quote]

    That assert is rather pointless. The pointer "should never get here" will be converted to a "true" value so that assert will do nothing. Much better to write

    if (cond)
      ...
    else
      ...
    default
      assert (0 && "should never get here");
    
    [/quote]
  • HandsomeStan (unregistered) in reply to Schol-R-LEA
    Schol-R-LEA:
    In C, one can (mis-)use strtok() to get the same effect:
        return (strtok(s, "aeiou") != NULL);
    

    It isn't what the function is meant for, but it will do the job. Seriously, how hard is that?

    Works great unless I pass in "aeiou" in which case it fails ...

  • fatfacemcfattypants (unregistered)

    return "error unknown".ToString();

    Is there any point to this?

  • Anonymouse (unregistered) in reply to Eh

    Surely any PEP8 checker would invalidate code without blank lines in the correct locations.

    pep8.py for instance moans if two blank lines are not left before a class definition, and it one line is not left between methods.

  • (cs)

    He could tell whether Y was a vowel if he weren't looking at only one letter. Y is a vowel if it neither precedes nor follows a vowel (as in "crypts", "rely" and "Ylvis", and in French, "il y a"), and this is probably true in all languages with a Latin-based alphabet.

  • Reductio Ad Ridiculousum (unregistered) in reply to gnasher729
    foo AKA fooo:
    They'd love to have a default branch in an if statement, just so they could write:
    if (cond)
      ...
    else
      ...
    default
      assert ("should never get here");
    
    I think it could be the next major breakthrough in software engineering. We could replace various constructs with the "Consider" statement. An example pseudocode would be:
    Consider "x" 
      On the one hand, I want you to do what I told you,
      on the other hand, I want you to do what I think I want,
      on the third hand, I want you do what I meant.
    
  • (cs) in reply to D-Coder
    D-Coder:
    Eh:
    I am a new employee for a software company controlled by developers who regard comments and program verbosity as blasphemies. We use Python as the primary development language so pep8 is rigidly and sometimes fanatically adheared to. Almost nothing is commented or documented. Whenever I ask how something work, I get the reply 'just read the code newbie'.((etc))
    As the Agilistas say, "Change your organization... or change your organization." If you can.

    And ask to see their code during the interview.

                               

  • Jeff Dege (unregistered) in reply to DWalker

    Comments aren't needed to tell me which revision created the line, the revision control software does that.

    When I write a program for the first time, I don't have a revision history, but I don't have any functionality, either. My first commit will be either an empty project, or a project that contains a do-nothing program. Every piece of functionality that is added will be added as a separate commit, and the revision control software will link the changes that implemented that piece of functionality with the commit comment.

    There are times comments are useful, or even needed. But I see that as primarily when there is something going on that wouldn't be obvious to a maintenance programmer reading through the code.

  • (cs)
    // converted all variables to strings since I read they are immutable
    // and immutable means that they can't be changed
    // and I don't want anyone changing my code
    
  • ph (unregistered) in reply to Doozerboy
    Doozerboy:
    Flabberghasted:
    In Java this can be done in one line: org.apache.commons.lang.StringUtils.containsAny(theword, "aeiou");

    in c# it'd be something like

    var exists = myString.IndexOfAny(new []{'a','e','i','o','u'}) != -1;

    For completeness, in C++ it would be:

    bool exists = myString.find_first_of("aeiouAEIOU")!=myString.npos;
    
  • (cs) in reply to Jeff Dege
    Jeff Dege:
    Comments aren't needed to tell me which revision created the line, the revision control software does that.

    When I write a program for the first time, I don't have a revision history, but I don't have any functionality, either. My first commit will be either an empty project, or a project that contains a do-nothing program. Every piece of functionality that is added will be added as a separate commit, and the revision control software will link the changes that implemented that piece of functionality with the commit comment.

    There are times comments are useful, or even needed. But I see that as primarily when there is something going on that wouldn't be obvious to a maintenance programmer reading through the code.

    This guy has got to be trolling. Either that or he's a retard.

  • (cs)

    why did they take out Multi-byte character support from vc++? this is terrible. i am dying now.

  • (cs) in reply to Matt Westwood
    Matt Westwood:
    Jeff Dege:
    Comments aren't needed to tell me which revision created the line, the revision control software does that.

    When I write a program for the first time, I don't have a revision history, but I don't have any functionality, either. My first commit will be either an empty project, or a project that contains a do-nothing program. Every piece of functionality that is added will be added as a separate commit, and the revision control software will link the changes that implemented that piece of functionality with the commit comment.

    There are times comments are useful, or even needed. But I see that as primarily when there is something going on that wouldn't be obvious to a maintenance programmer reading through the code.

    This guy has got to be trolling. Either that or he's a retard.

    snoıʌqo sı ןןoɹʇ snoıʌqo

  • (cs) in reply to Anon
    Anon:
    That admin guy:
    If seen stuff like this when the developer is trying to determine if an input contains actual words or just random crap. This follows the logical fallacy: 'All words have at least one vowel; therefor any text that contains a vowel must be a word'.
    Sky
    Nth
  • Fege-line (unregistered) in reply to Seahen
    Seahen:
    He could tell whether Y was a vowel if he weren't looking at only one letter. Y is a vowel if it neither precedes nor follows a vowel (as in "crypts", "rely" and "Ylvis", and in French, "il y a"), and this is probably true in all languages with a Latin-based alphabet.

    There are languages that only ever use Y as a vowel.

    Then again, with your algorithm it wouldn't matter, since it always returns true if it finds a Y in a word. "Rhythm" has a Y flanked by consonants, making it a vowel, but in "say" Y is preceded by an A, which is a vowel.

    And I do disagree with your characterization of the Y in "say" as a consonant.

  • Norman Diamond (unregistered)

    Compare the w sound in "no way" with the w sound in "vowel". Vowel's w sounds like a vowel.

  • Carrie (unregistered) in reply to Norman Diamond
    Norman Diamond:
    Compare the w sound in "no way" with the w sound in "vowel". Vowel's w sounds like a vowel.

    How do you get that? The 'ow' in vowel is just the same as in now. The w is the, well, w sound on the end of the ow bit. Not as distinct as in 'no way' I'll admit, since the e is normally unstressed so the 'wel' gets all run together into one sound like cowl or howl.

  • anonymous (unregistered) in reply to Seahen
    Seahen:
    He could tell whether Y was a vowel if he weren't looking at only one letter. Y is a vowel if it neither precedes nor follows a vowel (as in "crypts", "rely" and "Ylvis", and in French, "il y a"), and this is probably true in all languages with a Latin-based alphabet.
    There's an easier way to tell if a word contains a vowel. If it is known to be a word, it it contains at least one vowel sound; else it would be unpronounceable.

    However, if it isn't really known to be a word, then it may be unpronounceable, and your rule about Y being a vowel doesn't really apply.

  • VAXcat (unregistered)

    Back at my favorite coding job, the "standard" for commenting was that they had to consist mostly of quotes from popular culture like song lyrics, Monty Python, and MST3K. Oh, and about 20% in German (it was in the States, and none of us were from Germany - but several of us took in in college and thought it looked good in the commentary.

    I don't know how much use this commenting style was for maintainers, but we really enjoyed it.

  • борис (unregistered)

    When you work in a company that allows code like this, you have to ask, what's wrong with YOU that made them think you would be a good fit for their company?

  • v (unregistered)

    I believe the article submitter got trolled, hard, by some stackexchange answer or something.

  • (cs) in reply to anonymous
    anonymous:
    If it is known to be a word, it it contains at least one vowel sound; else it would be unpronounceable.
    Hmph.
  • (cs) in reply to Kivi
    Kivi:
    anonymous:
    If it is known to be a word, it it contains at least one vowel sound; else it would be unpronounceable.
    Hmph.
    Shh.

    Sincerely,

    Gene Wirchenko

  • Collecting thoughts from a million pieces on the ground. (unregistered)

    Holy fucking shit - this has got to win the all-time worst code ever award.

Leave a comment on “Too Much of a Bad Thing”

Log In or post as a guest

Replying to comment #:

« Return to Article