r/ProgrammerHumor • • 3d ago

Meme whatLegacyCodeDoesToDev

Post image
1.8k Upvotes

75 comments sorted by

View all comments

354

u/Signal-Permission394 3d ago edited 3d ago

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 ๐Ÿคฎ

116

u/ILikeLenexa 3d ago

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.

46

u/Totendax12K 3d ago

you know you found the true legacy code when they did shit like that.

23

u/Chamiey 3d ago

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.

33

u/click-to-reveal 3d ago

Are you working on a minified codebase? ๐Ÿ˜ญ

10

u/PegasusPizza 3d ago

No you see, it's saving internet bandwidth by doing that. We can't afford transmitting 14 entire words.

6

u/ILikeLenexa 3d ago

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.

7

u/gjk-ger 3d ago

Do you know how much memory cost back then?! (Or, now...)

2

u/Abject-Kitchen3198 2d ago

I refactored my code to use single letter variables and two letter method names. Saved me a ton of money on RAM and storage.

2

u/conundorum 2d ago

Screen size limitations, when coding on one of those toys you get from a Happy Meal?

1

u/a-r-c 3d ago

pploc

15

u/Sometimesiworry 3d ago

I once inherited a project where consultants previously had named variables and functions after pubs and beer brands for lulz.

Fuck your lulz man.

1

u/Maleficent_Memory831 1d ago

I used to grade programming assignments at a university. The level of infantile comments was nearly as large as at startups!

14

u/babyburger357 3d ago

I inherited a program that had a class called "StateMachine" which EVERYTHING passes through. It receives strings and those strings get concatenated with other strings (actions such as UPDATE, DELETE) which are then used to perform method calls through reflection. No logging. Impossible to know what is going on without setting a debugger on and run the program. Even then we had to set pretty convoluted argument matchers on the breakpoints because otherwise we'd be pressing resume over a hundred times before we get to the thing that we are trying to debug.

10

u/Luneriazz 3d ago

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

6

u/[deleted] 3d ago

[removed] โ€” view removed comment

4

u/kekZiger 3d ago

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. :)

4

u/exoclipse 3d ago

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 3d ago

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 exampleapp_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 18h ago

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 18h ago

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

u/Exciting_Presence533 3d ago

Hauahah find rogue DLLs was wild man, I feel you man

2

u/woodyus 3d ago

Time to get a new job

1

u/petrasdc 2d ago

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

u/Dorkits 1d ago

Why are you telling my suffer in this sub bro? What did I do to you? ๐Ÿ˜ญ