Patrick Smacchia [MVP C#]

Sponsors

The Lounge

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
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 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

[Advertisement]

Comments

Rob Cannon wrote re: Diff tools to see source files changes
on Mon, Apr 28 2008 7:12 AM

One free option you missed is Source Gear's DiffMerge.  Check it out at:

www.sourcegear.com/diffmerge

I have enjoyed using it when integrated with Visual Studio.

Yann Schwartz wrote re: Diff tools to see source files changes
on Mon, Apr 28 2008 7:29 AM

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.

Patrick Smacchia wrote re: Diff tools to see source files changes
on Mon, Apr 28 2008 7:55 AM

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 wrote re: Diff tools to see source files changes
on Mon, Apr 28 2008 8:22 AM

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.

Patrick Smacchia wrote re: Diff tools to see source files changes
on Mon, Apr 28 2008 9:10 AM

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.

real estate options wrote real estate options
on Tue, Apr 29 2008 5:29 PM

Pingback from  real estate options

pipe supports wrote pipe supports
on Sat, May 3 2008 2:58 AM

Pingback from  pipe supports

Sam Gentile wrote New and Notable 237
on Mon, May 5 2008 7:37 AM

Identity Management/OpenID/Security/P2P/WCF Scott Hanselman has a great post on OpenId P2P and WCF: Some

atwood tools wrote atwood tools
on Mon, May 12 2008 2:25 PM

Pingback from  atwood tools

Sam Gentile's Blog wrote New and Notable 237
on Tue, Dec 2 2008 5:11 PM

Identity Management/OpenID/Security/P2P/WCF Scott Hanselman has a great post on OpenId P2P and WCF: Some Resources - part of a great series. We use Peer Channel in Neuron by default. It's fast! Pablo: GetReady for OpenID Using IdentityModel: Converting

Patrick Smacchia [MVP C#] wrote Ship It Often vs. TDD
on Sun, Dec 21 2008 11:49 AM

Ayende recently answered the question what the bare minimum aspects of Agile project would be? His opinion

Community Blogs wrote Ship It Often vs. TDD
on Sun, Dec 21 2008 12:33 PM

Ayende recently answered the question what the bare minimum aspects of Agile project would be? His opinion

Ship It Often vs. TDD - taccato! trend tracker, cool hunting, new business ideas wrote Ship It Often vs. TDD - taccato! trend tracker, cool hunting, new business ideas
on Mon, Dec 22 2008 6:04 AM

Pingback from  Ship It Often vs. TDD - taccato! trend tracker, cool hunting, new business ideas

Ship It Often vs. TDD - taccato! trend tracker, cool hunting, new business ideas wrote Ship It Often vs. TDD - taccato! trend tracker, cool hunting, new business ideas
on Tue, Dec 23 2008 1:03 PM

Pingback from  Ship It Often vs. TDD - taccato! trend tracker, cool hunting, new business ideas

Ship It Often vs. TDD - taccato! trend tracker, cool hunting, new business ideas wrote Ship It Often vs. TDD - taccato! trend tracker, cool hunting, new business ideas
on Wed, Dec 24 2008 10:01 AM

Pingback from  Ship It Often vs. TDD - taccato! trend tracker, cool hunting, new business ideas

Ship It Often vs. TDD - taccato! trend tracker, cool hunting, new business ideas wrote Ship It Often vs. TDD - taccato! trend tracker, cool hunting, new business ideas
on Thu, Dec 25 2008 6:21 AM

Pingback from  Ship It Often vs. TDD - taccato! trend tracker, cool hunting, new business ideas

Ship It Often vs. TDD - taccato! trend tracker, cool hunting, new business ideas wrote Ship It Often vs. TDD - taccato! trend tracker, cool hunting, new business ideas
on Tue, Dec 30 2008 6:03 AM

Pingback from  Ship It Often vs. TDD - taccato! trend tracker, cool hunting, new business ideas

Ship It Often vs. TDD - taccato! trend tracker, cool hunting, new business ideas wrote Ship It Often vs. TDD - taccato! trend tracker, cool hunting, new business ideas
on Thu, Jan 1 2009 7:27 AM

Pingback from  Ship It Often vs. TDD - taccato! trend tracker, cool hunting, new business ideas

Patrick Smacchia [MVP C#] wrote Dramatically leverage your Code Reviews
on Sun, Mar 29 2009 6:27 AM

Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 I usually try to avoid superlative

Patrick Smacchia [MVP C#] wrote Scoop: Reflector v6 pro RTM to be released by 15th of this month
on Fri, Feb 5 2010 11:19 AM

This is really exciting time these days. Most of .NET tooling vendors are about to provide a major upgrade

Add a Comment

(required)  
(optional)
(required)  
Remember Me?