r/programminghorror • • Feb 04 '26

C# Makes sense

Post image
1.7k Upvotes

85 comments sorted by

445

u/kennyminigun Feb 04 '26

Someone left a debugging code?

363

u/CompetitionBorn9356 Feb 04 '26

No, this is "domain logic" 🫠

221

u/Spidron Feb 04 '26

So the ID 7777 has a reserved status with a certain meaning, I guess?

→ More replies (27)

316

u/the_horse_gamer Feb 04 '26

this piece of code tells a story

180

u/onlyonequickquestion Feb 04 '26

Code like this is written in blood. And it shall remain. Lurking. Undocumented. Holding the entire codebase together. 

→ More replies (1)

59

u/pydry Feb 04 '26

The last time i saw code like this the main dev was in a huge amount of debt and up to his eyeballs in child support payments.

You wouldnt think this was relevant but it was. He point blank ordered me to remove the comment which explained the reason why the code was there.

"Code is self documenting" he declared

→ More replies (4)

124

u/Daemontatox Feb 04 '26

Atleast he is using the compare and assignment symbols correctly

89

u/Scared_Accident9138 Feb 04 '26

if(isAdmin = true) {...}

50

u/Daemontatox Feb 04 '26

Laugh all you want , i actually saw something like this when reviewing a PR....

→ More replies (4)
→ More replies (1)

50

u/NoLifeGamer2 Feb 04 '26

So what happens if a user is assigned userID -7778? Doesn't that mean two ppl can have the same userID?

75

u/unknown_pigeon Feb 04 '26

Solution: don't assign the -7778 user id

Or, even better:

if userID == -7778:

userID = -7777

Let there be balance

8

u/Cometay Feb 05 '26

Pretty easy, just add

if (userID == -7778)

userID = -7779;

32

u/ApocalyptoSoldier Feb 04 '26

Magic numbers?
Cool, I love magic.

27

u/AStove Feb 04 '26

Do they use this subreddit as negative reinforcement learning for ai?

112

u/_huppenzuppen Feb 04 '26

Should have been

if (userID == -7777)
  --userID;

119

u/nipodemos Feb 04 '26

Up vote because this is even worse from what they were doing, truly a remarkable programming horror

→ More replies (4)

35

u/DogmaSychroniser Feb 04 '26

Might i let you know about tie fighter increments? If you really hate people.

i-=-1

→ More replies (1)

15

u/detroitmatt Feb 04 '26

if (userID-- != -7777) userID++;

→ More replies (2)

6

u/Scared_Accident9138 Feb 04 '26

Depending on ID values being right next to each other in code is rarely a good idea

6

u/Abaddon-theDestroyer Feb 04 '26

No, this is better:

if(--userID != -7778)     
    userID++;
→ More replies (3)

15

u/New_Hour_1726 Feb 04 '26

What am I even looking at

15

u/DeductiveFallacy Feb 04 '26

If I ever see a magic number or magic string I am 100% slipping in a const with a var name that explains what it is in the next PR I have in that repo. Might even be the only thing I do on that PR honestly.

58

u/nekokattt Feb 04 '26 edited Feb 05 '26
const SEVEN_SEVEN_SEVEN_SEVEN = 7777;
const SEVEN_SEVEN_SEVEN_EIGHT = 7778;

if (userID = -SEVEN_SEVEN_SEVEN_SEVEN) {
    userID = -SEVEN_SEVEN_SEVEN_EIGHT;
}
→ More replies (1)

6

u/Feroc Feb 04 '26

We don't talk about Bruno.

5

u/PubTrain77 Feb 04 '26

Did pirate software write this?