Skip to main content
13-Aquamarine
January 6, 2012
Question

Workflow Expression Best Practice

  • January 6, 2012
  • 3 replies
  • 986 views
For those nodes within a workflow that contain an expression what is the best practice for where the code exists? What I mean is this: Is it better for the majority of the expression code logic to be present within the Workflow Administrator UI for the node or is it better to create a java package that contains the classes and code logic and reference that package within the UI, effectively externalizing it?

What have you experienced and have found to work the best?

Patrick Williams | Engineering Systems | o: 616.698.3766 | c: 616.947.2110
[cid:image001.jpg@01CCCC74.D0EEDF10]

3 replies

1-Visitor
January 6, 2012

It is best to keep the code in the expression robots (or transitions) in the Workflow Administrator to a minimum. IMHO, the best approach is to have a single line of code in the expression robot that calls a method that actually "does the work".


For example, in a "validate" expression robot, we would have only one line of code to call the validation routine:


validationResponseVariable = ext.mycompany.WorflowHelper.validate(primaryBusinessObject);


Using this approach allows you more flexibility in maintaining your workflows. Each workflow controlled object gets a new instance of the workflow template (as the tempalte exists at the time of object creation,) and any code within the workflow becomes immutable (cannot change) for a given object instance.


By keeping the actual logic in an external class, you will have the flexibility of changing the implemetation details (business logic) and having those changes be applicable to any existing objects calling the external logic without assigning new workflow processes.


Our rule is generally "one line of code per robot - and that line of code should call one of our classes"


I hope this helps.


Todd

22-Sapphire I
January 6, 2012
We generally agree, but especially if a method is used multiple places - then definitely put in a helper class. If used only one place and more than one line, that may be ok.

By the way, we have a query builder report that allows outputting all Java code used in a workflow template - in Activity Transitions, Conditionals, etc. No easy way to find it all without this type of report.
1-Visitor
January 7, 2012
Hi

From my experience it has been a best practice to have the code packages
outside the workflow expression, and use only single line of code inside
the workflow expressions. Advantage is better maintainability of code.
Also, at a later stage if the business logic changes, this practice will
require only minimal or no changes in the workflow.

Praseeth M