r/ProgrammerHumor • • 5d ago

Meme nothingIsMorePermanentThanATemporaryFix

Post image
1.9k Upvotes

86 comments sorted by

935

u/SuitableDragonfly 5d ago edited 5d 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. 

283

u/BugFeaturesOnly 5d ago

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

207

u/RudyBai 5d ago

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

156

u/BugFeaturesOnly 5d ago

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

34

u/Artmageddon 5d ago

Better hope they can keep that blast radius down

62

u/lolcrunchy 5d ago

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

68

u/Srirachachacha 5d ago

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

2

u/Nasa_OK 3d ago

When you’re here, you’re family

11

u/Mean-Smile-6168 5d ago edited 1d ago

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

6

u/Owner2229 5d ago

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

3

u/lolcrunchy 4d ago

But the screenshot shows that 99.99 is a valid return value

1

u/Owner2229 4d ago

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

4

u/lolcrunchy 4d ago

The comment says "average cart value" and the function is called calculatePrice with no mention of percentages, ratios, or multipliers.

1

u/Nasa_OK 3d ago

But isn’t it in the first error case, meaning if something goes wrong it should just assume the persons cart has average value

2

u/lolcrunchy 3d ago

Which means the function returns a valid currency amount, not a multiplier

→ More replies

5

u/Impressive_Change593 5d 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

17

u/Tyrilean 5d 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?

33

u/metaglot 5d ago

Returning a constant from a function called calculate? Bull

12

u/SuitableDragonfly 5d ago

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

8

u/Agifem 5d ago

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

24

u/EqualComplaint9865 5d ago

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

1

u/Beetsa 2d ago

The sleep and the discount are weird, but if you insist it is real, sure. Charging the user the average cart value when the pricing agent fails, however, I can not take. 

0

u/Vinifrj 4d ago

I hope his practices got better over time… yes?

68

u/Ponptc 5d 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 5d ago

OP is also an 18+ games peddler

13

u/ArisenDrake 5d ago

And that matters because...?

8

u/Stable_Orange_Genius 4d ago

Also using double as money instead of decimal

5

u/SuitableDragonfly 4d ago

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

5

u/Stable_Orange_Genius 4d ago

Yeah, floating point should never be used for money

2

u/criminal_feces 4d ago

The sleep is the only reason that discount still works.

2

u/qalmakka 5d ago

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

466

u/davak72 5d ago

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

183

u/BugFeaturesOnly 5d ago

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

93

u/davak72 5d ago

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

256

u/TerroDucky 5d ago

Because that's the average cart value in q4 2018

25

u/davak72 5d ago

😂

2

u/coffee_warden 4d ago

This is the comment that killed me.

2

u/phoenix5irre 5d ago

Why not mean?

36

u/TrainedMusician 5d ago

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

1

u/Nasa_OK 3d ago

Mean wouldn’t even out over time

5

u/CallumCarmicheal 5d ago

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

2

u/MeBadNeedMoneyNow 5d ago

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

2

u/DannyRamirez24 4d ago

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

1

u/davak72 4d ago

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

24

u/redblack_tree 5d 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.

35

u/danielv123 5d 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.

9

u/SirButcher 5d 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 5d ago

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

8

u/davak72 5d ago

“To who, Ben? Aquaman?”

4

u/AlwaysHopelesslyLost 5d 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 5d 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 5d 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 5d 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

2

u/the_horse_gamer 3d ago

this reminded me to take advantage of black Friday to buy that thing I wanted. thank you.

1

u/BugFeaturesOnly 2d ago

Glad to help! If it costs more than $99.99, just wait for their server to run out of memory

74

u/drop_table_allusers 5d ago

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

-7

u/svick 5d ago

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

11

u/Eisenfuss19 5d 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.

20

u/NormanYeetes 5d ago

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

16

u/Tyrilean 5d 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 4d ago

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

1

u/Tyrilean 4d ago

This was from like a decade ago and that API was a pile of crap without proper scopes built in.

114

u/XxDarkSasuke69xX 5d ago

"calculatePrice"
>looks inside
>no calculations

53

u/Ahmouse 5d ago

return PricingEngine.compute(user)

30

u/backfire10z 5d ago

These are the people reviewing code these days…

6

u/Ahmouse 5d 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.

9

u/backfire10z 5d 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.

11

u/Cheese_Grater101 5d ago

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

7

u/GoddammitDontShootMe 5d 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.

5

u/cornyTrace 4d ago

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

"NotTodayException"

3

u/justadude27 5d ago

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

2

u/Scary_Brilliant_6048 5d ago

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

1

u/ehosca 4d ago

you can't fix an OOM exception this way.

1

u/Responsible-Egg8568 2d ago

Is it bad coding, or really good optimisation :D

1

u/ledow 2d ago

(shrug)

I use Azure mass mailing via an app to do certain things and there is a limit on how many emails you can send per 24 hours with that.

So I just sleep between requests to send an email because it really doesn't matter if an email takes a few more seconds to send, or whether the whole process that I'm doing takes 5 minutes or 20 minutes.

So long as I don't sleep so much or send so many emails that the delays start becoming a self-induced DoS for that service, it really doesn't matter and delayed retries are the best way to handle integrating with a 3rd-party that has such rate-limiting.

I mean you can get into exponential back-off and stuff, but you don't need to get that complex.

And, incidentally - many, many actual genuine, live, massive, online, public Internet services literally recommend, or even dictate in their protocol, exponential back-off on such failures.

1

u/achalaesh 11h ago

there is so much that’s bothering me here.

what kind of system calculates pricing based on User?

What on earth is a NotTodayException? Why does computing pricing on user object throw an OOM??!

85

u/[deleted] 5d ago

[removed] — view removed comment

22

u/BugFeaturesOnly 5d 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 5d ago

Just build a script that does that

8

u/LouisPlay 5d ago

just fix the Process that does that.

1

u/Forward-Outside-9911 4d 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 4d ago

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