Presentation is loading. Please wait.

Presentation is loading. Please wait.

Week 12: Activity & Sequence Diagrams

Similar presentations


Presentation on theme: "Week 12: Activity & Sequence Diagrams"— Presentation transcript:

1 Week 12: Activity & Sequence Diagrams
MSIS 670: UML Models Week 12: Activity & Sequence Diagrams Activity Diagram Communication (Collaboration) diagram Sequence Diagram 11/29/2018

2 UML Techniques for OO Design
Activity Diagram Communication (Collaboration) Diagram Sequence Diagram Package, Component, Deployment Diagrams 11/29/2018

3 Activity Diagrams Shows the conditional logic for the sequence of system activities needed to accomplish a business process Clearly shows parallel and alternative behaviors Can be used to show the logic of a use case An Activity diagram is a UML diagram that shows all of the flows of events for a use case in one place. To accomplish this, activity diagrams show different activities that the system performs and how different results cause the system to take different paths. Also, sometimes, it depicts the activities required to be performed in different places (e.g., departments). 11/29/2018

4 Activity Diagram Focus on system behavior
Model an object’s workflow during program execution Model the actions the object will perform and in what order UML representation Action state ( rectangle with its left and right sides replaced by arcs curving outwards) Action order ( arrow with a stick arrowhead) Initial state (solid circle) Final state (solid circle enclosed in an open circle) For many people looking at the latest version of the UML, the most unfamiliar diagram is the new activity diagram. This is particularly unfamiliar since it is a diagram that was not present in works of either Booch, Jacobson, or Rumbaugh. In fact it is based upon the event diagram of Odell, although the notation is very different to that in Odell's books. The activity diagram focuses on activities, chunks of process that may or may not correspond to methods or member functions, and the sequencing of these activities. In this sense it is like a flow chart. It differs, however, from a flow chart in that it explicitly supports parallel activities and their synchronization. In the diagram above we see the find class activity triggers both the check prerequisite and the check permission activities. Indeed these checks will be done for each of the classes entered if required. Thus, if there are three classes that require prerequisite checks, there will be three threads on these activities. These threads, together with other threads without prerequisite nor permission started by the find class activity, are synchronized before the registration is dispatched. Action states: Action states represent the noninterruptible actions of objects. Action Flow: Action flow arrows illustrate the relationships among action states. 11/29/2018

5 Components of Activity Diagram
Each activity represents a particular state within the execution of the encompassing method. Activities are linked by automatic transitions, represented by arrows, in the same way as transitions within statechart diagrams. When an activity terminates, the transition is triggered and the next activity starts. UML defines an optional stereotype for displaying decisions. A decision is represented by a diamond with many transitions coming out of it. The diagram below is equivalent to the last one, except for the fact that the decision is shown explicitly. Activity diagrams show synchronizations between control flows by using synchronization bars. A synchronization bar makes it possible to open and close parallel branches within the flow of execution of a method or a use case. The transitions pertaining to the start of a synchronization bar are triggered simultaneously. 11/29/2018

6 Fig. 5.30 | Activity diagram for a BalanceInquiry object.
11/29/2018

7 Fig. 5.31 | Activity diagram for a withdrawal transaction.
How to draw Activity Diagrams 1. Identify the scope of the activity diagram Begin by identifying what it is you are modeling. Is it a single use case? A portion of a use case? A business process that includes several use cases? A single method of a class? Once you identify the scope of your diagram, you should add a label at the top, using a note, indicating an appropriate title for the diagram and a unique identifier for it. You may also want to include the date and even the names of the authors of the diagram. 2. Add start and end points Every activity diagram has a starting point and an ending point, so you might as well add them right away. 3. Add activities If you are modeling a use case, introduce an activity for each major step initiated by an actor (this activity would include the initial step, plus any steps describing the response of the system to the initial step). 4. Add decision points Sometimes the logic of what you are modeling calls for a decision to be made. Perhaps something needs to be inspected or compared to something else. Important to note is that the use of decision points is optional. 5. Identify opportunities for parallel activities Two activities can occur in parallel when no direct relationship exists between them and they must both finish before a third activity can. Fig | Activity diagram for a withdrawal transaction. 11/29/2018

