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.
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.
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.
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.
private void SyncScoresFromGameMode() {
foreach (Player.Team team in CurrentGameMode.TeamScores.Keys) {
if (CurrentGameMode.ModeCondition == GameModeBase.PrimaryModeCondition.ScoreBased && teamScores[team] < CurrentGameMode.TeamScores[team]) {
teamScores[team] = CurrentGameMode.TeamScores[team];
} else if (teamScores[team] > CurrentGameMode.TeamScores[team]) {
teamScores[team] = CurrentGameMode.TeamScores[team];
}
}
UpdateAndEmitScore();
}
?
Actually, maybe. That if expression gets pretty big that way. Also, unless my brain is failing, I think you have the min and max reversed. Either way, there are two places that need updating if the assignment to teamScores[team] changes.
Min and max really are better because they express the intent directly
teamScores[team] = CurrentGameMode.TeamScores[team]; happening twice is a coincidence, not repetition
This is some kind of cleanup for incorrect calculation of game score that should have happened right away during the game. It's entirely possible that one of these will later include something like team.kickOnePlayer(), and the other wont. Because those are two separate game modes, they can have totally different rules
if (CurrentGameMode.ModeCondition != GameModeBase.PrimaryModeCondition.ScoreBased)
return;
changed = false;
for each (team in teams)
{
if (teamScores[team] != CurrentGameMode.TeamScores[team])
{
changed = true;
CurrentGameMode.TeamScores[team] = teamScores[team];
}
}
if (changed)
UpdateAndEmitScore();
The only real reason to do the check would be to prevent emitting the score unnecessarily. If the stuff that happens on the other side of the emit isn't worth preventing, you shouldn't even check if they're different, just update all the scores and emit every time.
In one case the score is updated if it is less than CurrentGameMode.TeamScores[team], in the other it is updated if it is greater. This seems to have very different behavior.
242
u/Za_Paranoia Mar 05 '26
How do you find stuff in your own code base? Are you working in a team?
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.
55
u/ryzzoa Mar 05 '26
Who needs formatting when you have vibes
6
u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” 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.
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
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
0
u/JollyJuniper1993 Mar 05 '26
Java moment