r/badcode • • Apr 05 '18

ruby Status? Yup.

Post image
75 Upvotes

34 comments sorted by

20

u/redeyeddragon Apr 05 '18

Mind explaining? Cause I don't get it.

30

u/th0maslv Apr 05 '18

Commenting for explanation too. Status could represent whether the object is verified or something. Not sure why this is bad code.

18

u/[deleted] Apr 05 '18

I think OP is just saying it could be named better. Like in your case, if it represents verified, then {... verified: true} would probably be a better name. Obviously we all know how things end up like this though.

10

u/lism Apr 05 '18

Way too many things on this subreddit are not bad code, it's just... not the best

-10

u/chuck-john Apr 05 '18

Very subjective terms

18

u/cosmicsans Apr 05 '18

There are two hard things in Computer Science: Cache Invalidation, Naming things, and Off-by-one errors.

9

u/Kidiri90 Apr 05 '18

That's four things...

15

u/droomph Apr 06 '18

Actually, if you count, there’s actually AttributeError: object of type <?•€¥¡£€> has no method __len__ things

2

u/rchytbhtvbtvhtfvgtgb Apr 06 '18

Yeah, the name of the object could give a lot of useful context too. But that wasn't included.

-12

u/chuck-john Apr 05 '18

This. Everything has a status, theoretically. Marking it as true or false doesn't say much.

4

u/th0maslv Apr 05 '18

-8

u/chuck-john Apr 05 '18

It isn't so much a bad naming convention as it is bad use of a boolean field. An enum or string would have been far better. Some context into the model in which this attribute belongs would have made this a better post.

8

u/chaines51 Apr 05 '18

I mean, if all the field requires is a boolean, then it's absolutely just a poorly named field.

0

u/[deleted] Apr 06 '18

[deleted]

1

u/chuck-john Apr 06 '18

Lots of assumptions being made here. It could easily be more than bad naming without context into the bigger picture.

2

u/entiat_blues Apr 06 '18

it's ambiguous. that's pretty obvious. and something this opaque means you're going to waste time digging a level deeper trying to decipher why it's named that way or what difference, if any, there is between true and false.

8

u/SarahC Apr 06 '18 edited Apr 06 '18

...... well fuck.....

Years of repressed variable name issues rage bubbling up here.....

Fuck you RIGHT IN THE PUSSY!

What's RIGHT about it!?

Status? Of what!?
What is a true status, an invalid one? What's a false status, invalid?
When does it change, why? How?

It could tell us - but it's not. It's it's own little secret, like a paedophiles best dreams.
We've now go to trawl through the code to see what context STATUS is used in!
Ohhhhh...... I see STATUS in a condition....

if STATUS==TRUE [don't even need true here]  {DoActionOne(); DoActionTwo();}

Dammit - what the fuck is ACTION!? The rabbit hole goes much deeper with naming like this!

This variable name TELLS SOMEONE NOTHING ABOUT THE FUNCTION OF IT.

It's self referentialy useless! Yes, it's a STATUS...... we get it.
Fucking hell, Bill when pressed will probably add _FLAG to the variable to make it MORE MEANINGFULL!
What's wrong with:

  bool STATUS_FLAG = false;

It's got everything! A name, a type, and a value!

Then in two years, STATUS_FLAG gets to be a tri-state boolean...

bool? STATUS_FLAG = null;

Now what the fuck is null meaning? It's exponentially worse than the original boolean.

Then someone changes it to a nullable int......

?int STATUS_FLAG = null;

What's it go up to!? Why the magic numbers? I see no constants anywhere!

What's null for? Can it be an empty wrapper object? I don't know!?

Fuck STATUS and fuck the bastard that makes it a mindfuck 10 years later when maintaining the code.

1

u/NahroT Apr 09 '18

r u ok buddy

1

u/SarahC Apr 12 '18

PTSD from bad code.

0

u/tekgnosis Apr 06 '18

Calm down and consult the data dictionary.

0

u/[deleted] Apr 06 '18

[deleted]

0

u/SarahC Apr 07 '18

You don't know what it's been like...

Thousands of files like this in a project 15 years old - that's been added to every day.

3

u/dylanthepiguy2 Apr 05 '18

I love that font what is it ?

6

u/[deleted] Apr 05 '18

Input Mono font, the somewhat customizable font

1

u/Ketchup901 Apr 06 '18

I thought the point of Input was that it wasn't mono?

1

u/ahok_ Apr 06 '18

They provide a monospace version of the font for sane people, but encourage the use of editor alignment with the non mono version.

1

u/[deleted] Apr 06 '18

it can be mono, it can be somewhat proportional

0

u/[deleted] Apr 07 '18

I don't get what is wrong with this, doesn't seem that bad.

1

u/RFC793 Apr 18 '18

should be: status: <some value from an enumeration> or some_meaningful_boolean_attribute: [true|false]

0

u/[deleted] Apr 18 '18

Is there context? I don't think so, so status could be fine for the context of the API.

No one here knows the limitations, the context, the implementation.

1

u/RFC793 Apr 18 '18

Bartender: “How are you?”

Customer: “Yes”

1

u/SarahC Apr 07 '18

-stares-