I have an application that makes use of two different interfaces that define one method each. The method name and returned result is the same, but the input parameters differ.
Examples:
Interface A
public interface IPropertyTypifier { IEnumerable<ProbabilityScore> CalculateProbabilities(AccessAddress accessAddress, AddressKey targetKey); }
Interface B
public interface INameTypifier
{
IEnumerable<ProbabilityScore> CalculateProbabilities(string name);
}
I have several classes that implement this interface, which are then added to another class that contains a list of these as such:
public class TypificationService
{
public IEnumerable<IPropertyTypifier> PropertyTypifiers { get; set; }
public IEnumerable<INameTypifier> NameTypifiers { get; set; }
TypificationResult Typify(AccessAddress accessAddress, AddressKey targetKey, string name)
{
// For each property typifier get result here
// For each name typifier get result here
// Return result
}
}
Does it make sense here to use Adapter to instead create an interface that allows me to keep a single list of typifiers, or is this design already flawed as it is?
Aucun commentaire:
Enregistrer un commentaire