Skip to content

Instantly share code, notes, and snippets.

@adelatorrefoss
Last active March 7, 2019 14:07
Show Gist options
  • Select an option

  • Save adelatorrefoss/c04e9a78d0ea781b25ad2cfc6a79dc20 to your computer and use it in GitHub Desktop.

Select an option

Save adelatorrefoss/c04e9a78d0ea781b25ad2cfc6a79dc20 to your computer and use it in GitHub Desktop.
Try to broke dependency on Configuration class
class SomeService {
private static String SOME_IMPORTANT_PARAMETER = Configuration.getPropertyFromDatabase("SOME_IMPORTANT_PARAMETER");
public void run() {
System.out.print(SOME_IMPORTANT_PARAMETER);
}
}
// This class simulates a framework deep configuration class, static and untouchable.
public class Configuration {
static String getPropertyFromDatabase(String parameter) {
// connect to database
return "some_value for " + parameter;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment