Information Analysis:Interaction diagrams
8.6 Interaction diagrams
There are two types of interaction diagram in UML: the sequence diagram and the collaboration diagram.
8.6.1 Sequence diagram
The sequence diagram models the collaboration between objects and actors, showing the exchange of messages needed to accomplish a specific purpose. Typically, a sequence diagram is prepared to represent a single use case. As with class diagrams, sequence diagrams are elaborated throughout the development process with design detail. At the conceptual level the sequence diagram should be consistent with the use case and the conceptual class model.
Figure 8.16 is a sequence diagram for the use case 'Internet ticket sale'. The dashed vertical line represents an object's lifeline, with time moving from the top of the diagram to the bottom. Objects are spread out across the page. Note that the class name is shown after a colon – this indicates that we are referring to an instance of the class, a particular production or performance rather than the class itself. Arrows represent the passing of messages from object to object. When a message is sent to an object it invokes an operation supported by that object's interface. The period of time that the operation is active is shown by a rectangle on the object's lifeline.
In figure 8.16 the collaboration begins with the Internet user finding a production. The production responds to the user by returning the details of the selected production (the return message is not shown, although it can be where it aids understanding). The user then requests a list of performances for the production by invoking the listPerformances() operation of the production object. The production object satisfies the request by sending the message [for all of the production's performances] getPerformanceDetails(). The iteration is shown by an asterisk. The Internet user then finds the prices for the different parts of the theatre by sending a message to the theatre. The next stage of the process is to find available seats.
In the second part of the Internet ticket sale use case (figure 8.17) the sequence is to check for an existing customer (and add a new one if needed), to check if the customer is due a discount on the price as a member, take payment and write the transaction, and finally to change the seat at performance status to booked. Note that instances are created for new customers and for the transaction class. The creation is shown at the point in the timeline they are created.Separating the use case into two parts is rather useful since the find seats and book seats parts of the use case could be reused. As well as creating new objects, a message might invoke the destruction of an object. In the use case 'cancel performance' the performance object then sends messages to invoke the object destruction operation for the seats at performance associated with that performance object (figure 8.18). The performance then sends a message to itself (reflexive) to destroy the performance instance.
8.6.2 Collaboration diagramCollaboration diagrams are the second interaction modeling technique in the UML. They are strongly linked to sequence diagrams. Again, arrows show messages, but in the collaboration diagram numbers are used to show the sequence of messaging.
Both forms of interaction diagram show collaboration between objects. From an analysis and conceptual modeling perspective it is probably sufficient to prepare a sequence diagram. As the diagrams are refined for design purposes then the collaboration diagram becomes more useful, allowing packages of processing to be identified from clusters of interactions. We have introduced some conditional behaviour into the second part of the sequence diagram (figure 8.17) to branch for customers who are members. As more conditional processing is added the interaction diagrams get more and more convoluted and it is wise to consider developing different diagrams for different scenarios, e.g., 'Internet ticket purchase by member' and 'Internet ticket purchase by nonmember'.
Comments
Post a Comment