Skip to content

Commit 955c88e

Browse files
committed
Added description of Dependency Injection pattern in README.md.
1 parent 182a4ff commit 955c88e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ Behavioral patterns are concerned with algorithms and the assignment of responsi
6060
* [Null Object](#null-object)
6161
* [Intercepting Filter](#intercepting-filter)
6262
* [Specification](#specification)
63+
* [Dependency Injection](#dependency-injection)
6364

6465
### Concurrency Patterns
6566

@@ -629,6 +630,15 @@ validation and for building to order
629630
* The objects are expensive to create (allocation cost)
630631
* You need a large number of short-lived objects (memory fragmentation)
631632

633+
## <a name="dependency-injection">Dependency Injection</a> [&#8593;](#list-of-design-patterns)
634+
**Intent:** Dependency Injection is a software design pattern in which one or more dependencies (or services) are injected, or passed by reference, into a dependent object (or client) and are made part of the client's state. The pattern separates the creation of a client's dependencies from its own behavior, which allows program designs to be loosely coupled and to follow the inversion of control and single responsibility principles.
635+
636+
![alt text](https://github.com/iluwatar/java-design-patterns/blob/master/dependency-injection/etc/dependency-injection.png "Dependency Injection")
637+
638+
**Applicability:** Use the Dependency Injection pattern when
639+
* When you need to remove knowledge of concrete implementation from object
640+
* To enable unit testing of classes in isolation using mock objects or stubs
641+
632642

633643

634644
# Frequently asked questions

0 commit comments

Comments
 (0)