The Six Stages of Code Grief

https://suppo.fi/post/9016065

I was part of project that scoffed at the idea documenting code. Comments were also few and far between. In retrospective, it really seemed like they wanted to give that elitist feel because everything reeked of wanting to keep things under wraps despite everything being done out in the freakin’ open.
Hey! This was my first real job. Is Matlab code written by physicists who just recently learned programming.
My first thought immediately was of academia also.

Ngl that’s like baby levels of nasty code. The real nasty shit is the stuff with pointless abstractions and call chains that make you question your sanity. Stuff that looks like it’s only purpose was to burn the clock and show off a niche language feature. Or worse than that even is when the project you inherit has decade old dependencies that have all been forked and patched by the old team

If all I had to worry about was organization and naming I’d be over the moon

Git commits with message saying “pushing changes” and there are over 50 files with unrelated code in it.
“fixed issue”

“Fix for critical issue.”

Followed by an equally large set of files in a commit with just the message:

“Fixup”

And then the actual fix turns out to be mixed in with “Start sprint 57 - AutoConfiguration Refactor”

In the past I had commit messages with change numbers from a system, that was no longer in use.

So the commit just said “CH-12345“. It is the kind of annoying, where you can’t even really be mad at someone.

I put my ticket numbers in my tickets, but i also try to describe the change too (e.g. “Fix bug where xyz happens due to zyx action”). Also, atomic commits: commit only related changes.

Yes, it takes longer to commit large changes, BUT you can easily merge the commits, and rollback only what needs to be rolled back.

My favorite was an abstract class that called 3 levels in to other classes that then called another implementation of said abstract class.

And people wonder why no one on our team ever got shit done.

Former coworkers: “oh, these two lines are the same in function x and function y. TIME TO ABSTRACT”
The real nasty stuff is not code it’s in proprietary blobs which can only be edited through proprietary software. The documentation is shit (because the editor also sells training) and there are no communities (because implementation specialists think having secrets is having an edge).
And hard casting onto the wrong class because a neat function lives in there (who will detect you did that and treat you a little different because you don’t have all the resuired data in that class instance) as a “quick fix”

Even if the abstractions aren’t pointless, there’s a limit to how many levels of abstraction you can make sense of.

I’ve seen some projects that are very well engineered, with nice code, good comments, well named variables and functions. But, the levels of abstraction and nesting get so deep that you forget why you were digging by the time you get somewhere relevant.

What’s frustrating there is that you can’t blame someone else. It’s just a limit for how much your brain can contain.

Well, I’m the only maintainer for my project, so ha! (I only have myself to blame.)
That just means my boss will have to do all the work. Ha, what an idiot. Wait… aw. 🙁
Even worse than there being no comments: the code is extensively commented, but its function has drifted from what the comments describe to the point where they are actively misleading.
The good old “signal left when switching to right lane.”
I mean sometimes you gotta trick the compiler to get a leg up in runtime.
JavaScript developer in a strongly typed language using dictionaries with single letter keys.

You got 3 letters?! Luck!

I worked at a japanese company whose engineers we're former NTT developers. Copypasta (i.e. not using functions), inefficient algos, single-letter var names, remote code execution from code as root, etc. good times!

single-letter var names

in kanji?

Such hits as 'a', 'b', 'x', and 'y'. I know the version of the language we were using didn't have native utf-8 support, so I don't think kanji varnames were possible. It even made comments in kana and kanji really wonky (I think the comments were shiftjis)
Those are amateur problems, real problems start when you are unable to run it or you don’t have source code

Oh God. Story time.

I had an important CICD pipeline that published a dinky little web-thing that was important for customer experience. The first line of the final docker file was from company-node:base. I had all the source code. I had all the docker files. At no point was there ever a container named company-node let alone a tag of base.

The one and only version of this container was on the CICD server.

