Technical Design of QuickFileCompare

From Acacia Support Wiki
Revision as of 10:03, 4 September 2021 by Gmcollett (talk | contribs)
Jump to navigation Jump to search

SwiftUI

This app is based as much as possible on SwiftUI. This is a great improvement to Apple software development and probably saves 95% of the code required to produce the user interface for an App.

Comparing Files

The foundation library provide simple difference and apply functions that in theory should make an App like this a no-brainer to develop, but the devil is in the detail.

Based on VCS?

Given the built in functions and existing software version tracking systems, the design began based on developing a simple version control system. File A is checked in, then checked out again and replaced with file B. The differences are then extracted and a side-by-side comparison. Simple ... or maybe not!

Parsing

The difference method can be applied to sets of objects such as [String] or [Character] which results in a list of remove and insert operations that will generate File B when applied to to File A.

It took many iterations to settle on using [String] as the basis of the comparisons. The next step is converting the text in File A into an appropriate array of String values for comparison. Simple splits by white space characters (new line, tab space etc) doesn't really work because the seperators disappear, and these are actually important when creating and displaying the differences. The parsing process ended up using regular expressions that retained the seperators including punctuation.

Presenting the Results

The final step in the comparison is generating the side-by-side text. This is done by reconstructing the LHS and RHS text from the arrays of words based on the difference results.