Friday, May 17, 2013

Advanced UML Sequence Diagrams


A Sequence Diagram is a type of UML Interaction Diagram that is used to model objects that need to pass messages to accomplish a task.

The messages are usually defined in the order of the execution.

Objects interactions can include:
  • creation and termination
  • requests
  • invoke object operations
  • notifications
In the very simple sequence diagram below, a user sends a query to a health IT application that retrieve a clinical document to an XDS Repository. The clinical data is returned back to the user (an actor in this type of diagram).

Object colors can indicates a different scope between objects (e.g gray here indicate a component that is part of a different sub-system, or out-of-scope for the current document or release etc).
























Lifelines are vertical dashed lines with the object positioned at the top.  

Messages are horizontal lines with arrows pointing in the direction in which the message is sent with annotation (method, parameters, arguments, return value, type of control flow etc ...)










































UML 2.0 has two forms of messages:
  • operation call : the invocation of an operation of a receiving object (either synchronous or asynchronous)
  • signal : a message object sen out by one object and handle by another one (always asynchronous)




Synchronous messages usually have solid arrows (by the way, in the tool I use, return synchronous messages for not have a solid arrow). Asynchronous message use dashed arrows.


















An interaction operand is a container that groups the interaction fragments and uses an optional guard expression or interaction constraint. When the guard condition is not present, the interaction is always executed.

Interaction operators include:
  • Alternative (alt) 
  • Option (opt) : 
  • Break (break) :
  • Parallel (par)
  • Loop (loop)  
  • Critical (critical) or (region)
  • Negative (neg)
  • Assertion (assert)
  • Strict Sequence (strict)
  • Weak Sequence (seq)
  • Ignore (ignore)
  • Consider (consider)
Lets consider a simple alternative (alt) operand.

Imagine that in the initial sequence diagram, that we want to request a document, we request a clinical document from an external source (CCD producer system).

In this case, the first thing is to add a combined fragment on top of the existing diagram, and choose the alt type:
































Then conditions are added (if and else equivalent):






























Then you can add the new alternative message (to the external CCD producer system) and re-organize the layout of the diagram : placing the combined fragment below the incoming message and moving the else clause separation (dotted line) below the first alternative (accessing the XDS repository). In my tool, you can use ALT-Left-Mouse click for this:









There are numerous UML modeling tools available (commercial or free). For his post, I used Enterprise Architect.