Contribution to remove duplicated code


I would like to hear from you about the contribution to removing duplicate code.

As everyone knows, removing duplicate codes has many advantages. The code is easier to read, easier to use, and fewer lines. That is, in most cases, removing duplication has a good effect on the code.

However, as far as I know, reformatting the code does not seem to be acceptable. By any chance, does removing duplicate code belong to reformatting?

There is no general answer. It should be considered case-by-case basis.

Another example of duplicated code is not so bad.

A little copying is better than a little dependency.

Thank you for your reply! It was a great help.