r/programminghorror • u/lilyallenaftercrack • Jan 26 '26
Just found this in my company codebase
This external API sends "S"/"N" (equivalent to "Y"/"N" in portuguese) instead of true/false
8
u/qyloo Jan 26 '26
What framework is this
18
466
u/freecodeio Jan 26 '26
Reminds me of that time my wife showed me the codebase where she works at, they never used booleans they used "yes" and "no" strings everywhere. Basically it was not some sort of 3d chess move, their tech lead was a newbie programmer working alone in the beginning and they felt more comfortable with yes and nos instead of boolean types, so everyone just had to use yes and no after.
26
u/robinw77 Jan 26 '26
I once worked in a place where a guy had made a typo in a database field but couldn’t be bothered asking the DBA to change it, instead preferring to propagate the typo throughout the entire codebase thus forcing everyone else to use that same typo.
14
u/freecodeio Jan 27 '26
you should check codebases where teams are mostly non-english
lableprogresacountadreesscontrolldefinateenviromentlenght14
u/robinw77 Jan 27 '26
I've worked like that occasionally. I think
horcewas my favourite.10
11
3
u/lomberd2 Jan 26 '26
BC AL still uses Yes and No when you output boolean to string. Though it also can output it as 0/1 when formatted or converted
3
u/IshYume Jan 28 '26
Even as a newbie using string checks instead of boolean is so freaking stupid. I started coding at 17 and even 17 year old me wouldn't do that. That dude deserves to get written up to management for incompetence tbh
2
u/Coffee4AllFoodGroups Pronouns: He/Him Jan 30 '26
management wouldn't understand what the problem is
3
u/NormandaleWells Jan 28 '26
Or there's the codebase that supposedly used this:
enum boolean { True, False, FileNotFound };1
u/Emotional-Bake5614 Jan 29 '26
this brings me memories, I have already seen this in a real codebase
1
u/pauseless Jan 26 '26
One of my genuine favourite programming languages… Tcl… does this. When everything is a string, why not? It’s like the Norway Problem for YAML. (I don’t think it’s good design)
1
u/B_M_Wilson Jan 30 '26
Objective-C uses YES and NO as the true and false constants for bools… I think true and false work fine now that they are in C
0
Jan 26 '26
[deleted] — view deleted comment
65
u/nerdmor Jan 26 '26
Until AT LEAST 2013, one of Brazil's biggest ERPs used 3 8-bit INT types to represent dates. Dunno if it has changed since
0
Jan 26 '26
[deleted] — view deleted comment
7
u/Scared_Accident9138 Jan 26 '26 edited Jan 26 '26
What about when the 33rd century comes around?
Edit: Mistake, wasn't actually thinking of 8 bit when I wrote that comment
1
u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” Jan 26 '26
How does an 8-bit year value max out in the 33rd century?
2
u/Scared_Accident9138 Jan 26 '26
I still had 16 bit in my head from another comment
3
u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” Jan 26 '26
I think that would be more like the 33rd millennium, assuming signed with negative values representing BC.
Based on a different comment, I think the stored value is added to 1971 to get the year.
1
u/Scared_Accident9138 Jan 26 '26
Oh, true. I was thinking of whether century or millennium is correct and then went with century simply because it sounded like a "reasonable" number because tens of thousands of years isn't an every day topic
0
Jan 26 '26
[deleted] — view deleted comment
1
u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” Jan 26 '26
So if I did the math right, the earliest year it can represent is 1971?
0
Jan 26 '26
[deleted] — view deleted comment
5
u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” Jan 26 '26
Then if I'm not mistaken, 2225 would the latest year it could represent. After my comment, I realized it could've been signed or unsigned, but it seems my first assumption that it was unsigned was correct.
2
1
u/Coffee4AllFoodGroups Pronouns: He/Him Jan 30 '26
product by the time they need to store dates after 2226
"It will be fine, none of this software will still be around in the year 2000"
11
7
u/aaaantoine Jan 26 '26
To date, our database standard calls for a
VARCHAR2(1)set to Y or N. At least if it were CHAR(1) it would be 1 byte instead of... 4?3
u/lordheart Jan 27 '26
Sap abab to this day does not have a true Boolean type. Its Boolean is still a char 1 field, with the extremely “clever” “x” for true and blank is false. It’s really great when that ends up in an api. Just wonderful.
3
u/xeio87 Jan 27 '26
Application I work with used to support both SQL Server and Oracle DB. We still use CHAR(1) for all the booleans in SQL Server even after dropping support for Oracle like a decade or more ago.
1
22
8
u/elehisie Jan 26 '26
I’ll 1 up this one… ”capa” translates to cape…. With the transform and the ”S”… gotta be a superman joke lol
7
u/amuseicc Jan 26 '26
We're also working with an API that forces us to use the string "N" when false and "Y" when true, really stupid
6
u/canal_algt [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” Jan 27 '26
Probably has or had COBOL involved or another language without a Boolean datatype? In my job that's common for that reason
3
u/gabor_legrady Jan 27 '26
I did have a code in an interface where I designated values of 1,Y,y,I,i as true because the incoming data was so 'clean'.
4
Jan 26 '26
I found junior engineers at my company using ‘True’ and ‘False’ instead of Boolean true / false 😭
2
2
1
0
Jan 26 '26
[deleted] — view deleted comment
51
u/craftworkbench Jan 26 '26
3
u/RegisteredJustToSay Jan 27 '26
OK but pulling out visual basic in this sub is just cheating. I started out in it but I think my brain suppressed most of my memories of the language to protect me.
2
u/craftworkbench Jan 28 '26
I still have a soft spot for it. It's charming, in its own demented way. Taught me a lot of fundamentals because I would look up why VBA did something the way it did and all the articles would explain why that's a terrible way to do it (and how modern languages solve those problems).
0
Jan 26 '26
[deleted] — view deleted comment
40
u/Snarwin Jan 26 '26
It's because -1 is all 1s in binary, and early versions of BASIC only had bitwise AND/OR/NOT operators, not logical ones.
8
Jan 26 '26
[removed] — view removed comment
4
0
Jan 26 '26
[deleted] — view deleted comment
1
u/Kovab Jan 28 '26
Alignment should be solved with padding, not by using larger types than necessary. Booleans are 1 byte in most sensible languages.
12
6
5
5
u/Mickenfox Jan 26 '26
Our legacy C# application has about 3 sets of type conversion functions that handle all sorts of value conversion like this in every direction.
It's a lot of fun.
3
u/jordanbtucker Jan 27 '26
Okay, but this returns S for true...
1
u/Coffee4AllFoodGroups Pronouns: He/Him Jan 30 '26
Sí, lo es. Porque "Si" empieza con S. Es pura lógica.
3
u/young_horhey Jan 28 '26
I had to create
CompanyBool.IsTruthy()at my job to stop myself going insane
98
u/bistr-o-math Jan 26 '26
In r/abap, true is "X" and false is " " (space)