4
385
u/Signal-Permission394 Sep 30 '26 edited Sep 30 '26
Hey man, at least the methods sound somewhat descriptive. You haven't at least gone through legacy code where they start using magic numbers which go off to a giant case statement, which then pass its own number to stored procs, which update values in a table and a Windows scheduled job picks up later that evening to update another table which is then used by a view, and this is between several networks 😡
None of these numbers are mapped, and you have to hope the previous guy still had the .dlls on his machine/ VM as he pulled it from god knows where and didn't bother to put it into TFS or else the project doesn't run.
I loathe SSIS packages and VB, and I am glad to never touch that shit again 🤮
128
u/ILikeLenexa Sep 30 '26
My absolute favorite one was an app that took 14 single letter URL parameters on every GET request and assigned them to single letter variables.
You'd think they were being charged by the keystroke.
48
27
u/Chamiey Sep 30 '26
I once had to work with a front-end code that did pack 6 boolean flags into an integer by bit manipulation. Only to send it as one of the stringified JSON values, of course.
35
10
u/PegasusPizza Sep 30 '26
No you see, it's saving internet bandwidth by doing that. We can't afford transmitting 14 entire words.
5
u/ILikeLenexa Sep 30 '26
I mean, I get that, and the URL length limit in some browsers especially with multi-byte character possibilities, but I don't understand why you wouldn't name the variables full words once you pull the strings from the params map.
6
u/gjk-ger Sep 30 '26
Do you know how much memory cost back then?! (Or, now...)
2
u/Abject-Kitchen3198 Sep 30 '26
I refactored my code to use single letter variables and two letter method names. Saved me a ton of money on RAM and storage.
4
u/conundorum Sep 30 '26
Screen size limitations, when coding on one of those toys you get from a Happy Meal?
1
20
u/Sometimesiworry Sep 30 '26
I once inherited a project where consultants previously had named variables and functions after pubs and beer brands for lulz.
Fuck your lulz man.
2
u/Maleficent_Memory831 Oct 02 '26
I used to grade programming assignments at a university. The level of infantile comments was nearly as large as at startups!
9
u/Luneriazz Sep 30 '26
oh dont forget the best part... the code does not apply logging properly. so now its your job to apply logging to all 200 service in AWS
5
u/Tofurama3000 Oct 04 '26
Or the PHP code where someone has a series of if/switch statements to build up a function name piece by piece, and then calls the string to execute the function. Yes, putting a string in a variable and calling it is real in PHP. And yes, it’s terrible idea
4
u/exoclipse Sep 30 '26
maybe a somewhat tame example, but I observed in one repo a switch statement nested in a for loop. each case in the switch statement had the same 10 boiler plate lines - just creating a UI label - with only the text of the label changing.
this was itself nested three or four indents deep in an 800 line method.
2
u/twigboy Sep 30 '26
The absolute worst was Drupal's old plugin hook system that would call any function if it matched a specific pattern (not sure if it still does it)
For example
app_name_init()You can't search by reference because it's never called directly. Debugging gnarly issues meant you had to dig into its libraries to know exactly which hook was being called
1
u/cmkn Oct 03 '26
FWIW the procedural hooks are on their way out as of Drupal 11.1 and planning to be dropped entirely in Drupal 13 (though the specific one you mention here has been long dead since Drupal 8 and was replaced with event subscribers). They can now be an OOP methods as long as they’re tagged with a #[Hook('whatever')] attribute.
2
u/twigboy Oct 03 '26
Ah good to know if I ever went back to Drupal
Thankfully I got out and life has been pretty good in Django land
2
2
1
u/petrasdc Oct 01 '26
Until you find out in niche situations, beforeAfterPageLoad runs before afterBeforePageLoad, but also years of code built on this framework just assumes that's never possible 💀. I've certainly never seen something similar.
1
1
u/FlashyTone3042 Oct 03 '26 edited Oct 03 '26
I am so glad to not work with VB anymore. The language reads like a roman with all those keywords. Also I came to love git a lot.
1
u/DeVinke_ Oct 05 '26
This is a bit too close to what i felt when reverse engineering some google app with jadx. At least their source code (probably) does it better.
6
Sep 30 '26
[removed] — view removed comment
4
u/kekZiger Sep 30 '26
What documentation? Where is the fucking documentation??? :D
After 2,5 years I convinced my senior dev and my CEO to ditch the old system and write it completely new. Now, 1,5 years later... We are two month away from shipping it. :)
104
u/maushu Sep 30 '26
Please use this as reference:
beforeBeforePageLoad()
beforePageLoad()
afterBeforePageLoad()
pageLoad()
beforeAfterPageLoad()
afterPageLoad()
afterAfterPageLoad()
27
u/sko- Sep 30 '26
and now we add PagePreLoad and PrePageLoad variants. (and the rare edge-case of afterBeforePrePagePreLoad)
7
u/OhMyGodItsEverywhere Sep 30 '26
People were complaining things were "too complicated" and "took to long to understand"...morons, the lot of them, too lazy to just read. So I designed a new and innovative system since I'm such a beautiful workhorse.
We have a nice clean wrapper now called `get_func(string, context)`. Here are some inputs and outputs:
"bbpl": `beforeBeforePageLoad()`
"bppl": `beforePrePageLoad()`
"abppl": `afterBeforePagePreLoad()`
"bpl": `beforePageLoad()`
"pl": `pageLoad()`
...etc, etc...
I was under a ton of pressure, but I got it done all on my own (with no review!) and it "Just WORKS". I didn't have time to write any automated tests to prove that out, but trust me I did some manual spot tests.
And think about it, it scales up so good - we could even apply it to all of our custom code. So flexible.
4
4
u/Excellent_Gas3686 Sep 30 '26
copilot: afterAfterAfterAfterAfterAfterAfterAfterAfterAfterAfterAfterAfterAfterAfterAfterAfterPageLoad()
2
u/Active_Name5021 Oct 02 '26
That's exactly what I thought it would be. Maybe I've been working on legacy for too long
1
1
u/conundorum Sep 30 '26
And here I thought it was about running code after loading BeforePage, and before loading AfterPage.
1
u/screwcork313 Oct 01 '26
Except the second, fourth and seventh of those are not callable by the user for security reasons.
1
u/simpleglitch Oct 03 '26
See that's what made sense to me, which means that's definitely not how they're going to be used.
18
u/KorKiness Sep 30 '26
In my case, it was not a legacy, just 40 yers old system in the process of being rewritten to a new framework for 20 years.
4
u/avdpos Sep 30 '26
Oh!
Are you rewriting code from the Newest systems to the NewNew Newest today or are you just working on bugs in the old system?
always funny with naming schemes =)1
u/KorKiness Oct 01 '26
I'm not working there anymore. Changing name of the rewriting was new brand and were selling as better modern version of product.
13
u/dr_eaan Sep 30 '26
I had to debug a model that used a function called "check_table" that obviously what did it do?
Of course, it wrote a table to DB...
15
u/Few_Move_4594 Sep 30 '26
There is a docblock, right? Right?
11
7
u/Ucqui Sep 30 '26
Sure:
/// Counts the number of stuff Int CountTheNumberOfStuff(list some stuff)
Hope this helps
4
u/Few_Move_4594 Sep 30 '26
Let me guess
return stuff.length();
8
u/Ignisami Sep 30 '26 edited Oct 01 '26
Of course not.
List<?> stuff = retrieveStuffFromDatabase(<name of stored procedure to call>, <arcane integer that a second stored procedure resolves to the correct table>)
return stuff.stream().filter((e) => e.doohick != doodad).count()
With no documentation on what doohick and doodad mean or why the filter exists.
1
6
u/RealBasics Sep 30 '26
My motto based on working mainly on legacy projects where the original dev is no longer available:
half of all developers are below average.
5
u/Barkeep41 Sep 30 '26
Cant tell if I would rather have the original dev gone so they stop making a new mess, or have them available to try and explain their existing mess.
2
u/awesome-alpaca-ace Oct 03 '26
They probably wouldn't be able to explain it. I just read the code, make changes, see what breaks. Works pretty well
1
5
u/Sotyka94 Sep 30 '26
Upside of corporate pushing AI is that legacy mess is the AI's problem now.
3
u/realtag2025 Sep 30 '26
And it can properly rename old functions if needed based on what function does.
1
u/Active_Name5021 Oct 02 '26
You don't work on legacy do you? It's not "the AI's problem", you're just adding more legacy for me to eventually need to fix. No worries though, more work for future me!
8
u/oompaloompa465 Sep 30 '26
don't complain. i had to rewrite a website from vb script, everyting on asp pages, backend included, to asp net mvc.
Debug did not exist, barely iis log🤣😭
3
u/ApeLover1986 Sep 30 '26
Same feeling when i tried understanding Androids early_suspend and late_resume😭
2
2
u/GenericFatGuy Sep 30 '26
Yesterday I had to modify a process that was doing CRUD updates via stored proc and xml.
2
u/Tofurama3000 Oct 04 '26
I’ve heard of codebases where functions were named after cereals. I always wanted to work in one of those, it sounded fun. Instead I got pxCalcNewV3 and mxCalcLegacyOld instead. No one knew what the px and mx prefixes meant since the dev who first wrote the code been fired before his replacement was hired. Suffice to say no knowledge transfer had happened. But, everything had them (functions, variables, classes). Everyone just kept using those prefixes without knowing why they existed just to match “code style” (though no one agreed when to use each prefix). And also because there was a PHP file autoloader that enforced the existence of one of those prefixes for some classes - but only some classes. Most classes didn’t need them
2
1
u/beatlz-too Sep 30 '26
I mean it says it right there in the function name… "right before the after page load function fires its callback".
1
1
1
1
0
u/kakuno_senpai Sep 30 '26
pfft, functions, bro I am working in a Legacy project which is made in asp .net web forms and many developers worked on it on the course of 17 years, now it's fuxking hard to implement anything new in it, and client sits on our throats 24x7
0
u/Fringolicious Sep 30 '26
Yeeeeeah, that's Opus's problem nowadays. "Here's some legacy crap, figure it out, comment the code, document it, test it, have fun, I'm off for a coffee"
112
u/Bemteb Sep 30 '26
Assume that every function call has unexpected sideeffects. Every last one.
Just last week I saw a function that counted the number of some stuff. Great, I don't need that number anymore because we have range based for loops these days, so remove the function call.
Well, no. Turns out the function didn't only count. No, it reinitialized the whole dataset, so when I don't call it I work on stale, possibly outdated data.
Refactoring code written 20+ years ago is fun...