I am developing an application that compares files. I decided to use the Strategy design template to handle different formats, so I have something like this:
public class Report {
CompareStrategy strategy;
...
}
public interface CompareStrategy {
int compare(InputStream A, InputStreamB);
}
Then, of course, I implement a comparison method for different file formats.
Now suppose I wanted to add another method that addresses certain restrictions for comparison (for example, omit the line in the case of an Excel or csv file or omit the node in XML).
Would be better:
- Add another way for the interface and each implementation (there are not many at the moment)
- Create a new interface that inherits from CompareStrategy, and then implement it?
The second question: since the differences can be of different types - it would be nice to make the difference marker interface to include something like:
int compareWithDifferences(..., Iterable<Difference> differences);
, ?