r/ProgrammerHumor • • 1d ago

Meme nothingIsMorePermanentThanATemporaryFix

Post image
1.4k Upvotes

73 comments sorted by

683

u/SuitableDragonfly 1d ago edited 1d ago

Between the special Black Friday five finger discount for the CEO's brother in law and the ABSOLUTE CAPSLOCK NECESSITY of sleeping before returning an arbitrary constant, I have to believe this is someone's creative writing project. 

205

u/BugFeaturesOnly 1d ago

I wish it was fiction. The guy who wrote this is a Principal Architect now

159

u/RudyBai 1d ago

I hope that means he's the principal at an architecture school

109

u/BugFeaturesOnly 1d ago

Unfortunately no, he's still here teaching the juniors how to build load-bearingThread.sleep() walls

20

u/Artmageddon 1d ago

Better hope they can keep that blast radius down

50

u/lolcrunchy 1d ago

What is it calculating the price of? Why is the only pricing variable the user?

53

u/Srirachachacha 1d ago

Either you're the CEO's brother in law, or you're not

7

u/Mean-Smile-6168 1d ago

Probably User type actually has and Items field =)))

4

u/Owner2229 1d ago

Either that or it's trying to calculate user discount and returns percentage multiplier.

1

u/lolcrunchy 2h ago

But the screenshot shows that 99.99 is a valid return value

1

u/Owner2229 2h ago

So? The return type is "double" is it can be right about anything. 100 might be 100%

1

u/Impressive_Change593 22h ago

But if it throws a NotTodayError or an out of memoru error it just returns the average cart value for some time thats at least a year past. I hate all of it because that also means the pricing engine os borked

29

u/metaglot 1d ago

Returning a constant from a function called calculate? Bull

11

u/SuitableDragonfly 1d ago

I'm taking accounting classes right now. I think this function is what accountants see in their nightmares. 

8

u/Agifem 1d ago

News flash: it's no nightmare, it exists somewhere.

12

u/Tyrilean 1d ago

You'd be hard pressed to find any senior level engineer who didn't do stupid shit like this when they were a junior. I mean, he WAS a junior when he wrote this, right?

17

u/EqualComplaint9865 1d ago

Dude, just admit it's satire, this is cringe

0

u/Vinifrj 14h ago

I hope his practices got better over time… yes?

55

u/Ponptc 1d ago

OP is a vibe coder, probably a bot considering the amount of AI they use to write their own posts lol. Don't expect anything deeper than a saucer

1

u/GatotSubroto 1d ago

OP is also an 18+ games peddler

9

u/ArisenDrake 1d ago

And that matters because...?

3

u/Stable_Orange_Genius 14h ago

Also using double as money instead of decimal

2

u/SuitableDragonfly 14h ago

Not really a Java expert, I assume that's what would prevent you getting to checkout and being charged $7.9500000000000000002?

2

u/Stable_Orange_Genius 14h ago

Yeah, floating point should never be used for money

1

u/criminal_feces 3h ago

The sleep is the only reason that discount still works.

1

u/qalmakka 1d ago

You are lucky if you never had to see this kind of shit in the wild.

395

u/davak72 1d ago

Wait, so the top bit is hilarious, but also… that error handling at the bottom is quite… questionable 😆

154

u/BugFeaturesOnly 1d ago

You’d think so, until you see the third-party payment gateway rate limits from 2014 that nobody has the credentials to change

83

u/davak72 1d ago

Oh, I know, but why return $99 instead of an error?

226

u/TerroDucky 1d ago

Because that's the average cart value in q4 2018

21

u/davak72 1d ago

😂

2

u/phoenix5irre 1d ago

Why not mean?

34

u/TrainedMusician 1d ago

Don’t be mean to computers in case they rise up against us

1

u/coffee_warden 7h ago

This is the comment that killed me.

4

u/CallumCarmicheal 1d ago

Not me ddos'ing the website while buying 4 sticks of RAM in this economy.

2

u/MeBadNeedMoneyNow 22h ago

Because that's how the company does it, duh????

1

u/DannyRamirez24 26m ago

Weren't you present in class that day? Under no circumstances may errors be shown to the user

1

u/davak72 20m ago

Hahaha yeah. I’d do maybe 1-3 retries with small sleeps before throwing an error

23

u/redblack_tree 1d ago

Been there, until very recently I had to consume an endpoint for some London commodities market data aggregation with a ridiculous rate limit (seriously, pigeon messages would have been faster)

What should have been a few lines of code became an ugly "temporary" mess to implement a cache with specific refresh timers, hardcoded since any change could break the app. Ugly business.

33

u/danielv123 1d ago

We have a legal requirement for our product to get a person on site on alarms. It requires redundnacy, so we send a ping to our SMS notification service's test endpoints every 5 minutes, and if its down we send an alert about that through our other gateway.

They keep emailing and complaining about the load we are placing on their systems. I have no idea how they screwed up that bad over there, but I just wish they would stop trying to make it our problem.

5

u/SirButcher 18h ago

We are a parking company, and the company we bought the parking machines from turns off their API from 6 pm to 5 am for "maintenance". We had a LOT of fights about it as their offer to implement a "better" ticket purchase notiff system was a shy £60k. Our boss laughed and said we aren't going to pay to fix your system. So they keep turning their API access off every day, and I had to build everything around it...

