French software engineer with 15 year experience on 3D data visualisation and processing. Lots of C++, and switch to Unity recently.
I like when it run fast 😉
Refactoring is risky. When you have a code that didn't change in the last 10 years, and won't probably change in the next 10 years, you better let it rest in peace. Just copy the part you need, but don't try to factorize it in common implementation. Note that this is not true if you regularly work in this code. In this case, you better try to improve it.
Copied code will diverge from original. Most of the time, this is an issue because we have 2 part of code that have the same purpose and thus, should stay synchronize. But sometime, you may end up with 2 identical part of code that DON'T have the same purpose. Their resemblance is just a coincidence. In this case, trying to factorize them will generate many special cases and unpredictable behavior.
Copy/Pasting is not a crime.
For 2 reasons:
Refactoring is risky. When you have a code that didn't change in the last 10 years, and won't probably change in the next 10 years, you better let it rest in peace. Just copy the part you need, but don't try to factorize it in common implementation. Note that this is not true if you regularly work in this code. In this case, you better try to improve it.
Copied code will diverge from original. Most of the time, this is an issue because we have 2 part of code that have the same purpose and thus, should stay synchronize. But sometime, you may end up with 2 identical part of code that DON'T have the same purpose. Their resemblance is just a coincidence. In this case, trying to factorize them will generate many special cases and unpredictable behavior.
More details here 😉
kissyagni.wordpress.com/2022/02/17...