Skip to content

Instantly share code, notes, and snippets.

@sudarshan89
Last active March 28, 2016 03:14
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 sudarshan89/6754712 to your computer and use it in GitHub Desktop.
Save sudarshan89/6754712 to your computer and use it in GitHub Desktop.
Split code in to 2 roles
/**
* 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