Note that there are some explanatory texts on larger screens.

plurals
  1. POStructureMap Constructor Injection without Interface?
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COUpon further testing, it seems StructureMap.MVC has no problem injecting anything. The concrete class in constructor parameters are injected without even manually config. But mocking during test seems to be the problem. Without interface, I have to mark all method virtual, and also specify constructor parameters in test. There are some arguments about this making test more vulnerable. Any suggestions? Thanks
      singulars
    2. COAs I understand it, you shouldn't just replace interfaces with concrete classes because having a 1:1 ratio of interfaces and classes is bad. What I hear Mark saying is that having a 1:1 ratio means that you have an architectural problem in your application, using poor abstractions. Read his [follow up post](http://blog.ploeh.dk/2010/12/03/Towardsbetterabstractions/) for some examples on how to improve the design.
      singulars
    3. COThanks for the follow up. That's the exact article that bring me to the question. My applications are usually simple, there will never be a different implementation of the same service. Even the IDbContext, I have no intention of having anything other than EfDbcontext. So the interfaces are there just for IoC and Unit test mocking, rather than abstraction. I read about you can mark everything virtual and mock the class, but there are disagreement there too. So I'm not really sure what I can do differently.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload