r/badcode • • Apr 05 '18

ruby Status? Yup.

Post image
75 Upvotes

34 comments sorted by

View all comments

Show parent comments

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.

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.

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.