tags:

views:

113

answers:

9

Is there a tool that can do a diff of two methods? I'm working on some legacy code that has several 100-200 line methods that contain a lot of duplication and I would like to abstract the duplication out. Being able to diff the two methods would be a huge help. In case it matters, I'm working with .NET and Visual Studio 2008.

A: 

I've used checkstyle for this, but it was for java.

s_t_e_v_e
+1  A: 

I've used WinMerge to solve that problem.

I copy the methods over into new documents in WinMerge and then work on it there until I have the extra pieces cut out.

chills42
A: 

I'd recommend Simian: http://www.redhillconsulting.com.au/products/simian/

Matt Grande
A: 

Visual Studio 2008 Team Edition has documaent comparison rolled into it. So depending on what version you are running you may just need to right click on the solution explorer and chose 'Compare'.

Stevo3000
A: 

The subversion GUI client Tortoise can make a diff of two text files (or code files in this case), just copy both methods in a different txt file, select them, right click and from the tortoise menu choose diff.

Pablo Fernandez
A: 

Sourcegear's Diffmerge is very nice and free. You would need to cut your code into different files so they could be compared side/side. You can use this (and most similar utilities) to compare three files at once.

Michael Haren
+1  A: 

Don't know if this is practical for you, but (unsurprisingly) emacs can do this for regions within two files both as a line-by-line or word-by-word comparison.

look up emacs ediff if interested (it also does file/buffer compares, file against ancestors, patches, 3 file compares and merges.... pretty comprehensive). I don't think I've seen a diff/merge system in any other programming editor quite as good.

simon
A: 

You could use a tool like Diffuse. Just drag and drop your files onto either pane, pick a line from one method, right click on what should be the corresponding line in the other pane and choose "Align to Selection". You can even double click then start re-factoring the code directly in Diffuse.

A: 

Compare++ just meets your needs. The diff tool is a visual specialized tool for source code file comparison, merging and folder synchronization. In the website:http:www.coodesoft.com,there are many screenshots, you can review them.

What you can do with Compare++

  • Compare sub-sections of files such as code structures;
  • Compare files and folders with lightning speed;
  • List all code structures change such as function changes
  • One step to merge multiple differences from side to side
  • Compare the containing folder for loaded files
  • Support "Edit files and instantly compare"
  • Automatically detect files and folders changes outside