this post was submitted on 13 Nov 2025
1078 points (99.3% liked)

Programmer Humor

27412 readers
2044 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
top 50 comments
sorted by: hot top controversial new old
[–] Epzillon@lemmy.world 35 points 6 days ago* (last edited 6 days ago) (1 children)

Jesus i worked at exactly this kind of project once. The only other dev was also very hostile and protective of this position. He did not want me there in the slightest. Took about 6 months before we cancelled the contract since this dude was just actively harrassing me in Teams DMs on the daily and he just ignored all my concerns regarding maintainability since "he could understand the code" and i was probably just "not experienced enough".

Don't downplay what this does to your mental health. 5 years of workplaces like this and I'm now starting to see a therapist due to exhaustion disorder symptoms in my goddamn 20s. Take care our there!

[–] tiramichu@sh.itjust.works 12 points 6 days ago

So infuriating when you have some dickhead making themselves unfireable by intentionally convoluting the codebase and chasing out any other hire. And even worse when management bought into it and think the guy's an actual irreplaceable genius.

Probably even believes it himself. I hate narcissists.

[–] GreenKnight23@lemmy.world 38 points 6 days ago (2 children)

longest file I have ever maintained contained 50,000 lines of code.

fifty THOUSAND.

forgive me for not weeping for 2000 lines.

my advice, don't fucking touch it. pull out as much functionality out of it into other things over time.

there will come a day when you can throw it away. maybe not today, maybe not tomorrow... but some day.

[–] meekah@discuss.tchncs.de 27 points 6 days ago* (last edited 6 days ago) (1 children)

Yeah, been there. The codebase I worked on also had a single method with 10k lines.

The database IDs were strings including the hostname of the machine that wrote to the DB. Since it was a centralized server, all IDs had the same hostname. The ID also included date and time accurate to the millisecond, and the table name itself.

Me: Mom, can we have UUIDs? Mom: We have UUIDs at home UUIDs at home: that shit

[–] rbn@sopuli.xyz 17 points 6 days ago

You should add the local weather forecast, a random fun fact and the canteen menu of the day to the key to make it more interesting to read.

load more comments (1 replies)
[–] gingersight@programming.dev 19 points 6 days ago (1 children)

