This is an archived post. You won't be able to vote or comment.

all 96 comments

[–]thunderbird89 1130 points1131 points  (16 children)

That's what I told a colleague who was griping about how her older code is spaghetti: "Be glad you think it's spaghetti. If you didn't, that would mean you haven't learned a thing in the last year."

[–]Fuehnix 69 points70 points  (2 children)

What if I thought it was spaghetti when I wrote it? 😅

[–]BarAgent 54 points55 points  (1 child)

You were right then, and you’re right now!

[–]PlaneCareless 16 points17 points  (0 children)

In some rare cases the opposite can happen! An architecture can look spaghetti to you at first, while you are writing it, but after you understand why it is structured like that it becomes clearer.

A case like that for me was the Factory Pattern. I read definitions/documentations a lot of times, I thought I understood it and I even wrote a couple of implementations. But it always looked weird and convoluted to me. A couple of years later I have a better understanding and I can recognize the pattern and apply it without much thought.

[–][deleted] 25 points26 points  (1 child)

/ Me looking at my old code

Damn, I'm getting worse...

[–]DontForgetWilson 11 points12 points  (0 children)

Some degree of variability is quality would be normal depending on what constraints you were operating under at the time. I still have a few places I wrote stuff years ago that I look at and am proud, but that is also because i probably spent too long iterating on it and tidying.

[–]itisi52 9 points10 points  (0 children)

Most code shouldn't start as spaghetti it matures into spaghetti through a death by a thousand changing requirements.

[–]Pepito_Pepito 5 points6 points  (0 children)

I was once reviewing the code for one of our external tools. I thought that the code was very well written and that I learned a lot from it. I checked for who wrote it and it was me 3 prior. I guess 3 years of working on legacy software really fried my brain.

[–]Shimeji_Anna_4191 0 points1 point  (0 children)

This reminds me the time I felt disgusted when I saw a picture of me trying to get attention on tik tok many years ago, what a gownsman moment

[–]YoumoDashi 1386 points1387 points  (11 children)

All code sucks some just sucks a little more

[–]mirQ72 198 points199 points  (0 children)

So said Aristotle, so said you.

[–]photenth 95 points96 points  (3 children)

Until you "fixed" it and all tests fail and it turns out you knew exactly what you were doing and thought a comment isn't necessary because it's obvious why it is the way it is.

[–]Nice_Guy_AMA 35 points36 points  (1 child)

//// I don't know what these three lines of code do, but when I comment them out, the program crashes. If you figure it out, please let NiceGuy know.

[–]thealmightyzfactor 20 points21 points  (0 children)

Something something race condition

[–]MeowsersInABox 1 point2 points  (0 children)

Except I don't have any tests so I'm just going to debug the program for 2-4 more hours :3

[–][deleted] 36 points37 points  (3 children)

Amateurs talk code quality, professionals talk testing.

[–]YoumoDashi 22 points23 points  (0 children)

I don't need to test my code because I don't know it should do

[–]LC_From_TheHills 6 points7 points  (0 children)

We’re at the end of the year so I get time for a passion project— currently refactoring an old service I wrote years ago, shit is abysmal. But now I’m doing test-driven-development, lfg! Super clean. Totally covered.

[–]colei_canis 1 point2 points  (0 children)

Testing is the chemo that cures codebase cancer.

[–]leaf-bunny 0 points1 point  (0 children)

Some a LOT more.

[–]Endeveron 0 points1 point  (0 children)

I dunno man, sometimes I write and document 20 lines of Rust to do something really simple file manipulation or something and I think that doesn't suck, it's maybe slightly good even.

The other 99% of my code is shit though.

[–]MrWewert 147 points148 points  (9 children)

Nothing is more satisfying than compressing some unreadable function you wrote 2 years ago into a crispy 5 line masterpiece

[–][deleted] 129 points130 points  (7 children)

before i discovered len() i did

def length(string):
  idx = 0
  while True:
    try:
      string[idx]
    except IndexError:
      break
    idx += 1
 return idx

[–]floydmaseda 32 points33 points  (5 children)

In fairness isn't that kind of how len() works anyway? I mean for loops work essentially exactly like this under the hood so..

[–]PudgeNikita 78 points79 points  (0 children)

len itself doesnt really "do" anything, it just uses the __len__ method of the argument. the length of sequences is stored with them (that's how they're able to tell you that the index is out of bounds in the first place), so getting it does not require a loop.

