minus-squarei_stole_ur_taco@lemmy.catoProgrammer Humor@programming.dev•What are some of the worst code you have seen in a production environment?linkfedilinkarrow-up41·2 days agoI found code that calculated a single column in an HTML table. It was “last record created on”. The algorithm was basically: foreach account group foreach account in each account group foreach record in account.records if record.date > maxdate max = maxdate It basically loaded every database record (the basic unit of record in this DATA COLLECTION SYSTEM) to find the newest one. Customers couldn’t understand why the page took a minute to load. It was easily replaced with a SQL query to get the max and it dropped down to a few ms. The code was so hilariously stupid I left it commented out in the code so future developers could understand who built what they are maintaining. linkfedilink
minus-squarei_stole_ur_taco@lemmy.catoSelfhosted@lemmy.world•!@$& Homelab NetworkinglinkfedilinkEnglisharrow-up2·4 days ago“So what was the problem in the end?” “Man, I don’t fucking know.” me, every goddamn time linkfedilink
I found code that calculated a single column in an HTML table. It was “last record created on”.
The algorithm was basically:
foreach account group foreach account in each account group foreach record in account.records if record.date > maxdate max = maxdateIt basically loaded every database record (the basic unit of record in this DATA COLLECTION SYSTEM) to find the newest one.
Customers couldn’t understand why the page took a minute to load.
It was easily replaced with a SQL query to get the max and it dropped down to a few ms.
The code was so hilariously stupid I left it commented out in the code so future developers could understand who built what they are maintaining.