this post was submitted on 09 Feb 2024
864 points (97.6% liked)

Programmer Humor

19501 readers
1119 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS
 
top 50 comments
sorted by: hot top controversial new old
[–] [email protected] 15 points 9 months ago (1 children)

A lot of you have a lot of faith in people reviewing PRs. I know a few Sr. developers, that if shit was too busy, would skim it and say 'fuck it, it will be QAs problem. If you put this in the correct sub-system in file that would only be executed once a month, for example a maintenance class, It would be really hard to notice something is wrong if it didn't cause issues seen immediately. Maybe this is the story of an intern that added something that also fucked up boolean comparisons in a subsystem used once a month. Where there is a 2 week lag between the execution and operations noticing something wrong.

[–] [email protected] 5 points 9 months ago

{devs} would skim it and say 'fuck it, it will be QAs problem.

And then delays until code complete would eat up all of QA's time so they have no real time left to test before app release into production.

[–] [email protected] 27 points 9 months ago (1 children)

Lol I don't think the preprocessor would be too happy with a space after #

[–] [email protected] 19 points 9 months ago (1 children)

C preprocessor wouldn't care about it

[–] [email protected] 4 points 9 months ago

Lol that's news to me!!

[–] [email protected] 6 points 9 months ago (1 children)

Is this some simple line of code that just shuffles everything around in file storage areas?

[–] [email protected] 43 points 9 months ago (1 children)

This looks like a C macro. Basically what it does is replaces the word "true" in the code with (rand() > 10). The rand() function will return a random number from 0 to 32767. So (rand() > 10) will very likely return "true" but not always.

So say you have some code like this: if (someVar == true) { // Do stuff } It would replace "true" with code that usually evaluates to "true" but not always. So every so often your code would just do the wrong thing but it would be hard to debug because it would be rare.

Granted, in that example you probably would just write "if (someVar)" making this moot, but there are more realistic cases where you'd use the constant "true"

[–] [email protected] 1 points 9 months ago (1 children)

rand() generates a number from 0 to a constant defined in stdlib, which usually corresponds to the architechture of your compiler. So, for 32 bit systems (assuming all the software in the line is 32 bit, too) it will be 2^31-1 = 2 147 483 647, as 1 bit in integers is reserved for negative numbers and 1 number is 0.

Though, by design it is guaranteed to be at least 32767, which is a value for 16 bit integers.

[–] [email protected] 1 points 9 months ago

Oh good to know. I googled it and got that 32767 number but it did say "guarantee to be at least 32767"

[–] [email protected] 58 points 9 months ago (1 children)

Funny but I call bullshit all day

[–] [email protected] 5 points 9 months ago (1 children)

Yeah, how did they commit this to anywhere that would hurt?

[–] [email protected] 3 points 9 months ago

They did not ✌️

[–] [email protected] 54 points 9 months ago* (last edited 9 months ago)

That happened 🙄

load more comments
view more: next ›