Topic2 UML Notes
Topic2 UML Notes
Notes
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 2
Important UML Diagrams
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 actors and the system and
between objects of the system
Statechart diagrams
Describe the dynamic behavior of an individual object (essentially a
finite state automaton)
Activity Diagrams
Model the dynamic behavior of a system, in particular the workflow
(essentially a flowchart)
Component diagrams
Model the dynamic behavior of a system, in particular the workflow
(essentially a flowchart)
Deployment diagrams
Model the dynamic behavior of a system, in particular the workflow
(essentially a flowchart)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 3
1. Use case diagrams
Actor
ReadTime
SetTime
WatchUser WatchRepairPerson
ChangeBattery
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 5
Use Case Diagrams
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 6
Actors
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 7
Use Case
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 8
Use Case Diagram: Example
Exit condition:
Passenger has ticket.
Anything missing?
Exceptional cases!
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 9
The <<extends>> Relationship
<<extends>> relationships
represent exceptional or seldom
invoked cases.
The exceptional event flows are
Passenger factored out of the main event flow
for clarity.
Use cases representing exceptional
flows can extend more than one
PurchaseTicket use case.
The direction of a <<extends>>
<<extends>> relationship is to the extended use
case
<<extends>>
<<extends>>
Cancel NoChange
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 10
The <<includes>> Relationship
<<includes>> relationship
represents behavior that is factored
Passenger out of the use case.
<<includes>> behavior is
factored out for reuse, not because
PurchaseMultiCard it is an exception.
PurchaseSingleTicket The direction of a <<includes>>
<<includes>>
relationship is to the using use case
(unlike <<extends>>
<<includes>>
relationships).
CollectMoney
<<extends>> <<extends>>
NoChange Cancel
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 11
Use Case Diagrams: Summary
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 12
2. Class diagrams
Class diagrams represent the structure of the system
Association
Class
Multiplicity Watch
1 1 1 1
2 1 2 1
PushButton LCDDisplay Battery Time
state blinkIdx load now
push() blinkSeconds()
release() blinkMinutes()
blinkHours()
stopBlinking()
referesh()
Attribute
Operations
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 13
Class Diagrams
TarifSchedule
Trip
Enumeration getZones() zone:Zone
Price getPrice(Zone)
* * Price: Price
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 14
Classes
TarifSchedule
Table zone2price
Enumeration getZones()
Name Price getPrice(Zone)
TarifSchedule
zone2price Attributes Signature
getZones()
getPrice()
Operations TarifSchedule
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 15
Instances
tarif_1974:TarifSchedule
zone2price = {
{‘1’, .20},
{‘2’, .40},
{‘3’, .60}}
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 16
Associations
TarifSchedule TripLeg
StockExchange * * Company
Lists
tickerSymbol
Button
CancelButton ZoneButton
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 19
Packages
DispatcherInterface
Notification IncidentManagement
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 20
3. Sequence diagram
Actor Object
pressButton1() blinkHours()
pressButton1() blinkMinutes()
Activation Lifeline
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 22
Nested messages
selectZone()
lookupPrice(selection)
price
displayPrice(price)
Dataflow
…to be continued...
The source of an arrow indicates the activation which sent the message
An activation is as long as all nested activations
Horizontal dashed arrows indicate data flow
Vertical dashed lines indicate lifelines
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 23
Iteration & condition
…continued from previous slide...
*insertChange(coin) lookupCoin(coin)
price
Iteration displayPrice(owedAmount)
[owedAmount<0] returnChange(-owedAmount)
Condition
…to be continued...
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 24
Creation and destruction
…continued from previous slide...
ChangeProcessor
Passenger
Creation
createTicket(selection)
Ticket
print()
free()
Destruction
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 25
Sequence Diagram Summary
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 26
4. Statechart diagrams for objects with interesting
dynamic behavior
Event State
Initial state
[button1&2Pressed] [button2Pressed]
BlinkHours IncrementHrs
[button1Pressed]
Transition
[button1&2Pressed] [button2Pressed]
BlinkMinutes IncrementMin.
[button1Pressed]
[button1&2Pressed] [button2Pressed]
BlinkSeconds IncrementSec.
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 28
Statechart Diagram vs. Activity Diagram
Statechart Diagram for Incident
(State: Attribute or Collection of Attributes of object of type Incident)
Event causes
State transition
Triggerless
Completion of activity Transition
causes state transition
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 29
Activity Diagram: Modeling Decisions
[lowPriority]
Open Allocate
Incident Resources
[fire & highPriority]
Notify
Police Chief
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 30
Activity Diagrams: Modeling Concurrency - التزامن
التوازي
Allocate
Splitting Resources Synchronization
Document
Incident
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 31
Activity Diagrams: Swimlanes خطوط السباحة
Allocate Dispatcher
Resources
FieldOfficer
Document
Incident
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 32
6. Drawing Hardware/Software Mappings in UML
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 33
Component Diagram
Component Diagram
A graph of components connected by dependency relationships.
Shows the dependencies among software components.
source code, linkable libraries, executables
Dependencies are shown as dashed arrows from the client
component to the supplier component.
The kinds of dependencies are implementation language specific.
A component diagram may also be used to show dependencies
on a façade:
Use dashed arrow the corresponding UML interface.
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 34
Component Diagram Example
Scheduler reservations
UML Component
UML Interface
Planner update
GUI
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 35
Deployment Diagram
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 36
Deployment Diagram Example
Compile Time
Dependency
:HostMachine
<<database>>
meetingsDB
:Scheduler
Runtime
Dependency
:PC
:Planner
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 37
UML Summary
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 38