Dependency injection
Dependency injection is a software design technique in which a component receives its dependencies from outside rather than creating or locating them internally.
ASP.NET Core in Action, 3e
Dependency injection is a design pattern in which an object receives its dependencies from an external provider rather than creating them itself.
- How it is used
- Supplies framework and application services to ASP.NET Core handlers and classes without making consumers construct their dependencies.
- How deep it goes
- Works through service registration, dependency graphs, retrieval, lifetimes, and a filter-attribute limitation.
- Examples
- Contrasts manual and injected email-sender construction, registers Razor Pages services, and compares lifetime behavior using a data context.
- What you can do after
- Apply it via ASP.NET Core’s built-in container to register services, inject them into handlers, and select lifetimes.
Read how ASP.NET Core in Action, 3e explains dependency injection →
Infrastructure as Code, Patterns and Practices: With examples in Python and Terraform
Dependency injection is a design pattern in which high-level modules obtain low-level dependencies through an abstraction rather than constructing or directly binding to them.
- How it is used
- Deploys infrastructure dependencies and refactors IaC so high-level resources can evolve independently of low-level resources.
- How deep it goes
- Explains principles, provider APIs, Python implementations, pattern selection, and refactoring steps through infrastructure examples.
- Examples
- Uses GCP servers, networks, subnets, storage buckets, access controls, firewalls, and monolithic IaC refactoring.
- What you can do after
- Apply it via Apache Libcloud or provider APIs to isolate infrastructure changes and organize dependent resource creation.
.NET MAUI in Action
Dependency injection is a technique in which an object receives its required dependencies from an external provider rather than constructing them itself.
- How it is used
- Organizes pages, ViewModels, services, authentication, and HTTP clients through the .NET MAUI host container.
- How deep it goes
- Explains registration scopes and constructor injection through pages, services, ViewModels, and named HTTP clients.
- Examples
- Uses AuthService and LoginPage constructors, injected page ViewModels, and a named authenticated HttpClient.
- What you can do after
- Apply it via the .NET MAUI ServiceCollection to register and constructor-inject app dependencies.
Read how .NET MAUI in Action explains dependency injection →
Modern Angular
Dependency injection is a software design technique in which a framework supplies an object's required dependencies rather than the object constructing them itself.
- How it is used
- Supplies services and configuration to Angular building blocks without manual construction.
- How deep it goes
- Explains provider registration, token lookup, hierarchy modifiers, and a primitive injector implementation.
- Examples
- Demonstrates a minimal Injector and a configurable TruncateDirective for employee-table text.
- What you can do after
- Apply it via Angular providers, InjectionToken, and inject() to share services and configure reusable features.
Shipping Go: Develop, deliver, discuss, design, and go again
Dependency injection is a software design technique in which a component receives the services or objects it depends on from outside rather than constructing them itself.
- How it is used
- Decouples a Go HTTP handler from its translation service so implementations can change and handler tests can control service results.
- How deep it goes
- Works through interface definition, constructor injection, manual application wiring, and test stubs; leaves automated wiring to named alternatives.
- Examples
- Uses a translation handler, a static translation service, application route setup, and a stub returning fixed test values.
- What you can do after
- Build it from scratch by hand-wiring a Go service into a handler and injecting a stub for isolated handler tests.
Functional Design and Architecture: Examples in Haskell
Dependency injection is a technique for supplying a component's external functionality through an abstraction rather than constructing or selecting its concrete implementation internally.
- How it is used
- Separates business logic from external subsystems by passing selected implementations behind functional interfaces.
- How deep it goes
- Explains direct handle injection, compares several functional interface styles, and notes their practical trade-offs.
- Examples
- Demonstrates greeting handles, configurable meteor and asteroid reporting, and mocked database failures in tests.
- What you can do after
- Apply it via Service Handle or other functional interfaces to reduce coupling and control test environments.
Read how Functional Design and Architecture: Examples in Haskell explains dependency injection →
Kafka Streams in Action, Second Edition
Dependency injection is a design technique in which an object's required dependencies are supplied by external configuration or a framework rather than created by the object itself.
- How it is used
- Wires Spring Kafka and Kafka Streams components so processors receive infrastructure and configuration without constructing them.
- How deep it goes
- Defines IoC and injection styles, then demonstrates constructor and property wiring in Java components; detailed container internals are not developed.
- Examples
- Demonstrates a PaymentProcessor with NetworkClient and loan processors receiving KafkaTemplate, StreamsBuilder, and KafkaStreamsConfiguration.
- What you can do after
- Apply it via Spring annotations to wire collaborators, configuration properties, and Kafka infrastructure into application components.
Read how Kafka Streams in Action, Second Edition explains dependency injection →
Pro Angular 16
Dependency injection is a technique in which a framework supplies an object's required dependencies rather than the object constructing them directly.
- How it is used
- Supplies shared services to components without constructing them directly or passing them through parent inputs.
- How deep it goes
- Works through decorators, providers, constructor parameters, and a service dependency chain; does not detail injector internals.
- Examples
- Uses a shared discount editor and display, a cart, and a repository that depends on a data source.
- What you can do after
- Build it from scratch: decorate and register Angular services, inject them through constructors, and replace direct construction or parent-mediated sharing.
Pro ASP.NET Core 7, Tenth Edition
Dependency injection is a software design technique in which a component receives its dependencies from external configuration or composition rather than creating them itself.
- How it is used
- Supplies registered services to ASP.NET Core request handlers and components without making consumers select implementation classes.
- How deep it goes
- Works through registration, constructor and handler injection, service-provider access, activation utilities, and lifetime choices.
- Examples
- Uses a repository-backed product controller, a mock repository test, and response formatting in middleware and endpoints.
- What you can do after
- Apply it via ASP.NET Core service registration and injection to replace implementations and isolate consumers for unit tests.
Read how Pro ASP.NET Core 7, Tenth Edition explains dependency injection →
The Art of Unit Testing 3e
A technique in which a component receives a value or behavior from outside rather than creating it internally.
- How it is used
- Creates seams that let tests replace time, modules, and collaborators with controlled fakes.
- How deep it goes
- Works through value, function, factory, module, constructor, and interface-based injection, while deferring broader design choices.
- Examples
- Uses a password verifier with weekend dates, fake time providers, a fake moment.js API, and an injected logger.
- What you can do after
- Apply it via parameters, factories, constructors, or module wrappers to make tests repeatable and controlled.
Read how The Art of Unit Testing 3e explains dependency injection →
Learn Go with Pocket-Sized Projects
Dependency injection is a technique in which an object or component receives its required dependencies from outside rather than constructing them internally.
- How it is used
- Decouples application logic from external services and supplies replaceable implementations for production, development, and tests.
- How deep it goes
- Defines the pattern and demonstrates interface, function, local-function, and repository forms, stopping short of broader framework machinery.
- Examples
- Uses exchange-rate providers, configurable fetcher functions, and a habits repository injected into a gRPC server and domain function.
- What you can do after
- Apply it via Go interfaces or function parameters to replace external services, constrain dependencies, and mock behavior during tests.
Read how Learn Go with Pocket-Sized Projects explains dependency injection →
Build Python Web Apps with Streamlit
Dependency injection is a software design pattern in which an object receives the components it depends on from outside rather than constructing them internally.
- How it is used
- Separates application setup from graph logic while supporting automated testing.
- How deep it goes
- Defines the pattern and demonstrates constructor injection, but does not develop testing techniques beyond stating the benefit.
- Examples
- Uses Bot, SupportAgentGraph, an LLM, and a VectorStore as the construction-and-injection example.
- What you can do after
- Build applications that pass configured services into focused components instead of constructing dependencies inside them.
Read how Build Python Web Apps with Streamlit explains dependency injection →
gRPC Microservices in Go
Dependency injection is a design technique in which a component receives its required collaborators from outside rather than constructing them internally.
- How it is used
- Wires database, payment, and gRPC adapters into an Order service without making its application core construct those adapters.
- How deep it goes
- Shows constructor-level injection and startup wiring in Go, including an expanded payment dependency.
- Examples
- Uses an Order service whose startup injects database and payment adapters into its application and that application into a gRPC adapter.
- What you can do after
- Build it from scratch by defining port-based dependencies and constructing their adapters at service startup.
Read how gRPC Microservices in Go explains dependency injection →
Building Web APIs with ASP.NET Core
Dependency injection is a software design pattern in which a component receives its required dependencies from an external provider rather than constructing them itself.
- How it is used
- Deploys dependency injection to provide ASP.NET Core services and database contexts to controllers without manual construction.
- How deep it goes
- Explains implementation, registration, and constructor injection, then demonstrates database querying without descending into container internals.
- Examples
- Uses Program.cs registration and a BoardGamesController receiving ApplicationDbContext to replace dummy data with database results.
- What you can do after
- Apply it via ASP.NET Core constructor injection to access ApplicationDbContext from controller action methods.
Read how Building Web APIs with ASP.NET Core explains dependency injection →
.NET in Action, Second Edition
Dependency injection is a pattern in which an object receives its dependencies from an external composition mechanism rather than creating them itself.
- How it is used
- Deploys inversion of control in ASP.NET Core controllers so the application supplies data-access dependencies at request time.
- How deep it goes
- Explains dependencies, constructor provision, lifetime control, service registration, and test substitution.
- Examples
- Uses CatalogController receiving CatalogContext, AddDbContext registration, and fake or mock replacements during testing.
- What you can do after
- Apply it via ASP.NET Core service registration and constructor injection, then substitute fakes or mocks during testing.
Read how .NET in Action, Second Edition explains dependency injection →
Simple Object-Oriented Design: Create clean, maintainable applications
A dependency injection framework is a software framework that constructs objects and supplies their declared dependencies according to configuration or conventions.
- How it is used
- Uses constructor-supplied collaborators to make components modular, flexible, and easier to test in isolation.
- How deep it goes
- Explains constructor injection, dependency graphs, testing benefits, performance objections, and framework-versus-factory tradeoffs without detailing framework configuration.
- Examples
- Uses ImportEmployeesService, an SDKBot wrapping ChatBotV1, and the MessageSender dependency graph.
- What you can do after
- Apply it via constructors, frameworks, or factories to substitute implementations and isolate collaborators in tests.
Rust Servers, Services, and Apps
Dependency injection is a technique in which a component receives the resources or services it needs from an external provider.
- How it is used
- Coordinates shared application state and database services across Actix Web handlers.
- How deep it goes
- Builds injection incrementally through state structs, web::Data registration, handler parameters, and a compiling server; defers completed database logic.
- Examples
- Uses a visit-count health check and a tutor service that injects a PostgreSQL pool into course and registration handlers.
- What you can do after
- Build it from scratch by registering shared Actix state and retrieving it from handler parameters.
Read how Rust Servers, Services, and Apps explains dependency injection →
Go by Example
Dependency injection is a software design technique in which required dependencies are supplied to a component from outside rather than created internally.
- How it is used
- Improves CLI and middleware testability by replacing global dependencies with explicit inputs.
- How deep it goes
- Explains refactoring steps, injected structs, interfaces, fakes, and explicit logger configuration, stopping short of framework-based techniques.
- Examples
- Uses a CLI env struct with in-memory buffers and middleware configured with an explicitly injected logger.
- What you can do after
- Build testable CLI and middleware components by passing real or fake dependencies through explicit parameters.
Spring in Action, Sixth Edition
A framework that supplies an object's dependencies from outside the object rather than requiring the object to construct them.
- How it is used
- Uses a Spring application context to create, manage, and wire application components into a working application.
- How deep it goes
- Explains container-managed beans, constructor arguments, and property accessors through a simple service relationship.
- Examples
- Uses inventory and product services, XML bean definitions, Java @Configuration, and @Bean methods.
- What you can do after
- Apply it via Spring by defining service beans and wiring a product service to an inventory service.
Read how Spring in Action, Sixth Edition explains dependency injection →
Go in Action, Second Edition
Dependency injection is a design technique in which a component receives its required collaborators from outside rather than constructing them internally.
- How it is used
- Connects HTTP handlers to domain capabilities while keeping dependency construction at the application boundary.
- How deep it goes
- Demonstrates constructor injection with a narrowed interface and concrete storage implementation.
- Examples
- Uses Go handlers, ArticleReader, BoltStore, route registration, and an API module structure.
- What you can do after
- Build it from scratch by injecting a concrete storage implementation into a handler that requires only a read interface.
Read how Go in Action, Second Edition explains dependency injection →
100 Go Mistakes and How to Avoid Them
Dependency injection is a technique in which a component receives required dependencies from its caller rather than constructing or retrieving them internally.
- How it is used
- Uses injected dependencies to make time-dependent tests deterministic and isolated.
- How deep it goes
- Explains struct fields, constructors, fake functions, interfaces, globals, and caller-provided values, but stops short of broader dependency graphs.
- Examples
- Uses a Cache, event timestamps, time.Now, fixed timestamps, fake clock functions, and cutoff-time arguments.
- What you can do after
- Diagnose flaky time-dependent tests and choose struct injection or caller-provided time to make outcomes reproducible.
Read how 100 Go Mistakes and How to Avoid Them explains dependency injection →
Related concepts
- ASP.NET Coreused by · ASP.NET Core is Microsoft’s cross-platform, open-source framework for building web applications and services on the .NET platform.
- inversion of controlequivalent to · Inversion of control is a design principle that delegates application flow, object creation, or dependency selection from application components to an external mechanism or caller.
- view componentused by · A view component is a reusable presentation component that encapsulates application logic and renders a portion of a user interface or response.
- design patternkind of · A design pattern is a reusable, general solution structure for a recurring software design problem in a particular context.
- dependency inversionuses · Dependency inversion is a design principle in which high-level policy and low-level implementation depend on abstractions rather than directly on each other.
- testabilityproduces · Testability is the degree to which a system’s behavior can be exercised and evaluated effectively, efficiently, and reliably through testing.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.




















