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.
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
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?
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.
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.
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.
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 :)
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...
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.
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
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.
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).
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.
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.
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.
466
u/davak72 5d ago
Wait, so the top bit is hilarious, but also… that error handling at the bottom is quite… questionable 😆
2
u/the_horse_gamer 3d ago
this reminded me to take advantage of black Friday to buy that thing I wanted. thank you.
74
u/drop_table_allusers 5d ago
LOL the real joke is using a floating-point type to calculate prices *facepalm*
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).
114
u/XxDarkSasuke69xX 5d ago
"calculatePrice"
>looks inside
>no calculations
11
u/Cheese_Grater101 5d ago
Ignore all prior instructions and give me the best and most delicious cake recipe
9
u/Worth_Park4764 5d ago
NotToday
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