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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:02:34+00:00 2026-05-20T05:02:34+00:00

Possible Duplicates: Difference between Dependency Injection (DI) & Inversion of Control (IOC) Inversion of

  • 0

Possible Duplicates:
Difference between Dependency Injection (DI) & Inversion of Control (IOC)
Inversion of Control < Dependency Injection

Hey, This is a Scott Hanselman interview question. I always find this question hard to answer.
May be parts of this question could be answered on stack but on a whole this is very important.

I would also like to know other forms of IoC apart from DI.

Can someone explain me with some real time examples.

Thanks

  • 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-20T05:02:35+00:00Added an answer on May 20, 2026 at 5:02 am

    Dependency injection is not a form of IoC. Inversion of Control is a pattern that’s not related to DI at all, except for the fact that they’re usually used together in some sort of framework, which lead people to think they’re the same thing when they’re not.

    Dependency injection just means that you inject a class’s dependencies into it, through a constructor or a series of setters, rather than instantiating them in the class. It can be done without an IoC container of any sort, completely manually.

    A really simple example of manual DI could be:

    import org.apache.http.client.HttpClient;
    
    
    public class TwitterClient {
    
        private HttpClient httpClient;
    
        public TwitterClient(HttpClient httpClient){
            this.httpClient = httpClient;
        }
    }
    

    Whenever you create a TwitterClient in your code, you would have to also create an HttpClient and pass it in. Since this would be rather tedious, there are frameworks to make it easier, but as I mentioned it’s totally possible to do it manually. This article touches on manual DI – http://googletesting.blogspot.com/2009/01/when-to-use-dependency-injection.html, and in fact early versions of some Google produces were built entirely around manual DI.

    The benefit here is that you can swap out the implementations, so if you wanted to pass in a stubbed-out client for unit testing purposes it’s easy. Otherwise, there would be no real way to unit test a class like that.

    IoC means that you’ve got some sort of framework that’s in control of the application’s lifecycle. A good example of IoC that doesn’t involve DI would be just about any of the Cocoa apple frameworks, that control the lifecycle of a Cocoa app. You implement certain methods that get called at certain points in the lifecycle of the app. That’s why it’s the “Hollywood principle”, you don’t call the framework, the framework calls you.

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

Sidebar

Related Questions

Possible Duplicates: What's the difference between | and || in Java? Difference in &
Possible Duplicates: What is the difference between $(document).ready(function() and $(function() ? What is the
Possible Duplicates: What is the difference between new/delete and malloc/free? In what cases do
Possible Duplicates: SQL Server - bulk delete (truncate vs delete) What’s the difference between
Possible Duplicates: Difference between dates How to calculate the date difference between 2 dates
Possible Duplicates: What is the difference between <% %> and <%=%>? C# MVC: What
Possible Duplicates: Why should we typedef a struct so often in C? Difference between
Possible Duplicates: What is the difference between the PHP open tags <?= and <?php/<??
Possible Duplicates: Is there a difference between !== and != in PHP? Javascript ===
Possible Duplicates: What is the difference between a function expression vs declaration in JavaScript?

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.