If I have 10 dependencies I need to inject and don't want to have 10 params in the constructor, which injection pattern should I use?
public class SomeClass
{
private IDependency1 _dependency1;
private IDependency2 _dependency2;
private IDependency3 _dependency3;
//...
}
Should I use setter method injection?
public class SomeClass
{
private IDependency1 _dependency1;
private IDependency2 _dependency2;
private IDependency3 _dependency3;
//...
[Inject]
public void SetDependency1(IDependency1 dependency1)
{
_dependency1 = dependency1;
}
//...
}
Or property injection?
public class SomeClass
{
[Inject]
public IDependency1 Dependency1 { private get; set; }
[Inject]
public IDependency2 Dependency2 { private get; set; }
[Inject]
public IDependency3 Dependency3 { private get; set; }
//...
}
According to the Ninject wiki, write only properties like the above are considered bad practice, but isn't it the same as the setter method injection above, just less codes?
Which pattern would make the most sense for this scenario?