I have many dataservices/classes injected into a constructor.
public MyClassConstructor (IAclass A, IBclass B, .... , IZclass Z){ ... }
The number I have to pass down goes well beyond 100. To solve this I created a Injected class that contains all the DataServices. Making it more streamline:
public MyClassConstructor (IDataServices dataServices){...}
This works well, but is unfortunately an anti-pattern. When testing I need to manually instantiate all the classes even if just a single one is needed (for all functions). As an alternative I created Interfaces to be passed down for only classes that are needed.
public MyClassConstructor (IMainInterface mainInterface) { A = new A(mainInterface); B = new B(mainInterface); } public AClassContructor (IAInterface) {...} public BClassContructor (IBInterface) {...}
This Resolves the previous two issues, but creates a new one where I am sitting with 100s of different Interface Classes.
Which one of these are is the best approach, and are there any more efficient/better ways to handle this problem?