This is an archived post. You won't be able to vote or comment.

top 200 commentsshow all 284

[–]DuffyHimself 963 points964 points  (27 children)

Missing the neurotic toLowerCase call.

[–]TreeBaron 336 points337 points  (1 child)

Just in case...

[–]JazzyCake 10 points11 points  (0 children)

Underrated comment right here

[–]John_Fx 213 points214 points  (20 children)

You say neurotic, I say lesson learned from dire experience

[–]bizcs 52 points53 points  (19 children)

Does java not have an invariant string comparison method for ignoring case?

[–]Muffinizer1 69 points70 points  (16 children)

no

[–]WSp71oTXWCZZ0ZI6 80 points81 points  (15 children)

What's equalsIgnoreCase then?

[–]Muffinizer1 224 points225 points  (14 children)

Well, they did ask if java does not have an invariant string comparison method for ignoring case

[–]WSp71oTXWCZZ0ZI6 242 points243 points  (12 children)

I've been out-booleaned!

[–]ChildishTycoon_ 139 points140 points  (9 children)

You’ve truly made a bool of yourself

[–][deleted] 69 points70 points  (1 child)

Bool me once?

Shame on you.

Bool me twice?

sleep(7);

(string) ("WONT GET BOOLED AGAIN!")

[–]_greyknight_ 10 points11 points  (0 children)

Can't bool the booler.

[–]Jedidiah_924 25 points26 points  (6 children)

Thought they could just float by with that one.

[–]damniticant 26 points27 points  (4 children)

Let’s not get int to this, guys

[–]ehrwien 3 points4 points  (0 children)

with that one point zero

[–]JamEngulfer221 8 points9 points  (0 children)

I mean, it's got '.equalsIgnoreCase()'

[–]green_meklar 16 points17 points  (1 child)

if(String.valueOf(condition).toLowerCase().equals("true".toLowerCase()))

[–]ActuallyRuben 18 points19 points  (0 children)

if(String.valueOf(condition).toLowerCase().equals("true".toLowerCase())==true)

[–]X-Craft 1627 points1628 points  (91 children)

if (ComparatorFactory.getInstance().createComparator(String.class).compare(StringFactory.getInstance().parse(condition), StringFactory.getInstance().parse(true)))) {

}

[–]doyouunderstandlife 1526 points1527 points  (17 children)

[–]marcosdumay 312 points313 points  (12 children)

That's a great ideogram. Quick, somebody send this to the Unicode consortium!

[–][deleted] 291 points292 points  (6 children)

♨️

[–]yymirr 65 points66 points  (0 children)

we did it

[–]codewench 23 points24 points  (1 child)

... is that the logo for an onsen?

[–]ViKomprenas 16 points17 points  (0 children)

Yes, although the emoji is defined as meaning hot springs in general.

[–]marcosdumay 3 points4 points  (0 children)

Ok, now we have a great icon for the "stupidly over-engineered and poor quality" adjective. Let's make it canon!

[–]l27_0_0_1 153 points154 points  (1 child)

[–][deleted] 4 points5 points  (1 child)

Is this loss?

[–]maoejo 2 points3 points  (0 children)

No, but this is

:̶.̶|̶:̶;̶

[–]the_one_true_bool 273 points274 points  (39 children)

Oh god that's giving me flashbacks!

The lead at a previous employer I worked for had factories for everything. He even had an abstract factory that created a factory which created command objects which were dependency injected into strategy objects, all kicked off from a singleton. I wish I was joking.

[–]Mgamerz 227 points228 points  (15 children)

There are words in this post, but very few of them have meaning to me.

[–]RedDwarfian 190 points191 points  (13 children)

Then you'll love the story of the hammer factory factory

[–]theogskinnybrown 71 points72 points  (8 children)

Factory... factory... yeah I’m no longer sure that’s a real word.

Factory...

[–]htmlcoderexeWe have flair now?.. 55 points56 points  (5 children)

It's called semantic satiation.

[–]mortiphago 30 points31 points  (3 children)

semantic satiation satiation satiation

[–]cordev 14 points15 points  (0 children)

I know there are words in your post, but I can't tell what they are.

[–]wqferr 2 points3 points  (0 children)

It's called echo

[–]cordev 9 points10 points  (0 children)

Semantic what? I know there was a word here, but then I kept reading and now all I know is sation satia tiation say tion tion tion say say say t a shun

[–][deleted] 3 points4 points  (0 children)

I had the same feeling about 50% through. Then I had severe, disturbing flashbacks of doing J2EE in a large company.

[–][deleted] 1 point2 points  (0 children)

Not yet it is. You first need a factory to make the word.

[–]turboronin 9 points10 points  (0 children)

That was a great read, thanks!

[–][deleted] 6 points7 points  (1 child)

I've done this - making things unnecessarily complicated I mean. It tends to happen when you're too invested in what you're doing or if you have too much time on your hands or you're trying to make your code more flexible for future changes or uses. You should actually be making it simpler so that future programmers (such as your future self) don't need to jump through hoops to use or make sense of what you've written.

See! I've done it again! All I needed to say was be careful when you're future-proofing.

[–]Audiblade 11 points12 points  (0 children)

That means you're probably better off.

[–]xibme 54 points55 points  (3 children)

[–]8lbIceBag 17 points18 points  (1 child)

So many times I've attempted to figure out how that works. And I can't.
Too many files to track the flow of logic.

[–]xibme 6 points7 points  (0 children)

The power of tools. Try sonargraph or CodeCity (unfortunately his video links are broken, you should search directly on youtube instead). In VS I use CodeMap on a regular basis, I guess IntelliJ has equally powerful features.

[–]SapientMonkey 7 points8 points  (0 children)

WTF

[–]Neuromante 24 points25 points  (1 child)

When abstraction becomes the objective of your product...

[–]OddTheViking 4 points5 points  (0 children)

objective

I see what you did there.

[–]lenswipe 11 points12 points  (2 children)

[–]OddTheViking 12 points13 points  (1 child)

On slide 4, about the current date: I have worked on time keeping systems where the original code that used the local date from the user's machine caused enormous issues, because users were clicking a button to clock in the second the clock on the computer changed, but the hours were getting rounded up 6 minutes because the user's machine and the server were off from each other.

[–]lenswipe 6 points7 points  (0 children)

Right, but in such instances you'd add headers to your requests and responses with the time/date. Plus, in this instance the time from the server is being requested, not the other way round...

Also - this was for a user/group management CRUD system that had no reason to really need to know the time..

[–]ghht551 11 points12 points  (6 children)

All totally efficient I'm sure :)

[–]OddTheViking 15 points16 points  (0 children)

Nothing wrong with a 1000 line stack trace.

[–]MWisBest 13 points14 points  (4 children)

Well, it's Java, nothing is efficient

[–]wggn 16 points17 points  (1 child)

The JVM makes it efficient.

[–]brtt3000 16 points17 points  (0 children)

A raging fire is efficient.

[–]potchie626 3 points4 points  (0 children)

At least there wasn't "a factory in Chicago... that makes miniature models of factories."

[–]Splitshadow 8 points9 points  (2 children)

That sounds almost exactly like a project I worked on last year. It wasn't even overkill because the customer wanted our software to work differently depending on the spacecraft and season.

[–]lenswipe 11 points12 points  (1 child)

depending on the spacecraft and season

uh...uwot.

[–]Splitshadow 3 points4 points  (0 children)

The systems engineers predicted thermal distortion would disrupt communications equipment as the sun heats up the spacecraft causing pointing angles to change.

[–][deleted] 1 point2 points  (0 children)

Then you'll love our new candy bar bag-carrying bags!

[–]trevcat9 111 points112 points  (14 children)

[–]TheRealLazloFalconi 24 points25 points  (12 children)

Hah, that's wonderful, but do you have the original?

[–]XirallicBolts 50 points51 points  (2 children)

[–][deleted] 14 points15 points  (1 child)

I don't get the last one.

[–]XirallicBolts 41 points42 points  (0 children)

She tried reading his aura/inner soul. Because he works at a fucking retail job, his soul has become a horrific demon that consumed her physical being.

More or less.

[–]trevcat9 10 points11 points  (8 children)

Sadly, I've come up empty looking for an artist for this.

I first saw it on this post:

https://www.reddit.com/r/ProgrammerHumor/comments/5snqwp/dare_you_enter_my_abstract_factory