Oh, it's only the files that have over 2k lines of code? Hell, I'll take that over what I'm dealing with now. I've got multiple FUNCTIONS that are over 2k lines. >:(

[–] ripcord@lemmy.world 14 points 6 days ago (3 children)

Yeah, I dont see a big problem with files over 2000 lines in some cases, as long as things remain well writrej, organized, abstractd.

One piece of garbage that I'll never touch again hae most functions this size. One was 50,000 lines! Hundreds.of lines of if/else, half of the functions passed the same 60 arguments because he didn't understand classes or even dictionaries, etc etc. And was used heavily.

[–] funkless_eck@sh.itjust.works 8 points 6 days ago (1 children)
load more comments (1 replies)
load more comments (2 replies)
[–] HugeNerd@lemmy.ca 18 points 6 days ago (1 children)

That's what agentic AI is for! Your OS will figure out by itself what you are doing and weave together a shambolic rococo digital house of cards that will be not just undocumented but utterly incomprehensible.

It's fine, just get a 5GHz CPU with 48 cores, 1TB of DDR5 HBM super RAM, and maybe a few petabytes of storage (in the cloud in a flatpack Docker that runs on a VM), so that you can finally make that button blue.

[–] CanadaPlus@lemmy.sdf.org 11 points 6 days ago (1 children)

Shut up and take my venture capital money! And maybe 2/3 of the whole market cap in stock options! /s

[–] HugeNerd@lemmy.ca 6 points 6 days ago

Fucken right, get your agentic AI to get in touch with my agentic AI (with wire transfer deets)

[–] madjo@feddit.nl 22 points 6 days ago (1 children)

ARGH this triggered a bit of PTSD for me....

"We're going to convert these COBOL applications to C#, and you need to test that the new application works exactly the same, including the same bugs as the old application."
"Ok, where's the specifications and test reports of the old COBOL applications?"
"They were lost to time, we don't know where they are."
"Ok, so how are the developers going to write the C# code?"
"They're going to read the COBOL scripts and recreate them into C#, we advise you do the same."

Cue me spending a month trying to decypher the COBOL gobbledigook into inputs and outputs, and write testcases based on that. And after that month was up, and I had delivered my testcases, they told me that my services were no longer needed.

load more comments (1 replies)
[–] ChickenLadyLovesLife@lemmy.world 18 points 6 days ago (2 children)

There are no comments in the code

At my last job, I was assigned to a project being run by a straight-out-of-college developer who felt that not only were comments unnecessary, they were actually a "code smell", a sign of professional incompetence on the part of whoever added them. It's an insane philosophy that could only appeal to people who have never had to take over an old codebase.

[–] CodeBlooded@programming.dev 6 points 6 days ago (2 children)

Or, it appeals to people that have had had to take over an old codebase where the comments were all lies.

“Code never lies. Comments sometimes do.”

load more comments (2 replies)
load more comments (1 replies)
[–] moseschrute@lemmy.world 15 points 6 days ago (3 children)

Bonus frame:

The 2000 line file is one function

load more comments (3 replies)
[–] Adalast@lemmy.world 26 points 6 days ago (4 children)

I literally told my boss that I was just going to rebuild the entire pipeline from the ground up when I took over the codebase. The legacy code is a massive pile of patchwork spaghetti that takes days just to track down where things are happening because someone, in their infinite wisdom, decided to just pass a dictionary around and add/remove shit from it so there is no actual way to find where or when anything is done.

load more comments (4 replies)
[–] explodicle@sh.itjust.works 16 points 6 days ago (1 children)

I've been doing this for years at my current job. It has become a masterpiece of refactoring and comments. They weren't even asking the right questions. I'm very proud of myself.

So naturally, I'm about to get fired and have the whole thing redone by AI.

[–] Shanmugha@lemmy.world 2 points 5 days ago

Then re-hired for 3x salary to make it work again, I hope. Or just watch the company/project fail spectacularly

[–] ieGod@lemmy.zip 17 points 6 days ago (1 children)

I'll get shit on for suggesting it but this is a great use case for AI: comment the code and generate some basic docs. Even if it's wrong it'll give you a sense of where to start looking for flows.

load more comments (1 replies)
[–] Blackmist@feddit.uk 14 points 6 days ago

I didn't even know we were hiring ...

[–] unimalion@sh.itjust.works 21 points 6 days ago (3 children)

I just inherited my first codebase a few months ago. It's like this everywhere and original developer was fired, so what should sometimes be a simple fix turns into a full day of finding what needs to change. Any recommendations on fixing/maintaining code like this or should I just make it the next person's problem?

[–] Lightfire228@pawb.social 34 points 6 days ago* (last edited 6 days ago) (2 children)
  • if it's not in git / SVC, add it as is. Create a "refactor" branch, and liberally use commits

  • Treat it like a decompilation

Figure out what something does, and rename it (with a stupidly verbose name, if you have to). Use the IDE refactor tools to rename all instances of that identifier

  • Take a function, figure out what it does, and refactor it in a way that makes sense to you

  • Use the editor's diff mode to compare duplicate code, extract out anything different into a variable or callback, and combine the code into a function call. Vscode's "select for compare" and "compare with selected" are useful for this

  • Track what you're doing / keep notes in something like Obsidian. You can use [[Wikilinks]] syntax to link between notes, which lets you build a graph structure using your notes as nodes

  • be cognizant of "Side Effects"

For example, a function or property, or class might be invoked using Reflection, via a string literal (or even worse, a constructed string). And renaming it can cause a reflective invocation somewhere else random to fail

Or function or operator overloading/overiding doing something bizarre

Or two tightly coupled objects that mutate each other, and expect certain unstated invariants to be held (like, foo() can only be called once, or thingyA.len() must equal thingyB.len()

  • write tests if you can, either using a testing framework or custom Python scripts

You can use these to more thoroughly compare behavior between the original and a refactor

[–] Lightfire228@pawb.social 17 points 6 days ago (4 children)
  • if something feels too "heavy", like it's doing xml formatting, file manips, a db insert, and making coffee, all in a single class or function

Separate out those "concerns", into their own object/interface, and pass them into the class / function at invocation (Dependency Injection)

  • use "if guards" and early returns to bail from a function, instead of wrapping the func body with an if

public Value? Func(String arg) {
  if (arg.IsEmpty()) {
    return null;
  }
  
  if (this.Bar == null) {
    return null;
  }

  // ...
  return new Value();


  /// instead of

  if (!arg.IsEmpty) {
    if (this.Bar != null) {
      // ...
      return new Value();
    }
  }
return null;
}
load more comments (4 replies)
load more comments (1 replies)
[–] hex123456@sh.itjust.works 14 points 6 days ago

Add comments as you go

load more comments (1 replies)
[–] MadMadBunny@lemmy.ca 23 points 6 days ago (1 children)
[–] janus2@lemmy.zip 37 points 6 days ago (5 children)

your paycheck is $5000 because you know COBOL

[–] MadMadBunny@lemmy.ca 10 points 6 days ago (1 children)
[–] AngryCommieKender@lemmy.world 11 points 6 days ago* (last edited 6 days ago) (2 children)

Not quite. More like per 40 hour week with no overtime, but my father insists on having up to 20 hours a week of overtime he's allowed to burn, so it's kinda like $7,500 a week. He generally gets paid byweekly or monthly. Subcontractor and all that BS

load more comments (2 replies)
load more comments (4 replies)
[–] WormFood@lemmy.world 10 points 6 days ago (1 children)

every programmer I've seen who says their code is self documenting writes dogshit code

load more comments (1 replies)
[–] Jankatarch@lemmy.world 18 points 6 days ago (4 children)

Time to go around commenting stuff yourself!

load more comments (4 replies)
[–] _stranger_@lemmy.world 12 points 6 days ago (3 children)

That time I started a new job and my first task was "fix bash"...and then I discovered a multi megabyte monstrosity called "bash.sh"

load more comments (3 replies)
[–] 87Six@lemmy.zip 12 points 6 days ago

Then you fix 90% of a problem and get blamed when the rest of 10% doesn't work

[–] catnip@lemmy.zip 10 points 6 days ago (2 children)

Those are rookie numbers. We got functions with 5000+ lines and 20 levels of indentation directly in the user-interaction event handlers :)

load more comments (2 replies)
[–] onnekas@sopuli.xyz 12 points 6 days ago

"Code IS documentation"

[–] thedeadwalking4242@lemmy.world 11 points 6 days ago

I’m dealing with this currently. Thank you all for confirming that I’m not crazy

[–] Xylight@lemdro.id 6 points 5 days ago

The link is a proxied image link for some reason.

Original link

[–] adhocfungus@midwest.social 8 points 6 days ago (2 children)

"Documenting the code base will be your first task for the next month to help show us how well you understand the codebase."

[–] mad_lentil@lemmy.ca 6 points 6 days ago

Translation: please help us understand our codebase. We're paralyzed by fear.

load more comments (1 replies)
[–] calcopiritus@lemmy.world 7 points 6 days ago

This is the dram. Since the entire codebase is shit, you basically have to rewrite it basically in its entirety.

Which means you can do it with an actual good design.

And if you mess up on something, you have a working version you can consult.

[–] cloudy1999@sh.itjust.works 4 points 5 days ago
  1. N-deep loops mixed with gotos, throws, multiple returns, and mixed memory management contracts.

#include "globals.h"

// please help

[–] Kazumara@discuss.tchncs.de 2 points 5 days ago

With the short variable you probably also get shadowing. That's super fun in a new code base.

Or another favourite of mine: The first time I had to edit a perl script at work someone had used a scalar and a hash with the same name. Took me a while to realize that scalars, arrays, and hashes have separate namespaces, and the two things with seemingly the same name were unrelated.

load more comments
view more: next ›