this post was submitted on 06 Jan 2024
785 points (96.4% liked)

Programmer Humor

33705 readers
300 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
top 46 comments
sorted by: hot top controversial new old
[–] autoexec@lemmy.blahaj.zone 72 points 1 year ago (3 children)

But you should probably touch it before all the dependencies are outdated. And before everyone who understands how to work with it has left. Especially if it happens to be core to the business.

:)

[–] BleatingZombie@lemmy.world 16 points 1 year ago

I completely agree. I think "touching" is the right word. Don't rebuild it, update as needed and get familiar (if needed)

[–] bappity@lemmy.world 10 points 1 year ago* (last edited 1 year ago)

had to completely replace a component in a massive project at my work recently because we forgor how it worked and had a newer different thing for it. it was so intertwined into that project that I practically had to do a ship of Theseus on it 😭😭😭😭

[–] Carighan@lemmy.world 1 points 1 year ago

Why would you touch your job security?

[–] LemmyIsFantastic@lemmy.world 53 points 1 year ago (1 children)

Absolutely untrue. Keep your shit up to date. If you have time, simplify code.

[–] tsonfeir@lemm.ee 2 points 1 year ago

There’s always opportunity for improvement.

[–] pearsaltchocolatebar@discuss.online 43 points 1 year ago (1 children)

looks at the startup scripts I just took from a 2h runtime to 15m

Guess I gotta revert those changes.

[–] Moops@lemmy.world 20 points 1 year ago* (last edited 1 year ago) (1 children)

I mean, runtimes can be a legit reason to say something's not working.

But it does work. Eventually.

Really, I fixed it because we're doing an OS upgrade and I didn't want to wait 2h every time I spun up a new instance to test a change.

[–] lobut@lemmy.ca 21 points 1 year ago (2 children)

Well over a decade ago I remember a coworker would just go through the codebase and add his own coding style.

