From aaebe65095c2f17726dc086e8d108642eac5aefd Mon Sep 17 00:00:00 2001 From: happyaccidents Date: Thu, 28 Nov 2013 14:00:56 +0000 Subject: [PATCH] Revisions --- _posts/06-01-01-Dependency-Injection.md | 9 +++++++-- _posts/06-02-01-Basic-Concept.md | 16 +++++----------- _posts/06-03-01-Complex-Problem.md | 9 ++++++++- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/_posts/06-01-01-Dependency-Injection.md b/_posts/06-01-01-Dependency-Injection.md index 3bac06e..e69c4a2 100644 --- a/_posts/06-01-01-Dependency-Injection.md +++ b/_posts/06-01-01-Dependency-Injection.md @@ -4,5 +4,10 @@ title: Dependency Injection # Dependency Injection {#dependency_injection_title} -Dependency Injection is a basic concept that solves a complex problem. As a software design pattern it is being adopted in -some way or another by all major PHP projects. +From [Wikipedia](http://en.wikipedia.org/wiki/Dependency_injection): + +> Dependency injection is a software design pattern that allows the removal of hard-coded dependencies and makes it +> possible to change them, whether at run-time or compile-time. + +This quote makes the concept sound much more complicated than it actually is. Dependency Injection is providing a component +with it's dependencies either through constructor injection, method calls or the setting of properties. It is that simple. diff --git a/_posts/06-02-01-Basic-Concept.md b/_posts/06-02-01-Basic-Concept.md index 1748afe..520415b 100644 --- a/_posts/06-02-01-Basic-Concept.md +++ b/_posts/06-02-01-Basic-Concept.md @@ -4,15 +4,11 @@ isChild: true ## Basic Concept {#basic_concept_title} -From [Wikipedia](http://en.wikipedia.org/wiki/Dependency_injection): +We can demonstrate the concept with a simple, yet naive. -> Dependency injection is a software design pattern that allows the removal of hard-coded dependencies and makes it -> possible to change them, whether at run-time or compile-time. - -This quote makes the concept sound much more complicated than it actually is. Dependency Injection is providing a component -with it's dependencies either through constructor injection, method calls or the setting of properties. It is that simple. - -We can demonstrate the concept with a simple, yet naive, example. +Here we have a `Database` class that requires an adapter to speak to the database. We instantiate the +adapter in the constructor and create a hard dependency. This makes testing difficult and means the `Database` class is +very tightly coupled to the adapter. {% highlight php %}