• (cs) in reply to foo AKA fooo

    Other than of course... Q Words without U

  • anon (unregistered) in reply to Taco

    My best guess from the way the code is written and the comments is that this is a student submission with a professor who requires comments on the code. I have seen many programs handed in like this in a much worse state with even stranger logic. But I know very few developers in the real world that comment code written this badly.

  • TwilitSoul (unregistered)

    Couldn't even bring myself to finish reading that code after I saw him call extraBool.toString().

  • foo AKA fooo (unregistered) in reply to neminem
    That guy:
    Also that you can't use quote to quote people that weren't in the thread here, unlike every other commenting system ever. >.>
    Well, you can, if you know the secret incantation. ;)

    Of course, TRWTF is that it lets invalid formatting get through and render incorrectly, but given the alternative ... yeah, I really like this feature. And the pointless "Reply" button! And Akismet! Yay!

  • foo AKA fooo (unregistered) in reply to Chris P. Peterson
    Chris P. Peterson:
    There are 3 logic errors in HasAVowel.
    There are four li^Hogic errors!
  • Scromble (unregistered) in reply to foo AKA fooo
    foo AKA fooo:
    Now this isn't all bad. Because the developer (who is no longer with Roger's company) was wise enough to include the default case in the switch statement, the fact that he forgot that 'q' was a letter didn't introduce any bugs. Whew. That was close.
    //I know what you think I should check for the letter
    //q here, but note that q is always being followed with the
    //letter of u which is already a vowel as you can see from my brillant
    //code above for example as in quiz or question
    //so i really don't need to check for the letter q this is called an
    //optimization which is always a very good thing to have
    
    Fixed?

    Which is still hysterically wrong. Not all English words with Q have a U, but those words do have another vowel.

  • faoileag (unregistered) in reply to Taco
    Taco:
    Why, why, why, would you check on vowels in a word? I cannot think of a sane reason.

    Anyone?

    A game. Present a list of words to several users at the same time and tell them to remove the vowels.

    Fastest one wins, but you have to check the submission, of course.

    CAPTCHA: nobis -> nbs

  • Lord Destructor (unregistered)

    6 Month ago I would have called that a fake. Then came the 'very very good Java-Developer'. He's long gone now - but this article made me realize I'm still depressed. It's like watching American-Idol where you ask yourself: "Does he really believe that he can sing, or is it an really good actor bullshitting me".

  • Eh (unregistered)

    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'. Not an easy task considering the problems we are trying to model are fairly complex and understanding how to solve one problem often requires diving into the program core where any sense of structure has been flat out crushed long ago due to hacks (undocumented of course, read the commit logs newbie) which have accumulated over time. Most of the comments I have submitted in the code have been flat out deleted. Whitespace such as blank lines is another offender and if you include any such blank lines in a commit you can almost be sure that the next commit will have erased them. The end result is a very dense codebase where everything is unnecessarily complex, it's hard to tell special cases from general ones, variables are inherited, passed and modified all over the place, and the structure is invisible. I am often at a loss what exactly our functions do because I have no idea what input they get or what exactly they output. Making changes to the code is time-demanding, expensive and frustrating due to the amount of technical debt that has accumulated over the year. But hey, at least our codebase follows Pep8.

    ps. The official Python documentation is shit.

  • golddog (unregistered) in reply to foo AKA fooo
    foo AKA fooo:
    Chris P. Peterson:
    There are 3 logic errors in HasAVowel.
    There are four li^Hogic errors!

    Well, nobody expects the Spanish Inquisition.

  • foo AKA fooo (unregistered) in reply to Lord Destructor
    Lord Destructor:
    6 Month ago I would have called that a fake. Then came the 'very very good Java-Developer'. He's long gone now - but this article made me realize I'm still depressed. It's like watching American-Idol where you ask yourself: "Does he really believe that he can sing, or is it an really good actor bullshitting me".
    Doesn't time fly? (Yes, the "foo" there was me, I didn't have my alias back then ...)
  • Anon (unregistered) in reply to That admin guy
    That admin guy:
    Taco:
    Why, why, why, would you check on vowels in a word? I cannot think of a sane reason.

    Anyone?

    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

  • QJo (unregistered)

    Comic genius. Funniest piece of code I've seen in a long time.

  • Anon (unregistered) in reply to SpasticWeasel
    SpasticWeasel:
    public bool Why(string s) { return s.ToUpper(CultureInfo.CurrentCulture).Any(c => ("AEIOU").Contains(c)); }

    FTFY. (note: I read the other day that the .NET runtime is optimized for upper case string comparisons.)

  • Brian_EE (unregistered)

    Everyone is forgetting that W can also be a vowel. So the code isn't even complete.

    http://www.quickanddirtytips.com/education/grammar/when-is-w-a-vowel

  • Anon (unregistered) in reply to Anon
    Anon:
    SpasticWeasel:
    public bool Why(string s) { return s.ToUpper(CultureInfo.CurrentCulture).Any(c => ("AEIOU").Contains(c)); }

    FTFY. (note: I read the other day that the .NET runtime is optimized for upper case string comparisons.)

    see: http://stackoverflow.com/questions/9033/hidden-features-of-c#12137

  • (cs)

    This is literally the worst code that I've ever seen.

  • Darfeld (unregistered) in reply to foo AKA fooo

    I like wikipedia, it really has anything in it:

    http://en.wikipedia.org/wiki/List_of_English_words_containing_Q_not_followed_by_U

  • (cs)

    aside from the fact that he loops through every character in the string then returns in all cases so it isn't really a loop...

    Of course if it contains 'y' it should return FileNotFound.

  • (cs)

    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.

  • Jeff Dege (unregistered)

    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.

  • Geoff (unregistered) in reply to Flabberghasted

    This code is inexcusably poor but break after return is not IMHO necessarily bad code. Sure its unreachable; but anyone reading the code or mentally evaluated the function for a given input will know that when they hit the 'return' they can stop running down that branch with total confidence.

    What it does do is keep your switch/case/select statement symmetrical which makes it visually quick to check you have not omitted a break where there should be one.
    It also means that if you refactor and take that return out that break is there, and you don't forget it resulting in unexpected fall thru behavior.

    While we are on the subject isn't 'break' the real wtf in all the C syntax mimicking variants of switch/case/select in other languages? I have been programing a long time and the percentage of the time I want the fall through control flow rather than a break after each case is tiny. I with the default flow was break and you make things fall thru with 'next' or something.

  • Lord Destructor (unregistered) in reply to foo AKA fooo

    "You suggest we should have talent shows for programmers on TV?"

    => FizzBuzz seems to be enough to sort out that kind of programmer...that's the new talent show in my company (small variation of FizzBuzz). That's nothing and every C.S.-studend can solve that in a minute, I once thought. Try it, and you will have a hard time believing what 'very very good Developers' are capable to produce. Of cause I sucked too when I started Basic on my C64. But I knew I sucked. That's what I just don't get with those people. Maybe it's some kind of a phychic desease or something.

    string extraMegaBool = "FIND_ANOTHER_JOB".ToString();

  • Lord Destructor (unregistered) in reply to Geoff
    Geoff:
    This code is inexcusably poor but break after return is not IMHO necessarily bad code. Sure its unreachable; but anyone reading the code or mentally evaluated the function for a given input will know that when they hit the 'return' they can stop running down that branch with total confidence.

    What it does do is keep your switch/case/select statement symmetrical which makes it visually quick to check you have not omitted a break where there should be one.
    It also means that if you refactor and take that return out that break is there, and you don't forget it resulting in unexpected fall thru behavior.

    I do that for exactly the same reasons. But it still feels a litte weird, so I apologize in the comments.

    #pragma warning disable 0162 //unreachable code => switch => case => return => break; Sorry I like the unnecessary breaks

  • Blah (unregistered)

    If this was not an overly-confident student's programming assignment, then my only other theory was busy work for the president's daughter.

    CAPTCHA: ideo - an term used to describe those stupid enough to pass of 101 assignments as mature code.

  • dv (unregistered) in reply to 1337 H4CK3R
    1337 H4CK3R:
    mozzis:
    Why do so many of you think it only looks at the first char in the string? Did you miss the 'foreach' ?

    I hope you're trolling.

    If you're that thick, note that the "loop" always returns during the first iteration due to the default case.

    Actually the loop always returns period. In every case.

  • Humble Programmer (unregistered) in reply to chubertdev
    chubertdev:
    This is literally the worst code that I've ever seen.

    You are truly blessed. I'm sorry to say that the codebase at my job, while actually compiling, is significantly more asinine than this.

  • dv (unregistered) in reply to That admin guy
    That admin guy:
    Taco:
    Why, why, why, would you check on vowels in a word? I cannot think of a sane reason.

    Anyone?

    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'.

    Actually there are languages out there (yes, Czech, i'm looking your way) that contain perfectly cromulent words containing only consonants. The missing vowels are "cheated in" during pronunciation, usually something like a schwa is added to the so-called syllable-forming consonants. There is a well known czech phrase "Strč prst skrz krk" (literally "put a finger through your throat") containing four basic and widely used consonant-only words. The longest consonant-only czech word would be "scvrnkls" ([you] flicked [something] down [from somewhere] [with your finger]), which when pronounced gives two syllables.

  • WTF (unregistered) in reply to foo AKA fooo
    foo AKA fooo:
    KattMan:
    foo AKA fooo:
    Now this isn't all bad. Because the developer (who is no longer with Roger's company) was wise enough to include the default case in the switch statement, the fact that he forgot that 'q' was a letter didn't introduce any bugs. Whew. That was close.
    //I know what you think I should check for the letter
    //q here, but note that q is always being followed with the
    //letter of u which is already a vowel as you can see from my brillant
    //code above for example as in quiz or question
    //so i really don't need to check for the letter q this is called an
    //optimization which is always a very good thing to have
    
    Fixed?

    Nope, try Qat, yes it is a word.

    D'oh, we're talking about q, not Q! AKA woosh!
    And Qadi. http://en.wikipedia.org/wiki/Qadi

  • Jack (unregistered) in reply to Josh
    Josh:
    In ASCII land these implementations would somehow work. Ever dealt with code running on inputs from multiple locales?
    Ever had a job that didn't care about supporting the entire fucking world? Yeah, there are plenty of developers who really don't have to worry about non-ASCII input, so complaining that it doesn't support non-ASCII input is quite retarded.
  • Evan (unregistered) in reply to KattMan
    KattMan:
    Nope, try Qat, yes it is a word.
    https://www.youtube.com/watch?v=_dvPhtNZCj0
  • (cs)

    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?

  • (cs) in reply to Geoff
    Geoff:
    This code is inexcusably poor but break after return is not IMHO necessarily bad code. Sure its unreachable; but anyone reading the code or mentally evaluated the function for a given input will know that when they hit the 'return' they can stop running down that branch with total confidence.

    What it does do is keep your switch/case/select statement symmetrical which makes it visually quick to check you have not omitted a break where there should be one.
    It also means that if you refactor and take that return out that break is there, and you don't forget it resulting in unexpected fall thru behavior.

    While we are on the subject isn't 'break' the real wtf in all the C syntax mimicking variants of switch/case/select in other languages? I have been programing a long time and the percentage of the time I want the fall through control flow rather than a break after each case is tiny. I with the default flow was break and you make things fall thru with 'next' or something.

    Please don't excuse bad code. If you can't tell that a return statement will make the loop only iterate once, you shouldn't be touching code.

  • Jeremy (unregistered)

    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.

  • (cs) 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.

    SKIIIIIIIINNEEEEEEEEEEEER!!!!!!!!

  • ¯\(°_o)/¯ I DUNNO LOL (unregistered) in reply to Leo
    Leo:
    I went down to the cwm and played my crwth, but I heard the howling of the Cwn Annwn!

    http://dictionary.reference.com/help/faq/language/t50.html

    Ah yes, Welsh, where 'w' is a vowel.

    [image] The Welsh reads: "I am not in the office at the moment. Send any work to be translated."
  • OldCoder (unregistered) in reply to Matt Westwood
    Matt Westwood:
    So "crwth" has no vowel in it?
    He has no rhythm, obviously.
  • ¯\(°_o)/¯ I DUNNO LOL (unregistered) in reply to Geoff
    Geoff:
    What it does do is keep your switch/case/select statement symmetrical which makes it visually quick to check you have not omitted a break where there should be one. It also means that if you refactor and take that return out that break is there, and you don't forget it resulting in unexpected fall thru behavior.
    The IAR C compiler gives an unreachable code warning when you have a break after a return.

    And when you enable the default set of MISRA-C warnings, it also gives a warning when there is NOT a break after a return, for the rule where every case of a switch statement must have a break.

  • Tsaukpaetra (unregistered) in reply to ¯\(°_o)/¯ I DUNNO LOL

    Schrodinger's Break?

    Captcha: Suscipit; For when I suspect- oh whatever, just skip it!

  • like (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

    "like"

    Valley girl ?

  • (cs) in reply to That admin guy
    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'.

    Strč prst skrz krk

  • Davio (unregistered)

    I refuse to accept that a word is an actual word if it doesn't contain at least one vowel. This real world experience makes our method much cleaner:

    public static bool HasAVowel(String theword) { return true; }

    Note that this even works if the input is null which is, as you can see, a word with a vowel.

  • (cs) in reply to Geoff
    Geoff:
    This code is inexcusably poor but break after return is not IMHO necessarily bad code. Sure its unreachable; but anyone reading the code or mentally evaluated the function for a given input will know that when they hit the 'return' they can stop running down that branch with total confidence.

    What it does do is keep your switch/case/select statement symmetrical which makes it visually quick to check you have not omitted a break where there should be one.
    It also means that if you refactor and take that return out that break is there, and you don't forget it resulting in unexpected fall thru behavior.

    While we are on the subject isn't 'break' the real wtf in all the C syntax mimicking variants of switch/case/select in other languages? I have been programing a long time and the percentage of the time I want the fall through control flow rather than a break after each case is tiny. I with the default flow was break and you make things fall thru with 'next' or something.

    Well, no. If you are using a clean case -> break for each case, then maybe you need to restructure your project so as to use a series of subclasses or something. The advantage of a case statement is that you do have the fall-through option, and that you would use a switch precisely when you need to implement the sort of thing that lends itself to the fall-through behaviour.

  • (cs) in reply to Geoff
    Geoff:
    This code is inexcusably poor but break after return is not IMHO necessarily bad code. Sure its unreachable; but anyone reading the code or mentally evaluated the function for a given input will know that when they hit the 'return' they can stop running down that branch with total confidence.

    What it does do is keep your switch/case/select statement symmetrical which makes it visually quick to check you have not omitted a break where there should be one.
    It also means that if you refactor and take that return out that break is there, and you don't forget it resulting in unexpected fall thru behavior.

    While we are on the subject isn't 'break' the real wtf in all the C syntax mimicking variants of switch/case/select in other languages? I have been programing a long time and the percentage of the time I want the fall through control flow rather than a break after each case is tiny. I with the default flow was break and you make things fall thru with 'next' or something.

    Actually now I think about it, I wonder whether the code originally didn't have the Return statements in it. Then it would loop through every element in the character string, doing its incomprehensible shit. The developer realised it was doing the wrong thing and thought: d'oh! as soon as i've found a vowel I can return! Then overthought it and added return to all cases.

  • (cs) in reply to Leo
    Leo:
    I went down to the cwm and played my crwth, but I heard the howling of the Cwn Annwn!

    http://dictionary.reference.com/help/faq/language/t50.html

    I was wondering if anyone would mention 'w' as a vowel.

  • (cs) in reply to eric76
    eric76:
    Leo:
    I went down to the cwm and played my crwth, but I heard the howling of the Cwn Annwn!

    http://dictionary.reference.com/help/faq/language/t50.html

    I was wondering if anyone would mention 'w' as a vowel.

    Yes I bloody did ages before this bozo, can't you bloody read?

  • (cs) in reply to Matt Westwood
    Matt Westwood:
    eric76:
    Leo:
    I went down to the cwm and played my crwth, but I heard the howling of the Cwn Annwn!

    http://dictionary.reference.com/help/faq/language/t50.html

    I was wondering if anyone would mention 'w' as a vowel.

    Yes I bloody did ages before this bozo, can't you bloody read?

    As a pedantic programmer, I do have to mention that "anyone" != "first one"

  • (cs) in reply to foo AKA fooo
    foo AKA fooo:
    Now this isn't all bad. Because the developer (who is no longer with Roger's company) was wise enough to include the default case in the switch statement, the fact that he forgot that 'q' was a letter didn't introduce any bugs. Whew. That was close.
    //I know what you think I should check for the letter
    //q here, but note that q is always being followed with the
    //letter of u which is already a vowel as you can see from my brillant
    //code above for example as in quiz or question
    //so i really don't need to check for the letter q this is called an
    //optimization which is always a very good thing to have
    
    Fixed?

    As any good scrabble player will know, q is not always followed by a vowel: tranq, umiaq, and suq.

  • (cs) in reply to Matt Westwood
    Matt Westwood:
    eric76:
    Leo:
    I went down to the cwm and played my crwth, but I heard the howling of the Cwn Annwn!

    http://dictionary.reference.com/help/faq/language/t50.html

    I was wondering if anyone would mention 'w' as a vowel.

    Yes I bloody did ages before this bozo, can't you bloody read?

    Oops.

  • Matteo (unregistered) in reply to foo AKA fooo
    foo AKA fooo:
    Now this isn't all bad. Because the developer (who is no longer with Roger's company) was wise enough to include the default case in the switch statement, the fact that he forgot that 'q' was a letter didn't introduce any bugs. Whew. That was close.
    //I know what you think I should check for the letter
    //q here, but note that q is always being followed with the
    //letter of u which is already a vowel as you can see from my brillant
    //code above for example as in quiz or question
    //so i really don't need to check for the letter q this is called an
    //optimization which is always a very good thing to have
    
    Fixed?

    You mean, like in "Iraq" or "QED"? :-)

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

Log In or post as a guest

Replying to comment #:

« Return to Article