Two words, unit testing.
One of the most compelling reasons for DI is to allow easier unit testing without having to hit a database and worry about setting up ‘test’ data.
More Related Contents:
- Ioc/DI – Why do I have to reference all layers/assemblies in application’s entry point?
- Is there a pattern for initializing objects created via a DI container
- Why not use an IoC container to resolve dependencies for entities/business objects?
- Why do I need an IoC container as opposed to straightforward DI code? [closed]
- What is a composition root in the context of dependency injection?
- Why does one use dependency injection?
- Dependency Injection vs Factory Pattern
- Inversion of Control vs Dependency Injection
- Inversion of Control < Dependency Injection [closed]
- Dependency injection through constructors or property setters?
- Avoiding all DI antipatterns for types requiring asynchronous initialization
- When to use PerThreadLifetimeManager?
- Comparing Castle Windsor, Unity and StructureMap
- When are .NET Core dependency injected instances disposed?
- How to extend a component with dependency injection?
- Meaning of bean discovery mode annotated in CDI 1.1
- Property Injection in ASP.NET Core
- Dagger @Reusable scope vs @Singleton
- What is the purpose of the getter methods in Components in Dagger 2?
- MEF (Managed Extensibility Framework) vs IoC/DI
- ASP.Net Core Call a controller from another controller
- Passing constructor arguments when using StructureMap
- Net Core Dependency Injection for Non-Controller
- Resolving HttpControllerContext with Castle Windsor
- How do I handle classes with static methods with Ninject?
- Windsor castle Injecting properties of constructed object
- Is IDependencyResolver an anti-pattern?
- Null User on HttpContext obtained from StructureMap
- What are the benefits of dependency injection containers?
- How to use dependency injection in WinForms