this post was submitted on 21 Apr 2024
131 points (95.8% liked)

Programming

17432 readers
221 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 1 year ago
MODERATORS
 

I don't entirely subscribe to the first paragraph – I've never worked at a place so dear to me that spurred me to spend time thinking about its architecture (beyond the usual rants). Other than that, spot on

you are viewing a single comment's thread
view the rest of the comments
[–] tsonfeir@lemm.ee 14 points 7 months ago (3 children)

I believe refactoring never ends. Just because it works, doesn’t mean it can’t work better. The better it works, the easier it will be to add features… that can be refactored too.

[–] monkeyman512@lemmy.world 10 points 7 months ago

I think there is an author that said, "Books aren't completed, they are abandoned." Code can feel the same.

[–] blackbirdbiryani@lemmy.world 7 points 7 months ago (2 children)

Bosses will never understand this and discourage refactoring until months later nothing works and everything has to be rewritten...

[–] nous@programming.dev 7 points 7 months ago

Refactoring should not be a separate task that a boss can deny. You need to do feature X, feature X benefits from reworking some abstraction a bit, then you rework that abstraction before starting on feature X. And then maybe refactor a bit more after feature X now you know what it looks like. None of that should take substantially longer, and saves vast amounts of time later on if you don't include it as part of the feature work.

You can occasionally squeeze in a feature without reworking things first if time for something is tight, but you will run into problems if you do this too often and start thinking refactoring is a separate task to feature work.

[–] MajorHavoc@programming.dev 5 points 7 months ago

So true! That's why I never use 'the R word'.

Instead, I use synonyms:

  • performance tuning
  • proactive maintenance
  • fixed a subtle bug
  • fixed a failing test
  • corrected a CI/CD failure

CI/CD failure is my favorite, because technically our CI/CD enforces a code review, so technically "we don't like how this is written" counts as a CI/CD failure.

[–] Dark_Arc@social.packetloss.gg 5 points 7 months ago* (last edited 7 months ago)

I agree; I prefer a "hammer and chisel" strategy, I tend to leave things a little less precisely organized/factored earlier in the project and then make a some incremental passes to clean things up as it becomes more clear that what I've done handles all the cases it needs to handle.

It's the same vein as the "don't prematurely optimize."

Minimizing responsibilities of individual functions/classes/components is the only thing that I take a pretty hard line on. Making sure that I can reason about the code later and objectively say simple sentences like "given X this does Y." I want all the complex pieces to be isolated into their own individual smaller pieces that can be reasoned about.

All of the code bases I've been in where I go "oh my god why", the typical reason is been because that's not true; when I'm in the function I don't know what it does because it does a lot of things depending on different state flags.