Week 8- SWE202.pdf
Document Details
Uploaded by RichTourmaline9881
Yakın Doğu Üniversitesi Dişhekimliği Fakültesi
Tags
Full Transcript
SWE202 SOFTWARE CONSTRUCTION WEEK 6 Interaction diagrams, sequence and collaboration diagrams Oluwaseun Priscilla Olawale (MSc.) Objectives Interaction diagrams Sequence diagrams Collaboration diagrams Inter...
SWE202 SOFTWARE CONSTRUCTION WEEK 6 Interaction diagrams, sequence and collaboration diagrams Oluwaseun Priscilla Olawale (MSc.) Objectives Interaction diagrams Sequence diagrams Collaboration diagrams Interaction diagrams UML interaction diagrams represent interaction (communication, collaboration) between objects/classes. They used to visualize the dynamic aspect of a system. For dynamic object modelling. UML interaction diagrams consist of ○ Sequence diagrams ○ Communication diagrams Sequence Diagrams Sequence diagrams describe interactions among classes/objects in terms of an exchange of messages over time. They're also called event diagrams. A sequence diagram is a good way to visualize and validate various runtime scenarios These can help to predict how a system will behave and to discover responsibilities a class may need to have in the process of modelling a new system. Sequence Diagrams Sequence diagrams usually capture the following: ○ the interaction that takes place in a collaboration that either realizes a use case or an operation (instance diagrams or generic diagrams) ○ high-level interactions between user of the system and the system, between the system and other systems, or between subsystems (sometimes known as system sequence diagrams) Sequence Diagram Example: Below is a sequence diagram for making a hotel reservation. The object initiating the sequence of messages is a Reservation window. Sequence Diagram Notations - Actor a type of role played by an entity that interacts with the subject (e.g., by exchanging signals and data) external to the subject (i.e., in the sense that an instance of an actor is not a part of the instance of its corresponding subject). represent roles played by human users, external hardware, or other subjects. Sequence Diagram Notations - Lifeline A lifeline represents an individual participant in the Interaction. Sequence Diagram Notations - Activations A thin rectangle on a lifeline) represents the period during which an element is performing an operation. The top and the bottom of the of the rectangle are aligned with the initiation and the completion time respectively Sequence Diagram Notations - Call Message Call message is a kind of message that represents an invocation of operation of target lifeline. Sequence Diagram Notations - Return Message Return message is a kind of message that represents the pass of information back to the caller of a corresponded former message. Sequence Diagram Notations - Self Message Self message is a kind of message that represents the invocation of message of the same lifeline. Sequence Diagram Notations - Recursive Message Recursive message is a kind of message that represents the invocation of message of the same lifeline. It's target points to an activation on top of the activation where the message was invoked from. Sequence Diagram Notations - Create Message Create message is a kind of message that represents the instantiation of (target) lifeline. Sequence Diagram Notations - Destroy Message Destroy message is a kind of message that represents the request of destroying the lifecycle of target lifeline. Sequence Diagram Notations - Duration Message Duration message shows the distance between two time instants for a message invocation. Sequence Diagram Notations - Note A note (comment) gives the ability to attach various remarks to elements. A comment carries no semantic force, but may contain information that is useful to a modeler. Collaboration Diagrams Collaboration diagrams my also be referred to as communication diagrams. It is an illustration of the relationships and interactions among software objects. A collaboration diagram resembles a flowchart that portrays the roles, functionality and behavior of individual objects as well as the overall operation of the system in real time. What is a Collaboration? A Collaboration is a collection of named objects and actors with links connecting them. They collaborate in performing some task. A Collaboration defines a set of participants and relationships that are meaningful for a given set of purposes A Collaboration between objects working together provides emergent desirable functionalities in Object- Oriented systems Each object (responsibility) partially supports emergent functionalities Objects are able to produce (usable) high-level functionalities by working together Objects collaborate by communicating (passing messages) with one another in order to work together Steps for Creating Collaboration Diagrams Identify behavior whose realization and implementation is specified Identify the structural elements (class roles, objects, subsystems) necessary to carry out the functionality of the collaboration ○ Decide on the context of interaction: system, subsystem, use case and operation Steps for Creating Collaboration Diagrams Model structural relationships between those elements to produce a diagram showing the context of the interaction. Consider the alternative scenarios that may be required ○ Draw instance level collaboration diagrams, if required. ○ Optionally draw a specification level collaboration diagram to summarize the alternative scenarios in the instance level sequence diagrams Collaboration Diagrams Example Collaboration Diagram Notations The four major components of a collaboration diagram include the following: Objects ○ These are shown as rectangles with naming labels inside. The naming label follows the convention of object name: class name. If an object has a property or state that specifically influences the collaboration, this should also be noted. Actors ○ These are instances that invoke the interaction in the diagram. Each actor has a name and a role, with one actor initiating the entire use case. Collaboration Diagram Notations Links ○ These connect objects with actors and are depicted using a solid line between two elements. Each link is an instance where messages can be sent. Messages between objects ○ These are shown as a labeled arrow placed near a link. These messages are communications between objects that convey information about the activity and can include the sequence number. Sequence vs. Collaboration Diagrams Collaboration diagrams visualize the structural organization of objects and their interactions. On the other hand, sequence diagrams focus on the order of messages that flow between objects. In most scenarios, a single figure is not sufficient in describing the behavior of a system and both figures are required.