Jump to: navigation, search

Difference between revisions of "TaskFlow/Best practices"

(Top tips)
(Top tips)
Line 21: Line 21:
 
* '''Always''' associate a (major, minor) version with your tasks so that on software upgrades the previously (potentially partially) completed tasks can be migrated & resumed/reverted.
 
* '''Always''' associate a (major, minor) version with your tasks so that on software upgrades the previously (potentially partially) completed tasks can be migrated & resumed/reverted.
 
* Return '''serializable''' objects from tasks not '''resources''' (or other non-serializable objects); expect that all returned objects may be persisted indefinitely.
 
* Return '''serializable''' objects from tasks not '''resources''' (or other non-serializable objects); expect that all returned objects may be persisted indefinitely.
* '''Clean up''' after yourself, logbooks should be eventually expired and the underlying data deleted; do this periodically (TODO: add a feature todo this automatically).
+
* '''Clean up after yourself''', logbooks should be eventually expired and the underlying data deleted; do this periodically ('''TODO:''' add a feature to do this automatically??).
 
* Clearly name your tasks with '''relevant''' names;  names are how restarted flows are re-associated with there previously (potentially partially) completed tasks for resumption or reversion so choose carefully.
 
* Clearly name your tasks with '''relevant''' names;  names are how restarted flows are re-associated with there previously (potentially partially) completed tasks for resumption or reversion so choose carefully.
 
* Raise '''meaningful''' exceptions to trigger task and flow reversion;  the exception which triggered the flow reversion may be persistently stored (and can be referred to later), make sure it is as useful & meaningful as possible.
 
* Raise '''meaningful''' exceptions to trigger task and flow reversion;  the exception which triggered the flow reversion may be persistently stored (and can be referred to later), make sure it is as useful & meaningful as possible.

Revision as of 18:14, 13 October 2013

Summary

Best practices.png

Why

Since taskflow creates a path toward stable, resumable, and trackable workflows it is helpful to have a small set of recommended best practices to make sure you as a user of taskflow (the library) maximize the benefit you receive from using taskflow. Certain common patterns and best practices will be listed below to show the what, why and how so that you can maximize your taskflow experience and minimize the pain associated with understanding some of the taskflow key primitives.

Note: this list will likely continue growing as new usages of taskflow emerge (and new features are introduced into taskflow), please feel free to add any of your own below.

Top tips

  • Create reuseable tasks that do one thing well; if that task has side-effects undo those side-effects in the revert method.
  • Clearly define what a task provides so that future (potentially not yet created) tasks can depend on those outputs.
  • Clearly define what a task requires so that engine/s can deduce the correct order to run your tasks in.
  • Link tasks that do one thing well together with the supplied patterns to create flows that do many things well together.
  • For hierarchical workflows, prefer pattern composition (a flow with a subflow...) over excessive manual linking.
  • Prefer automatic ordering deduction over manual ordering deduction as the former is more resilient to future alternations while the latter is not.
  • Be very careful about RPC boundaries and be meticulous about how these boundaries affect your flow & tasks.
  • Always associate a (major, minor) version with your tasks so that on software upgrades the previously (potentially partially) completed tasks can be migrated & resumed/reverted.
  • Return serializable objects from tasks not resources (or other non-serializable objects); expect that all returned objects may be persisted indefinitely.
  • Clean up after yourself, logbooks should be eventually expired and the underlying data deleted; do this periodically (TODO: add a feature to do this automatically??).
  • Clearly name your tasks with relevant names; names are how restarted flows are re-associated with there previously (potentially partially) completed tasks for resumption or reversion so choose carefully.
  • Raise meaningful exceptions to trigger task and flow reversion; the exception which triggered the flow reversion may be persistently stored (and can be referred to later), make sure it is as useful & meaningful as possible.