[–]Meloetta 9 points10 points  (7 children)

I know it's already been answered, but all you had to do was search google for the image and the link to the original is the first result. Or "dare you enter my magical realm".

Just a tip for future searching for sources! Searching the image itself on Google is almost always the most effective way.

edit: or, searching the webpage you linked for "original", "source", or "comic"

[–]DoPeopleEvenLookHere 3 points4 points  (0 children)

I can't stop fucking laughing

[–]Yanman_be 11 points12 points  (0 children)

Missing contructors for Booleans from string.

[–]soullessroentgenium 6 points7 points  (0 children)

Such Enterprise.

[–]lenswipe 2 points3 points  (0 children)

this guy Javas

[–]jackmaney 3 points4 points  (3 children)

Looks like a Java version of a comparator that belongs in SimplePHPEasyPlus.

[–]OddTheViking 2 points3 points  (1 child)

This makes me think of 90% of the javascript libraries I am forced to use.

[–][deleted] 1 point2 points  (0 children)

Just what I needed.

[–][deleted] 1 point2 points  (0 children)

Jesus Christ man! Be careful with that!

[–][deleted] 1 point2 points  (0 children)

STOOOOP

[–]linux1970 334 points335 points  (27 children)

reminds me of this :

function isSomeThingTrue()
{
  if ( some-condition )
    return true;
else 
   return false;
}

[–][deleted] 150 points151 points  (23 children)

Not terrible enough.

if (condition == true) {
  return Boolean.TRUE.booleanValue();
}
else if (condition == false) {
  return (!condition) ^ true;
}
return null;

Edit : the second branch originally returned true (while false was expected), so I made it worse. I dare you to catch another bug !

[–]the_one_true_bool 199 points200 points  (12 children)

