Bang Bang; When ALL != ALL



  • Just found this in some code checked in for this weeks' release:

     

      public boolean checkIfYes(String s) {
    return s != null && !"".equals(s) && !s.equals("Y");
    }

    Let's see, the middle test is useless, and the third test returns the opposite of what you want.

    If you pass lower case 'y' you get true.
    If you pass upper case 'Y' you get false. Don't get me started on YES, yes and so on. Then everywhere: if (checkIfYes(someStringVar)) { do stuff for not Yes } else { do stuff for yes }. Except for those places where we have: if (!checkIfYes(s)) { do stuff for yes }.

    This pattern is used everywhere. Why?

    The guy who wrote it said that his kid runs around shouting "bang bang" so he decided to stick with a double negative pattern.

    -----------------------------------

    Another gem by this same guy...

    if (!"ALL".equals(stringContainingSomethingPossiblyEqualToALL)) { log.error("ALL != ALL"); }

    The code that calls it is passing "ALL " (trailing space). In about 10,000 places. But you can't tell that from the log statements because he hard coded the error instead of doing something like: log.error(" 'ALL' != ["+s+"]");

    This pattern is also used in about 10,000 places. 

    We told him to do it the right way. He declined citing "developer choice". My boss won't force him to fix it, so I get to spend the rest of the week fixing this. 

    You just know what I'm going to find along the way as I follow the yellow brick road through his code...



  • @snoofle said:

    The guy who wrote it said that his kid runs around shouting "bang bang" so he decided to stick with a double negative pattern.
     

    ...I don't understand this sentence.

     



  • @mott555 said:

    @snoofle said:
    The guy who wrote it said that his kid runs around shouting "bang bang" so he decided to stick with a double negative pattern.
    ...I don't understand this sentence.

    Double negative = !! in C. ! is called 'bang' by some idiots I hate. Therefore, "bang bang" = "!!", as in "!!variableName".

    Edit: don't get me wrong it's a TERRIBLE joke. I'm just explaining it.



  • @Blakeyrat: of course, your explanation is correct, and I too, hate it!

     



  • @blakeyrat said:

    ! is called 'bang' by some idiots I hate.

    Why do you hate them? Unless they're the same idiots who pronounce "//" as "whack whack". Then you can hate til you burn. Because those people are idiots.



  • That's the worst explanation for crappy code I've ever heard.

    But why is the middle test useless?



  • @Xyro said:

    @blakeyrat said:
    ! is called 'bang' by some idiots I hate.

    Why do you hate them? Unless they're the same idiots who pronounce "//" as "whack whack". Then you can hate til you burn. Because those people are idiots.

    I think this is just a statistical statement. He hates enough people for so many reasons that there must be some of them in there.



  • Let me guess: he's a FT employee who's been working there for 5-10 years (or more), and there's a snowballs chance in hell of EVER getting him fired, right?

    I've come across a few of these, what I like to call, "lifers".  They act like they're part of a union, and they know they've got their job for life.  Shitty, toxic, "fuck the man" kind of attitude?



  • @Sutherlands said:

    But why is the middle test useless?

    Because it's going to test for equality to "Y" anyway.



  • Atrocious. Make's Uncle Bob's little nephew cry. The guy should be thrown out. And when he asks why, you say "manager choice".



  • @Xyro said:

    @Sutherlands said:
    But why is the middle test useless?

    Because it's going to test for equality to "Y" anyway.

    No, it's testing for inequality to "Y". So, you get a false return from null, "" and "Y". Everything else (" '", "y", "yes", "no", "file not found", "fuck you", "42") returns true! It sounds like something that was meant for a specific situation, where you knew exactly what values you would get. Then other people saw it, and the love spread.



  • @Xyro said:

    @blakeyrat said:
    ! is called 'bang' by some idiots I hate.
    Why do you hate them? Unless they're the same idiots who pronounce "//" as "whack whack". Then you can hate til you burn. Because those people are idiots.

     

    I had a tech lead, many years ago, that not only used "whack whack" for forward slashes but, "hack hack" for back-slashes. To this day he pretends like we're freinds and asks me to be a reference for him when he's looking for work.

    http://www.youtube.com/watch?v=jA-lKOKyRJo

     

    Bang Bang

     


  • Discourse touched me in a no-no place

    @Xyro said:

    @blakeyrat said:
    ! is called 'bang' by some idiots I hate.

    Why do you hate them? Unless they're the same idiots who pronounce "//" as "whack whack". Then you can hate til you burn. Because those people are idiots.
    "whack" is a sysadmin construct for . Using it for / is wrong as fuck.

    As far as why it exists at all, YOU try going around saying "backslash backslash" all fucking day long. It gets shitty after the second person you try to convey a UNC path to.



  • @Weng said:

    @Xyro said:

    @blakeyrat said:
    ! is called 'bang' by some idiots I hate.
    Why do you hate them? Unless they're the same idiots who pronounce "//" as "whack whack". Then you can hate til you burn. Because those people are idiots.
    "whack" is a sysadmin construct for . Using it for / is wrong as fuck.

    As far as why it exists at all, YOU try going around saying "backslash backslash" all fucking day long. It gets shitty after the second person you try to convey a UNC path to.

    Huh!


  • Discourse touched me in a no-no place

    @rudraigh said:

    Huh!

    BLASPHEMY. Besides, forward slashes already have a convenient term. They're called fucking "slash".


  • @Weng said:

    @rudraigh said:

    Huh!

    BLASPHEMY. Besides, forward slashes already have a convenient term. They're called fucking "slash".
     

    Which in some places means "piss", so I can see why sensitive types would want a substitute shorthand.

     



  • @Weng said:

    @rudraigh said:

    Huh!

    BLASPHEMY. Besides, forward slashes already have a convenient term. They're called fucking "slash".

    I understand, now. Weng has a whack whack.

     



  • @snoofle said:

    We told him to do it the right way. He declined citing "developer choice". My boss won't force him to fix it, so I get to spend the rest of the week fixing this.
     

    That sounds like a good opportunity for a CBA doc.

    It also sounds like a good opportunity to leak the CBA doc to your boss' boss.

    If your boss is going to not force him to fix it, fair enough. They are the boss, they get to make those calls. They also get to wear the consequences of the calls.

    I imagine a week of your time is a not-insignificant cost to the company.

     



  • @Sutherlands said:

    That's the worst explanation for crappy code I've ever heard.

    I think his other explanation is worse:

    We told him to do it the right way. He declined citing "developer choice".

    The way he says it, it's almost as if he thinks there's something in the constitution or some historic supreme court decision that requires everyone to respect the choice of any developer. How do you "cite" developer choice? Is it done the same way one "cites" equal opportunity or fair trade?



  • @TGV said:

    The guy should be thrown out. And when he asks why, you say "[b]You're being fired: bang bang[/b]".

     

    Explain it in terms he can understand.

     



  • I'll just cite this here, before anyone else does. It's a poem.

     

    ^<@<.@*
    }"# |
    -@$&/
    %
    !( @|=>
    ;`+$?^?
    ,#"~|)^G


    hat less at less point at star

    backbrace double base pound space bar

    dash at cash and slash base rate

    wow open tab at bar is great

    semi backquote plus cash huh DEL

    comma pound double tilde bar close BEL

     


  • Discourse touched me in a no-no place

    @Pim said:

    ^<@<.@*
    }"# |
    -@$&/
    %
    !( @|=>
    ;`+$?^?
    ,#"~|)^G
    Does it actually do anything in any language? (Like, say, Black Perl?)



  • @PJH said:

    @Pim said:
    ^<@<.@*
    }"# |
    -@$&/
    %
    !( @|=>
    ;`+$?^?
    ,#"~|)^G
    Does it actually do anything in any language? (Like, say, Black Perl?)

    Or perhaps Flying Dutchman.



  • @PJH said:

    @Pim said:
    ^<@<.@*
    }"# |
    -@$&/
    %
    !( @|=>
    ;`+$?^?
    ,#"~|)^G
    Does it actually do anything in any language? (Like, say, Black Perl?)
     

    I'm pretty sure it would do something in TECO, but it needs a greater man than me to guess what.



  • @Ilya Ehrenburg said:

    @PJH said:

    @Pim said:
    ^<@<.@* }"# | -@$&/% !( @|=> ;`+$?^? ,#"~|)^G
    Does it actually do anything in any language? (Like, say, Black Perl?)
     

    I'm pretty sure it would do something in TECO, but it needs a greater man than me to guess what.

    Alright, I'm going to guess.... it prints "Hello World" to the screen.


  • @snoofle said:

    The guy who wrote it said that his kid runs around shouting "bang bang" so he decided to stick with a double negative pattern.
    That's some shitty shitty "bang bang" right there.



  • @PJH said:

    @Pim said:
    ^<@<.@*

    }"# |

    -@$&/
    %

    !( @|=>

    ;`+$?^?

    ,#"~|)^G

    Does it actually do anything in any language? (Like, say, Black Perl?)

    Given the layout, I'd try Befunge as my first choice.



  • @Sutherlands said:

    @Ilya Ehrenburg said:

    @PJH said:

    @Pim said:
    ^<@<.@* }"# | -@$&/% !( @|=> ;`+$?^? ,#"~|)^G
    Does it actually do anything in any language? (Like, say, Black Perl?)
     

    I'm pretty sure it would do something in TECO, but it needs a greater man than me to guess what.

    Alright, I'm going to guess.... it prints "Hello World" to the screen.
    And rings the bell when done.

     



  • @Weng said:

    @Xyro said:

    @blakeyrat said:
    ! is called 'bang' by some idiots I hate.

    Why do you hate them? Unless they're the same idiots who pronounce "//" as "whack whack". Then you can hate til you burn. Because those people are idiots.
    "whack" is a sysadmin construct for . Using it for / is wrong as fuck.

    As far as why it exists at all, YOU try going around saying "backslash backslash" all fucking day long. It gets shitty after the second person you try to convey a UNC path to.

    I worked in a place where people called '#' a "Tic-tac-toe". You could hear people saying "tic-tac-toe" a lot of times everyday. Enough to drive one crazy.



  • @blakeyrat said:

    Double negative = !! in C. ! is called 'bang' by some idiots I hate
     

    And what exactly is your problem with jargon? Presumably you'd rather not have us go around saying "the character you get instead of backslash when you press backslash while you press shift too" instead of "pipe"? Why are you always so negative?

    NOTE: depending on your keyboard layout, obviously.

     



  • What? No, !! is not bang bang, it's BOOM! And // is not whack whack, it's THWACK...



  • @Weng said:

    Besides, forward slashes already have a convenient term. They're called fucking "slash".

    Technically, they're called 'solidus,' but I don't know anyone except typographers who actually say 'solidus' instead of 'slash.' Of course, in the UK, they are sometimes called 'oblique,' but that's another story.



  • @Monomelodies said:

    @blakeyrat said:

    Double negative = !! in C. ! is called 'bang' by some idiots I hate
     

    And what exactly is your problem with jargon? Presumably you'd rather not have us go around saying "the character you get instead of backslash when you press backslash while you press shift too" instead of "pipe"? Why are you always so negative?

    NOTE: depending on your keyboard layout, obviously.

     

     

    I always had trouble getting people on the phone to figure out what the "carat", "hat" or (in a PL/I shop) "not" sign was supposed to be.  That is, until I started telling them to type a "capital six".

     



  • @Cad Delworth said:

    @Weng said:
    Besides, forward slashes already have a convenient term. They're called fucking "slash".

    Technically, they're called 'solidus,' but I don't know anyone except typographers who actually say 'solidus' instead of 'slash.' Of course, in the UK, they are sometimes called 'oblique,' but that's another story.
     

    In what sense are all those other names better than "virgule"?



  • @da Doctah said:

    @Cad Delworth said:

    @Weng said:
    Besides, forward slashes already have a convenient term. They're called fucking "slash".

    Technically, they're called 'solidus,' but I don't know anyone except typographers who actually say 'solidus' instead of 'slash.' Of course, in the UK, they are sometimes called 'oblique,' but that's another story.
     

    In what sense are all those other names better than "virgule"?

     

    They don't sound like an abbreviation for "virgin ghoul"?

     



  •  @Cad Delworth said:

    Technically, they're called 'solidus,' but I don't know anyone except typographers who actually say 'solidus' instead of 'slash.' Of course, in the UK, they are sometimes called 'oblique,' but that's another story.
    And of course there is the occasional BBC presenter who will say "stroke". As in "Bee bee cee dot co dot you kay stroke mastermind".

     

    I can't believe I registered just to post that, but there you go 



  • Way back when, in 7th grade I was learning Pascal (1980), I would sort of talk to myself while programming. I referred to the colon (:) as dot - dot, and a semi-colon (;) as dot-comma. 

    The other students looked at me like I was crazy .  A comma B dot dot integer dot comma c dot dot string dot comma  and on and on.

     



  • @blakeyrat said:

    @mott555 said:
    @snoofle said:
    The guy who wrote it said that his kid runs around shouting "bang bang" so he decided to stick with a double negative pattern.
    ...I don't understand this sentence.

    Double negative = !! in C. ! is called 'bang' by some idiots I hate. Therefore, "bang bang" = "!!", as in "!!variableName".

    Edit: don't get me wrong it's a TERRIBLE joke. I'm just explaining it.

     

    Pedantic dickweedery. !! isn't actually a double negative. It's a double logical not, and

     !!a

    has the same effect as

     a != 0

    but is obviously far cooler, in that nobody who doesn't have arcane levels of C experience will understand it and it requires a reasonably intelligent compiler to produce code of the same efficiency as the 2nd version.

    But obviously, coolness overrides maintainability, etc, etc.

     



  • @Medezark said:

    Way back when, in 7th grade I was learning Pascal (1980), I would sort of talk to myself while programming. I referred to the colon (:) as dot - dot, and a semi-colon (;) as dot-comma. 

    The other students looked at me like I was crazy .  A comma B dot dot integer dot comma c dot dot string dot comma  and on and on.

    I do similar, I find it useful for me to silently sound out what I'm typing in order to stay focused. However, the formal names of these non-alphanum characters take too long to think about... so instead, they get sound effects.

    ~ is like a "whoop" with the tone of the vowels following the curvature of the tilde
    # is the low-pitched sound you make when describing a minor collision
    $ is a high-pitched "ching", as in "cha-ching"
    ? is a Canadian "eh?", especially in ternary expressions
    ( is a very airy "flip"
    ) is a very airy "flop"
    etc, etc.

    ... As far as I am aware of myself, I do not pronounce them out loud.

    ... I hope I don't pronounce them out loud.



  • Back when I was in high school / college I had a TI-83+ graphing calculator, and with that came TI-BASIC. Now for some reason in TI-BASIC, you couldn't assign variables with any sort of sensible expressions like "x = 5"; no, you had to do it backwards, and use a special arrow operator: "5 -> x" (note: the arrow operator was actually a special character, not a dash followed by a greater-than sign). I thus came to call the -> operator a "gazinta" operator (as in "5 goes into x").

    Now, when I see the lambda operator => in C#, I also call it "gazinta", even though it doesn't quite mean the same thing...



  • @ekolis said:

    Back when I was in high school / college I had a TI-83+ graphing calculator, and with that came TI-BASIC. Now for some reason in TI-BASIC, you couldn't assign variables with any sort of sensible expressions like "x = 5"; no, you had to do it backwards, and use a special arrow operator: "5 -> x" (note: the arrow operator was actually a special character, not a dash followed by a greater-than sign). I thus came to call the -> operator a "gazinta" operator (as in "5 goes into x").

    Now, when I see the lambda operator => in C#, I also call it "gazinta", even though it doesn't quite mean the same thing...

    You've created an ambiguity there; "gazinta" traditionally refers to the division operation, as in "three gazinta twelve four times"...

     



  • @thosrtanner said:

    Pedantic dickweedery. !! isn't actually a double negative. It's a double logical not, and

     !!a

    has the same effect as

     a != 0

    but is obviously far cooler, in that nobody who doesn't have arcane levels of C experience will understand it

    !!foo seems like a reasonably obvious way to generate a normalized boolean value from foo. It could confuse beginners, who may think there is some sort of relationship between & and && versus ! and !!. On the other hand, I'm having trouble grammatically parsing your use of a double negative, and I have far more experience in English than in C.

    Of course, the problem with the original code is that it's not using a double negation, it's using inverted truth values with misleading function names.



  • @snoofle said:

      public boolean checkIfYes(String s) {
    return s != null && !"".equals(s) && !s.equals("Y");
    }

    Let's see, the middle test is useless, and the third test returns the opposite of what you want.

    If you pass lower case 'y' you get true.
    If you pass upper case 'Y' you get false. Don't get me started on YES, yes and so on. Then everywhere: if (checkIfYes(someStringVar)) { do stuff for not Yes } else { do stuff for yes }. Except for those places where we have: if (!checkIfYes(s)) { do stuff for yes }.

    Clearly, you need a better notation for active-low methods.

    public class BangBang {
    public static void main(String[]] args) {
    if (!c̅h̅e̅c̅k̅I̅f̅Y̅e̅s̅("Y"))
    System.out.println("do stuff for yes");
    else
    System.out.println("do stuff for not yes");
    }

    public static boolean c̅h̅e̅c̅k̅I̅f̅Y̅e̅s̅(String s) {
    	return s != null &amp;&amp; !"".equals(s) &amp;&amp; !s.equals("Y");
    }
    

    }

    Ah, so much better. This prints "do stuff for yes" as expected. (Just make sure you specify the correct -encoding when invoking javac.)



  • @thosrtanner said:

    Pedantic dickweedery. !! isn't actually a double negative. It's a double logical not

    This is the worst pedantic dickweedery I've ever seen.  I hope you get better in the future.


  • Discourse touched me in a no-no place

    @Pim said:

    I'll just cite this here, before anyone else does. It's a poem.

     

    ^<@<.@*
    }"# |
    -@$&/
    %
    !( @|=>
    ;`+$?^?
    ,#"~|)^G


    hat less at less point at star

    backbrace double base pound space bar

    dash at cash and slash base rate

    wow open tab at bar is great

    semi backquote plus cash huh DEL

    comma pound double tilde bar close BEL

     




  • Just remember:

     (!!a) != (~~a) for most values of a....



  • @DaveK said:

    You've created an ambiguity there; "gazinta" traditionally refers to the division operation, as in "three gazinta twelve four times"...

     

    Well, I never much cared for that style of division - I prefer "twelve divided by three is four", or "twelve over three is four"...



  • @DaveK said:

    @ekolis said:

    I thus came to call the -> operator a "gazinta" operator (as in "5 goes into x").

    Now, when I see the lambda operator => in C#, I also call it "gazinta", even though it doesn't quite mean the same thing...

    You've created an ambiguity there; "gazinta" traditionally refers to the division operation, as in "three gazinta twelve four times"...

     

     

    You've also (probably under the eevul influence of the TI-BASIC paradigm) started work on a regional dialect.  The traditional right-to-left assignment is pronounced "gets", as in "x gets 5".

    (Also, the > comparison operator should be pronounced "morn".  Example:  "if x > 5 then..." is read as "if ecks morn five then..."

     



  • @da Doctah said:

    @DaveK said:

    @ekolis said:

    I thus came to call the -> operator a "gazinta" operator (as in "5 goes into x").

    Now, when I see the lambda operator => in C#, I also call it "gazinta", even though it doesn't quite mean the same thing...

    You've created an ambiguity there; "gazinta" traditionally refers to the division operation, as in "three gazinta twelve four times"...

     

    You've also (probably under the eevul influence of the TI-BASIC paradigm) started work on a regional dialect.  The traditional right-to-left assignment is pronounced "gets", as in "x gets 5".

    (Also, the > comparison operator should be pronounced "morn".  Example:  "if x > 5 then..." is read as "if ecks morn five then..."

    Ah, then the < operator must be pronounced "larn"?




  • @DaveK said:

    Ah, then the < operator must be pronounced "larn"?

    No, that would be "lessen"


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.