issues faster

Database Tools

Must-have SQL Server tools and tools for MySQL, Oracle, and PostgreSQL database development, management and administration

Data Connectivity

The most trusted solutions for your data connectivity needs: ADO.NET, ODBC, SSIS, Excel, dbExpress, Delphi Components

Productivity Tools

Write code, create reviews, compare sources, track the working hours with the web app, utilize the power of ORM Solutions

Data Services

Data integration, online backup, web-based SQL tools, cloud connectivity solution
Previous Next

Structure Comparison in Text Compare Tool


The concept of Code Orientation is what makes Code Compare stand out from an oceanful of counterpart text compare tools. It processes source files as code and rests on several foundations, Structure Comparison being one of them. This method recognizes source files code written in popular programming languages, namely C#, C++, JavaScript, Java, Visual Basic and XML.

Structure Comparison is a mode for the Code Compare text compare tool. It can be toggled using the eponymous button on the toolbar. With Structure Comparison turned off, the application returns to the usual comparison mode.

The following examples can help you better understand the advantages of Structure Comparison.

Moved Code Elements

The first example demonstrates how Structure Comparison can be used to trace code elements movement.

The following screenshot shows comparison of two files using the usual text comparison algorithm:

Comparison of two files

The code remained essentially the same but two strings were swapped. Default text comparison detected differences in corresponding strings and highlighted them using the preset colors.

With Structure Comparison enabled, the tool compared the source files like this:

Comparison of two files - Structure Comparison

The Structure Comparison algorithm recognized the C# syntax and highlighted no difference, since the code would run the same way as before.

Renamed Methods

The second example demonstrates another practical feature of Structure Comparison — association of renamed methods that contain similar parameters. The method Paint was renamed to Render while its parameters remained unchanged.

The first screenshot depicts comparison using the usual text comparison algorithm.

Text comparison algorithm - Renamed Methods

With no code recognition algorithm enabled, the blocks were treated as totally different ones.

Structure comparison algorithm - Renamed Methods

The Structure Comparison algorithm detected identical parameters and treated the Render method as a renamed Paint method, highlighting the difference as a single modified block.

Similar Names

The third example describes the use of Structure Comparison to associate methods with similar names.

Text Comparison - Similar Names

Just like in previous cases, when you compare source code using usual comparison algorithm, the blocks are considered absolutely different.

Structure comparison - Similar Names

Structure Comparison detected similar method names and handled the blocks as modified. This feature can be especially useful for mistype detection.

See Also

Implementation of XML structure comparison has its own peculiarities and is covered in a separate article of our blog.

For details on the major feature set of our file diff and merge tool, refer to the overview page of Code Compare.