Last active
March 7, 2019 14:07
-
-
Save adelatorrefoss/c04e9a78d0ea781b25ad2cfc6a79dc20 to your computer and use it in GitHub Desktop.
Try to broke dependency on Configuration class
This file contains hidden or 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 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