this post was submitted on 22 Jul 2023
678 points (98.6% liked)

Programmer Humor

19512 readers
459 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 1 year ago
MODERATORS
 
top 19 comments
sorted by: hot top controversial new old
[–] TheSaneWriter@lemmy.thesanewriter.com 38 points 1 year ago* (last edited 1 year ago)

At least refactoring the code can make the bug easier to find. What I hate is when I spend hours looking for a bug because I missed a single line in some documentation and misunderstood how something in the project worked, that always hurts.

[–] mrmanager@lemmy.today 24 points 1 year ago* (last edited 1 year ago) (2 children)

I try to always rewrite complicated code. As an example, another dev who left the team had written a program in Elixir that nobody knew or understood. I rewrote it in python (with his help, since I still had contact with him over chat). After that, everyone in the team could understand the code and we could make changes very easily to it and document it.

Another program he wrote in python was kind of complicated and we would have bugs in it that we didn't know how to fix. So I rewrote it with a completely different architecture with focus on simplicity. And again, now everyone could just read the code and understand it.

I think many devs are writing code that is not simple to understand for others. Then rewriting it can be worth it to avoid the pain of trying to fix bugs in complicated code.

[–] Phoenix@programming.dev 6 points 1 year ago (1 children)

That's only the first stage. Once you get tired enough you start writing code that not even you can understand the next morning, but which you're loathe to change because "it just works".

[–] mrmanager@lemmy.today 6 points 1 year ago* (last edited 1 year ago) (1 children)

Yeah I've had that experience too. But sometimes I write a lot of hackish code to get it to work, and then after spend time rewriting it so it's easy to understand. But it depends on mood. Sometimes I don't change it because it's complicated and it would be too much thinking required to make it better. :)

Programmers are often lazy by nature...

[–] Phoenix@programming.dev 5 points 1 year ago (1 children)

Lazy is right. Spending fifty hours to automate a task that doesn't take even five minutes is commonplace.

It takes laziness to new, artful heights.

[–] Beanie@programming.dev 1 points 1 year ago

wouldn't doing significantly more work than necessary be the opposite of laziness?

[–] ipkpjersi@lemmy.one 3 points 1 year ago* (last edited 1 year ago)

I did that too (swapping out a complex codebase with a simpler new modern one), then I got laid off along with another dev and we got replaced by friends of our boss lmao

Although I do admit it's nice my new job that I'm starting next week pays me nearly 30% more than my old job did along with a better title to match the level I was performing at my old job lol

[–] stevedidWHAT@lemmy.world 23 points 1 year ago

Refactored into a feature

+10 points to ravenclaw

[–] tweeks@feddit.nl 11 points 1 year ago (1 children)

To be fair, if the refactoring has been done well it should be now easier to fix the bug. Your walls need to be steady before you fix the roof.

[–] agent_flounder@lemmy.one 4 points 1 year ago (2 children)

Not a dev but hobbyist so maybe I'm wrong thinking this feels a little like https://youtu.be/AbSehcT19u0

[–] PipedLinkBot@feddit.rocks 4 points 1 year ago (1 children)

Here is an alternative Piped link(s): https://piped.video/AbSehcT19u0

Piped is a privacy-respecting open-source alternative frontend to YouTube.

I'm open-source, check me out at GitHub.

[–] nintendiator@feddit.cl 1 points 1 year ago
[–] newIdentity@sh.itjust.works 2 points 1 year ago

Yeah that's exactly what it is.

[–] Phoenix@programming.dev 10 points 1 year ago

"The bug is fixed, but we inadvertently created two new ones, one of which broke production because it was inexplicably not caught."

[–] tdawg@lemmy.world 10 points 1 year ago (2 children)

Honestly refactoring everything isn't an "improvement." More often than not it's a sign of that developer not understanding what the code does. Which is fine if they need to do that in a new code base or are otherwise rather green. Writing code is easier than reading it, after all. However they really should stash those changes or reopen a new branch after that exploratory phase.

IMO (in general) a good bug fix makes the smallest possible change to implement said fix. Otherwise the focus is about documention of the bug if needed and some minor refactoring to improve readability, consistency, or efficency

[–] ngcbassman@sh.itjust.works 14 points 1 year ago* (last edited 1 year ago) (1 children)

I like the approach of when finding a bug, write a test to reproduce it, fix the bug so the test passes, next do whatever refactoring you want because you have a test passing :)

[–] tdawg@lemmy.world 2 points 1 year ago

This sounds like a great technique. I'll have to give it a go on Monday haha

[–] kSPvhmTOlwvMd7Y7E@programming.dev 1 points 1 year ago* (last edited 1 year ago)

Unfortunately sometimes the code base is fuckd up beyond repair, it can't even be tested. that's why i submitted 3000 line PR ☠️

load more comments
view more: next ›