Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Our way
- abstract public class AbstractTask {
- void runMe(){
- try {
- run();
- onSuccess();
- } catch(Exception e){
- //log exception
- }
- }
- abstract public void run();
- abstract public void onSuccess();
- }
- // I prefer this one
- public interface ITask {
- void run();
- void onSuccess();
- void onError();
- }
- public class TaskRunner{
- void runTask(ITask task){
- try {
- task.run();
- task.onSuccess();
- } catch(Exception e){
- task.onError();
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment