Detecting duplicate code

Copy and paste development is generally regarded as a bad practice, because bug fixes or enhancements in one area of code have to be repeated in all the other copies of the same code. Not only is this time consuming and tedious, but in large code bases, it's very easy to miss a change, leading to bugs and lower overall quality.

Frequently, code duplication can be unavoidable, especially on larger projects with multiple contributors. Not to mention that using an unfamiliar code base can make it easy to unintentionally write duplicate code. With Visual Studio, Microsoft has provided a way to detect these duplicates so that you can take remedial action to clean it up. Let's see how this is done.

Getting ready

You will need Visual ...

Get Visual Studio 2015 Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.