vendredi 9 octobre 2015

Task and Command pattern

I'm trying to implement (in python) the design pattern described at this page.

I'm having trouble to understand the point 3 of the explanation of how the pattern works and how to implement it.

Here is the part I do not understand in section 3 of the page :

Idea: Create an abstract class (AbstractTask) that all tasks will extend. AbstractTask registers listeners that want to monitor the task. Every time a new event is fired in AbstractTask, AbstractTask passes the right command to all its listeners. Create a Mediator class to be the main listener for the events of the abstract task. The Mediator will then do what the Command object passed by AbstractTask tells it to do.

What kind of event is it talking about ?

Is this event related to the command in the setCommand method ?

How is the event fired in the example of LongTask ?

What is the setCommand method used for ?

Does the run() method inside LongTask have to call getCommand().execute() ?

How exactly the client gets notified of the progress ?

Thanks you for any examples or clearer explanation.

Aucun commentaire:

Enregistrer un commentaire