I know a system where id is changed to the same but negative to mark special accounts without having to deal with additional tables or flags.
But that's a system that was originally developed by students, it's been running for over a decade, and has many tables for important data, hence some non-standard design choices, lol.
At least 2 messengers (Telegram and VK, which makes sense considering they had the same original developer team) use negative user IDs to distinguish between bot accounts and real ones, at least in API
Also having negative ids (reassigning positive id to be negative) still keeps the autoincrement working normally since that positive id got used up and won't be reused. So there's no risk of collision, as there can't be both x and -x unless you manually insert with those...
... I mean, no collision UNLESS you have magical id in the code that gets reassigned to another magical id (instead of being that id already in the db) like OP does, of course.
In a previous job there was an acquisition and we needed to merge the two user databases. We negated the user IDs from the new users to prevent clashes.
Kinda dumb, what happens if there is another acquisition? Change user IDs to complex numbers??
Sometimes i wonder why every time i try to find a job, i dont qualify, but when i listen to friends in IT telling about their colleagues, its always complete dumbasses
The interviewing process is usually hell to me but once inside its extremely simple.
Like there's this one meme about how in the interview you are asked to implement the transformer arch from scratch with examples but once you get the job its just import transformers and thats it.
For some reason the interview process has been over complicated
Thats why i decided to halt my job search as dev/tester/engineer, and am actually working as scientific researcher in my uni and part time programming teacher for kids
Also, i did try one interview task. But the technical task was so poorly written, that i had to write 5 paragraphs totalling about 2 pages of my assumptions and clarifications i just needed to make in order to make the final work. There was also no testing, so had NO FUCKING IDEA if i did it right, so even technical task akin to what they regularly do was actually harder than what they do regularly. Somehow employees that work there for years have easier time than entry level folk? Fucked up.
While trying to add two userIDs or something wouldn't make any sense, since they are often generated in a sequence, I think incrementing (or in this case, decrementing) them would be a lot more forgivable.
I'm guessing this is part of the code that handles new user creation. I'll have to assume the other code grabs the last userID from the database and subtracts 1 from it to get the new userID. This has to be the first time I've ever heard of negative userIDs.
Even this incremental increase is a dangerous game. An ID is fundamentally not a number. It's adding a bunch of operations on a variable that the concept it's representing should not have.
IDs are best as UUID strings, or they will embed information in them they should not have (sequence of user creation, etc) they become something a lot more complex if they are not opaque string uuids.
(to be clear, I have seen and made worse, codebase is unlikely to explode over this, but I have learned it's a bad idea first hand to think about a ID as anything other than a UUID)
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.
When you see an old man at a bar with a missing finger, we donāt say āshould have been more careful, huh, you idiotā - we buy the guy a drink if he looks like he needs it.
If this is in production code - godspeed, developer who wrote this line
445
u/kennyminigun Feb 04 '26
Someone left a debugging code?
316
u/the_horse_gamer Feb 04 '26
this piece of code tells a story
124
u/Daemontatox [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo "You live" Feb 04 '26
Atleast he is using the compare and assignment symbols correctly
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?
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
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.
6
u/Feroc Feb 04 '26
We don't talk about Bruno.
5
u/PubTrain77 Feb 04 '26
Did pirate software write this?
2
u/BrianScottGregory Feb 04 '26
Someone with a poor relationship with their DBA
2
u/StochasticTinkr Feb 04 '26
āBill was fired ā
Next day āBillās back. But now his user id is invalid. Fix itā
3
u/tekanet Feb 04 '26
Is the horror the capitalized ID?
Iāve spent all my professional life using ID, recently decided to switch to Id, still unsure about this big life choice.
2
u/RealAggressiveNooby Feb 04 '26
Maybe use
1
u/null_reference_user Feb 06 '26
Uhhhhh what the fuck
1
u/damemecherogringo Feb 06 '26
When you see an old man at a bar with a missing finger, we donāt say āshould have been more careful, huh, you idiotā - we buy the guy a drink if he looks like he needs it.
If this is in production code - godspeed, developer who wrote this line
1
u/calmcl1 Feb 07 '26
sudo chmod -R ${userID} /1
u/MeLittleThing Feb 07 '26
haha in your face,
-7777, you are no more!0
u/Hijo-de-la-Luna Feb 05 '26
With JS everything is possible!
0
u/[deleted] Feb 04 '26
[deleted] ā view deleted comment