How do you know you're not introducing a bug by replacing copy/paste code with common functions?
Most of the production code I've touched I would never dare to do something like this until I had a very good understanding of the codebase as a whole.
Most of the production code I've touched I would never dare to do something like this until I had a very good understanding of the codebase as a whole.
Obviously any but the most trivial refactor requires some care. Is it worth it, when (in the context of OP) you're in there to do something else? Sometimes yes, sometimes no. One rule of thumb is whether you're just rearranging code or changing the fundamental way that it works. Refactors of the first type can generally be kept low-risk and are probably worthwhile. Rewrites of the second type involve more risk and are probably better left to be projects unto themselves.