“Every line of code is written without reason, maintained out of weakness, and deleted by chance” Jean-Paul Sartre’s Programming in ANSI C.
Every line of code written comes at a price: maintenance. To...
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
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.
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.
I don’t understand too. Are you suggesting me to drop bunch of features in the product?
That means it’s not easy to delete. So your initial premise is wrong.
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
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.
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.
Sounds like you read the first paragraph only
No, title only