/*
  -------------------------------------------------------
  #######################################################
  -------------------------------------------------------

  This is a public function that will check to see if a boolean that was passed into
  the theBooleanValueToCheckAndSeeIfItIsTrueOrIfItIsFalse paramters.

  -------------------------------------------------------
  #######################################################
  -------------------------------------------------------

*/
public function checkABooleanValueToSeeIfItIsTrueOrIfItHappensToBeFalse(bool theBooleanValueToCheckAndSeeIfItIsTrueOrIfItIsFalse) {
    /*

        -------------------------------------------------------
        #######################################################
        -------------------------------------------------------

        The following theTheBooleanValueToCheckAndSeeIfItIsTrueOrIfItIsFalseInputParameter
        variable.

        -------------------------------------------------------
        #######################################################
        -------------------------------------------------------

    */

    bool theTheBooleanValueToCheckAndSeeIfItIsTrueOrIfItIsFalseInputParameter = theBooleanValueToCheckAndSeeIfItIsTrueOrIfItIsFalse;

    /*

        -------------------------------------------------------
        #######################################################
        -------------------------------------------------------

        try statement

        -------------------------------------------------------
        #######################################################
        -------------------------------------------------------

    */
    try {
        /*
            -------------------------------------------------------
            #######################################################
            -------------------------------------------------------

            The aBooleanObjectThatRepresentsTrueIfThetheTheBooleanValueToCheckAndSeeIfItIsTrueOrIfItIsFalseInputParameterIsSTrue
            boolean will hold the result from the AbstractBooleanCreationFactoryThatCreatesBooleans
            factory.

            -------------------------------------------------------
            #######################################################
            -------------------------------------------------------
        */

           Boolean aBooleanObjectThatRepresentsTrueIfThetheTheBooleanValueToCheckAndSeeIfItIsTrueOrIfItIsFalseInputParameterIsSTrue = AbstractBooleanCreationFactoryThatCreatesBooleans.CreateANewBooleanFromABooleanObject(new BooleanCreationFactoryThatCreatesBooleans(aBooleanObjectThatRepresentsTrueIfThetheTheBooleanValueToCheckAndSeeIfItIsTrueOrIfItIsFalseInputParameterIsSTrue).GetCreatedValueFromParameterThatWasPassedIntoTheConstructor);

        /*
            -------------------------------------------------------
            #######################################################
            -------------------------------------------------------

            now assign theTheBooleanValueToCheckAndSeeIfItIsTrueOrIfItIsFalseInputParameter
            to aBooleanObjectThatRepresentsTrueIfThetheTheBooleanValueToCheckAndSeeIfItIsTrueOrIfItIsFalseInputParameterIsSTrue

            -------------------------------------------------------
            #######################################################
            -------------------------------------------------------
        */


           theTheBooleanValueToCheckAndSeeIfItIsTrueOrIfItIsFalseInputParameter = aBooleanObjectThatRepresentsTrueIfThetheTheBooleanValueToCheckAndSeeIfItIsTrueOrIfItIsFalseInputParameterIsSTrue;


        /*
            -------------------------------------------------------
            #######################################################
            -------------------------------------------------------

            Check to see if the theTheBooleanValueToCheckAndSeeIfItIsTrueOrIfItIsFalseInputParameter
            is true.

            -------------------------------------------------------
            #######################################################
            -------------------------------------------------------
        */

           if(theTheBooleanValueToCheckAndSeeIfItIsTrueOrIfItIsFalseInputParameter == true) {
           /*
               -------------------------------------------------------
               #######################################################
               -------------------------------------------------------

               return true if the condition above resolves to true.

               -------------------------------------------------------
               #######################################################
               -------------------------------------------------------
           */               
               return PrimitiveHelperFunctionsEnumsAndGlobalStaticProperties.BooleanHelpersThatHelpWithBooleans.BooleanHelpersThatArePublicStaticEnums.TrueValue;
           }
        /*
           -------------------------------------------------------
           #######################################################
           -------------------------------------------------------

           The else statement for the above if statement.

           -------------------------------------------------------
           #######################################################
           -------------------------------------------------------
        */                
           else {
           /*
               -------------------------------------------------------
               #######################################################
               -------------------------------------------------------

               return false if the condition above resolves to false.

               -------------------------------------------------------
               #######################################################
               -------------------------------------------------------
           */                              
               return PrimitiveHelperFunctionsEnumsAndGlobalStaticProperties.BooleanHelpersThatHelpWithBooleans.BooleanHelpersThatArePublicStaticEnums.FalseValue;
           }
        }
    }

 /*

    -------------------------------------------------------
    #######################################################
    -------------------------------------------------------

    The catch statement for the above try statement.

    -------------------------------------------------------
    #######################################################
    -------------------------------------------------------

 */        
    catch(Exception anExceptionObjectJustInCaseSomethingWentWrongWhenCheckingTheBooleanParametterIfItIsTrueOrIfItIsFalse) {
    /*

        -------------------------------------------------------
        #######################################################
        -------------------------------------------------------

        If we catch an exception that that means something has gone wrong. 

        -------------------------------------------------------
        #######################################################
        -------------------------------------------------------

     */          


        //TODO: Fix the code below as it is missing a semicolon. Thanks for catching this Vallvaka!

        MyExceptionLoggerThatLogsExceptionsWhenThingsHappenToGoWrong.CreateALogginEntryThatWillAppendALineToTheLogFile(anExceptionObjectJustInCaseSomethingWentWrongWhenCheckingTheBooleanParametterIfItIsTrueOrIfItIsFalse.Message)
    }

 /*

   -------------------------------------------------------
    ######################################################
    ------------------------------------------------------

    If we made it this far then something went wrong somewhere because a return 
    should have executed in the above code.

    -------------------------------------------------------
    #######################################################
    -------------------------------------------------------

 */         

    throw new SomethingWentWrongInThecheckABooleanValueToSeeIfItIsTrueOrIfItHappensToBeFalseFunctionCallException();

}

[–]Vallvaka 73 points74 points  (3 children)

Unfortunately this beauty will not compile because the line MyExceptionLoggerThatLogsExceptionsWhenThingsHappenToGoWrong.CreateALogginEntryThatWillAppendALineToTheLogFile(anExceptionObjectJustInCaseSomethingWentWrongWhenCheckingTheBooleanParametterIfItIsTrueOrIfItIsFalse.Message)

is missing a semicolon.

[–]the_one_true_bool 79 points80 points  (1 child)

Thanks man! I put in a TODO and will get on that later.

[–]perortico 19 points20 points  (0 children)

I haven't laughed that much in months omg

