How to convince a colleague that code duplication is bad?

Posted by vitaut on Stack Overflow See other posts from Stack Overflow or by vitaut
Published on 2010-11-19T15:08:34Z Indexed on 2011/01/01 3:54 UTC
Read the original article Hit count: 284

A colleague of mine was implementing a new feature in a project we work on together and he did it by taking a file containing the implementation of a similar feature from the same project, creating a copy of it renaming all the global declarations and slightly modifying the implementation. So we ended up with two large files that are almost identical apart from renaming.

I tried to explain that it makes our project more difficult to maintain but he doesn't want to change anything saying that it is easier for him to program in such way and that there is no reason to fix the code if it "ain't broke".

How can I convince him that such code duplication is a bad thing?

It is related to this questions, but I am more interested in the answers targeted to a technical person (another programmer), for example a reference to an authoritative source like a book would be great. I have already tried simple arguments and haven't succeeded.

© Stack Overflow or respective owner

Related posts about refactoring

Related posts about coding-style