0

My question is not in regards to the limitation of the language, but a good design practice. I am using DI extensively, primarily because it helps the TDD by opening doors to Mocking. I have reached a point where one of my business classes has a ctor with 11 parameters all of which are filled by the DI container (Ninject, Simple Injector, etc).

Is that bad? Should I use the property injection instead?

fahadash
  • 3,133
  • 1
  • 30
  • 59
  • 1
    Well... from the perspective of the `single responsibility principle` you might want to check if the receiving class isn't violating that, and, if it does, if it is an issue in you project. – Stefan Jun 06 '17 at 11:22
  • I'd say that problem is not with constructor but with the fact your class has 11 different dependencies (so property injection will not solve that). – Evk Jun 06 '17 at 11:22
  • I have separate repositories for each database area (User, Order, Employee, Product, etc); most of my dependencies used by this class in question are repositories. – fahadash Jun 06 '17 at 11:25
  • 1
    Ah, if so I wouldn't worry about the dependency count. As for the database, you might want to check this excellent post about query and command separation. Maybe not for now, but for future projects: https://cuttingedge.it/blogs/steven/pivot/entry.php?id=91 – Stefan Jun 07 '17 at 07:26

0 Answers0