c# - Best Practice: How to get several dependency repositories into a ActionController? -


I have an inventory controller that becomes uncontrolled in an INNTIO repository, although my needs have changed, One of the methods is also required to use the other 2 repositories, to get information about the ILONS repository (items of borrowing items) and second, where some data and additional information is available.

The way this works is that a View Modellbluilder class, which is an action-line in the inventory controller, it really needs those people. Currently I was passing the controller from IInventoryRepository to the builder But how should I do this now? Should I get injections in 3 repository controllers, and then send them to the builder, just like I am doing now? Or should I just do an IOC. GetInstance ()? (Although I think this is not an anti-pattern?)

Thanks!

In these circumstances, the following guidelines come into play:

    < Li> A lot of dependency is a smell that you violate.
  • There should not be more than four dependencies. This is a relative guideline I personally try to reduce; As soon as I add a third dependency (see the first item above) I get sickness, but can stay up to four I

As far as I can tell with three dependencies Whenever it comes to the number of dependencies, even then there is more or less within the security zone, however, you should start looking at that special design aspect more carefully.

However, as I understand your current implementation, you just have to depend on a ViewModelBuilder (thus violating the third bullet) is a better option for an intangible (like, Ivmodelbuilder) Define and inject all the three repositories instead of the controller.

In any situation, you should not resort to service locator anti-pattern (IoC.GetInstance ()).


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -