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 6606695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:25:24+00:00 2026-05-25T19:25:24+00:00

I have some questions about DI containers (Unity in particular) and how they actually

  • 0

I have some questions about DI containers (Unity in particular) and how they actually aid in DI.

I believe I understand IoC/DI and have been using constructor based DI for some years. Usually with my use of DI it involved simply having a constructor on my class, say MyClassX that takes an interface as an argument say IDataService and then using the new operator to create an instance of an IDataService implementing class and pass it into MyClassX’s constructor. This way MyClassX doesn’t need to know the exact type of the IDataService it is using decoupling it from a specific type. Now correct me if I am wrong, but that’s what I understand DI to be…though it does not have to be constructor based.

Now I have seen a stack of examples of Unity on the net, but I am finding it difficult to not only understand everything it does (it seems like a magic object factory to me) but also how it exactly aids in DI as I understand it. To me Unity seems more like a Factory implementation (or a Mock framework?) rather than anything to do specifically with DI. I think I have really missed something though and am waiting for an “ah ha” moment. I have done alot of Googling but examples don’t help… I need an theoretical explanation.

Can someone explain to me what Unity is exactly for…the broad points of what it does and how it is related to DI as I understand it.

  • 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-25T19:25:25+00:00Added an answer on May 25, 2026 at 7:25 pm

    Your understanding of basic Dependency Injection is correct. Constructor injection is the most common pattern.

    Some other DI Unity does:

    1. Lifetime management – instance creation can be singleton, one per
      thread, and other advanced models.
    2. Handles dependency graphs – request a root object and Unity creates all its dependency’s
      dependencies.
    3. Enables method and property injection – requires a
      Unity attribute in your business code (which I prefer to avoid)
    4. Service locator pattern – generally considered an anti-pattern

    1 and 2 are nice when you need them. I think #3 and #4 are to be avoided when possible because it adds dependencies in your code to your Unity container.

    The big bang that you are missing is Aspect Oriented Programing enabled by Interception with Unity. This allows the implementation of cross cutting concerns. Logging is the classic example. If you want more, start reading all the Enterprise Library Call Handlers for exception handling, validation, etc. or just start searching the web for AOP.

    When you combine constructor injection of dependencies with external implementation of cross cutting concerns, you can get very close to business objects that only contain business logic. In a large Enterprise development team, that’s a very big bang.

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

Sidebar

Related Questions

I have some questions about using MySQLi queries, and related memory management. Suppose I
I am using Tomcat 6 and have some questions about Apache mod_jk as follows.
I have some questions about user-defined exceptions in Python and how they should be
I have some questions about importing data from Excel/CSV File into SQL Server. Let
i have some questions about constructors in ColdFusion : must i use the name
I have some questions about the default values in a function parameter list Is
I have some questions about vector in STL to clarify..... Where are the objects
I have some questions about the registry. We have Preferences p = Preferences.userRoot(); If
I have some questions about the performance of this simple python script: import sys,
I have created a wildcard App ID and have some questions about bundle ID

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.