this post was submitted on 29 Oct 2024
59 points (92.8% liked)

Programming

17326 readers
217 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
you are viewing a single comment's thread
view the rest of the comments
[–] Kache@lemm.ee 9 points 1 week ago* (last edited 1 week ago) (7 children)

I don't understand, if you've got easy to delete copy-pasted code, then delete it. It'll be a nice and cathartic exercise.

But sounds like what you're really talking about is code that isn't easy to delete.

[–] Lysergid@lemmy.ml 3 points 6 days ago (6 children)

I don’t understand too. Are you suggesting me to drop bunch of features in the product?

[–] samus7070@programming.dev 3 points 6 days ago (3 children)

I think the responder means that duplicate code is usually easy to refactor into single methods. Typically I see copy pasted code that is changed just a little bit. However much of a duplicated function can be broken into smaller functions and the redundant code removed in favor of calling into the functions. Often what is left then becomes easier to reason about and refactor accordingly. I love the PRs that I make which delete more code than I add but still manage to add functionality. It doesn’t happen often but it’s fun when it does.

[–] Lysergid@lemmy.ml -3 points 5 days ago (1 children)

Right, but my initial comment was about article’s statement being wrong. Refactoring in the way you described will make code harder to delete which is bad according to the article.

[–] Evotech@lemmy.world 3 points 5 days ago (1 children)

Sounds like you read the first paragraph only

[–] Lysergid@lemmy.ml -2 points 5 days ago

No, title only

load more comments (1 replies)
load more comments (3 replies)
load more comments (3 replies)