this post was submitted on 08 Jul 2026
54 points (96.6% liked)

Programming

27724 readers
327 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 3 years ago
MODERATORS
 

Spent an hour today renaming env vars across three services to make them "consistent." Broke staging in the process because one service cached the old values. Should've just left the mess alone — it worked fine before I touched it.

top 28 comments
sorted by: hot top controversial new old
[–] FizzyOrange@programming.dev 2 points 5 days ago

It doesn't mean you made the wrong decision. Changing the names has a potential cost - you break something (this is especially risky for environment variables which have insanely global scope, no static type checking, etc.).

Not changing the names has a potential cost too - causing confusion in future, wasted time, or even bugs due to the increased chance of mistakes.

I'm currently leaving a company where they almost never clean up their messes. Tons of old unused code is just left in the repo. Causes huge wastes of time.

Don't underestimate the potential cost of not keeping things orderly. There was a famous case (Knight Capital) caused by not cleaning up an old unused CLI flag and it cost them $440m and destroyed the company.

[–] HaraldvonBlauzahn@feddit.org 2 points 5 days ago* (last edited 5 days ago)

Good names matter.

If you don't refactor codebases continuously and consistently(!), the'll become a total mess over time. I've worked recently with code bases that still use DOS character encodings common before 2000 or so.

If something is purely local, in a single process, it is easy to change. But the more stuff it touches, the more difficult and laborious it gets. On the extreme end, there are things like network protocols like IPv4 which are almost impossible to get rid of.

[–] CombatWombat@feddit.online 36 points 1 week ago (2 children)

I had a senior early on in my career who took pride in producing the smallest diff possible to solve any given ticket and I thought it was so strange -- I'm already in the file, why not clean up a bit? In hindsight, they were entirely right, and I always regret doing just a little cleanup without it being strictly necessary.

[–] Lysergid@lemmy.ml 27 points 1 week ago (2 children)

You can have both. Just not in one MR. Do what is needed, push, branch off, do what is nice

[–] deadcream@sopuli.xyz 16 points 1 week ago (5 children)

Not if your team's policy is that every MR must be associated with a Jira ticket for a bug/feature and creating tickets for refactoring/cleanups is simply not done.

[–] JackbyDev@programming.dev 1 points 2 days ago

You could always just make the ticket yourself. But yeah, I hate this policy as well.

[–] Kache@lemmy.zip 1 points 6 days ago* (last edited 6 days ago)

Refactor first

Engineering has to draw the line somewhere. Excuse my analogy, but if the order is "you are not allowed to clean up the construction site, only build", and there's so much crap around that it's no longer safe, then the answer is, "no, I can't work like this, find someone else to do it"

That said, there is an art to working in and managing tech debt. The amazing thing about software is how flexible and how twisted it can get behind the external interface

[–] kibiz0r@midwest.social 14 points 1 week ago (1 children)

I’ve seen that before. It’s a self-destructive policy.

[–] deadcream@sopuli.xyz 2 points 1 week ago

Usually it happens because there were multiple instances of such changes breaking stuff. Then QA team starts asking questions why are we breaking what's not broke. Also QA team works on Jira tickets, so if the change is not associated with relevant bug/feature then they won't know what needs to be tested and such breakage gets discovered too late.

[–] cecilkorik@lemmy.ca 12 points 1 week ago

I just tag it with the same ticket I was working on when I discovered it needed cleanup. My logic is, it IS directly related to that ticket because that's when the file was being touched, which implies it's time is due to clean up some of its technical debt. Nobody's ever challenged it and I see other people doing similar things. It depends on the company culture, obviously, but it's not necessarily a no-go.

[–] ID10T@programming.dev 3 points 1 week ago* (last edited 1 week ago) (1 children)

Just make the ticket. Be the change you want to see.

Or, as suggested, just attach it to the ticket you were working on like it’s an omnibus.

[–] deadcream@sopuli.xyz 3 points 1 week ago (1 children)

Devs can't create tickets themselves either. Sneaking it with your "official" work is the only way.

[–] expr@programming.dev 4 points 1 week ago

Red flag right there. Devs can and should be able to make tickets.

[–] kibiz0r@midwest.social 9 points 1 week ago

Agreed.

I’m also a fan of Kent Beck’s “make the change easy, then make the easy change”.

i.e. Do one PR that changes the code’s design but not its behavior, in order to make the next feature easier to implement. Then do another PR that changes just the behavior but not the design.

This way, you get earlier feedback on refactors and you keep behavior PRs small so you reduce the likelihood of the scenario where “we really need to ship this feature but it’s tied to this massive refactor that isn’t quite right”.

(Note that this is just for the case where a feature genuinely requires a refactor. If it’s just “boy-scouting”, then order shouldn’t matter but you should still keep them separate.)

[–] tryagain@sopuli.xyz 10 points 1 week ago

I'm so, so guilty of this. But that's also because I've inherited a codebase that's almost comically badly structured and every file I open is a new outrage.

[–] voytrekk@sopuli.xyz 22 points 1 week ago (1 children)

Better to break things in staging than prod.

[–] indidev@lemmy.world 8 points 1 week ago

Yeah, that's the silver lining I guess. Still felt dumb staring at broken builds because of a rename that nobody asked for.

[–] tomiant@piefed.world 19 points 1 week ago

"Let me just clean this thing aaaaaand it's gone"

[–] Maestro@fedia.io 7 points 1 week ago

Yes, guilty. But also no longer regretting it a year later now that there's a clear naming scheme and structure and I can easily find what I'm looking for.

When refactoring, it always gets worse before it gets better. So, make sure to finish it so you get to the "better" state and don't leave it at "worse"

[–] footfaults@lemmygrad.ml 5 points 1 week ago

If you are doing a rename you should have it look for the new environment variable and then fall back to the old one if it's not set. Log an error when that occurs, and then slowly go through and remove the old environment variables in your deploy code, then remove the compatibility code

[–] ell1e@leminal.space 5 points 1 week ago* (last edited 1 week ago)

I feel like it depends on the project.

Typically in the ones I work on, whenever I spot an inconsistency I fix it no matter how much of a mess that causes. Yes it hurts at first, but it may hurt more down the line when the weirdnesses accumulate to the point where it impacts operations and it'll be a much bigger problem to fix.

However, I can totally see a more chill strategy work better for a project that is mostly just relatively simple code, like perhaps some website deployments. In my opinion it depends a lot on whether the code is generally already complicated, which is when you'll typically want to refactor earlier than later.

[–] partial_accumen@lemmy.world 4 points 1 week ago
  • $variable1
  • $othervariable
  • $july2014fixvariable
  • $notneeded

...and finally...

*$otherothervariable

These shall be the variable names until the heat death of the universe! Blessed be! So say we all!

[–] mrmaplebar@fedia.io 3 points 1 week ago

The problem with renaming environment variables is that you don't always control the environment.

[–] valar@lemmy.ca 3 points 1 week ago

I've not done this specifically, but I know the pain of wanting to make things neat and it breaking things. Then having to live with the unsatisfying setup instead of making everything symmetrical and scratching my brain itch.

[–] locuester@lemmy.zip 3 points 1 week ago

This is one of those things that break two golden rules. Minimal change, or consistency? The only further variable a most senior person considers is the brittleness of the environment and deployment process.

[–] fuckwit_mcbumcrumble@lemmy.dbzer0.com 2 points 1 week ago (1 children)

"If it aint broke don't fix it"

[–] thenextguy@sh.itjust.works 8 points 1 week ago

"If it ain't broke, it's about to be."

[–] farmgineer@nord.pub 2 points 1 week ago* (last edited 1 week ago)

At a place years ago, I misspelled a word (stupid English) which made its way into the APIs our FE consumed. FE guy decided to do a quick find/replace and broke prod. He missed some files.

(One of oldest database tables also had a spelling error from the site's first dev because English sucks)

Edit: WTAF, autocorrect?