Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

One of our team member duplicates code. Code duplication causes confusion among my team members reading his code, it causes bugs down the line when the duplicated segment is fixed in one location and not the others and it bloats the size of his code-base.

I have discussed with him not to duplicate code. But he show excuses that it will delay our projects deadline if he refactors all the places where he made code duplication.

How better can I deal with him?

share|improve this question

marked as duplicate by thorsten müller, gnat, Bart van Ingen Schenau, MichaelT, JeffO Apr 16 '13 at 14:12

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Point this person to Why is “copy and paste” of code dangerous? – Oded Apr 16 '13 at 13:01
@Oded, +1 to your comment. Nice resource. I will point this resource to him. – Md. Mahbubur R. Aaman Apr 16 '13 at 13:03
Almost always the answer to these "inept colleague" questions is global Code Review. – glenatron Apr 16 '13 at 13:11
Changing the behaviour of a team member is never easy. Daily code reviews for a long period is the only thing which may break bad habits. – Doc Brown Apr 16 '13 at 13:26
am I the only one who finds it ironic that this got closed for being a dupe? – ratchet freak Apr 16 '13 at 15:39
up vote 8 down vote accepted

You can explain that it would be more costly in delays to fix the same bug in 5 locations.

And then finding out that the fix was missed in location 6.

It also delays the team when they look at a piece of code, expecting it be be called from one location, but it never does, as it is duplicated elsewhere, where it is being called.

This is particularly problematic when certain versions of the duplication change slightly - it is then difficult to tell which one is the "right" one and why - this is one of the most difficult things to correct and is very time consuming.

You can also send them to Why is “copy and paste” of code dangerous?

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.