Created
October 24, 2016 15:19
-
-
Save kleinron/a4217c30e3ff5fcc925219c8d1a02df0 to your computer and use it in GitHub Desktop.
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
// given that we already have an instance of shakersProvider | |
String color = getColor(); | |
// no if-else, and no switch-case-default, the provider should do the work (aka service locator) | |
IShaker shaker = shakersProvider.getByColor(color); | |
shaker.shake(); | |
// or with reusable constants | |
IShaker shaker2 = shakersProvider.getByColor(MyConstants.Brown); | |
shaker2.shake(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment