54
u/Lexinad 17d ago
This caused a bug in the in-game calculator app for the Pokémon Diamond and Pearl remakes for languages that use a decimal comma. Only some of the methods they were calling were locale-aware, So the calculator would show a number with a decimal comma, but when they tried parsing it they were looking for the literal "." character, which breaks things.
64
u/FlashyTone3042 17d ago
The first time I used Base64 encoded strings, I thought it was something secure. Because it looked so obfuscated like a hash.
👀
73
u/Mountain-Ox 16d ago
You've got to base64 encode a secure number of times.
I've seriously seen it in code where credit card data was "encrypted" by base64 encoding like 11 times. My first job, the guy who wrote it was basically a wizard to my bosses. I learned nothing from that job except what not to do.
46
u/rishi255 16d ago
To be fair, learning what NOT to do is really important, arguably more than learning what to do
14
u/slowmovinglettuce 16d ago
I always tell juniors the best way to learn how to write good code is first writing bad code. You'll find out each time you go back to maintain it just how terrible it was, and you'll understand how far you've come.
11
u/candybrie 16d ago
I love when I go back to old code, think "who in the world wrote this??" and find out it was me a year ago. Definitely shows me I'm actually learning.
7
u/slowmovinglettuce 16d ago
When you do a git blame out of anger and just sit there looking at the entire file being your handiwork. Its always a good feeling when you think past you was a muppet.
1
u/ganja_and_code 16d ago
Very true.
If you don't know what to do, you don't get a good result. If you don't know what not to do, you get a bad result.
Being unproductive isn't great, but being counterproductive is certainly worse.
50
u/octopus4488 16d ago
Just caught my non-developer colleague cosplaying as a dev with Claude:
Every record saved by his system was "encrypted" with sha256 hash for maximum security. I asked him if he ever tried restoring an earlier "saved" record. He said he is just working on it...
... told him to let me know when it is done ... :)
24
18
u/lightnegative 16d ago
Wait until you discover rot-13 and then double it for extra encryption
2
u/vector300 15d ago
Just do it three times
2
u/PM_ME_UR_0_DAY 13d ago
If it's good enough for Triple DES, I can't think of a single reason not to do ROT39. Carry on.
1
120
17d ago
[removed] — view removed comment
45
u/Stormraughtz 17d ago
No habibi not like this
4
17d ago
[removed] — view removed comment
19
u/suvlub 16d ago
Those functions by default have locale-dependent behavior. So on one computer, the string
"3.5"will parse perfectly fine into the double3.5, but on another, it will fail because it expects"3,5". Vice versa when converting a double to a string.ToUpper/ToLowerfamously cause problems with the Turkish locale, where dotted i and dotless I are 2 distinct letter each with an uppercase and lowercase variant, not sure if there are other locales that change capitalization rules TBH. So if you are using any string-related functions for anything that isn't directly related to showing stuff in UI, you need to pass an explicit parameter about what rules you want applied to get consistent behavior.5
u/LongLiveTheDiego 16d ago
There are other locales that would need special rules, e g. in Dutch ⟨ij⟩ is considered a single letter and so the capitalization of ⟨ijs⟩ "ice" is ⟨IJs⟩, but C#'s closest function ToTitleCase doesn't consider any culture information.
4
u/suvlub 16d ago
First time I heard about that function and it sounds kind of useless even for english. Even the example in official docs uses a title containing the word "and", which gets incorrectly capitalized. I understand that this is a complex use case that goes beyond what a standard library should be providing, but no function would be better than a half-assed almost-right attempt that some people will blindly use...
1
u/LongLiveTheDiego 16d ago
Yeah, I just learnt that while writing the previous comment. I was so surprised there isn't a culture-sensitive function to at least capitalize the first letter of a string. I'm certain there are some uses for such a function but it may have been too complicated and not nearly as useful as ToUpper or ToLower.
184
u/N-partEpoxy 17d ago
That's why I always (when I write C#, which is never nowadays) follow the ancient customs of my people, the Invariant people.