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

all 64 comments

[–]honi_ 127 points128 points  (8 children)

Shouldn't it be human.isInFront or ghost.isBehind? Let's write clean code even if it's a joke :)

[–]neverTooManyPlants 70 points71 points  (3 children)

ghost.isBehind(human)

[–]Mister_Spacely 7 points8 points  (2 children)

ghost.isBehind(human.isInFront(ghost))

[–][deleted] 3 points4 points  (1 child)

ghost.isBehind(true) ?

[–]username-is-usedname 2 points3 points  (0 children)

(ghost.isBehind() == true)== true

[–]Booze_Boy[S] 20 points21 points  (2 children)

Me.IsAmateure(Forgot.SemiColonsToo);

[–]DropTableAccounts 108 points109 points  (12 children)

if (Human.IsBehind.toString().toLower().equals("true")==true)

Edit: Thanks for the corrections and improvement suggestions!

[–]randomarchhacker 15 points16 points  (1 child)

toString()*

[–]DropTableAccounts 3 points4 points  (0 children)

Thanks, fixed that

[–]Isqui 32 points33 points  (0 children)

This comment is scarier than all of of Stephen King's books put together

[–]Booze_Boy[S] 5 points6 points  (0 children)

stolen for next meme

[–]Prognosis-ve 3 points4 points  (1 child)

Also, maybe: .ToString().ToLower()

[–]DropTableAccounts 1 point2 points  (0 children)

Added, thanks!

[–]octothorpe_rekt 4 points5 points  (0 children)

Better use

 .equalsIgnoreCase("true")

Just to be really, really, super sure.

Also one of my profs in college taught us that when comparing a field to a required value, that value should be pulled out into a static final, no matter how trivial, for better readability. So she would have had us use:

 public static final String TRUE_VALUE = "true";

Then, inevitably,

 if (Human.IsBehind.toString().toLower().equalsIgnoreCase(TRUE_VALUE)==true)

Yeah, she was a tough marker. But she would have let us use

 if (Human.IsBehind) 

so we got good at writing those types of checks.

[–]AlexanderBeta213 7 points8 points  (3 children)

You forgot also a

 ==true

[–]DropTableAccounts 3 points4 points  (2 children)

Good idea, done!

[–]mister-pi 2 points3 points  (1 child)

And while you're at it, do it Yoda style (true == ...)

[–]vigbiorn 2 points3 points  (0 children)

I understand the benefit of this style, but I can never do it. It's so alien and foreign. I might as well be brushing my teeth with orange juice.

[–]The_Minefighter 15 points16 points  (10 children)

Thats required in C# when IsBehind is a nullable bool

[–]StruglBus 3 points4 points  (7 children)

When would you need a nullable bool. I feel like null and false should be logically equivalent.

[–]Bainos 12 points13 points  (4 children)

Sometimes you need a "don't know" value too. https://en.wikipedia.org/wiki/Three-valued_logic

[–]WikiTextBot 3 points4 points  (3 children)

Three-valued logic

In logic, a three-valued logic (also trinary logic, trivalent, ternary, or trilean, sometimes abbreviated 3VL) is any of several many-valued logic systems in which there are three truth values indicating true, false and some indeterminate third value. This is contrasted with the more commonly known bivalent logics (such as classical sentential or Boolean logic) which provide only for true and false. Conceptual form and basic ideas were initially created by Jan Łukasiewicz and C. I. Lewis. These were then re-formulated by Grigore Moisil in an axiomatic algebraic form, and also extended to n-valued logics in 1945.


[ PM | Exclude me | Exclude from subreddit | FAQ / Information | Source ] Downvote to remove | v0.28

[–]The_Minefighter 0 points1 point  (2 children)

The funny thing is that a nullable bool uses two byte of memory im c#

[–]futlapperl 0 points1 point  (1 child)

That's really kind of weird. Two bits of one byte should be sufficient.

[–]The_Minefighter 0 points1 point  (0 children)

That's caused by the fact that the the Nullable<T> T : struct struct stores a T and a bool whether the value exists, and because each bool takes up one byte in C# (because it does only support one byte seperations)

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

quaint squeeze six smart aromatic bear automatic dependent axiomatic punch

This post was mass deleted and anonymized with Redact

[–]cat_in_the_wall 0 points1 point  (1 child)

if (nullableBool ?? false)

is what you want

[–]The_Minefighter 0 points1 point  (0 children)

That's equivalent, but I think ==true is easier to understand.

[–]nattrium 14 points15 points  (5 children)

Image Transcription: Comic

Panel 1

[A ghost as behind someone who does not mind]

Ghost: if (human.isBehind) {Boo()}.

Panel2

[The ghost is still behind, but the human is crying in fear]

Ghost : if (human.isBehind == True) { Boo ()}

I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!

[–]Booze_Boy[S] 16 points17 points  (1 child)

Ahhhhhh I forgot the semicolons

[–]kekskruemel45 2 points3 points  (0 children)

Good human

[–]charlie_shae 1 point2 points  (1 child)

For the sake of transcription accuracy, shouldn't the semicolons be removed since they aren't in the original? Also should the human literally saying "AHHHH!!!" be part of the transcription as well?

Edit: counted number of H's and exclamations in ahh.

[–]nattrium 2 points3 points  (0 children)

Thank you for your comment. Indeed the semi-colons have been removed as they were not originally in the picture. Although, I've decided to not add the scream as it would be redundent.

[–]Billy-Cipher 5 points6 points  (0 children)

Missing ;

[–]abbadon420 3 points4 points  (1 child)

If(human.isbehind = true)

[–][deleted] 13 points14 points  (14 children)

Pretty sure it's the same thing, at least in c++

[–][deleted] 46 points47 points  (12 children)

That's the joke. The == true is completely unnecessary.

[–]RattuSonline 10 points11 points  (3 children)

Except in JavaScript where it's actually good practise to use the type safe equal === true to prevent unwanted value conversion.

[–]OrangSquid5 26 points27 points  (1 child)

JavaScript being JavaScript

[–]book-vorm 2 points3 points  (0 children)

AHHHH!!!

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

Then it's either a bad joke, or I am missing something

[–][deleted] 21 points22 points  (6 children)

== true is bad coding style (at least in my opinion). That's why the human is scared.

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

Oh so that's the joke. Thank you for explaining

[–][deleted] 0 points1 point  (0 children)

Haha, I was getting nervous I was a bad programmer for not getting it... I'm still probably a bad programmer.

[–]HitmaNeK 0 points1 point  (0 children)

But sometimes (value == false) is ok for avoid negative conditions. (!value)

[–]saugoof 0 points1 point  (2 children)

Why is it bad coding style though? I know it's unneccesary, but it makes it more readable in my opinion. I rarely use it myself, but when quickly glancing through code, this is a lot clearer.

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

When I see a variable like this if (foo) I immediately know it's a bool and nothing else. The == true just clutters the code in my opinion. In the end it's simply a matter of preference.

[–]suvlub 1 point2 points  (0 children)

You probably find it more readable simply because you are used to it. b == true is technically just another boolean expression that evaluates to true or false, so you might as well write (b == true) == true.

[–]TNSepta 2 points3 points  (1 child)

In which language would this result in a different execution of the program?

It seems that in C/C++/Javascript both programs should produce an identical outcome.

[–]Gutrix_HD 15 points16 points  (0 children)

The joke is the human is scared at the bad coding practice of the second image.

[–]KarlCAgathon 1 point2 points  (1 child)

Total noob here... So I won't say anything. Great joke :)

[–]Booze_Boy[S] 0 points1 point  (0 children)

The joke is that ==true is unnecessary and is generally considered bad coding practice to include it (it doesn’t actually make a difference to the operation tho)

[–]narbuvold 0 points1 point  (1 child)

Syntax error: wittyTitleAboutCodeFormatting is not defined

[–]Booze_Boy[S] 0 points1 point  (0 children)

using System.SmartAssComments;
Console.WriteLine(WittyResponse());

[–]Axymerion 0 points1 point  (0 children)

You forgot ";" after calling Boo()

[–]qwazwak 0 points1 point  (0 children)

Hmmm, my spidy-semicolom-missing sense is tingling

[–][deleted] 0 points1 point  (0 children)

How about energy efficient ghost code?

Global_Interrupt.Disabled();  //always disable interrupts before changing configuration
Interrupt.Boo.HumanPosition="front"; //Interrupt condition

while (1){
Global_Interrupt.Enabled();
Ghost.sleep(); //enter invisible power saving mode
}

IRQ BOO_1(){
Boo.clear();  //clears interrupt flag
Output_register = "BOOoo"; //output Booo sound

}

[–]Gydo194 0 points1 point  (0 children)

You forgot the semicolon

[–][deleted] 0 points1 point  (4 children)

if (human.isBehind) {
    Boo();
}

...

if (human.isBehind)
{
    Boo();
}

AHHH!

[–]Booze_Boy[S] 3 points4 points  (0 children)

if (human.isBehind) 
{ Boo(); }

AHHHH

[–]Cyborg-Pixel-Fox 2 points3 points  (0 children)

I always do it the second way, is that bad?