Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 961749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:23:41+00:00 2026-05-16T01:23:41+00:00

Is it best practise to resolve and inject concrete types at the edge of

  • 0

Is it best practise to resolve and inject concrete types at the edge of the domain model and then have these fall down through the domain? For example, having the container inject concrete types into MVC controller constructors in a web app, or service endpoints in a service based app?

My understanding of container object graph wire up is a little ropey.

Is it ever appropriate to do the equivalent of Container.Resolve() within the domain?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T01:23:42+00:00Added an answer on May 16, 2026 at 1:23 am

    DI is really only a means to an end: loose coupling. It is a way to enable loose coupling by injecting interfaces (or base classes) into consumers so that you can vary both independently of each other.

    As a general rule, nothing much is gained by injecting a concrete type. You can’t swap the type with another type, so the main advantage of DI is lost.

    You could argue that this means that you’d just as well just create the concrete instances from within the consumers, but a better alternative is to extract interfaces from those types (and then inject them).

    And no: it’s never appropriate to pull from the container from within the Domain Model. That is the Service Locator anti-pattern. The Hollywood Principle applies here as well:

    Don’t call the container; it’ll call you

    (That said, even with a concrete type there are some secondary benefits from injecting it. If it’s non-sealed and has one or more virtual members, you can still override a bit of its behavior, and even if it’s sealed, you still get to control its lifetime if you inject it – e.g. you can share the same instance between multiple consumers. However, these benefits are purely secondary and usually not the main reason we decide to inject anything.)


    Another question (and the one you seem to be actually asking) is whether it’s appropriate to inject services just to be passing them on to other services. No, it’s not, since it would violate the Single Responsibility Principle and lead to Constructor Over-Injection.

    It’s better to wrap fine-grained service in more coarse-grained services. I call these Aggregate Services or Abstract Facades. While these in themselves will have dependencies (like the service endpoints you mention), these will be implementation details. From the point of view of the top-level consumer, they don’t exist.

    Not only does this nicely solve the issue around too many dependencies in the constructor, it also helps you have better isolation between application layers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question regarding the best practise of handling formated text when using
I read that it is best practise to have table names in Pascal Case
Just looking for the best practise way of doing this. I have a table
Just wondering what the best practise advice would be on the architecture for a
What is the best-practise way of Identifying dynamically generated element on page? Let me
It is a best practise to initialise a variable at the time of declaration.
What is the best practise for using the this keyword in Java? For example,
What's the best practise when adapting C-style functions which return a true/false to Java?
I want to best practise for this job.What is the best solution for run
What is the best practise solution for programmaticaly changing the XML file where the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.