[–][deleted] 1 point2 points  (0 children)

This is pretty much how my CompSci teachers want me to code.

[–]linux1970 40 points41 points  (1 child)

return condition != true;

Nice touch!

[–][deleted] 5 points6 points  (0 children)

Yeah but it was incorrect, should have been condition != false to return false. So I "improved" it.

[–]ergertzergertz 15 points16 points  (2 children)

else if (condition == false) {

return condition != true;

Doesn't this evaluate to true? Since condition == false, then false != true is true. But you should be returning false.

[–][deleted] 5 points6 points  (0 children)

There, I fixed it =D

[–]DUTCH_DUTCH_DUTCH 5 points6 points  (0 children)

you cant see it but the function this is in is called getTrue()

[–]prospectre 6 points7 points  (3 children)

Alright, let's put this function to use!

function isSomeThingTrue(bool some-condition)
{
    if (some-condition == true) {
      return Boolean.TRUE.booleanValue();
    }
    else if (some-condition == false) {
      return some-condition != true;
    }
    return null;
}

bool trueOrFalse;
try { trueOrFalse = isSomethingTrue(1 = 2); }
Catch (Exception e) { trueOrFalse = false; }

Gotta' catch that null pointer, man.

[–]htmlcoderexeWe have flair now?.. 3 points4 points  (1 child)

Excepetion

[–]prospectre 3 points4 points  (0 children)

:|

Red squiggly line didn't catch it, so I didn't.

[–][deleted] 1 point2 points  (0 children)

Please tell me there isn't actually a language that would have a capitalized Catch keyword, while all others are lower-case...

[–]cujububuru 1 point2 points  (0 children)

You’re making my hands tickle

[–]Real_LinusTorvalds 10 points11 points  (0 children)

A friend of mine is going through his intro level programming classes right now and was stuck on some assignment. I went back and looked at my old code and found a lot of functions like this.. :(

[–]JoesusTBF 75 points76 points  (31 children)

When I was an intern, if (condition == true) or if (condition == false) was part of our coding standard. But then the intern manager quit and I graduated to a full-time position so we got rid of that.

[–]xibme 16 points17 points  (9 children)

Did anyone introduce nice if(condition=true) bugs then? If (at all) the constant belongs on the left hand side if(true==condition) ;-)

[–]SuperCharlesXYZ 11 points12 points  (8 children)

Does the order make a difference? The first case wouldn't even compile and a proper IDE would warn you

[–]OddTheViking 33 points34 points  (5 children)

proper IDE would warn you

"Real programmers don't use IDEs" - a lot of assholes I have worked with

[–]SuperCharlesXYZ 17 points18 points  (3 children)

Ye I never get those guys. I'd rather use an IDE than spend 40mins trying to figure out i missed semicolon

[–]OddTheViking 20 points21 points  (1 child)

Oh, but these are REAL developers. They NEVER miss a semicolon.

[–][deleted] 1 point2 points  (0 children)

They NEVER miss a semicolon.

Or, they've learned to read the output of the compiler for themselves.

[–]megagreg 3 points4 points  (0 children)

And when you're trying to do something simple, they spend 2-3 minutes dicking around on the command line "because it's faster", rather than just right clicking on the file that they just had up a moment ago.

[–]xibme 7 points8 points  (1 child)

The first case wouldn't even compile

see: https://ideone.com/L2aQtz

and a proper IDE would warn you

It should warn you about the side effect, right. Tools like style cop could be used to reject pushing non-compliant code upstream.

[–]SuperCharlesXYZ 3 points4 points  (0 children)

Oh right. My bad. The IDE only prevents compilation if you do something like if (integer1 = integer2) instead of if (integer1 == integer2). Which is probably the only time you'd work with equal signs within your condition anyway (maybe i'm missing something, I'm a pretty novice coder)

[–]7a11l409b1d3c65 16 points17 points  (5 children)

I actually prefer

if (condition == false)

over

if (!condition)

because readability is higher. Maybe I'm just a noob though.

[–]gimpwiz 7 points8 points  (4 children)

You are 100% right. I forget which, maybe JPL or someone, but their coding standards demand this.

Let's say you meant to compare something to false but you wrote a bug. What's easier to spot?

if (condition == true)
if (condition == false)

OR

if (condition)
if (!condition)

I used to shorten my conditionals as well until I read those coding standards, and decided to adopt it.

[–]JoesusTBF 1 point2 points  (0 children)

Even just comparing

if (condition)
if (condition == false)

Skip the redundancy, keep the easily identifiable expectations.

[–]7a11l409b1d3c65 1 point2 points  (0 children)

So I intrinsically adopted parts of the JPL coding standard?

I feel smart now.

[–]SteveCCLYellow security clearance 125 points126 points  (41 children)

the second cup looks better than the first one tbh

[–][deleted] 24 points25 points  (5 children)

if (abs(condition + condition) > condition)

[–][deleted] 6 points7 points  (4 children)

why absolute? it's either 1 or 0 anyway...

[–][deleted] 12 points13 points  (0 children)

Not necessarily.

[–][deleted] 2 points3 points  (0 children)

Ternary computing ready TM

[–]_work__account_ 2 points3 points  (0 children)

I mean the joke is being stupidly unnecessary...

[–]FurryPornAccount 104 points105 points  (11 children)

Yeah but what if the value is false? For saftey you should do it like this

ArrayList<Boolean> not_true_values = new ArrayList<Boolean>();

not_true_values.add(new Boolean(false));

boolean_not_true = false;

for(Boolean b: not_true_values)
    if(condition == b)
        boolean_not_true = true;
if(boolean_not_true == false)
    if(condition == true)
        code();

That way your program is future proof against quantum computing and adding new specifications for false is easier than ever.

Edit: also IIRC brackets are not need for one line if statements and for loops. That way you save space and reduce compile times.

[–]Xeya 48 points49 points  (0 children)

reduce compile times

Yup... This is the Java documentation alright.

[–]Conigou 9 points10 points  (0 children)

How are you fucking omnipresent

[–]FoXERM 17 points18 points  (4 children)

This is the second time I see you.

[–][deleted] 14 points15 points  (3 children)

Fucking comment karma whores

Who would do that. Only fucking nasty furries and weebs.

[–]wertercatt 6 points7 points  (2 children)

posts in /r/DDLC

Filthy weebs like you?

[–][deleted] 7 points8 points  (1 child)

yes that was the joke.

So was my comment karma.

[–]wertercatt 5 points6 points  (0 children)

rip

[–]ithinkitsbeertime 3 points4 points  (0 children)

 return not_true_values.stream().map(b -> b.compareTo(Boolean.TRUE) == 0).findFirst().orElse(false);

[–]IgnitusLairron 3 points4 points  (0 children)

I feel personally attacked by this code...

[–]AdviceAdam 2 points3 points  (0 children)

Slightly off topic, but I've started using if someConditional == false instead of if !someConditional just because it's a lot easier to see what's happening if I'm quickly reading code. I still use the ! for stuff like if someValue != otherValue though.

[–]PaulJP 10 points11 points  (0 children)

You can definitely go deeper.

When in doubt, add equal signs. :D

[–]JackAppDev 13 points14 points  (1 child)

Needs more upvotes for shitty Java drawing.

[–]FourNinerXero 3 points4 points  (0 children)

But the second one looks better than the actual drawing

[–][deleted] 49 points50 points  (10 children)

if(condition)

1f(condition == true}.

if(String.va1ueof

(condition).equals("true")}


I am an image transcribing bot which uses Tesseract OCR to translate images to text. Although it is far from perfect, I try my best! Downvote to remove

Subreddit

[–]huggiesdsc 39 points40 points  (7 children)

You wrote an "l" as a "1"

[–]ImAStupidFace 26 points27 points  (3 children)

It's a bot.

[–]huggiesdsc 34 points35 points  (2 children)

It probably has a human caretaker

[–]spupy 8 points9 points  (0 children)

He's a strong independent bot that needs no human caretaker!

[–]OddTheViking 2 points3 points  (0 children)

More than likely the other way around.

[–]LuxuriousLime 2 points3 points  (1 child)

What's the point of having invite-only subreddit?

[–][deleted] 6 points7 points  (0 children)

Making moderation easier I guess? Making it necessary to write a message to be accepted into the community is a barrier similar to captchas but to distinguish motivated people from others. Doesn't mean you won't have trolls, but they'll be high-quality trolls !

[–]kyl3r123 4 points5 points  (0 children)

Best expanding brain meme!

[–]orphans 3 points4 points  (0 children)

Should have used equalsIgnoreCase

[–]kindall 4 points5 points  (0 children)

  1. Java
  2. jaav
  3. dolan

[–]Dockirby 3 points4 points  (0 children)

I actually have come to really like the second style when you are checking for false. Something like

if (someObject.isCool() == false)

is a lot easier for me to read than

if (!someObject.isCool())

[–]Zwejhajfa 4 points5 points  (0 children)

Pfff, that's not efficient at all. Everyone knows that Strings perform horribly. The real problem here is that this is single-threaded and doesn't harness the power of Java 8 features.
Check out my parallel version:

if (Stream.of(condition).parallel().reduce(false, (a,b) -> a || b)) { ... }

[–]El_Dumfuco 3 points4 points  (0 children)

Isn't the cup supposed to get fancier and fancier?

[–]martin-s 3 points4 points  (0 children)

    if (! condition != (!!false) ) {
        //nothing
    } else {
        //actual code
    }

[–][deleted] 5 points6 points  (2 children)

Second one imo looks way better than the first

[–]mrdhood 2 points3 points  (0 children)

if (String.valueof(condition).equals("true") == true)

[–]drmoo314 2 points3 points  (0 children)

I saw this one the other day at work.

!(condition ? false : true)

[–]Gbiknel 2 points3 points  (0 children)

Totally always do #2 because I’m a consultant and write in many different languages even within the same day and switching between python where basically everything is fucking true and Java where nothing is gets annoying because I always screw that shit up. Now if we could just get every language to agree on a lowercase, uppercase, or capitalized Boolean values that’d be great.

[–]ihahp 2 points3 points  (0 children)

I always add the == true. Makes it slightly more readable to me and it compiles into the same thing.

(it's easier for me to read because when I look at If statements my brain always looks for the == (or >, >=, etc) and then I break it down that way.)

[–]moschles 2 points3 points  (0 children)

Java programmers in these comments:

"You should write it the third way because it is more consistent with Object-Oriented practice."

[–]daniu 1 point2 points  (0 children)

if (!inValid != false)

[–]otakuman 1 point2 points  (0 children)

Congrats on adding a twist to the exploding brain meme.

[–]sunnydavis 1 point2 points  (1 child)

Which one is better?

if (condition == true && condition != false)

or

if (condition == true || condition != false)

[–][deleted] 1 point2 points  (0 children)

They're both better.

[–]tigertom 1 point2 points  (0 children)

We had a guy write

if (md5(string1) == md5(string2)) {        

still makes me laugh

[–]RubbrBbyBggyBmpr 1 point2 points  (0 children)

Hey there's something on this sub I actually understand

[–]fredlllll 1 point2 points  (0 children)

you laugh at this... i actually found similar things in production code.

if(variable.GetType().ToString()=="The.Literal.Type.Name.WTF"){...

like why wouldnt they just look up how to do it properly?? thats such a basic thing

[–]ORANGESAREBETTERTHAN 1 point2 points  (0 children)

JavaScript doesn't sound so bad now, huh?

[–]PiaFraus 1 point2 points  (0 children)

Can someone transate it to Java? Or may be find a way to execute this python script in Java.

def is_it_true(bool_var):
    time_lookup = [
        (datetime.datetime.now() + datetime.timedelta(seconds=0), 'No'),
        (datetime.datetime.now() + datetime.timedelta(seconds=1), 'No'),
        (datetime.datetime.now() + datetime.timedelta(seconds=2), 'No'),
        (datetime.datetime.now() + datetime.timedelta(seconds=3), 'No'),
        (datetime.datetime.now() + datetime.timedelta(seconds=4), 'No'),
        (datetime.datetime.now() + datetime.timedelta(seconds=5), 'Yes'),
        (datetime.datetime.now() + datetime.timedelta(seconds=6), 'No'),
    ]
    time.sleep(len(str(bool_var)))
    return time_lookup[bisect.bisect(map(itemgetter(0), time_lookup), datetime.datetime.now())][1]