Clone Detective – Hunting out clones
One of the the currently under used resources for .Net developers has to be CodePlex ,the astounding number of great open source projects hosted there is pretty amazing. If you are a .Net developer and do not have the Codeplex newsletter in your RSS reader then i highly suggest you add it now.
Ok enough of the codeplex love :) and onto the main topic here. Clone detective is one of the better open source projects that have been hosted on codeplex. The basic function that it serves is to find and eliminate duplicate pieces of code in your project.
As most developers will tell you that duplicate code is one of the biggest annoyances when it comes to programming , it usually results from copy and paste programming and usually hurts the developer the most when a small pieces of code change in one section and the rest do not get updated.
Now while TDD does aim to prevent and solve this problem , a lot of people and companies cannot just implement TDD into their projects as it usually needs to be done in the very beginning of the project. So an alternative for now is clone detective , it will check your code for duplicates and highlight the duplicate code in the code editor window. The one important thing that makes Clone Detective from every other checker is that it turns the code in token and compares that , what this means is that code does have to be typed exactly the same way to be detected as a duplicate. For a detailed explanation on how it does tokenization have a look at the videos page .
There are a number of other interesting facts that Clone Detective presents , for example it can show per file how much of the file is a clone , how many lines are cloned and how many cloned sections were found. On a whole Clone detective is really awesome just don’t over use it, there are some times when clones just cant be refactored. This should be one tool that every developer uses or at least knows of. This tool is best used in conjunction with Resharper , if you don’t have or use either i suggest you go and get them now.
~stalkerh

