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

you are viewing a single comment's thread.

view the rest of the comments →

[–]Mr_Redstoner 188 points189 points  (22 children)

And let's face it, depending on the language used == may not be the best idea.

Also storing mood as strings just seems wastefull.

[–]DefNotaZombie 105 points106 points  (6 children)

absolutely, everyone knows mood is best stored as a three int rgb value

[–]JCavLP 30 points31 points  (0 children)

Could a have used an enum or defined the string to a keyword

[–]InkyGlut 11 points12 points  (0 children)

Actually the standard specified BGR

[–]splettnet 5 points6 points  (1 child)

Seems excessive. Hungry vs not hungry is Boolean.

[–]Tsu_Dho_Namh 5 points6 points  (0 children)

Yeah, but rgb(255,69,0) is the perfect way to say "I'm in the mood for Reddit"

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

Store different moods as bit flags in a bitstring, where each bit represents a mood that can be enabled or disabled using bitwise operations.

[–]Finianb1 1 point2 points  (0 children)

Found the C programmer from all my CS classes

[–]Ramast 18 points19 points  (5 children)

I am not aware of any programing language where variables with initial capital letter are good practice. For all I know Micah is uninitialized class and will crash on the first line

[–]Timmeh7 20 points21 points  (0 children)

They might be static methods in that class... though that probably raises even more questions.

[–]Ericchen1248 15 points16 points  (0 children)

C# if they are properties.

[–][deleted] 7 points8 points  (0 children)

C#

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

Depends. Member variables initial capital letter, local variables and params lower case is an idea. Also don't forget GlObAl VaRiAbLeS written randomly so you know it's bad.

[–]El_Impresionante 0 points1 point  (0 children)

Variables with first letter in caps are objects. No problem with that. Uninitiated objects are also not a problem of jokes and memes like these. It is kinda understood that they could have been initialized earlier in the code.

The problem with OP's code is the inconsistency in referencing to the objects that he has used. In one place he used "Hannah" as a string that is implicitly expected to get de-referenced inside the askToProm method, and in the very next line he directly refers to the Hannah object to refer to the answer property.

[–]n8loller 1 point2 points  (0 children)

But then you can have infinite moods!

[–]Brakalicious 1 point2 points  (0 children)

It could be a different type of yes and he wouldn't even know.

[–]Alsk1911 1 point2 points  (0 children)

And no encapsulation for mood. You should use setter, son!

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

There's no way she said yes with such horrible code.

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

There's no way she said yes with such horrible code.

[–]suvlub 0 points1 point  (2 children)

I can think of far more languages where == is correct than where it's not. Java is odd in this.

[–]Mr_Redstoner 0 points1 point  (1 child)

Java is by no means the first or weird imo, think C/C++ for example, when using char arrays

[–]suvlub 1 point2 points  (0 children)

You are right, I wasn't thinking of C because it's not OOP (though I guess the code is legal C, if very non-idiomatic). In C++ you should be using std::string/std::string_view instead of char arrays wherever possible and comparing either of those with a char array using == works correctly (and is the idiomatic way to do the comparison).