Symptoms
CausesSome duplication occurs because programmers work independently in different parts of the system, and they don't realize that they are creating almost identical code. Sometimes people realize there's duplication, but they're too lazy to remove it. Other times, duplication will be hidden by other smells; once those smells are fixed, the duplication becomes more obvious. A worse -case (but perhaps the most common) scenario occurs when the programmers intentionally duplicate code. They find some code that is almost right, so they copy and paste it into the new spot with some slight alterations. What to Do
PayoffReduces duplication. Lowers size. Can lead to better abstractions and more flexible code. ContraindicationsIn very rare cases, you may conclude that the duplication communicates significantly better and decide to leave it in place. Or you may have duplication that is only coincidental; in this case, folding the two places together would only confuse the reader. |