Jump to: navigation, search

Difference between revisions of "TaskFlow/Best practices"

(Top 10)
(Top 10)
Line 17: Line 17:
 
* '''Always''' associate a version with your tasks so that on software upgrades the previously partially completed tasks can be migrated & resumed.
 
* '''Always''' associate a version with your tasks so that on software upgrades the previously partially completed tasks can be migrated & resumed.
 
* Return '''serializable''' objects from tasks; acquire '''resources''' via object constructors (lazily preferred).
 
* Return '''serializable''' objects from tasks; acquire '''resources''' via object constructors (lazily preferred).
* Clearly name your tasks with '''relevant''' names; names are how restarted flows (after say a <code>service restart</code>) are re-associated with there previously (potentially partially) completed tasks for resumption so choose carefully.
+
* Clearly name your tasks with '''relevant''' names
 +
** '''Note:''' names are how restarted flows (after say a <code>service restart</code>) are re-associated with there previously (potentially partially) completed tasks for resumption so choose carefully.

Revision as of 02:55, 12 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 (with examples) 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. 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 10

  • Create 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 flow patterns to accomplish many things.
  • Be very careful about RPC boundaries (especially when the workflow spans this boundary) and choose how you deal with this in a careful manner.
  • Always associate a version with your tasks so that on software upgrades the previously partially completed tasks can be migrated & resumed.
  • Return serializable objects from tasks; acquire resources via object constructors (lazily preferred).
  • Clearly name your tasks with relevant names
    • Note: names are how restarted flows (after say a service restart) are re-associated with there previously (potentially partially) completed tasks for resumption so choose carefully.