Last active
August 29, 2015 14:00
-
-
Save minisu/11179770 to your computer and use it in GitHub Desktop.
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
/* | |
* When a Task is aborted, it should b aborted in the taskQueue and its state should be | |
* persisted to taskStorage. There is also a start method with similar requirements. | |
* | |
* Below are different implementation alternatives for a REST method. | |
*/ | |
// Alt. 1 -- Task knows about taskStorage and taskQueue: | |
taskStorage.getTask( id ).abort().save(); | |
// ------------------------ | |
// Alt. 2: | |
taskStorage.getTask( id ).abort(); | |
taskStorage.save( t ); | |
taskQueue.abort( e ); | |
// ------------------------ | |
// Alt. 3 | |
taskStorage.abort( id ); | |
taskQueue.abort( id ); | |
// ------------------------ | |
// Alt. 4 -- Task knows about taskQueue. A callback that updates taskStorage | |
// has been registered using Task.setOnAborted: | |
taskStorage.getTask( id ).abort(); | |
// ------------------------ | |
// Alt. 5 -- Similar to alt. 4, but Task doesn't know about taskQueue. | |
taskQueue.abort( id ); | |
// ------------------------ | |
// Alt. 6 -- Aspect Oriented Programming | |
// This annotation would only be used once in the codebase. | |
class TaskQueue { | |
@PersistState | |
void abort( Task t ) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment