Guest User

Untitled

a guest
Jan 18th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. // Our way
  2. abstract public class AbstractTask {
  3. void runMe(){
  4. try {
  5. run();
  6. onSuccess();
  7. } catch(Exception e){
  8. //log exception
  9. }
  10. }
  11. abstract public void run();
  12.  
  13. abstract public void onSuccess();
  14. }
  15.  
  16.  
  17. // I prefer this one
  18. public interface ITask {
  19. void run();
  20. void onSuccess();
  21. void onError();
  22. }
  23.  
  24. public class TaskRunner{
  25. void runTask(ITask task){
  26. try {
  27. task.run();
  28. task.onSuccess();
  29. } catch(Exception e){
  30. task.onError();
  31. }
  32. }
  33. }
  34. }
Add Comment
Please, Sign In to add comment