Laurent has some thoughts on the value of duplication. They are laudably contrarian.
However, I can't quite bring myself to think duplication is often a good thing. Certainly, for a manager who needs to get a quick assessment of whether a given chunk of code is good enough, it can be expedient to compare it to another chunk that is known to be good.
This approach of looking for duplication will work if the aim is very short term. Humans are good at pattern recognition. We can assume that there are other practices in place to make sure the code works properly (testing for one). If it looks okay and works okay, it probably is okay.
I see a couple of problems here.
For one, why is a manager having to judge whether a given chunk is okay? I know that every manager who has been in the trenches is tempted to go back, even if only vicariously. However, the best people to judge code are programmers who work in the same area. And nobody likes to look bad in front of their peers.
For another, it only applies if the two code chunks really should look alike. Sometimes that will be true: if we are employed it is often because we have experience solving the same type of problem. But new code jury-rigged to fit into a template of the old code, that might be a positively bad thing. Looking at it would not be enough to tell if that was the case.
Talking about duplication? I personally believe that duplication, in any for is not a good thing. It doesn't promote any type of real thought. If Bob uses the code that Bill just wrote, and it gets the job that Bob was trying to get done sooner, then where is the benefit for Bill? What was Bob doing if he wasn't writing the real code for the program he was supposed to do? Was he out with the manager at a long lunch? Was he Schmoozing with the President at some meeting securing himself in another position, maybe Bill's? When some people duplicate code, it makes them lazy. It doesn't really hone in on the particular skill set that they need to perform their duties or job, thus making them more reliable on the original coder. If Bob relies on Bill for code, then what is next? Katie relies on Sally who relies on Carmen who relies on Jerome who relies on Bob who relies on Bill? Sorry for the rant but it is crap building ontop of crap just to come up with a whole lot of crap that is sitting ontop of the realy diamond.
No need to apologize for the rant. It's worthwhile reading Laurent's original piece that I linked to for context, but duplication is not normally something anyone would want to defend. I think Laurent is playing the devil's advocate. I tried to respond with something new, not the usual objections to duplication. Looking back, I think my points are pretty banal. A rant could be just the right antidote to that banality.