you are viewing a single comment's thread
view the rest of the comments
[–] 17 points 2 years ago (3 children)

TLDR;

My current project has mostly easy to delete code and not easy to extend. Why? Coz shit was copy-pasted 50 times. It’s not fun to work in this project.

  • source
  • hideshow 6 child comments
  • [–] 9 points 2 years ago* (1 child)

    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.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 2 points 2 years ago (2 children)

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

  • source
  • parent
  • hideshow 4 child comments
  • [–] 5 points 2 years ago (1 child)

    That means it’s not easy to delete. So your initial premise is wrong.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 4 points 2 years ago*

    No, that means you falling into author’s bait where they misuse term “delete”. Refactoring is not equal to deleting. One can be result of another. But the truth is that extendable code needs to be modular to be extendable. And modular code is easy to refactor. Author couldn’t not name it “Write code that is easy to refactor, not easy to extend” coz it’s even more dumb

  • source
  • parent
  • [–] 3 points 2 years ago (1 child)

    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.

  • source
  • parent
  • hideshow 2 child comments
  • [–] -3 points 2 years ago (1 child)

    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.

  • source
  • parent
  • hideshow 2 child comments