Created
April 15, 2015 08:12
-
-
Save GRAgmLauncher/32c83b0458b78eff2c5f to your computer and use it in GitHub Desktop.
Tight coupling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface FooContext { | |
public function foo(); // i.e. cache | |
public function bar(); // i.e. dbConnection | |
public function baz(); // i.e. logger | |
} | |
// If we're not doing dependency injection, then you need to handle permutations like below... | |
// It's easy to see how quickly this gets out of control |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class StandardFooContext implements FooContext | |
{ | |
public function foo() | |
{ | |
return new FileCache(...); | |
} | |
public function bar() | |
{ | |
return new PDOConnection(...); | |
} | |
public function baz() | |
{ | |
return new Monolog(...); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class StandardFooContextWithMongoDB implements FooContext | |
{ | |
public function foo() | |
{ | |
return new FileCache(...); | |
} | |
public function bar() | |
{ | |
return new MongoDB(...); | |
} | |
public function baz() | |
{ | |
return new Monolog(...); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class StandardFooContextWithMongoDBAndRedisCache implements FooContext | |
{ | |
public function foo() | |
{ | |
return new Redis(...); | |
} | |
public function bar() | |
{ | |
return new MongoDB(...); | |
} | |
public function baz() | |
{ | |
return new Monolog(...); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment