Software Development
Blogs and Discussion
developer.*
Books Articles Blogs Subscribe d.* Gear About Home

Open Comments Thread for "The Task Pattern: A Design Pattern for Processing and Monitoring Long-Running Tasks" by Hugo Troche

This an open comments thread for the developer.* Magazine article "The Task Pattern: A Design Pattern for Processing and Monitoring Long-Running Tasks," by Hugo Troche. If you haven't already, you can read it here, then add your comments below.

Task Pattern Code Example

This is a little late in coming, but I'm doing housekeeping today and found the comments below (and attached code) that was sent to me some time back by "Task Pattern" author Hugo Troche. A reader sent the following question to Hugo:

I have some questions about your article in developer.*, "The Task Pattern: A Design Pattern for Procession and Monitoring Long-Running Tasks":

Question 1: Do you have a minimal working Java example of the UML classes you describe in Figure 3? I couldn't get it working.

Question 2: What is not clear to me is the following: You wrote, "Of course, this implementation is inefficient because the client of the task has to constantly monitor the task. It is much better if the task tells its clients when it has changed."

I fully agree, but how does the clients gets informed if the status of the task changed? Do you have an working example for me where it is demonstrated?

Hugo's response:

I don't have a simple example of the task pattern. On the other hand I have a few real examples I am attaching to this email (Editor's note: click here to download a zip file of Hugo's code).

I attached the source code for an application I did. Check out the method saveWorkspace in SadlMediator. In it I am using the task SaveWSTask to save the workspace of that particular application. Note how the task uses 3 commands (as in the GOF command pattern) to inform the listener (in this case the mediator) of what is going on. Also see how this example uses a worker to run the task in another thread. This will be an example of the UML diagram in figure 6 of the article. You will find that both mediators in the example use heavily the task pattern.

As you can see from the example the task is in charge of informing the mediator when changes happen, not the mediator constantly checking the task for changes.

In the zip file you will find the entire source code for this application (Sadl). This application was part of my Master's project so it is in the public domain.

I hope these examples help. Let me know if you need more info. Thank you for reading the article and your questions.

You can download a zip file of Hugo's code here.

--Dan

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

User login

About our advertising.

Atom Feed

developer.* Blogs also has an Atom feed, located at this url.

Click here for more information about Atom.

A Jolt Award Finalist
Software Creativity 2.0
Foreword by Tom DeMarco

Recent Posters

Based on most recent 60 days, sorted by # of posts and name.

Google
Web developer.*

Who's online

There are currently 0 users and 17 guests online.

Syndicate

Syndicate content
All views expressed by authors, bloggers, and commentors are their own and do not necessarily reflect the views of developer.* or its proprietors.
Click to read the Copyright Notice.

All content copyright ©2000-2005 by the individual specified authors (and where not specified, copyright by Read Media, LLC). Reprint or redistribute only with written permission from the author and/or developer.*.

www.developerdotstar.com