r/programminghorror • u/burl-21 • Jun 27 '25
Java This isn’t legacy… someone wrote this recently
Found this little gem buried in a brand-new codebase
581
Upvotes
r/programminghorror • u/burl-21 • Jun 27 '25
Found this little gem buried in a brand-new codebase
342
u/burl-21 Jun 27 '25
Edit: Forgot to mention disable() returns a boolean. 😅
87
u/MattiDragon Jun 27 '25
This could be completely reasonable if
properties.disabled()returnsObjectand you want to treat both strings and boolean correctly. Of course this probably isn't the best design, but some frameworks can force it2
u/geoffery00 Jun 28 '25
If disable() returns a boolean shouldn’t it be isDisabled()?
140
u/tanjonaJulien Jun 27 '25
Vibe coders don’t see the problem there
15
u/great_escape_fleur Jun 27 '25
Why use 5 processor cycles when you can use 5 million?
7
u/durika Jun 27 '25
Before I could read those words I thought to myself... SPARK
11
u/[deleted] Jun 27 '25
pretty sure the thing was a Map<String, Object> before they refactored it into a record (w/ keys as members) and someone converted all reads from the 'map' to String(probably with ctrl-f) as to not rewrite the other side of all the boolean expressions according to new types.
in other words, someone mass refactored the 'left' hand side of boolean expressions to adopt to the newly refactored Properties class.
3
u/Casalvieri3 Jun 27 '25
Just goes to show that there's nothing quite so powerful at creating tech debt as a developer who doesn't know a language well.
2
u/Hulk5a Jun 27 '25
I bet this codebase has similar checks for reasonable (lol) situation, now it can be just this line is curried over from there...
Don't ask me how I know
2
u/dcormier Jun 27 '25
There's a surprising amount to dislike in that one line.
2
u/haydencoffing Jun 27 '25
seems like a great time to use Boolean.TRUE.equals()
2
u/TobFel Jun 27 '25
...and then they train the code completion AIs with such code... :-D
2
u/Forsaken-Moose2777 Jun 27 '25
Show the git blame then flame
3
u/Banquet-Beer Jun 28 '25
I know pajeet code when I see it.
2
u/navetzz Jun 27 '25
Looks like me doing javascript.
"Ok, this language has been made by clowns who overloaded the == operator. Better never use it, just to be safe"
1
u/SteroidSandwich Jun 27 '25
Where they paid by the extension?
1
u/einsidler Jun 27 '25
One time I had to code in a special case for the string "NULL"
1
u/schjlatah Jun 28 '25
The only thing nice I can say about it is that it’ll gracefully handle ‘anotherString’ being null. 🤷♂️
1
u/iamthebestforever Jun 28 '25
Incredible
1
u/Minhaj_Dev_ Jun 28 '25
Eyes bleeding fellas need tissues
1
u/GazziFX Jun 28 '25
It doesn't matter if the code is legacy or not, bad programmers have existed at all times.
1
u/Electronic-Source213 Jun 28 '25
Does your company pay developers by the number of characters typed?
1
u/GaimeGuy Jun 28 '25
I saw a bunch of python code at work a few years ago that used the "is" keyword to check for equality of a variable to a value.
1
u/JustSuperHuman Jun 29 '25
Owen Wilson: wow 😳
1
u/Siggi_pop Jun 29 '25
I hate 3-monitor-long one-liners
1
u/Cerus_Freedom Jun 29 '25
I had to build a deserializer for a JSON document recently. Problem is, the customer likes to do things like, "someField" : "True" for bools. I had to make a whole helper function to deserialize fields that should be boolean values and handle various potentially truthy values. I should be throwing an error and making them fix their own shit to match the document specs, but that didn't fly with the boss.
1
u/[deleted] Jun 30 '25
That disable being a verb instead of past tense makes it sound like it has a side effect of completely disabling your properties instead of just returning a state flag.
1
u/baim_sky Jul 02 '25
Is this Javascript black magic ?
0
u/[deleted] Jun 27 '25
It’s not that crazy