Hi,
What I'm thinking is to introduce factory classes. So, the code would look like:
public class SomeService : ISomeService
{
private readonly ISomeComponentFactory factory;
public SomeService()
: this(new Mode1ComponentFactory())
{
}
public SomeService(ISomeComponentFactory factory)
{
this.factory = factory;
}
}
I believe this version is much cleaner than the previous one. It looks simple and readable too. The factory hides the complexity of instantiating the internal component. What do you think? Please feel free to let me know if you think there's a much better solution than this. I'm open to suggestions. Thanks!
No comments:
Post a Comment