Diff tools to see source files changes

Making easy to compare 2 versions of a code base is something that I consider super
important and that is why it became a major feature of NDepend
. While source file repository tools (a la VSS or CVS…) also provide this feature, the great thing with NDepend is that changes are not considered just as text file modifications. For example
you can dissociate code change from comment change and from structural change
with these 3 CQL queries:

SELECT METHODS WHERE CodeWasChanged

SELECT METHODS WHERE CommentsWereChanged

SELECT METHODS WHERE VisibilityWasChanged

 …and there are plenty of others trick supported, to see what is not used in a tiers assembly or to see how the coupling has been impacted by code changes. These are summarized in this 3mn screencast.

Often knowing where the code was changed is not enough, you want to see what was changed by comparing older and newer versions of source files. This is useful to focus code reviews on code that has been changed. Doing so is a killer practice to rationalize code reviews and make the most of it by often pinpointing subtle last-minutes bugs. Empirically, I came to the conclusion that the bulk of bugs are luring inside the code that is not yet in production, in other words, the code that has been refactored or added since the last release. I wrote an article on this topic: How to avoid
regression bugs while adding new features
 

NDepend used to rely on the good old WinDiff tool to compare 2 versions of a file:


One of the most common feature request we got was to support any source files diff tools. Thus we added this as an option, with a list of the most popular text diff tools available:


Notice that we want to make sure to provide a flexible support for any diff tool with the command line arguments tags $OldSrcFilePath$ and $NewSrcFilePath$. Thus, the list of tools is here to make it more convenient to bind NDepend with your prefered tool but you can still choose any tool outside the list. We also provided the tags $OldSrcFileLine$ and $NewSrcFileLine$ but surprisingly, none of the diff tool we tried support these command line arguments.

It was quite interesting to churn the web for the most popular diff tools. It seems that some free tools, especially WinMerge, sustain the comparison with non-free tools. There are some passionate debates around which diff tools to use, such as on the Jeff Atwood’s blog that praises for Beyond Compare. There is also a feature I was not aware: You can compare 3 versions of a file. This seems to be supported only by KDiff3 and Araxis Merge. One of the must-have feature that most of tool supports is the ability to compare recursively 2 folders to see which files have been deleted/added/changed.

Frankly, I haven’t tested thoroughly all tools. At first sight, Araxis Merge seems to be the most featured one with an impressive list of features and I found it quite easy to grasp. However this is also the most expensive one.

The main difference that I have found between free and commercial tools is on how the tool got polished. By polish I mean things like: Is it localized, How smartly the command are organized, Startup time, On-Line and Embedded Documentation, No UI Freeze or user wait, No pesky crash, How cleverly the UI real-estate is used, Options persistence and sharing…. However, let’s mention that the freeware WinMerge is really polished.

As the team lead of a commercial tool for .NET developers, I found that indeed polishing a software is the best (and only) way to extend the set of users from the enthusiast/early ones to the (much bigger) set of potentially interested users. For the development team this is also a great satisfaction to be allowed to spend time on all minor but important details. This is usually a burden list that tends to grow. There are always numerous features in the pipe to add but when the minor-TODO list gets shortened, you’ll notice a lot of positive energy and feedbacks.

After this digression, it is worth providing the list of tools we found:

Finally, I noticed a free diff tool that comes with an intuitive presentation of changes
but unfortunately it is only available on Unix. Kompare:

Here is a list of dream feature sets for diff tools (in praise of Beyond Compare) but personally, such a simple and intuitive way to browse changes could make me prefer one diff tool over the super-polished ones.

 

This entry was posted in Uncategorized. Bookmark the permalink. Follow any comments here with the RSS feed for this post.
  • Scott Wade

    What about UltraCompare? It’s up there with Araxis Merge and other commerical tools…..but I would argue the most features and can do a 3-way comparison:

    http://www.ultraedit.com/products/ultracompare.html

  • http://www.NDepend.com Patrick Smacchia

    Indeed Yann, it is possible to link with any other diff tool and I just added:

    Notice that we want to make sure to provide a flexible support for any diff tool with the command line arguments tags $OldSrcFilePath$ and $NewSrcFilePath$. Thus, the list of tools is here to make it more convenient to bind NDepend with your prefered tool but you can still choose any tool outside the list. We also provided the tags $OldSrcFileLine$ and $NewSrcFileLine$ but surprisingly, none of the diff tool we tried support these command line arguments.

  • Yann Schwartz

    You could also make it possible to add a custom diff tool, since the command line options are pretty generic and it wouldn’t be too hard for a user to add it himself.

  • http://www.NDepend.com Patrick Smacchia

    Thanks for this useful feedback,
    the v2.8.1 has just been released but be sure that DiffMerge will be referenced by the Diff tools list of NDepend within the next version.

  • Yann Schwartz

    Hi Patrick. I

    concur with Rob. DiffMerge is a really nice free – as in beer – tool. I’ve switched from WinMerge to DiffMerge a while ago. The 3-way diff is peculiarly nice.

  • Rob Cannon

    One free option you missed is Source Gear’s DiffMerge. Check it out at:
    http://www.sourcegear.com/diffmerge/

    I have enjoyed using it when integrated with Visual Studio.