Skip to content
DevMeme
1633 of 7435
The Cardinal Sin of Redundant Boolean Checks
Juniors Post #1826, on Aug 1, 2020 in TG

The Cardinal Sin of Redundant Boolean Checks

Why is this Juniors meme funny?

Level 1: Just Yes or No

Imagine you ask your friend a very simple yes-or-no question, like: “Did you finish your homework?” Now picture your friend replying:

“If it is true that I finished my homework and it isn’t false, then yes. Otherwise, if it is false that I finished my homework and it isn’t true, then no.”

😕 That’s a super confusing way to answer, right? They basically said “yes” or “no,” but wrapped it in a huge, unnecessary sentence. You’d probably laugh and ask, “Why didn’t you just say yes or no in the first place?!”

In this meme, the new programmer did the same kind of silly thing, but with code. The task was simple: return either true or false. There was already a direct way to do it (just return the boolean value). But the beginner wrote a whole mini-story of checks to arrive at the same answer, just like our friend who gave the long-winded answer about homework. It’s funny because the solution was obvious and short, yet the newbie over-complicated it for no good reason.

The last picture in the meme (with the police officer) is like a teacher or a coding mentor jokingly saying, “Alright, that’s enough. We don’t do it that way!” It’s as if the code itself broke a rule and the “code police” showed up to correct it. The emotional core here is clear and simple: doing way too much work to answer a straightforward question is silly! In programming (and in life), sometimes the best thing to do is just give the simple answer. Just say yes or no — or in code, just return the boolean — and everyone will be happier (and you won’t get “arrested” by the code cops! 😉).

Level 2: No If Required

Let’s break down what’s going on in simpler terms. We have a variable someBool which is a Boolean – that means it can only ever be true or false (like a yes-or-no flag in the code). In many programming languages, you can return that boolean value directly. For example, return someBool; will send back true if someBool is true, or false if someBool is false. Nice and clean!

Now look at the newbie’s code. They used an if-else statement to do the exact same thing in a long-winded way. The code says:

  • If someBool == true and someBool != false, then return true.
  • Else if someBool == false and someBool != true, then return false.

This is a mouthful, but notice something: the conditions someBool == true and someBool != false are actually checking the same thing. If someBool is true, of course it’s not false! The newbie double-checked the condition in a way that isn’t needed. Similarly, the else-if is checking if someBool is false and not true (again the same idea twice). Effectively, the logic is: “if someBool is true, return true; otherwise if someBool is false, return false.” But that’s the definition of return someBool;! The extra == true and != false parts don’t add any new information – they’re just excessive conditional checks that make the code longer and harder to read.

Why would a beginner write such code? Often, new programmers feel like they must spell everything out. They might not realize that the programming language already understands booleans. In many languages, writing if(someBool) is enough to check truth, but newbies might write if(someBool == true) because it reads like English (“if someBool is true”). They’re being extra cautious. Think of it as over-explaining to the computer. But the computer is a strict logical machine – it doesn’t need that redundancy. All those == true comparisons are like repeating yourself. There’s even a term for this kind of unnecessary code: a code smell (meaning the code works, but it’s a bit off or could be better). Seasoned developers have learned to avoid these smells by following clean code principles. One principle is to make code simple and readable: don’t use eight lines of code when one line will do the job.

The meme uses the popular Drake Hotline Bling format to make this point. In the top panel, the text shows return someBool; and Drake (the guy in the orange jacket) is waving his hand like “nah, I don’t want that.” This represents the junior dev rejecting the simple solution. In the next panel, Drake is smiling and pointing approvingly at the big, clunky if(someBool==true&&someBool!=false){...} code block – the newbie likes the complicated approach (thinking it’s better or being proud they used if-else). It’s an inversion of what we’d expect: usually we cheer for the simple solution, not the complex one! That contrast is the humor. Finally, the bottom image shows Drake being led away by a police officer. This is a funny way to say “writing code like that is so wrong, it’s almost a crime.” The “code quality police” (a pretend concept referencing senior developers or strict reviewers) have caught our newbie red-handed writing unnecessarily messy code.

This is all very relatable humor in programming circles. Almost every developer remembers a time when they or their classmate wrote an overly complicated piece of code to handle something simple. It might happen in a first project or an intro class: for instance, using five if statements when one would do, or in this case explicitly checking true/false instead of trusting the boolean. The tags like #CodeSmells and #CleanCodePrinciples are nudging at the idea that as you gain experience, you learn to recognize and remove these awkward patterns. The meme is basically a lighthearted teaching moment: “Hey, if you have a boolean, you don’t need an if to return true or false – just return it!” Keep code straightforward, because simpler code is not only easier to read, it’s less prone to errors. And as shown, it keeps you out of trouble with the (fictional) coding cops! 👮‍♂️😄

Level 3: Reinventing the Boolean

At first glance, any experienced coder can spot that the second code snippet is committing a small coding crime. The meme shows a newbie developer (represented by Drake in the famous orange jacket) rejecting the simple one-liner return someBool; and instead embracing an over-complicated if/else block. To a senior developer, this choice is hilariously wrong – it’s like the Clean Code police should step in (and in the meme, a real police officer does exactly that, hauling Drake away for his offense).

In that verbose snippet, the newcomer wrote:

boolean someBool = /* ... */;

// Over-engineered approach (beginner style)
if (someBool == true && someBool != false) {
    return true;   // Redundant check: true && not false is just true
} else if (someBool == false && someBool != true) {
    return false;  // Redundant check: false && not true is just false
}

// Clean, simple approach (expert style)
// return someBool;

What is this code doing? Essentially: “if someBool is true, return true; else if someBool is false, return false.” Well… duh! 🙃 That’s logically the same as just return someBool;. In Boolean algebra, checking (X == true && X != false) is 100% equivalent to just X itself (since a boolean can’t be true and false at the same time). The newbie has wrapped a simple truth value in layers of pointless conditions, a textbook case of excessive conditional checks.

Why is this funny to seasoned devs? It violates a bunch of well-known coding principles in a comically obvious way. First, it breaks the KISS principle (Keep It Simple, Stupid): a one-line return got blown up into a multi-line logic maze for no gain. It’s also a minor breach of DRY (Don’t Repeat Yourself): the code literally repeats the fact that someBool can only be true or false by checking both conditions explicitly. We have a saying that fits here: this is the coding equivalent of wearing both belt and suspenders to hold up your pants – totally redundant and unnecessary, but the newbie perhaps felt extra “safety” by double-checking everything.

In real projects, this pattern is recognized as a small code smell. It doesn’t necessarily break the program, but it’s a sign the author didn’t know a cleaner way. During a code review, a senior engineer would immediately flag this and ask, “Why not just return the boolean directly?” In fact, many linters or IDEs will automatically warn about this kind of thing (e.g., “Simplify boolean expression” or “Redundant boolean literal comparison”). The humor is amplified by the meme’s format: Drake turning away from the correct solution and approving the wrong one, then facing comedic consequences. It’s a playful jab that every senior developer has seen (or written!) clunky logic like this at some point, and we’re collectively saying, “Nope, not on our watch!” 🔍👮‍♂️

Ultimately, the meme exaggerates a fundamental lesson in programming: don’t over-engineer a solution that’s already straightforward. Writing extra checks for a boolean is like inventing a convoluted ritual to answer a yes/no question. It’s silly, it clutters the code, and it makes other developers want to call the code quality police. The seasoned perspective here is clear – keep your code simple and let the language do its job, or you might get “arrested” in the court of developer humor.

Description

A three-panel meme captioned 'newbie programmer be like:'. The first two panels use the 'Drake Hotline Bling' format. In the top panel, Drake looks away in disapproval from a simple, clean line of code: 'return someBool;'. In the middle panel, Drake smiles approvingly at a much more verbose and convoluted block of code that accomplishes the exact same thing: 'if(someBool==true&&someBool!=false){ return true; } else if(someBool==false&&someBool!=true){ return false; }'. The third panel, the punchline, shows Drake being escorted away by a police officer, implying that writing such unnecessarily complex code is a criminal offense against programming principles. The meme satirizes a common mistake made by beginner programmers who haven't yet grasped concise boolean logic, often explicitly checking for true/false conditions when the variable itself is already a boolean. For senior developers, this is a painfully familiar anti-pattern seen in code reviews, and the final panel is a humorous exaggeration of their desire for code quality enforcement

Comments

7
Anonymous ★ Top Pick This is why the 'git blame' command exists. It's not for attribution, it's for building the case for the prosecution
  1. Anonymous ★ Top Pick

    This is why the 'git blame' command exists. It's not for attribution, it's for building the case for the prosecution

  2. Anonymous

    The junior’s PR turned “return flag;” into a 12-line if/else because “defensive coding.” I told him the only thing that code defends against is the CPU’s branch predictor having a quiet evening

  3. Anonymous

    This is the same code pattern I've seen in production after a 6-month enterprise consulting engagement that billed $2M to "ensure robust boolean validation across all service boundaries."

  4. Anonymous

    Ah yes, the classic junior move: checking if a boolean is simultaneously true AND false - Schrödinger's variable, where the code exists in a superposition of 'will never execute' and 'why did this pass code review?' The real kicker is that even if you removed the impossible logic, you'd still be left with 'if(someBool==true) return true; else return false;' - which is just 'return someBool;' with extra steps and a desperate cry for mentorship

  5. Anonymous

    Turning “return b;” into “if (b == true && b != false) …” is SAT-solver cosplay - leave three-valued logic to the legacy DB; in a language with booleans, just return the bit

  6. Anonymous

    If your boolean needs both == true and != false, you’re auditioning for a SAT solver - return someBool and let the linter retire in peace

  7. Anonymous

    Because trusting a boolean's self-awareness is for senior devs; newbies need if-else therapy to confirm true isn't lying

Use J and K for navigation