Link Search Menu Expand Document

RG-ANA-001 Workflow Cognitive Compexity

Description

RG-ANA-001 calculates the Cognitive Complexity score of a workflow.

Cognitive Complexity is a measurement that reflects the relative difficulty of understanding, and therefore of maintaining the workflow’s logic.

It increments its score for every instance of:

  • Looping or decision branching.
  • the depth of nesting where looping or decision branching logic occurs.
  • the complexity of Boolean expressions used by looping or decision branching.
  • breaks in linear logic flow such as exception handling.

Comparing the relative score of workflows in a project identifies workflows that should be reviewed and simplified. The aim is to create a project containing workflows that all have low Cognitive Complexity Scores.

Impact

Accrual of Technical Debt.

Workflows with high Cognitive Complexity

  • are harder to understand.
  • are harder to maintain.
  • are less flexible to reuse.
  • require greater testing effort.

Mitigation

To mitigate high Cognitive Complexity scores:

  • Break complex workflows down into multiple granular workflows.
  • Have granular workflows perform one purpose and define a set of simple input and output arguments to utilize them.
  • Invoke granular workflows rather than nesting activities in the current workflow.
  • Use workflow templates best suited to the level of decision or looping logic.
    • Sequence: for small linear processes with only a single level of decision branching.
    • Flowchart: for processes having two to three nested decision points.
    • State Machine: for processes with complex multi-layered decision branching.
  • As a “Rule of Thumb”, a workflow displayed in UiPath Studio should fit within a single screen or require minimal vertical scrolling to be read end to end. Any horizontal scrolling is an early indication of activity nesting that is too deep which results in a high Cognitive Complexity score.

Further Reading