Improving Code Quality - Code Clones

Run Analyze Solution for Code Clones from the Analyze menu.

This checks for any repeated code in your projects, and rates the repetition as strong, medium or weak.

When I ran this I was surprised to find a few strong matches. The first match was where I was calling a stored procedure and mapping the returned data table back to a list of classes (different stored procedure and a different class type each time). In all instances the code followed the exact same format – the only difference being the name of the stored procedure running, and the type the data table was then mapped back to. I could rewrite this logic using generics and then call that method in all 3 places just passing in the type to map to and the stored procedure name. This reduces my line count and improves the code maintainability and reusability.

Next: Improving Code Quality - Code Analysis



Tagged: Code Quality, Visual Studio, .Net,
Categorised: Application Lifecycle Management,
By:
On: