Last active
February 22, 2017 10:42
-
-
Save atomgomba/4db4437fdbcdbcfeda7f1ea1efd6eafe to your computer and use it in GitHub Desktop.
Two ways of Dependency Injection
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
// injection via constructor | |
Baby baby = new Baby(new MockBottle()); | |
// injection via setter | |
Baby baby = new Baby(); | |
baby.giveBottle(new MockBottle()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment