I am php programmer, but since its not only for PHP, I post it here, it should be good I guess.
Now I want to ask - is there sometimes excuse for dublicating code?
We have this problem:
we make the software, PHP, so push it to the server and its running.
We go and develop other modules of it, which have similar code, so the code could use same functions to avoid dublication.
But - I was told to make it as isolated - try to touch existing code as minimally as posible. WHy? Because - what if in the production bugs start to appear?
Lets say I have modified the code - not dublicating - and I have to delay what I am doing now and go back to bug fixing of earlier code which is in production. But now - how can I do this if I have modified it already? Maybe there is a small fix to that bug, but since I modified it for my new module, it becomes a big fix, so the code would work with new module and at the same time fix the existing bug. The system needs to be carefully tested and worse - it cannot be fixed so fast.
If my new module is isolated from from existing modules, then I can fix the existing module, push it to the production togetther with incomplete new module and it should be fine, since new module is not visible to end user yet. So quick fix can be done without making more bugs. This makes sence.
But I asked my friend, also I have googled about this topic and I only see answer - do not dublicate code.
So how can you explain - how would I solve my situation which I decscribed - to fix small bug quickly, without need to test all modules, but only one to let system run as soon as posible when programming withouth code dublication?