Skip to content

Instantly share code, notes, and snippets.

@kleinron
Created October 24, 2016 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kleinron/a4217c30e3ff5fcc925219c8d1a02df0 to your computer and use it in GitHub Desktop.
Save kleinron/a4217c30e3ff5fcc925219c8d1a02df0 to your computer and use it in GitHub Desktop.
// 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