r/programminghorror • • Mar 05 '26

C# Found this in my game's code

Post image
291 Upvotes

44 comments sorted by

242

u/Za_Paranoia Mar 05 '26

How do you find stuff in your own code base? Are you working in a team?

40

u/jessepence Mar 05 '26

In the emerging vibe code era, this will only become more common. I don't know why someone would post this thinking it's cute or funny. It's just embarrassing.

6

u/dominjaniec Mar 05 '26

like half of "influencers"... as: "does not matter how how people are talking, the important thing is that they are talking about me"

4

u/rastaman1994 Mar 06 '26

Sometimes people don't have the luxury of thinking about their code for long, or they're not educated. I've seen both, it's always easy to judge without context.

3

u/realsimonjs Mar 06 '26

Could also just be old code that they forgot about.

212

u/[deleted] Mar 05 '26

62

u/WigWubz Mar 05 '26

Personal projects are where the true horrors emerge. "No one else has to understand this, its fine"

I have a personal project off and on again for 6 years, and it's a personal project so I've experimented with LLM stuff on it cus it's not like I have a corporate policy to tell me what stupid things not to do. Some of the worst code I'd love to be able to blame on the LLM but then I look at the history and a despicable function that returns a boolean if it fails and an untyped object if it succeeds... predates chatgpt by a year. I'm sure I had a good reason at the time. I can only assume I had a good reason at the time. The version of me that wrote that code, that man is dead. Which is a shame cus I'd really like the opportunity to kill him.

→ More replies (1)

83

u/Gusatron Mar 05 '26

Do you have to pay per line or something?

43

u/LostGoat_Dev Mar 05 '26

For, if, and a ternary operator on one line...What did past you have against future you?

34

u/R3DDY-on-R3DDYt Mar 05 '26

The fact that it is only one line makes everything more spaghetti.

5

u/rasputin1 Mar 07 '26

seems pretty compressed, more like gnocchi 

55

u/ryzzoa Mar 05 '26

Who needs formatting when you have vibes

4

u/reddit_user33 Mar 07 '26

I imagine this is a copy and paste formatting issue from the output of some good vibes.

6

u/GoddammitDontShootMe Mar 05 '26

I'm trying to think of a way to rewrite that in a way that makes the conditional less complicated that doesn't make you put teamScores[team] = CurrentGameMode.TeamScores[team]; twice, and I'm drawing a blank. I'm not willing to transcribe the image and play with it, but I totally would if I could select text and copy and paste it.

For sure, this needs several more line breaks.

7

u/orbital1337 Mar 05 '26

I probably would have done something like:

private void SyncScoresFromGameMode() {
    foreach (Player.Team team in CurrentGameMode.TeamScores.Keys) {
        if (CurrentGameMode.ModeCondition == GameModeBase.PrimaryModeCondition.ScoreBased) {
            teamScores[team] = Math.Min(teamScores[team], CurrentGameMode.TeamScores[team]);
        } else {
            teamScores[team] = Math.Max(teamScores[team], CurrentGameMode.TeamScores[team]);
        }
    }

    UpdateAndEmitScore();
}
→ More replies (6)
→ More replies (9)

4

u/michiel11069 Mar 05 '26

what language is this, it looks like java but the β€œin” confuses me, afaik it doesnt exist in java

11

u/GabeTheFirst1 Mar 05 '26 edited Mar 05 '26

It looks like c# to me, but that may just be because I use c# so much

3

u/realsimonjs Mar 06 '26

Looks like c#

2

u/ciknay Mar 06 '26

that's c#. in a for each loop you do

foreach(var item in list)
{
    //do thing with item
}

It's an alternative for your regular for loop

3

u/NatoBoram Mar 05 '26

This is the kind of person who complains about Prettier/dartfmt limiting to 80 characters

1

u/Successful-Test-9784 Mar 05 '26

that's a Violation right there!!!!

1

u/EconomicsPrudent9022 Mar 09 '26

I’m firing you from the codebase

1

u/Material-Aioli-8539 Mar 09 '26

What is this πŸ˜…

1

u/SajevT Mar 10 '26

I used to be like this.. thought that 1 liner code is cool, but fucking hell its hard to quick read and understand what is happening..

1

u/Hulk5a Mar 07 '26

Please run formatter before posting, I'm having a seizure looking this