Instead of if (predicate) {

He would do if ( predicate )

I would always ask why he did it and he said, "well we don't have any coding standards so I'm going to do it" ... I replied, "there's things like unwritten rules and sticking to whatever's in the codebase makes it easy". I told the seniors and they chose not to do anything (everyone just merged into trunk) and they just left him for a while.

Then he turned rewrote built-in logical functions in code like this: if (predicate || predicate) {

Into code like this: if ( or( predicate, predicate ) ) {

This was C# and there was no Prettier back then.

Also, he would private every constructor and then create a static factory method.

Eventually the seniors told him to knock it off. All I said was that I initially tried telling them weeks ahead of time and now we got a mess on our hands.

[–] electric@lemmy.world 18 points 1 year ago

Hilarious but their fault for not making a standard. The guy was just taking the initiative.

[–] savvywolf@pawb.social 9 points 1 year ago

The best part is that his "or" function changes the semantics of the code in a subtle and hard to find way. :D

[–] AlmightySnoo@lemmy.world 21 points 1 year ago

That's a good way of maximizing technical debt.

[–] h_a_r_u_k_i@programming.dev 20 points 1 year ago

This is actually not a good advice, from my experience. If we don't monitor, refactor, or improve the code, the software will rot, sooner or later. "Don't touch" doesn't mean we don't ever think about the code, but we make the conscious choice not to modify it.

[–] Vlyn@lemmy.zip 15 points 1 year ago

Yeah, I've worked with the leave it alone types. What do you get in return? Components of your system which haven't been updated in the last 20 years and still run .NET 3.5. They obviously never stopped working, but you have security concerns, worse performance (didn't matter much in that case) and when you actually need to touch them you're fucked.

Why? Because updating takes a lot of time (as things break with every major revision) and on top of that if you then decide not to update (yeah, same coworker..) then you have to code around age old standards and run into bugs that you can't even find on Stack Overflow, because people didn't have to solve those in the last 20 years.

[–] wabafee@lemm.ee 14 points 1 year ago* (last edited 1 year ago)

Or you do the right thing re-write or refactor, apply the latest practice add some tests to it. This way you won't have a black box anymore. Who knows there might be a hidden bug there that might be a huge security issue and could bite you back in the future.

[–] humorlessrepost@lemmy.world 13 points 1 year ago* (last edited 1 year ago) (1 children)

i = 0x5f3759df - ( i >> 1 );

// what the fuck?

[–] rooster_butt@lemm.ee 3 points 1 year ago

Fast inverse square root?

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

“That sign can’t stop me because I can’t read!”

[–] tsonfeir@lemm.ee 7 points 1 year ago (1 children)

I’m a big fan or refactoring and rewriting my code as often as I can. Not only does it keep my brain “on topic” but it allows me to make major improvements. Nothing will ever be perfect. Just try to leave it in a better state than it was before.

[–] Da_Boom@iusearchlinux.fyi 4 points 1 year ago (1 children)

At least untill you refactor something, and the act of refactoring, even though it shouldn't logically cause any problems, causes everything to break.

[–] tsonfeir@lemm.ee 5 points 1 year ago (1 children)

Then you’re not done refactoring ;)

[–] Da_Boom@iusearchlinux.fyi 2 points 1 year ago (1 children)

Though usually not long after that point you start to ask yourself "Why the fuck did I get myself into this mess"

[–] tsonfeir@lemm.ee 3 points 1 year ago

That’s ever day of my life 🥹

[–] ikidd@lemmy.world 6 points 1 year ago

Fix it til it breaks.

[–] jetsetdorito@lemm.ee 5 points 1 year ago

flipside: it needs to be fixed but the only person who understands it is OOO

[–] OttoVonNoob@lemmy.ca 5 points 1 year ago

Its ok to touch up code. If you have lots of notes, on what its supposed to do.. I learned this the hardway.

[–] kamen@lemmy.world 5 points 1 year ago

No, we must rewrite it in this fancy new framework that came out last week.

(/s if not obvious)

[–] ares35@kbin.social 4 points 1 year ago

if it ain't broke, don't fix it.

if it's still under-budget, break it carefully.

[–] LazaroFilm@lemmy.world 4 points 1 year ago

Update: bug fixes and some performance enhancement.

Don’t touch things unless you have a good reason to do so. And when you have a good reason, touch it exactly as much as you need - but never more.

[–] marcos@lemmy.world 4 points 1 year ago

If you know it works, you also know it well enough to touch it.

Almost everybody that says it is talking about something that doesn't work, and they don't know it.

And those two add-up to make any advice completely useless.

[–] treechicken@lemmy.world 4 points 1 year ago

This week I am to propose two major redesigns to an external API and webpage on my rollercoaster of a project. Let's see this code monkey land a backflip :,)

[–] Secret300@sh.itjust.works 3 points 1 year ago

Sorry I live by "if it ain't broke, I'll fix it"

[–] snowe@programming.dev 3 points 1 year ago

Man this would have been great to have read a day ago.

[–] Carighan@lemmy.world 3 points 1 year ago

... said no programmer, ever. Especially not after hearing about a cool new feature in their favorite language or library that was just added in the newest unstable version!

[–] Floshie@lemmy.blahaj.zone 3 points 1 year ago (1 children)
[–] Ghostalmedia@lemmy.world 6 points 1 year ago

Found the junior dev that wants to refactor everything.

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

I accept the challenge

[–] entropicdrift@lemmy.sdf.org 2 points 1 year ago* (last edited 1 year ago)

Ice cold take: You don't have enough tests if you can't safely refactor on a whim.

A well-tested project should allow you to refactor arbitrarily. As long as all existing tests pass, rewritten code is at least functionally equivalent to the previous code. This allows for fearless performance rewrites, refactoring, and even complete redesigns of components.

In other words, the tests are more valuable than the code itself. The spec for the codebase proper should be defined by the tests. When the spec changes or grows, the tests should change or grow, and then the main codebase should be modified to pass all tests once again.

TL;DR TDD evades this issue entirely and is fantastic for larger and/or longer-term projects

[–] FatTony@lemmy.world 2 points 1 year ago* (last edited 1 year ago)

I don't care, you're not to use static!

also applicable to "do not touch willie"

[–] trustnoone@lemmy.sdf.org 1 points 1 year ago

The best debugger is a good night sleep.

[–] metaStatic@kbin.social 1 points 1 year ago

Lousy Smarch weather

[–] ThePythonist95@discuss.tchncs.de 0 points 1 year ago* (last edited 1 year ago) (1 children)

In German we say:

„Ein funktionierendes System nie anfassen!“

[–] trk@aussie.zone 1 points 1 year ago

"Ach du lieber! Das ist not eine boobie!"