chapter 4 , use case and statechart diagrams
DESCRIPTION
Chapter 4 , Use Case and Statechart Diagrams. Outline of this Class. Use case diagrams Describe the functional behavior of the system as seen by the user Class diagrams Describe the static structure of the system: Objects, attributes, associations Sequence diagrams - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Chapter 4 , Use Case and Statechart Diagrams](https://reader033.vdocuments.site/reader033/viewer/2022061612/5681604d550346895dcf790e/html5/thumbnails/1.jpg)
Usi
ng U
ML,
Pat
tern
s, an
d Ja
vaO
bjec
t-O
rien
ted
Soft
war
e E
ngin
eeri
ngChapter 4,Use Case and
Statechart Diagrams
![Page 2: Chapter 4 , Use Case and Statechart Diagrams](https://reader033.vdocuments.site/reader033/viewer/2022061612/5681604d550346895dcf790e/html5/thumbnails/2.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 2
Outline of this Class• Use case diagrams
• Describe the functional behavior of the system as seen by the user
• Class diagrams• Describe the static structure of the system: Objects,
attributes, associations• Sequence diagrams
• Describe the dynamic behavior between objects of the system
• Statechart diagrams• Describe the dynamic behavior of an individual
object• Activity diagrams
• Describe the dynamic behavior of a system, in particular the workflow.
![Page 3: Chapter 4 , Use Case and Statechart Diagrams](https://reader033.vdocuments.site/reader033/viewer/2022061612/5681604d550346895dcf790e/html5/thumbnails/3.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 3
Another view on UML Diagrams
![Page 4: Chapter 4 , Use Case and Statechart Diagrams](https://reader033.vdocuments.site/reader033/viewer/2022061612/5681604d550346895dcf790e/html5/thumbnails/4.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 4
UML Use Case Diagrams
An actor represents a role, that is, a type of user of the system.
Passenger
PurchaseTicket
Used during requirements elicitation and analysis to represent external behavior (“visible from the outside of the system”)
Use case model: The set of all use cases that completely describe the functionality of the system.
A use case represents a class of functionality provided by the system.
![Page 5: Chapter 4 , Use Case and Statechart Diagrams](https://reader033.vdocuments.site/reader033/viewer/2022061612/5681604d550346895dcf790e/html5/thumbnails/5.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 5
Use Case ExampleHandle Returns
Main Success Scenario: A customer arrives at a checkout with items to return. The cashier uses the POS system to record each returned item.Alternate Scenarios:- If they paid by credit, and the reimbursement
transaction to their credit account is rejected, inform the customer and play them with cash.
- If the item identifier is not found in the system, notify the Cashier and suggest manual entry of the identifier code.
- If the system detects failure to communicate with the external accounting system, .....
![Page 6: Chapter 4 , Use Case and Statechart Diagrams](https://reader033.vdocuments.site/reader033/viewer/2022061612/5681604d550346895dcf790e/html5/thumbnails/6.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 6
Actors• An actor is a model for an external
entity which interacts (communicates) with the system:
• User• External system (Another system)• Physical environment (e.g. Weather)
• An actor has a unique name and an optional description
• Examples:• Passenger: A person in the train• GPS satellite: An external system that
provides the system with GPS coordinates.
Passenger
Name
Optional Description
![Page 7: Chapter 4 , Use Case and Statechart Diagrams](https://reader033.vdocuments.site/reader033/viewer/2022061612/5681604d550346895dcf790e/html5/thumbnails/7.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 7
Use Case• A use case represents a class of functionality provided by the system.• Use cases can be described textually, with a focus on the event flow between actor and system.• The textual use case description consists of 6 parts:
1. Unique name2. Participating actors3. Entry conditions4. Exit conditions5. Flow of events6. Special requirements.
PurchaseTicket
![Page 8: Chapter 4 , Use Case and Statechart Diagrams](https://reader033.vdocuments.site/reader033/viewer/2022061612/5681604d550346895dcf790e/html5/thumbnails/8.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 8
Textual Use Case Description Example1. Name: Purchase ticket
2. Participating actor: Passenger
3. Entry condition: • Passenger stands in front
of ticket distributor• Passenger has sufficient
money to purchase ticket
4. Exit condition:• Passenger has ticket
5. Flow of events:1. Passenger selects the
number of zones to be traveled
2. Ticket Distributor displays the amount due
3. Passenger inserts money, at least the amount due
4. Ticket Distributor returns change
5. Ticket Distributor issues ticket
6. Special requirements: None.
Passenger PurchaseTicket
![Page 9: Chapter 4 , Use Case and Statechart Diagrams](https://reader033.vdocuments.site/reader033/viewer/2022061612/5681604d550346895dcf790e/html5/thumbnails/9.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 9
Uses Cases can be related
• Extends Relationship• To represent seldom invoked use cases or exceptional
functionality• Includes Relationship
• To represent functional behavior common to more than one use case.
![Page 10: Chapter 4 , Use Case and Statechart Diagrams](https://reader033.vdocuments.site/reader033/viewer/2022061612/5681604d550346895dcf790e/html5/thumbnails/10.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 10
The <<extends>> Relationship• <<extends>> relationships
model exceptional or seldom invoked cases
• The exceptional event flows are factored out of the main event flow for clarity
• The direction of an <<extends>> relationship is to the extended use case
• Use cases representing exceptional flows can extend more than one use case.
Passenger
PurchaseTicket
TimeOut
<<extends>>
NoChange
<<extends>>OutOfOrder
<<extends>>
Cancel
<<extends>>
![Page 11: Chapter 4 , Use Case and Statechart Diagrams](https://reader033.vdocuments.site/reader033/viewer/2022061612/5681604d550346895dcf790e/html5/thumbnails/11.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 11
The <<includes>> Relationship• <<includes>> relationship
represents common functionality needed in more than one use case.
• <<includes>> behavior is factored out for reuse, not because it is an exception.
• The direction of a <<includes>> relationship is to the using use case (unlike the direction of the <<extends>> relationship).
• Two use cases are related by an include relationship, if one of them includes the second one in its own flow of events.
Passenger
PurchaseSingleTicket
PurchaseMultiCard
<<includes>>
CollectMoney
<<includes>>
NoChange
<<extends>>
Cancel
<<extends>>
Cancel
<<extends>>
![Page 12: Chapter 4 , Use Case and Statechart Diagrams](https://reader033.vdocuments.site/reader033/viewer/2022061612/5681604d550346895dcf790e/html5/thumbnails/12.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 12
Example of <<includes>> relationship - 1
![Page 13: Chapter 4 , Use Case and Statechart Diagrams](https://reader033.vdocuments.site/reader033/viewer/2022061612/5681604d550346895dcf790e/html5/thumbnails/13.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 13
Example of <<includes>> relationship - 2
![Page 14: Chapter 4 , Use Case and Statechart Diagrams](https://reader033.vdocuments.site/reader033/viewer/2022061612/5681604d550346895dcf790e/html5/thumbnails/14.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 14
Example of <<includes>> relationship - 3
![Page 15: Chapter 4 , Use Case and Statechart Diagrams](https://reader033.vdocuments.site/reader033/viewer/2022061612/5681604d550346895dcf790e/html5/thumbnails/15.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 15
Example of <<extends>> relationship
![Page 16: Chapter 4 , Use Case and Statechart Diagrams](https://reader033.vdocuments.site/reader033/viewer/2022061612/5681604d550346895dcf790e/html5/thumbnails/16.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 16
Textual Use Case Description Example1. Name: DoHomework
2. Participating actor: Student
3. Entry condition: • Student received exercise
sheet• Student is in good health
4. Exit condition:• Student delivered solution
5. Flow of events:1. Student fetches the
exercise sheet2. Student reads through
the assignments3. Student processes the
assignments and types the solution in his Computer.
4. Student prints out the solution
5. Student delivers the solution in the following exercise
6. Special requirements:None.
Student
DoHomework
![Page 17: Chapter 4 , Use Case and Statechart Diagrams](https://reader033.vdocuments.site/reader033/viewer/2022061612/5681604d550346895dcf790e/html5/thumbnails/17.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 17
Sınıf Çalışması (10 dakika)- Müşteri, garsona sipariş verir. - Restoranda çalışmak isteyen adayların başvurularını restoran yöneticisi değerlendirir. İşe alımları da o yapar.- Restoranda kullanılan malzemeler için düzenli sipariş verilmesi gerekmektedir. Malzemeler belirli bir tedarikçiden sağlanır. - Malzemelerin siparişini restoran yöneticisi verir. Bunu yaparken, sürekli olarak satışları ve stokları takip etmesi gerekir.- Stokları takip etmek için, restoran yöneticisinin tuttuğu düzenli raporlar bulunur.
![Page 18: Chapter 4 , Use Case and Statechart Diagrams](https://reader033.vdocuments.site/reader033/viewer/2022061612/5681604d550346895dcf790e/html5/thumbnails/18.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 18
Sınıf Çalışması
Order Food
Hire Employee
Reordersupplies
Producemgt. reports
Track salesand inv. data
<<uses>>
<<uses>>
Customer
Applicant
Supplier
Service Person
Manager
![Page 19: Chapter 4 , Use Case and Statechart Diagrams](https://reader033.vdocuments.site/reader033/viewer/2022061612/5681604d550346895dcf790e/html5/thumbnails/19.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 19
Another view on UML Diagrams
![Page 20: Chapter 4 , Use Case and Statechart Diagrams](https://reader033.vdocuments.site/reader033/viewer/2022061612/5681604d550346895dcf790e/html5/thumbnails/20.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 20
Sequence Diagrams
• Used during analysis• To refine use case descriptions• to find additional objects
(“participating objects”)• Used during system design
• to refine subsystem interfaces• Instances are represented by
rectangles. Actors by sticky figures
• Lifelines are represented by dashed lines
• Messages are represented by arrows
• Activations are represented by narrow rectangles.
selectZone()
pickupChange()
pickUpTicket()
insertCoins()
TicketMachinePassenger
Focus on Controlflow
Messages ->Operations on
participating Object
zone2priceselectZone()insertCoins()pickupChange()pickUpTicket()
TicketMachine
![Page 21: Chapter 4 , Use Case and Statechart Diagrams](https://reader033.vdocuments.site/reader033/viewer/2022061612/5681604d550346895dcf790e/html5/thumbnails/21.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 21
Sequence Diagrams can also model the Flow of Data
• The source of an arrow indicates the activation which sent the message
• Horizontal dashed arrows indicate data flow, for example return results from a message
Passenger
selectZone()
ZoneButton TarifSchedule Display
lookupPrice(selection)
displayPrice(price)
price
Dataflow
…continued on next slide...
![Page 22: Chapter 4 , Use Case and Statechart Diagrams](https://reader033.vdocuments.site/reader033/viewer/2022061612/5681604d550346895dcf790e/html5/thumbnails/22.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 22
Messages
• Define a particular communication between lifelines of an interaction
• Examples of communication • raising a signal• invoking an operation• creating or destroying an instance
• Specify (implicitly) sender and receiver• are shown as a line from the sender to the
receiver• Form of line and arrowhead reflect message
properties
![Page 23: Chapter 4 , Use Case and Statechart Diagrams](https://reader033.vdocuments.site/reader033/viewer/2022061612/5681604d550346895dcf790e/html5/thumbnails/23.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 23
Message Types
• Asynchronous• Synchronous • Call and Object creation• Reply• Lost• Found
![Page 24: Chapter 4 , Use Case and Statechart Diagrams](https://reader033.vdocuments.site/reader033/viewer/2022061612/5681604d550346895dcf790e/html5/thumbnails/24.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 24
Lifeline and Execution Specification
• A lifeline represents an individual participant (or object) in the interaction
• A lifeline is shown using a symbol that consists of a rectangle forming its “head” followed by a vertical line (which may be dashed) that represents the lifetime of the participant
• An execution specification specifies a behavior or interaction within the lifeline
• An execution specification is represented as a thin rectangle on the lifeline.
![Page 25: Chapter 4 , Use Case and Statechart Diagrams](https://reader033.vdocuments.site/reader033/viewer/2022061612/5681604d550346895dcf790e/html5/thumbnails/25.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 25
Sequence Diagrams: Iteration & Condition
• Iteration is denoted by a * preceding the message name• Condition is denoted by boolean expression in [ ] before
the message name
Passenger ChangeProcessor
insertChange(coin)
CoinIdentifier Display CoinDrop
displayPrice(owedAmount)
lookupCoin(coin)
price
[owedAmount<0] returnChange(-owedAmount)
Iteration
Condition
…continued on next slide...
…continued from previous slide...
*
![Page 26: Chapter 4 , Use Case and Statechart Diagrams](https://reader033.vdocuments.site/reader033/viewer/2022061612/5681604d550346895dcf790e/html5/thumbnails/26.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 26
Creation and destruction
• Creation is denoted by a message arrow pointing to the object• Destruction is denoted by an X mark at the end of the
destruction activation• In garbage collection environments, destruction can be used to
denote the end of the useful life of an object.
Passenger ChangeProcessor
…continued from previous slide...
Ticket
createTicket(selection)
free()
Creation of Ticket
Destruction of Ticket
print()
![Page 27: Chapter 4 , Use Case and Statechart Diagrams](https://reader033.vdocuments.site/reader033/viewer/2022061612/5681604d550346895dcf790e/html5/thumbnails/27.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 27
ExecutionSpecification
Sequence diagram: An Example
Sequence diagrams represent the behavior of a system
as messages (“interactions”) between different objects.
Lifeline
Message
![Page 28: Chapter 4 , Use Case and Statechart Diagrams](https://reader033.vdocuments.site/reader033/viewer/2022061612/5681604d550346895dcf790e/html5/thumbnails/28.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 28
Sequence Diagram - Ex
![Page 29: Chapter 4 , Use Case and Statechart Diagrams](https://reader033.vdocuments.site/reader033/viewer/2022061612/5681604d550346895dcf790e/html5/thumbnails/29.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 29
Sequence Diagram - Ex
![Page 30: Chapter 4 , Use Case and Statechart Diagrams](https://reader033.vdocuments.site/reader033/viewer/2022061612/5681604d550346895dcf790e/html5/thumbnails/30.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 30
Sequence diagram: An Example
![Page 31: Chapter 4 , Use Case and Statechart Diagrams](https://reader033.vdocuments.site/reader033/viewer/2022061612/5681604d550346895dcf790e/html5/thumbnails/31.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 31
Sequence diagram: An Example
![Page 32: Chapter 4 , Use Case and Statechart Diagrams](https://reader033.vdocuments.site/reader033/viewer/2022061612/5681604d550346895dcf790e/html5/thumbnails/32.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 32
Sequence Diagram Properties
• UML sequence diagram represent behavior in terms of interactions
• Useful to identify or find missing objects• Time consuming to build, but worth the
investment• Complement the class diagrams (which
represent structure).
![Page 33: Chapter 4 , Use Case and Statechart Diagrams](https://reader033.vdocuments.site/reader033/viewer/2022061612/5681604d550346895dcf790e/html5/thumbnails/33.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 33
Sınıf Çalışması (15 dakika)Müşterinin ATM’den para çekmek istemesine ait sıralama (sequence) diyagramını çiziniz.
- Sokulan kart kontrol edilmeli.- Eğer onaylanırsa, müşterinin istediği miktar kontrol edilmeli.- Eğer onaylanırsa, işlem başlatılmalı.- Para verildikten sonra, müşteriye dekont verilmesi.- Müşteri hesabında yapılan işlemlerin kaydedilmesi.
![Page 34: Chapter 4 , Use Case and Statechart Diagrams](https://reader033.vdocuments.site/reader033/viewer/2022061612/5681604d550346895dcf790e/html5/thumbnails/34.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 34
Örnek Çözüm
![Page 35: Chapter 4 , Use Case and Statechart Diagrams](https://reader033.vdocuments.site/reader033/viewer/2022061612/5681604d550346895dcf790e/html5/thumbnails/35.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 35
Another view on UML Diagrams
![Page 36: Chapter 4 , Use Case and Statechart Diagrams](https://reader033.vdocuments.site/reader033/viewer/2022061612/5681604d550346895dcf790e/html5/thumbnails/36.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 36
UML first pass: Statechart diagrams
State
Initial state
Final state
Transition
Event
Represent behavior of a single object with interesting dynamic behavior.
button1&2Pressed
button1Pressed
button2Pressed
button2Pressed
button2Pressed
button1Pressed
button1&2Pressed IncrementMinutes
IncrementHours
BlinkHours
BlinkSeconds
BlinkMinutes
IncrementSeconds
StopBlinking
![Page 37: Chapter 4 , Use Case and Statechart Diagrams](https://reader033.vdocuments.site/reader033/viewer/2022061612/5681604d550346895dcf790e/html5/thumbnails/37.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 37
How to draw statechart diagrams?
• Identify important objects to be analyzed.• Identify the states.• Identify the events.
![Page 38: Chapter 4 , Use Case and Statechart Diagrams](https://reader033.vdocuments.site/reader033/viewer/2022061612/5681604d550346895dcf790e/html5/thumbnails/38.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 38
Statechart Diagram Example
![Page 39: Chapter 4 , Use Case and Statechart Diagrams](https://reader033.vdocuments.site/reader033/viewer/2022061612/5681604d550346895dcf790e/html5/thumbnails/39.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 39
Statechart Diagram Example
![Page 40: Chapter 4 , Use Case and Statechart Diagrams](https://reader033.vdocuments.site/reader033/viewer/2022061612/5681604d550346895dcf790e/html5/thumbnails/40.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 40
UML Summary
• UML provides a wide variety of notations for representing many aspects of software development
• Powerful, but complex• UML is a programming language
• Can be misused to generate unreadable models• Can be misunderstood when using too many exotic
features• We concentrated on a few notations:
• Functional model: Use case diagram• Object model: class diagram• Dynamic model: sequence diagrams, statechart and
activity diagrams