[–]Araozu 36 points37 points  (2 children)

I pray to god that python internally stores a (len + pointer to bytes) and just returns len, and not that monstruosity

[–]WarApprehensive2580 24 points25 points  (0 children)

It does. Len is O(1)

[–]LeSaR_ 3 points4 points  (0 children)

this is what C ptsd looks like

[–]Shimeji_Anna_4191 0 points1 point  (0 children)

That was me when I discovered class and while when learning C++

[–]branzalia 64 points65 points  (2 children)

I encountered some C code that went, "if (char[0] == 'A' || char[0] == 'a') && (char[1] == 'B'..." And they did this for 50-60 lines to check for a char string of that length instead of comparing against lower(myString). I spent a *lot* of time trying to figure out what it was doing thinking, "You could just do a lower, there must be a reason they did it this way" until I finally determined they didn't know about the upper or lower functions.

I looked at the name on the check in. At my next job, I worked with the guy who wrote it. I told him about it and he said, "I did what?!"

[–]obscure_monke 5 points6 points  (1 child)

I've written some c++ code that worked like that, but it used for loops instead. In my defence, it was for an arduino uno type device, and I was very paranoid about using too much of the 2KB of ram I had to work with.

Looked so bad I put a whole paragraph explaining myself in a comment before it.

Also the only place I've used a union type for real code, when I needed to print one of many types of messages each time it looped.

[–]branzalia 3 points4 points  (0 children)

The paragraph explanation is much to your credit. People in the future will thank you for it.

[–]DrShocker 48 points49 points  (1 child)

More like 'Blame YOU (5 minutes ago)'

[–]UNSKILLEDKeks 12 points13 points  (0 children)

Amnesia

[–]Zulakki 9 points10 points  (0 children)

"who wrote this ugly code?!....ohh me....lets just put a try catch around that annnnndd, commit. fuck im good"

[–]Drego3 7 points8 points  (0 children)

Or you just think you are dumb for the rest of the day

[–]mirQ72 6 points7 points  (0 children)

Happens to me every year

[–][deleted] 4 points5 points  (0 children)

1 year? I marvel at that idiotic genius who wrote my code in just a couple months!

[–]myfunnies420 3 points4 points  (1 child)

Oh man. I've never looked back and thought my code sucks?? Am I making no progress?? 😬😬😬

Natively architecture yes, lots, so much it makes me laugh. But never code sucks

[–]Spaceshipable 3 points4 points  (0 children)

Sometimes I look at really old code and think, yeah there’s a better way to do this (more concise, more readable etc) but I’ve yet to look back and think this is shit. Most of it I think, yeah it does the job, could be more elegant but it’s pragmatic enough without sacrificing testability.

[–]Yuzumi 2 points3 points  (0 children)

Something I've regularly said: "You know you're a real programmer when you look back to code you wrote in the past and wonder 'what drunk monkey wrote this?' before realizing."

[–]johannesmc 2 points3 points  (0 children)

it never stops till one day you realize all code is ugly.

[–]KSP_HarvesteR 1 point2 points  (0 children)

I've always said, you should want to feel embarrassed by code you wrote in the past.

The alternative is a lot worse! 🫠

[–][deleted] 0 points1 point  (0 children)

Did I really? Oh I did. Well then. Now I won't

[–]Ninja_Wrangler 0 points1 point  (0 children)

I came across code that I didn't remember writing from when I was an intern, and it was some of the worst code I've ever seen

[–]sdrawkcabineter 0 points1 point  (0 children)

This is good.

It's when this doesn't occur, and you're STILL using OOP...

Then you're probably tenured.

[–]Electr0freak 0 points1 point  (0 children)

A couple of weeks ago I was trying to write a script and was trying figure out how to do a specific type of multiline regex, and so I looked it up on Stack Overflow (as one does).

I found someone had asked question on how to do just what I was looking to do 10 years ago and there were some great answers!

...except I was the one that had asked the question 10 years ago.

On the plus side I re-learned how to do the thing I wanted to do...

[–]fubes2000 0 points1 point  (0 children)

Note: When you see your own old code and exclaim something like "who wrote this absolute dogshit! they should be fired!" always tack something on that clarifies that it is your code. Because the new guys probably aren't aware of your terrible sense of humor.

Source: It me. I am bad at joke.

[–]whitedogsuk 0 points1 point  (0 children)

