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 maybe 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.
Posted
Mon, Apr 28 2008 12:02 PM
by
Patrick Smacchia