Last active
March 28, 2016 03:14
-
-
Save sudarshan89/6754712 to your computer and use it in GitHub Desktop.
Split code in to 2 roles
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
/** | |
* A typical method which handles both co-ordination and logic | |
* / | |
public void AServicMethodWithBothRolesMixedUp(){ | |
List<String> pullDataFromWS = wsCall(); | |
// Pulling more data from various sources | |
//Performing logic on pullDataFromWS | |
// transforming the above data | |
dbSave(pullDataFromWS) | |
} | |
/** | |
* If we just split the above code into 2 explicit roles, one which does co-ordination and the other which does logic, ,maybe like the below | |
* | |
* / | |
public void IAmTheCoordinator(){ | |
List<String> pullDataFromWS = wsCall(); | |
// Again pull data | |
/*****************************************/ | |
IAmTheLogicExecutorPileOne (pullDataFromWS) | |
SensibleReturn = IAmTheLogicExecutorPileTwo (someOtherDate) | |
// Multiple logical executors | |
/*****************************************/ | |
// Testing the above logic executors should be a easy | |
// Put in DB | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment