Activity diagram, Sequence iagram, Include, extend, generalization Case Study : Automatic Teller Machine ATM Chapter 4 UML, Identify Actors, Hossein Tohidi 1 Review A use case represents the specification of a sequence of actions, including variants, that a system can perform, interacting with actors of the system. For each actor identified previously, it is advisable to search for the different business goals, according to which is using the system. Contrary to what we might believe, all actors do not necessarily use the system We call the one for whom the use case produces an observable result the primary actor In contrast, secondary actors constitute the other participants of the use case. A use case diagram shows the relationships among actors and the subject (system), and use cases. We draw use cases(ellipses) inside the ATM system (box) and linked by associations (lines) to their primary actors (the “stick man” icon). As far as possible, place the primary actors to the left of the use cases and the secondary actors to the right. Shared use case is a special case that one use case is connected to more than one actor while some of these actors for this use case need different secondary actor thus it wouldn't be possible to represent this concepts. The solution would be to distinguish the shared use case to two or more use cases regarding to the actors that need different secondary actor. In order to explain the dynamics of a use case in detail, the most obvious way of going about it involves textually compiling a list of all the interactions between the actors and the system
UML, Case Study 1 (ATM), Hossein Tohidi 2
Elements involved Actor Static Context Diagram Use case Use Case Diagram Primary actor, Secondary Actor Textual Description of a Use Case Scenario, sequence System Sequence Diagram Activity Diagram Inclusion, extension and generalization Package use cases
UML, Case Study 1 (ATM), Hossein Tohidi 3
Use Case Graphical Description However, the text also has its disadvantages as it difficult to show how the sequences follow one another, or at what moment the secondary actors are requested. Besides, keeping a record of changes often turns out to be rather tiresome. It is therefore recommended to complete the textual description with one or more dynamic UML diagrams. UML, Case Study 1 (ATM), Hossein Tohidi 4 Dynamic d descriptions of a use case
UML, Case Study 1 (ATM), Hossein Tohidi 5
Dynamic d descriptions of a use case For use cases, we recommend the activity diagram, as users find it far easier to understand since it resembles a traditional diagram. ◦ However, the state diagram may be useful for use cases that are very interactive. For certain scenarios, the sequence diagram works well. We recommend that you present it by showing the primary actor on the left, then an object representing the system in a black box, and finally, any secondary actors that may be requested during the scenario on the right of the system. We will use the title system sequence diagram as proposed by Larman.
UML, Case Study 1 (ATM), Hossein Tohidi 6
Creating Sequence Diagram
? Create a system sequence diagram that
describes the main success scenario of the Withdraw money using a Visa card use case. We use sequence diagram to describe main success scenario for a use case.
UML, Case Study 1 (ATM), Hossein Tohidi 7
Creating Sequence Diagram For start to draw this diagram All you need to do is copy the interactions quoted in the textual scenario of Withdraw money using a Visa card use case into a sequence diagram by following the graphical conventions listed above: 1. According to the “Unique Actor Rule” for each use case we have just one primary actor, in result for each main success scenario we have just one main actor. We put that primary actor, Visa CardHolder (in this example), on the left. 2. An object representing the ATM system as a whole in the middle. 3. The secondary actor(s), Visa AS, to the right of the ATM.
UML, Case Study 1 (ATM), Hossein Tohidi 8
Sequence Diagram
UML, Case Study 1 (ATM), Hossein Tohidi 9
Activity Diagram As we mentioned, sequence diagram is useful to present main success scenario, so the question is that how we can present all of the main and alternative and also error scenario for while of a use case. The answer is activity diagram. Unlike the previous sequence diagram that only describes the main success scenario, the activity diagram can represent all the activities that are carried out by the system, with all the conditional branches and all the possible loops. The activity diagram is essentially a flowchart, showing flow of control from activity to activity. The transitions are triggered at the end of activities or actions; steps can be carried out in parallel or in sequence.
UML, Case Study 1 (ATM), Hossein Tohidi 10
Elements of Activity Diagram 1. Activity states explained next slide 2. Action state explained next slide 3. Transition show what activity state follows after another. 4. Decisions (branch) for which a set of guard conditions are defined. These are conditions that must be met to trigger the transition. 5. Synchronization bars, which you can use to show parallel subflows. Synchronization bars allow you to show concurrent threads - fork or join.
UML, Case Study 1 (ATM), Hossein Tohidi 11
Activity state vs. Action state An activity state models the realisation of an activity that: ◦ is complex and can be broken down into activities or actions, ◦ can be interrupted by an event. In general activity state, is a collection of some atomic action is packaged in one unit.
An action state models the realisation of an action
that: ◦ is simple and cannot be broken down, ◦ is atomic, which cannot be interrupted.
UML, Case Study 1 (ATM), Hossein Tohidi 12
Start!! For a given use case, by considering all of the main success and alternative and error scenario, we start to draw the activity diagram from initial state. For alternative sequence and also error sequences we use conditional branches and also Failed State.
UML, Case Study 1 (ATM), Hossein Tohidi 13
Activity Diagram
UML, Case Study 1 (ATM), Hossein Tohidi 14
Diagrams Activity Diagram
UML, Case Study 1 (ATM), Hossein Tohidi 16
Activity Diagram
UML, Case Study 1 (ATM), Hossein Tohidi 17
Activity Diagram
UML, Case Study 1 (ATM), Hossein Tohidi 18
Activity Diagram
UML, Case Study 1 (ATM), Hossein Tohidi 19
Activity Diagram
UML, Case Study 1 (ATM), Hossein Tohidi 20
An improvement! It is possible to show alternative and error sequence over sequence diagram. We can do this one when a diagram that is less complex to read than an activity diagram, as there are fewer symbols, but it nevertheless retains an informative content for the specialist. This possibility is useful in order to introduce the following: ◦ The main internal activities of the system by means of messages that it sends to itself. ◦ References to “alternative” and error sequences by means of notes. In the next slide you can see the updated version of the last sequence diagram.
UML, Case Study 1 (ATM), Hossein Tohidi 21
Improved Sequence Diagram
UML, Case Study 1 (ATM), Hossein Tohidi 22
Summary and Conclusion However, the text also has its disadvantages as it difficult to show how the sequences follow one another, or at what moment the secondary actors are requested. We use sequence diagram to describe main success scenario for a use case. Sequence diagram is a graphical presentation for the main success Scenario. As we mentioned, sequence diagram is useful to present main success scenario, so the question is that how we can present all of the main and alternative and also error scenario for while of a use case. The answer is activity diagram. Unlike the previous sequence diagram that only describes the main success scenario, the activity diagram can represent all the activities that are carried out by the system, with all the conditional branches and all the possible loops. It is possible to show alternative and error sequence over sequence diagram, but still activity diagram is better. Future Works We continue our discussion with the other case studies to make the previous concepts more clear. We continue the main topic by start to talk about static and dynamic parts, and also class diagram. On the basis of a new case study, we will allow us to outline the main difficulties, step by step, that the construction of UML class diagrams poses. The class diagram has always been the most important diagram in all object oriented methods. This is the diagram that automatic code generation tools use first and foremost. This is also the diagram that contains the widest range of notationsand variants; hence the difficulty in using all these concepts correctly. UML, Case Study 1 (ATM), Hossein Tohidi 24