Communication Diagram vs. Sequence Diagram vs. State Machine Diagram

A student raise a good question on what are the differences among communication diagrams, sequence diagrams, and state machine diagrams.
 
In programming, we have three basic constructs, namely iteration, sequence and decision, to write a typical program.

  • We are unable to express iterations in communication diagram precisely. For instance, how do we model a loop that executes the loop 100 times, and each time, it involves 10 objects in a communication diagram? Would it make a communication diagram very tedious? In this connection, communication diagram is unsuitable to express object interactions in details. This diagram is more suitable to express our high level design (as what you use in the OOD report template and in our design methodology).

 

  • Sequence diagram is for modeling of a more detailed design. It has all the basic programming control constructs, namely iteration (loop), sequence, and decision (condition, or "alt" combinedfragment).

 

  • A state machine diagram focuses on how an object may possibly go through its object states. Neither communication diagram nor sequence diagram provides any information about object states, and thus, we are unable to know what the responses of the object under different situations (i.e., states) when receiving a message. Moreover, if a class has been used in multiple sequence diagrams, we need to ensure the program logic of the class to support each invovled sequence diagram. In this case, we may model the object life of this class through a state machine diagram. We never use a sequence diagram for this purpose; otherwise, sooner or later, we need merge all the sequence diagrams into a huge sequence diagram (which is too complex to be used).
     

Selected Tags

Tag Groups

Links

ACM SigSoft
IEEE Software Engineering Online