About 15,300,000 results
Open links in new tab
  1. When to use Dependency Injection? When not to? - Stack Overflow

    Oct 9, 2009 · Use Dependency Injection when you want to create alternative implementations of a given service type. The canonical example of this is substituting a mock object in place of a service provider for testing purposes.

  2. When is it not appropriate to use the dependency injection

    Outside of dependency-injection frameworks, dependency injection (via constructor injection or setter injection) is very nearly a zero-sum game: you decrease the coupling between object A and it's dependency B, but now any object that needs an instance of A …

  3. When to use Dependency Injection - Stack Overflow

    Sep 6, 2016 · You can use dependancy injection if you instanciate in a static way an object. For example, if you use a class which can convert objects into XML file or JSON file and if you need only the XML file. You will have to instanciate the object and configure a lot of thing if you don't use dependancy injection. When should you not use depandancy ...

  4. Dependency Injection(DI) Design Pattern - GeeksforGeeks

    Apr 4, 2025 · Fundamentally, dependency injection is a method that addresses how components or objects are constructed and how they acquire the dependencies required for proper operation. What is the Dependency Injection Design Pattern? When to use Dependency Injection Design Pattern? When not to use Dependency Injection Design Pattern?

  5. What are the downsides to using dependency injection?

    Feb 11, 2013 · Dependency injection is a great and incredibly powerful pattern. But it definitely can be confusing and you will almost certainly spend some time cursing at whatever dependency injection framework you choose. Also, I agree with other …

  6. A quick intro to Dependency Injection: what it is, and when to use it

    Oct 18, 2018 · So, transferring the task of creating the object to someone else and directly using the dependency is called dependency injection. What if code could speak? Why should I use dependency injection?

  7. When to use Dependency Injection - Jenkov.com

    May 25, 2014 · Dependency injection is a powerful technique that can be applied in many situations across all layers of an application. But this does not mean that dependency injection should be used every time a class depends on another class.

  8. The ‘New Rule’ — When to Use Constructors vs. Dependency Injection

    Apr 12, 2025 · Use dependency injection for collaborators. This rule helps ensure clarity, modularity, and testability in your architecture. Overconstruction: Business logic directly instantiates its...

  9. Understanding Dependency Injection: Pros, Cons, and Real-Life …

    Aug 17, 2024 · Dependency Injection (DI) is a design pattern used in software development to achieve Inversion of Control (IoC) between classes and their dependencies. In simpler terms, DI is a technique where an object receives its dependencies from an external source rather than creating them within itself.

  10. object oriented design - How to know when to use dependency injection ...

    Jun 9, 2018 · Whenever you need something done but you don't want to do it here. The big thing I'd like you to understand about reference passing (or Dependency Injection if you insist on being fancy) is that using a known good default is ok. You are not forbidden from using new.

  11. Some results have been removed
Refresh