Documente Academic
Documente Profesional
Documente Cultură
Chapter 8:
Modelling Interactions and
Behaviour
8.1 Interaction Diagrams
• Instances of classes
—Shown as boxes with the class and object identifier
underlined
• Actors
—Use the stick-person symbol as in use case diagrams
• Messages
—Shown as arrows from actor to object, or from object
to object
:CourseSection :Student
requestToRegister :Registration
<<create>>
addToSchedule
addToRegistrationList
requestToRegister
requestToRegister
prereq :=
(aStudent)
hasPrerequisite := getPrerequisite
hasPassedCourse(prereq)
[hasPrerequisite]
<<create>> :Registration
addToRegistrationList addToSchedule
computeTotal
cancelBooking
cancel
deleteFromItinerary
deleteFromPassengerList
1: <<create>> 2: addToSchedule
:CourseSection :Registration :Student
3: addToRegistrationList
3: hasPrerequisite := 5: addToRegistrationList
hasPassedCourse(prereq) 4: [hasPrerequisite] <<parameter>>
<<parameter>> <<create>>
aStudent: :Registration
Student 5: addToSchedule
<<parameter>>
a)
proxy heavyWeight
Student PersistentStudent
Proxy
client
CourseSection
b)
• tic-tac-toe game
XWin
XTurn
Tie
OWin
OTurn
• Special states:
—A black circle represents the start state
—A circle with a ring around it represents an end state
vehicleWaitingToTurn
GreenLight GreenLightChangeTriggered
after(5s) after(5s)
RedLight RedLight
Planned
openRegistration
closeRegistration requestToRegister
Cancelled OpenNotEnoughStudents (aStudent)
cancel /createRegistration
closeRegistration
requestToRegister
Closed OpenEnoughStudents (aStudent)
classSize >= maximum /createRegistration
press button
ProposeSelection MusicPlaying
do:
play chosen
selection
Closed Opening
Enter / pressButton Enter /
stop motor run motor forwards
closingCompleted
openingCompleted
pressButton
endOfProgram
Wait
selectReverse
Neutral Reverse
selectNeutral
selectFirst selectDrive selectSecond selectNeutral
reachSecondSpeed reachThirdSpeed
[driveSelected] [driveSelected]
First Second Third
dropBelowSecondSpeed dropBelowThirdSpeed
[driveSelected]
selectFirst selectSecond
Planned
openRegistration
Cancelled Open requestToRegister
cancel (aStudent)
do:
NotEnoughStudents /createRegistration
unregister
students closeRegistration
• An activity diagram
—Can be used to understand the flow of work that an object or
component performs.
—Can also be used to visualize the interrelation and interaction
between different use cases.
—Is most often associated with several classes.
Check Verify
prerequisites course not
full
[not ok] [ok]
[ok] [not ok]
Check
special [ok]
permission
[not ok]
Complete
registration
Receive course
registration request
Check Verify
prerequisites course not
full
[not ok] [ok]
[ok] [not ok]
Check
special [ok]
permission
[not ok]
Complete
registration
States:
• ‘Planned’:
— closedOrCancelled == false && open
== false
• ‘Cancelled’:
— closedOrCancelled == true &&
registrationList.size() == 0
• ‘Closed’ (course section is too full, or being taught):
— closedOrCancelled == true &&
registrationList.size() > 0
States:
• ‘Open’ (accepting registrations):
— open == true
• ‘NotEnoughStudents’ (substate of ‘Open’):
— open == true &&
registrationList.size() <
course.getMinimum()
• ‘EnoughStudents’ (substate of ‘Open’):
— open == true &&
registrationList.size() >=
course.getMinimum()
Class diagram