Skip to content

Commit

Permalink
Merge pull request #4156 from shaedrich/dependency-injection
Browse files Browse the repository at this point in the history
Create topic "Dependency injection"
  • Loading branch information
ahpook authored Jan 4, 2024
2 parents de57b0a + 6511aa9 commit d7e08c0
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions topics/dependency-injection/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
aliases: dependency-injection-pattern
topic: dependency-injection
display_name: Dependency injection
short_description: Dependency injection separates the depndency's implementation from the class that's using it by passing it in from outside.
related: separation-of-concerns, loose-coupling, dependency-inversion-principle, inversion-of-control, constructor-injection, service-locator-pattern, dependency-injection-container
wikipedia_url: https://en.wikipedia.org/wiki/Dependency_injection
url: https://martinfowler.com/articles/injection.html
created_by: Martin Fowler
released: January 23, 2004
---
**Dependency injection** (**DI**) is an implementation of the [dependency inversion principle](/topics/dependency-inversion-principle) with the aim of [separation of concerns](/topics/separation-of-concerns) by separating the depndency's implementation from the class that's using it. That kind of abstraction makes it possible to have different implementations with the same public methods so the class using it, doesn't need to care which of the implementations is used. This is also especially useful for [unit testing](/topics/unit-testing).

There are different types of dependency injection:
* [constructor injection](/topics/constructor-injection)
* [setter injection](/topics/setter-injection)
* [interface injection](/topics/interface-injection)

0 comments on commit d7e08c0

Please sign in to comment.