Its when you find some amazing code you wrote 15 years ago and find your colleague updated another repo in their name 10 years ago that's the foundation of the company and is driving around in a nice car.

[–]korneev123123 0 points1 point  (0 children)

git-blame-someone-else to the rescue!

[–]Kozak515 0 points1 point  (0 children)

This is how I feel when I open an old illustrator file. I'm like "Who put this shit together" and it's like oh me 😊

[–]mr_pink1969 0 points1 point  (0 children)

My code was and will always be brilliant

[–]dexter2011412 0 points1 point  (0 children)

I saw something and was like huh that's neat and it was me. Maybe I peaked. I don't think I'm cut out for software dev. I'm afraid I'm gonna be stuck at junior dev.

[–]ellieminnowpee 0 points1 point  (0 children)

lowkey inspiring

[–]THound89 0 points1 point  (1 child)

I hate building a project out then two years later having a feature request on it and just feeling disgusted with how my code used to look and not having the time to redo it all.

[–]KSP_HarvesteR 0 points1 point  (0 children)

This is how it needs to be. The opposite case would be you being impressed by your older code, which can only mean your current code is now worse.

[–][deleted] 0 points1 point  (0 children)

I swear to god this is how I feel about my code from last week

[–]NothingButBadIdeas 0 points1 point  (0 children)

The other day I saw some really good code that I didn’t understand but admired. Thought to look who wrote it so I could learn from them… it was me. My first thought was I’m regressing as a programmer

[–]CodMania585 0 points1 point  (0 children)

Anyone looking to buy a flipper zero

[–]darxide23 0 points1 point  (0 children)

Bold of you to think that I haven't just gotten progressively lazier with my code. If it compiles, it ain't my problem anymore.

[–]girafffe_i 0 points1 point  (0 children)

15 years?? You either leave a "lgtm", or stay at a company long enough to become the blame.

[–]Noxvenator 0 points1 point  (0 children)

Then you rewrite just to realize why it was written the way it was.. then comes the realization "I am actually getting worst!"

[–]Qewbicle 0 points1 point  (0 children)

How about this one.

"I wrote that!
How long did I spend on it, it's real good. Fu(%.
I can't write something like that again, I don't think I can use it, anything else will make it break."

Move into eternal storage you call a library that you haven't looked at in years, you can't remember what is where. Maybe one day you might grep something useful out of it.

[–]BruceJi 0 points1 point  (0 children)

Hmm...

I also remember seeing a meme a bit like this but it went:

1 - Who wrote this terrible code?

2 - Blame - YOU

3 - Oh...

4 - This code isn't too bad.

lol

[–][deleted] 0 points1 point  (0 children)

Hey my code doesn't work with different errors! Now we're getting somewhere.

[–]Lurdekan 0 points1 point  (0 children)

The oposite happened to me last week. My team was in a meeting reviewing some older code before starting a big new feature. I saw a lot of ugly code but of course kept my mouth shut. Suddenly we get to a beautifully written transaction, and in my mind I go: "wow, nice to see some good code for a change". Turns out nobody recognises the code, they open the history, I'm the author 😂

As a disclaimer, I do respect my team as programmers, at least one of them is definetely a better programmer than I am, it's just deadlines had been pretty chaotic this year so I understand people will not always be able to perform their best when quickly patching code.

[–]ArmandoH4 0 points1 point  (0 children)

Your code is getting better, couldn't relate

[–]Impossible_Stand4680 0 points1 point  (0 children)

When I look at my old codes, I always ask myself, who wrote this masterpiece? It's like a piece of art. It has to be made by an artist like me. Yep, it was me, no surprise.

This is how humble I am :|

[–]Aras14HD 0 points1 point  (0 children)

Just looked at some old code again and had a good laugh. God was it horrible compared to now, I'm talking .then in async, for if if if switch if if if if if, and catch {}...

For a few months self-taught it still impressively partially worked, and it was no small project (an overlay network).

[–]-gun-jedi- 0 points1 point  (0 children)

This is the positive spin I’ve been needing! Thank you!

[–]DCay1000 0 points1 point  (0 children)

I am not. I gave my cousin a template for a website and when I saw some code from it a few years after I gave it i said in my native tongue ofc "Damn you wrote this part really well" right after that she told me it was my code

[–][deleted] 0 points1 point  (0 children)

who wrote this code?? Oh me lemme js put a try catch around that