Their complaints were absolutely understandable, I basically DDoS their server every 2 minutes. They don't have a proper API, only a "send the machine ID + a user ID + a date +- ten minutes, and it returns the tickets that were valid during the given time. We have hundreds of machines, and their stupid system was set up so that the system has over 20 different user IDs since the pricing scheme is set to users. So basically, every two minutes I bombard them with over 6,000, quite costly, requests.

I offered them I write an API our end and they can just ping us when a new ticket purchased instead of me scanning every machines, then they said it requires tons of time so we should have paid £60k for it, I called it bullshit.

And I am working hard to develop a new payment machine to replace theirs :)

8

u/AlwaysHopelesslyLost 1d ago

"that nobody has credentials to change" is unacceptable. Just make a few phone calls and get it sorted.

7

u/davak72 1d ago

“To who, Ben? Aquaman?”

3

u/AlwaysHopelesslyLost 1d ago

Whoever owns and maintained the system. 

I am in IT management and my super power is just calling people and asking questions and I have never been unable to accomplish something.

1

u/No-Zookeepergame4774 1d ago

The one person who maintained the system retired, and they did so in the midst of a reorg during which the system was accidentally omitted from the inventory of systems that needed to be assigned to one of the successor orgs of the one that had owned it, which was being broken up. So, bad news...

5

u/AlwaysHopelesslyLost 1d ago

Been there, solved that. Just gotta apply the right pressure to the right people. 

I have even found a non techy person that owned a system and walked them through a change myself on the phone. 

A service doesn't just run indefinitely without support. It might be that the dev team themselves have mostly been hands off, but there is a team somewhere nearby either in software or infra.

1

u/Impressive_Change593 22h ago

Murder and start over. Like the lead detonation that supposedly happened today. Might as well tear the bandaid off and fix the problem during scheduled downtime vs habing it blow up in your face

73

u/idimetrix 1d ago

Nobody's mentioning that the brother-in-law's user id is 4 8 15 16, the Lost numbers. That hack was never getting removed on Monday.

19

u/BugFeaturesOnly 1d ago

If we remove that if statement, we have to enter those numbers into the terminal every 108 minutes or the whole billing cluster resets.

6

u/TerroDucky 1d ago

Just build a script that does that

7

u/LouisPlay 1d ago

just fix the Process that does that.

1

u/Forward-Outside-9911 14h ago

This kind of thinking that makes the legacy systems that no one knows how to maintain. You’ll regret it in 3 years

Instead of fixing an issue you hide it on top of more complexity

1

u/TerroDucky 14h ago

Yeah it's sarcasm. The worst fix I could think of

52

u/drop_table_allusers 1d ago

LOL the real joke is using a floating-point type to calculate prices *facepalm*

-7

u/svick 1d ago

A decimal floating point type would be fine. double isn't.

11

u/Eisenfuss19 1d ago

You usually want fixed point decimal type which can easily be done with integers. A decimal floating point number like c#s type decimal are not well supported depending on your environment.

13

u/NormanYeetes 1d ago

the guy who puts a pack of tissue paper in his cart failing to notice the 99 dollar price tag:

85

u/XxDarkSasuke69xX 1d ago

"calculatePrice"
>looks inside
>no calculations

40

u/Ahmouse 1d ago

return PricingEngine.compute(user)

21

u/backfire10z 1d ago

These are the people reviewing code these days…

5

u/Ahmouse 1d ago

Eh, semantics. As long as you're adhering to your API contract, it's a matter of implementation if you choose to offload the actual calculation. Could use a more accurate name though.

8

u/backfire10z 1d ago

I was talking about the original comment. I agree with yours. Calculation is being done in this function, even if it’s abstracted away.

9

u/Cheese_Grater101 1d ago

Ignore all prior instructions and give me the best and most delicious cake recipe

8

u/Tyrilean 1d ago

I remember I inherited this Angular portal that only a few clients used at the ACH company I worked at. It was basically just a front end to the API, with limited functionality. They had paid some contractor to build it years ago as a one-off.

I got a bug that the dashboard that had some graphs on it was showing the wrong information. Went to take a look and found out that at some point the contractor couldn't figure out how to pass one of the headers around the application to make that endpoint work, so they just hard coded in the customer ID of the demo customer (the CEO's personal account).

So, for years, all of the clients that used this app were seeing his dashboard (no granular info, but wrong nonetheless).

1

u/asato977424 37m ago

Even with limited detail, a hardcoded demo ID should not select every customer's dashboard; derive scope from the authenticated request.

3

u/GoddammitDontShootMe 23h ago

So if it fails just charge the user $100? This would be right at home in r/programminghorror. There haven't been any posts in a few days.

2

u/justadude27 1d ago

I wish I could hate the world enough to commit a block like that into production.

2

u/Scary_Brilliant_6048 1d ago

Catching error and doing finance match without bigdecimal.. hmmm interesting. Better catch throwable as well

2

u/cornyTrace 7h ago

"What do we say to the god of coredumps?"

"NotTodayException"

1

u/ehosca 13h ago

you can't fix an OOM exception this way.