Sequence diagrams- an example Course section Student requestToRegister : Registration <<create>> addTo Schedule add ToRegistrationList Course CourseSection Registration Student getPrerequisite request To Register add ToSchedule add To RegistrationList hasPassedCourse www.oseng.com O Lethbridge/Laganiere 2001 Chapter 8: Modelling Interactions and behaviour 6
© Lethbridge/Laganière 2001 Chapter 8: Modelling Interactions and Behaviour 6 Sequence diagrams – an example requestToRegister addToSchedule <<create>> :Student :Registration :CourseSection addToRegistrationList * CourseSection * * requestToRegister Course Registration getPrerequisite Student addToSchedule hasPassedCourse addToRegistrationList
Sequence diagrams A sequence diagram shows the sequence of messages exchanged by the set of objects performing a certain task The objects are arranged horizontally across the diagram An actor that initiates the interaction is often shown on the left The vertical dimension represents time A vertical line, called a lifeline, is attached to each object or actor The lifeline becomes a broad box, called an activation box during the live activation period A message is represented as an arrow between activation boxes of the sender and receiver - a message is labelled and can have an argument list and a return value www.oseng.com O Lethbridge/Laganiere 2001 Chapter 8: Modelling Interactions and behaviour
© Lethbridge/Laganière 2001 Chapter 8: Modelling Interactions and Behaviour 7 Sequence diagrams A sequence diagram shows the sequence of messages exchanged by the set of objects performing a certain task • The objects are arranged horizontally across the diagram. • An actor that initiatesthe interaction is often shown on the left. • The vertical dimension representstime. • A vertical line, called a lifeline, is attached to each object or actor. • The lifeline becomes a broad box, called an activation box during the live activation period. • A message is represented as an arrow between activation boxes of the sender and receiver. —A message is labelled and can have an argument list and a return value
Sequence diagrams same example, more details GUI Course Section a Student: Course Student I request ToRegister requestToRegister (astudent) as Prerequisite getPrerequsiter囗 sPassedcourse (prereq [hasPrerequisite <<create>> Registration add ToRegistrationList add ToSchedule I www.oseng.com O Lethbridge/Laganiere 2001 Chapter 8: Modelling Interactions and behaviour 8
© Lethbridge/Laganière 2001 Chapter 8: Modelling Interactions and Behaviour 8 Sequence diagrams – same example, more details requestToRegister (aStudent) addToSchedule aStudent: Student :Registration GUI :CourseSection requestToRegister :Course [hasPrerequisite] <<create>> prereq := getPrerequisite hasPrerequisite := hasPassedCourse(prereq) addToRegistrationList
Sequence diagrams an example with replicated messages An iteration over objects is indicated by an asterisk preceding the message name Bill Purchase Item for all PurchaselgetSubtotal ge uNitpRice ompu te Total Bill Purchase Item quantity pnce www.oseng.com O Lethbridge/Laganiere 2001 Chapter 8: Modelling Interactions and behaviour
© Lethbridge/Laganière 2001 Chapter 8: Modelling Interactions and Behaviour 9 • An iteration over objects is indicated by an asterisk preceding the message name * Purchase * quantity Bill Item price *[for all Purchase] getSubtotal :Bill :Item getUnitPrice computeTotal :Purchase Sequence diagrams – an example with replicated messages
Sequence diagrams an example with object deletion If an object' s life ends, this is shown with an x at the end of the lifeline Speci ficFlight Booking Passen gerRole cancelBookings cancel de lete fromltine ran de lete From Passen gerlist www.oseng.com O Lethbridge/Laganiere 2001 Chapter 8: Modelling Interactions and behaviour
© Lethbridge/Laganière 2001 Chapter 8: Modelling Interactions and Behaviour 10 • If an object’s life ends, this is shown with an X at the end of the lifeline Sequence diagrams – an example with object deletion cancelBooking deleteFromItinerary cancel :SpecificFlight :Booking :PassengerRole deleteFromPassengerList