Collaboration diagrams-an example 1: <<create>> 2: add ToSchedule CourseSection Registration Student 3: addToRegistrationList www.oseng.com O Lethbridge/Laganiere 2001 Chapter 8: Modelling Interactions and behaviour
© Lethbridge/Laganière 2001 Chapter 8: Modelling Interactions and Behaviour 11 Collaboration diagrams – an example 1: <<create>> 2: addToSchedule :CourseSection :Registration :Student 3: addToRegistrationList
Collaboration diagrams Collaboration diagrams emphasise how the objects collaborate in order to realize an interaction A collaboration diagram is a graph with the objects as the vertices Communication links are added between objects Messages are attached to these links Shown as arrows labelled with the message name Time ordering is indicated by prefixing the message with some numbering scheme www.oseng.com O Lethbridge/Laganiere 2001 Chapter 8: Modelling Interactions and behaviour
© Lethbridge/Laganière 2001 Chapter 8: Modelling Interactions and Behaviour 12 Collaboration diagrams Collaboration diagrams emphasise how the objects collaborate in order to realize an interaction • A collaboration diagram is a graph with the objects as the vertices. • Communication links are added between objects • Messages are attached to these links. —Shown as arrows labelled with the message name • Time ordering is indicated by prefixing the message with some numbering scheme
Collaboration diagrams same example, more detaIls 1: request ToRegister(aStudent) 2: prereq getPrerequisite <<local>> GUI Course Section Course asPrerequl sIte hasPassedcourse(prereg A5:addToRegistrationList 4: [has Prerequisite <<parameter>> <parameter>> <<create aStudent Registration Student 5: add Toschedule <<parameter www.oseng.com O Lethbridge/Laganiere 2001 Chapter 8: Modelling Interactions and behaviour 13
© Lethbridge/Laganière 2001 Chapter 8: Modelling Interactions and Behaviour 13 Collaboration diagrams – same example, more details 1: requestToRegister(aStudent) <<local>> 5: addToSchedule <<parameter>> aStudent: Student :Registration GUI :CourseSection :Course 4: [hasPrerequisite] <<create>> 2: prereq := getPrerequisite 3: hasPrerequisite := hasPassedCourse(prereq) <<parameter>> 5: addToRegistrationList <<parameter>>
Communication links a communication link can exist between two objects whenever it is possible for one object to send a message to the other one Several situations can make this message exchange possible 1. The classes of the two objects have an association between them This is the most common case If all messages are sent in the same direction, then probably the association can be made unidirectional www.oseng.com O Lethbridge/Laganiere 2001 Chapter 8: Modelling Interactions and behaviour 14
© Lethbridge/Laganière 2001 Chapter 8: Modelling Interactions and Behaviour 14 Communication links • A communication link can exist between two objects whenever it is possible for one object to send a message to the other one. • Several situations can make this message exchange possible: 1. The classes of the two objects have an association between them. - This is the most common case. - If all messages are sent in the same direction, then probably the association can be made unidirectional
Other communication links 2. The receiving object is stored in a local variable of the sending method This often happens when the object is created in the sending method or when some computation returns an object The stereotype to be used is < local>or LI 3. a reference to the receiving object has been received as a parameter of the sending method The stereotype is <parameter or [P] www.oseng.com O Lethbridge/Laganiere 2001 Chapter 8: Modelling Interactions and behaviour 15
© Lethbridge/Laganière 2001 Chapter 8: Modelling Interactions and Behaviour 15 Other communication links 2. The receiving object is stored in a local variable of the sending method. - This often happens when the object is created in the sending method or when some computation returns an object . - The stereotype to be used is «local» or [L]. 3. A reference to the receiving object has been received as a parameter of the sending method. - The stereotype is «parameter» or [P]