8 When to Use Activity Diagrams
Activity diagrams are useful when you want to describe a behavior which is parallel, or when you want to show how behaviors in several use-cases interact. Use Communication diagrams when you want to show how objects collaborate to implement an activity diagram. Use a state (chart) diagram to show how one object (attribute) changes during its lifetime. Activity diagram is used to understand the each of the use case in more detail. From here, we start thinking about “objects” used in each of the activities described in the diagram. It continues to collaboration diagram and sequence diagram (both are called interaction diagrams). The interaction diagrams show a number of example objects and the messages that are passed between these objects within the use-case. 11/29/2018

9 Interaction Diagrams Model interactions use UML Communication diagrams
Also called collaboration diagrams Emphasize which objects participate in collaborations Sequence diagrams Emphasize when messages are sent between objects Interaction diagrams are models that describe how a group of objects collaborate in some behavior - typically a single use-case. Interaction diagrams come in two forms, both present in the UML: Sequence diagram and communication (collaboration) diagram Sequence diagram: objects are shown as vertical lines with the messages as horizontal lines between them. This form was first popularized by Jacobson. 11/29/2018

10 A communication diagram
Objects Modeled as rectangles Contain names in the form objectName : className Objects are connected with solid lines Messages are passed alone these lines in the direction shown by arrows Name of message appears next to the arrow Fig | Communication diagram of the ATM executing a balance inquiry. 11/29/2018

11 Sequence diagrams Help model the timing of collaborations Lifeline
Dotted line extending down from an object’s rectangle Represents the progression of time Activation Thin vertical rectangle Indicates that an object is executing Creating a Sequence Diagram Select a use case: A use case describes the steps in a business process. In this sense, an activity diagram may be used for the basis for this diagram. Add the actor, UI objects, and use case text: Each use case is carried out by an actor (signifying a specific type of user). This step simply involves adding the appropriate actor and a UI class to the sequence diagram, as shown in Figure 2. Select Objects/Classes to Carry out the System Response: When choosing the classes that carry out the system response, you need to examine each step of the use case and add the appropriate objects/classes to the diagram. This may take a bit of thought, because it may not be readily apparent which class you should choose to carry out each responsibility. If you have created the collaboration diagram, it is a good source of information. Add Messages between Objects: This step involves adding messages between objects to carry out each step of the use case. This includes both message calls and, optionally, return values 11/29/2018

12 Fig. 7.28 | Sequence diagram that models a Withdrawal executing.
A Sequence Diagram Fig | Sequence diagram that models a Withdrawal executing. Sequence Diagram (Visio 2002) 11/29/2018

13 Elements in Sequence Diagrams
Objects: Objects that are involved in the sequence of events you are documenting should be placed at the top of the sequence diagram across its horizontal axis. Sometimes, it's a good idea to place the actor that initiates a particular sequence at the upper left side of the diagram (not in this figure). You can also place a "UI" (user interface) placeholder class on the diagram with which the actor interacts. This is an excellent tool for providing context for a use case. Next, you can place objects on the diagram that are instantiated by the UI or by other objects. You should place the most important objects to the left and subordinate objects to the right. It's best to place objects on the diagram in a way that minimizes lines that cross. Lifelines: The lifeline is the dotted line that extends down the vertical axis from the base of each object. The lifeline indicates the life span of an object over a period of time. Messages: Messages are the most important elements of a sequence diagram. They indicate when one object calls an operation on another object (or itself). They are also used to indicate return values. Message flow begins at the top left object (which is usually an actor or UI) and flows down the vertical axis from one object to another. Messages are shown on UML diagrams as labeled arrows, with the arrowhead indicating the direction of the call. When a message is sent to an object, the text associated with the message specifies the name of the method that is being called on the receiving object. For example, in the figure above, the prepare() message is sent to the “:Order" object. This indicates that the Order object has a method named “prepare()." 11/29/2018

14 Creating a Sequence Diagram
As mentioned previously, you often create a sequence diagram to model the logic of a use case. Figure above modeling the logic of a “logging-in” use case demonstrates the basic elements of sequence diagram. 11/29/2018


Download ppt "Week 12: Activity & Sequence Diagrams"

Similar presentations


Ads by Google