If I understand you correctly, you wish to add a second parser method in
CSVParser that returns a different type? Is this correct? Then I'm assuming both of these methods would parse CSV files?
The problem derives from naming conflicts as I see it. The way you structured your code, there is one
Parser for each type of file, in this case an
XMLParser for xml files and a
CSVParser for csv files. This is all fine and good if you will only have one said parser for each type of file, but apparently that is no longer your case.
While you could add a 2nd method in
Parser and throw an
NotImplementedException in the
XmlParser second method, you have to really ask yourself if
XmlParser is the exception to the rule or if it is the rule. In other words, if tomorrow you decide to add yet another parser, will this new parser return both a list of
AType as well as a list of
BType? In that case,
XmlParser is the odd one out, and it may be a good idea to extend this behavior to
Parser, but I'm guessing that isn't the case here.
Therefore it would most likely be a bad idea to add a 2nd method to
Parser. Thankfully there are alternatives! Since a
Parser implementation is no longer tied only to the type of file, a straightforward solution might be to have a
CSVToATypeParser and a
CSVToBTypeParser. In this way, you can use either one as you would any other parser.
A second solution would be to combine
BType somehow as
CType so that a call to
CSVParser would return all the information you'd require from
BType in a single method. Consider that you're still performing one pass regardless, so aside from a increase in memory usage, there would be no added disadvantage.
Hope that helps!