This is the first thought I got while reading Interface Implementation (Interface Segregation Principle)
Thought
To introduce a new interface that would represents method parameters instead of passing individual parameter values. As shown below:
interface IServiceProviderInput
{
string Username { get; }
string Password { get; }
string AgentId { get; } // XYZServiceProvider needs this.
// Similarly add props here to represent new parameters
// required by future service provider implementations.
}
interface IServiceProvider
{
bool Authenticate(IServiceProviderInput parameters);
}
class ABCServiceProvider : IServiceProvider
{
public bool Authenticate(IServiceProviderInput parameters)
{
return true;
}
}
class EFGServiceProvider : IServiceProvider
{
public bool Authenticate(IServiceProviderInput parameters)
{
return true;
}
}
class XYZServiceProvider : IServiceProvider
{
public bool Authenticate(IServiceProviderInput parameters)
{
return true;
}
}
Question
Would this make sense or what are the flaws in this? Any thoughts?
Edit
Another thought to add more specific interface for XYZ provider:
interface IServiceProviderInput
{
string Username { get; }
string Password { get; }
}
interface IXYZServiceProviderInput : IServiceProviderInput
{
string AgentId { get; }
}
class XYZServiceProvider : IServiceProvider
{
public bool Authenticate(IXYZServiceProviderInput parameters)
{
return true;
}
}
It is possible that both the thoughts are incorrect or have flaws, I am not sure, hence the question.