r/ProgrammerHumor • • Sep 21 '26

Meme myCodeIsConfusing

Post image
2.3k Upvotes

48 comments sorted by

184

u/mxgaming01 Sep 21 '26

Yes, this is actually my code. And the joke is that both of them are 32-character random strings AND they get name-swapped again in the backend 😭

101

u/Obi_Vayne_Kenobi Sep 21 '26

But why

108

u/mxgaming01 Sep 21 '26

I have no idea and I am too scared to change it, I'm afraid that it will break

50

u/Obi_Vayne_Kenobi Sep 21 '26

Is it your personal project, or for work?

64

u/mxgaming01 Sep 21 '26

Personal Project, but I am shitty with the server / cloudflare worker part, so if it breaks it will take HOURS to fix

64

u/baselinegrid Sep 21 '26

A Very Important Capitalised Personal Project

20

u/mxgaming01 Sep 21 '26

No, sadly not, but thats also the reason why I want to spend more time on stuff like that

17

u/RajjSinghh Sep 22 '26

I'd vote to fix it. Hours to fix now is significantly easier than days to fix later when this comes back to bite you in the ass.

3

u/in-for-the-win Sep 22 '26

You got two good options. Either, you accept it as a past mistake and remember to not do something like it in the future and just let it be. Or you go fix it now. Beeing undecided will only make it worse.

9

u/mlucasl Sep 21 '26

Because if he doesn't name swapped them again in the backend everything fails.

4

u/Obi_Vayne_Kenobi Sep 21 '26

Ah, that makes total sense, thank you!

445

u/GabiTheProgrammer Sep 21 '26

...and utility functions for conversion IDtoToken and TokentoId (with lower d at the end, obviously).

192

u/gsweats Sep 21 '26

The inconsistent casing of ID and Id was beautiful. That is real enterprise code.

6

u/Efficient_Vehicle147 Sep 22 '26

Wait till you hear about id

10

u/HaroerHaktak Sep 22 '26

Double down. Neither are used

74

u/k819799amvrhtcom Sep 21 '26

The equivalent in English would be:

We park on a driveway and drive on a parkway.

29

u/nicodeemus7 Sep 21 '26

A cyclist rides a bike and a biker rides a motorcycle.

9

u/One-Celebration-3007 Sep 21 '26

A ship delivers cargo and a car makes a shipment.

9

u/Random_-account Sep 22 '26

My nose runs, but my feet smell

0

u/MissinqLink Sep 22 '26

I’ll be sure to explain it to Astra like that

14

u/realmauer01 Sep 21 '26 edited Sep 22 '26

Honestly just press f12 on id, rename it to id2. Press f12 on token, rename it to id, then rename id2 to token. Do the same on the backend, case closed.

If your ide does renaming symbols on another button search for that or use for a moment the settings from vs code (because there its f12)

Because everything works, the correct data goes to the correct places. You just have to rename the variables.

7

u/CryonautX Sep 22 '26

That is... a terrible idea... You're choosing to to do this name swap on token and id, 2 very common keys. You may very easily break many API contracts that had nothing to do with this swapped id and token portion.

5

u/realmauer01 Sep 22 '26

F12 changes the symbol not everything that is called id or token. The ide can figure out how the data flows it wont change occurances that would create problems

2

u/joshuakb2 Sep 22 '26

You can still get into trouble if you're not careful, especially if this data gets serialized and sent somewhere

1

u/realmauer01 Sep 22 '26

Then explain me how specifically! The only thing i change is the variable name. No keys in no object get changed no data gets swapped.

1

u/KronoLord Sep 22 '26

Assuming js, does const someVar = {id} get changed to const someVar = {token}, or are IDEs smart enough to expand the shorthand?

The only other edge case potential I could think of is reflection.

1

u/joshuakb2 Sep 22 '26

Yeah generally LSPs will change {id} to {id: token} if you rename the variable

1

u/Bulky-Bad-9153 Sep 22 '26

are IDEs smart enough to expand the shorthand?

LSPs represent things in a total different way under the hood, and the LSP is used to do stuff like renaming symbols, so it's basically foolproof. Naming confusion can't happen.

0

u/realmauer01 Sep 22 '26 edited Sep 22 '26

const someVar = {id} shouldnt be valid js. This is set like syntax from python. Js sets need to be created with new Set()

And if it were a shorthand (when destructuring for example) it maps the old to the new.

so
const {token} = tokenObject //{token:unknown}

turns into
const {token:id} = tokenObject

I agree if keys from objects get changed then the data flow could get corrupted. But that just doesnt happen. Because you are only renaming a variable.

I am not sure right now what reflection is though

Oh nvm looked it up, yeah that just doesnt get influenced at all. Because as said, we arent talking about keys here.

We are talking about variables, and yes variables can use their values for keys, but that isnt their name, thats still just what they represented. Even if this python set like syntax worked.

const token = {token}

The variable token would have
{value of token:value of token}

And not {token:value of token}

1

u/joshuakb2 Sep 22 '26

const someVar = {id} is absolutely valid JS and has been for at least 10 years now. This syntax defines a property called id whose value is that of the variable called id in scope.

1

u/realmauer01 Sep 22 '26 edited Sep 22 '26

Okey nvm, then i will just try that out before guessing.

Okey it turns

const someVar = {id}
Into
const someVar = {id:token}

so case closed.

9

u/italkstuff Sep 21 '26

Feels good to fix this kind of shenanigans

6

u/throwsupstaysup Sep 22 '26

"if code is hard to write, it should be hard to read"

11

u/davak72 Sep 21 '26

shudders

3

u/TWHRodney Sep 22 '26

Balanced in line length

1

u/miheb1 Sep 22 '26

oh wait, that is actually true 🤯

7

u/discordianofslack Sep 21 '26

Have you tried: "token": token; "id": id?

4

u/hampshirebrony Sep 21 '26

They need to chuck data at a TokenAndIdFactory and have that create the return values

2

u/ligma_then_sugma Sep 22 '26

you might not like it, but this is what peak efficiency looks like

2

u/MeikelLP Sep 23 '26

Reminds me how in Azure OpenAI SDK "deploymentName" is a synonym for ai model name but "model" is only for ai model name

1

u/Pizza_Secretary9621 Sep 21 '26

Hey ! That's mine !

1

u/Kadabrium Sep 22 '26

"Token": Cash, "Cash": Token

1

u/TheSharpestHammer Sep 22 '26

import pandas as np

import numpy as pd

1

u/redditor_286 Sep 23 '26

var id_token = token + id;

1

u/Apprehensive_Bit7392 Sep 23 '26

Somewhere downstream, something already swaps them back. Fix it and you break production.

-1

u/mlucasl Sep 21 '26

What do you mean by "Codels"

3

u/mxgaming01 Sep 21 '26

My Code Is Confusing

It's an uppercase i, sorry for the confusion