Interface Arguments in ASP.NET MVC

I am developing an ASP.NET MVC project, and after several weeks of research, I have a pretty good structure using StructureMap to register dependencies at boot time, create my controllers with the correct implementations, a custom communication device to transfer data to my controller, etc. .

After thinking about the data objects transferred to my controller actions, I began to wonder ... should the controller actions take interfaces or specific types?

It makes sense that when my controller is created by the factory controller, the dependencies should be passed to my constructor as interfaces, but what about the data objects created by the connecting device? Should they be registered in my IoC container?

In the code, these are just a few extra lines to intercept all of this, so the technical overhead is pretty low. On the other hand, based on the nature of the structure, I do not need to process various implementations in the final product. But with all that I learned about the โ€œfuture validationโ€ of my code, the interface-oriented design, the development for validation, free communication and any other words you can come up with on this topic, my gut still tells me that interfaces should to be the way.

I hope I have a point in my dilemma. Does anyone have any strong opinions anyway on this topic?

TIA, -J

+3
source share
1 answer

. , IoC.

, . IoC . , ? , , ILogger IRepository.

IMHO , ( ) .

+2

Source: https://habr.com/ru/post/1753404/