The team lead has spend the last two months writing a permissions library that nobody understands how to use or debug. He wrote it with Cthulhu at his side. Soon not even Cthulhu will understand it.
The next row would be “boss fires you thinking Claude can maintain the codebase.”
At least there’s a kind of happy ending when we walk past the old boss and don’t toss a dollar into his pan-handling hat.
Honest question: would an LLM be able to write useful comments in code like this?
It would probably struggle to see the larger picture. I can see it being used to add comments in self-contained functions though without too much difficulty.

Honest question: would an LLM be able to write useful comments in code like this?

It can be better han nothing, but not really. The LLM faces the same challenge that any competent coder does: neither were present to learn the human, business and organization context when the code was first written.

use the LLM to generate regression tests for the large file, then start refactoring it
100% I use them a lot to ingest and understand shitty code for me. Of course it’s not perfect, it’s like having a colleague who’s not super strong but has infinite patience for bullshit
Yeah, that was a fun job… at least the database tended to have some descriptive column names. They never lined up with the entity they mapped to, but it was better than nothing.

The only experience I have like this is when I wanted to see how the ARMA Life mod was doing certain things, but it was programmed by like 20 different people in 3 different languages. Most of it was in German and French.

It was easier to just to find my own way of doing what I wanted to do.

This was me when I started working with my current full time job.

What a nightmare.

The language is COBOL.

your paycheck is $5000 because you know COBOL

Per day.
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.

subcontractor

that’s why it’s $7500.

COBOL. That’s why he’s a subcontractor.

Pretty sure that knowing COBOL isn’t the hard part. It has relatively few language concepts.

This lack of language concepts just makes it difficult to reason about it, so that’s what you’re getting a paycheck for. Well, and possibly also because it might take months to have a new dev figure out your legacy codebase, so it’s cheaper to keep the current dev by paying them competitive prices.

What? I make that kind of money by dabbling in Ansible, Python and Kubernetes. $5000 sounds pretty lowball for fairly niche knowledge like COBOL.
*sigh* why the fuck didn’t I major in CS!?
I don’t know, but for me it was undiagnosed ADHD. 😋 Fortunately IT is one of the areas where lack of a degree isn’t a showstopper.

i mean i recently did a contract gig updating a 6 year old legacy codebase in a language I’ve never used

oh also I’ve barely coded anything in my life

you guessed it, i used an LLM (as the contracter requested, but still…) ¯\(ツ)

so i keep waffling between “my (then) undiagnosed ADHD would have stunted my CS learning hard enough that I’d barely be any more knowledgeable than I am now anyway” and “despite it being a terrible fucking idea companies are going to try their damnedest to replace all software engineering with vibe coding”

so i end up back at “at least i have a degree in pipetting and can go get a $20/hr job moving small volumes of liquid back and forth until pipetting robots become cheaper than me”

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.
FUCK. Triggers me. Just got let go from a place that had this problem and wouldn’t let me make any changes whatsoever. I didn’t even push hard.

I did this once

I was generation a lot of fake data that had to make sense in certain ways. I created a neat thing in C# where you could index a hashmap by the type of model it stored, and it would give you the collection storing that data.

This made obtaining resources for generation trivial

However, it made figuring out the order i needed to generate things an effing nightmare

Side-rant:
I rarely write Python code. One reason for that is the lack of type safety.
Whenever I’m automating something and try to use some 3rd party Python library, it feels like there’s a good 50/50 chance that front and center in its API is some method that takes a dict of strings. What the fuck. I feel like there’s perhaps also something of a cultural difference between users of scripting languages and those of backend languages.

What you described sounds so much worse though holy shit.

Yeah, the new pipeline is based HEAVILY on object inheritance and method/property calls so there is a paper trail for ALL of it. Also using Abstract Base Classes so future developers are forced to adhere to the architecture. It has to be in Python, but I am also trying to use the type hinting as much as humanly possible to force things into something resembling a typed codebase.

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.

Yeah, been there. The codebase I worked on also hat a single Methode with 10k lines. The databass 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 hostbame. 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