From 955c88e3361d024da551aeed3036f34f6e5c82bb Mon Sep 17 00:00:00 2001 From: Ilkka Seppala Date: Mon, 25 May 2015 19:29:24 +0300 Subject: [PATCH] Added description of Dependency Injection pattern in README.md. --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 51ff51c0d..99bf1ac26 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,7 @@ Behavioral patterns are concerned with algorithms and the assignment of responsi * [Null Object](#null-object) * [Intercepting Filter](#intercepting-filter) * [Specification](#specification) +* [Dependency Injection](#dependency-injection) ### Concurrency Patterns @@ -629,6 +630,15 @@ validation and for building to order * The objects are expensive to create (allocation cost) * You need a large number of short-lived objects (memory fragmentation) +## Dependency Injection [↑](#list-of-design-patterns) +**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. + +![alt text](https://github.com/iluwatar/java-design-patterns/blob/master/dependency-injection/etc/dependency-injection.png "Dependency Injection") + +**Applicability:** Use the Dependency Injection pattern when +* When you need to remove knowledge of concrete implementation from object +* To enable unit testing of classes in isolation using mock objects or stubs + # Frequently asked questions