Hi,
Which is the correct way of providing values to a abstract factory method?
Eg.
interface IFactory
{
ISomething Create(int runTimeValue);
}
class Factory : IFactory
{
public ISomething Create(int runTimeValue)
{
return new Something(repository, runTimeValue);
}
}
In the example the repository is injected via the constructor when factory is created but I could instead move the repository to the IFactory interface
interface IFactory
{
ISomething Create(IRepository repository, int runTimeValue);
}
class Factory : IFactory
{
public ISomething Create(IRepository repository, int runTimeValue)
{
return new Something(repository, runTimeValue);
}
}
What is considered "correct" way of doing this? How should one reason when designing an abstract factory?