10/16/2015CPSC-4360-01, CPSC-5360-01, Lecture 61 Software Engineering, CPSC-4360-01, CPSC-5360-01,...

75
03/25/22 CPSC-4360-01, CPSC-5360-01, Lecture 6 1 Software Engineering, CPSC-4360-01, CPSC-5360- 01, Lecture 6

Transcript of 10/16/2015CPSC-4360-01, CPSC-5360-01, Lecture 61 Software Engineering, CPSC-4360-01, CPSC-5360-01,...

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 1

Software Engineering, CPSC-4360-01, CPSC-5360-01,Lecture 6  

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 2

Review of Last Lecture

Design: Major activities during design phase. Tools:

Class Diagram. Object Diagram.

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 3

Overview of This Lecture

Class Diagram Association Class, Reification N-Ary Association Qualified Association Interface

Interactions diagrams Collaborations, classifier and association roles Interaction diagrams, object creation and destruction Role multiplicity and iterated messages Multi-objects Conditional messages, messages to self

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 4

Where are we now?

Requirement

Analysis

Design

Implement

Test

In depth look at the relevant tools: Class Diagram Interaction Diagram

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 5

Association: Review

Annotation for Association:

MultiplicityNumber of instances

associated

Association Name

Description of the relationship

Role NameThe role of the instance in the relationship.

Represented as reference name

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 6

Association: Review

Role names can also help to distinguish multiple associations, or self association.

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 7

Properties of Links

There are cases where information about the link need to be kept.

Example: A student takes a module and gets a mark for it. The mark only makes sense if we know the student

and the module. The mark is not simply an attribute of either class.

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 8

Association Class Association Classes can be added. Behave like a combination of both association and class:

Association: Can connect two classes. Class: Allow attribute to be stored.

Syntax: dashed line between association and class icon.

Association Class

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 9

Association Class Example

John: Student

Example: John took CPSC4360, and scored 25 marks.

CPSC4360 : Module

:Takes

mark = 25

The Takes instance is uniquely defined by both John:Student and CPSC4360:Module.

Follow Up: What if John retakes CPSC4360, and scored 99 marks?

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 10

Reification Another technique to capture association information

is reification. Reification means “Replacing an association with a

Class”.

Apply Reification. An intermediate class is added

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 11

Reification Example Draw an object diagram for the two examples given

previously: John takes CPSC4360 and score 25 John retakes CPSC4360 and score 99

The reification has the property of allowing students to take a module more than once, in case they failed first time.

This property was not possible for previous slide, when there is exactly one link between a student and a module.

Question to ponder: Is reification and association class the same?

Draw the Object Diagram before Lecture

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 12

Association Class Property Association classes are classes … So they can participate in associations. Example: MarkSheet lists all students taking a module

with the marks they got.

Can participate in the relationship just like a normal class

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 13

N-ary Association Associations can connect more than two classes:

A 3-way association could be used to store marks. Multiplicity at a given association end defines the number of

instances of the class at that end that can be linked to a tuple of instances, one from each of the other ends of association.

Example: ‘*’ specifies that each pair of student and module object can be linked to zero or more Attempt objects.

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 14

Qualified Association In the real world, “objects” are usually identified by a

unique value (also known as key). Example:

University uses Matriculation Number to identify a student.

University Student

matric : Integername : String

1 *

Problems: Is matric number unique? Is it represented as such? How do we know the matric can be used as a key?

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 15

Qualified Association Syntax:

The key is known as a qualifier. The qualifier is written in a square box attached to the

class used to identify the other party. The multiplicity is changed to reflect the relationship with

the qualifier instead of the class.

University Student

Name : String

1 0..1matric:Integer

Qualifier Changed Multiplicity

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 16

Qualified Association

Semantics: The set of qualifiers is unique in the context of the

attached class: E.g., the University has a set of unique matric values.

The multiplicity reflects the relationship between the identified class and the qualifier: E.g., a Student is given exactly one matric in the University. E.g., an University object will use matric to uniquely identify

zero or one Student (why zero?).

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 17

Qualified Association: Example Draw an object diagram to show:

A student John in LU university with matric. no. 007. A student Helen in LU university with matric. no. 1234.

LU: University

:Student

Name = John007

1234

:Student

Name = Helen

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 18

Interface

An interface in UML is a named set of operations. Interfaces are used to characterize the behaviour of

an entity. shown as a stereotyped class:

<<interface>>List

Add( )isEmpty( )…

Generalization can be defined between interfaces.

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 19

Realizing an Interface A class realizes an interface if it provides

implementations of all the operations. Similar to the implements keyword in Java.

UML provides two equivalent ways of denoting this relationship:

<<interface>>List

CircularLinkedList

CircularLinkedListList

Both represent “CircularLinkedList implements all operations defined by the List interface”.

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 20

Interface Dependency A class can be dependent on an interface.

This means that it makes use of the operations defined in that interface.

E.g., the Restaurant class makes use of the List interface:

Restaurant

List

<<use>>

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 21

Interface Dependency

This information can also be attached to the role name (known as the interface specifier):

Restaurant

List

<<use>>

CircularLinkedList

RestaurantCircularLinkedListbookingList : List

If the class realizing the interface is known, the dependency can be specified by:

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 22

Evolution of Class Diagram

Class Diagram evolves with the development process: Starts out as a Domain Model:

Classes with name and attribute only. Refined to an Analysis Class Model:

Classes with name, attribute and simplified operation. Refined to a Design Class Model:

Classes with name, attribute and operation. Type information and Scope defined for attribute and

operation.

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 23

Interaction Diagrams

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 24

Interaction Diagrams When a system is running, objects interact by

passing messages. The messages define the system’s behaviour,

but they are not shown on static diagrams (such as class diagrams).

UML defines two types of diagram for showing interactions: collaboration diagram. sequence diagram.

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 25

Using Object Diagram: Interaction A message can be added to an Object Diagram. Syntax :

An arrow with message name and parameter ( ) Example:

The Bank performs “Fund Transfer” by withdrawing from one account, and deposit to another account.

message

Object Diagram with Message

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 26

Problems with Object Diagrams Object diagrams show a specific scenario:

They show specific objects, not the general case: Can we withdraw from a2 and deposit in a1 instead?

They show a fixed number of objects and links: Can we withdraw from a1 and deposit into a1 again (for

whatever reason)? They cannot show alternative functionality:

What if the withdraw causes overdraft in a1? Can we proceed with the deposit?

In a nutshell, we need something more general.

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 27

Solution to this Problem

A more general method is needed to specify behaviour.

Collaborations in UML in general do not show individual objects, but rather the roles that objects can play in the interaction.

An object diagram used to illustrate a collaboration is known as a collaboration instance set.

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 28

Classifier Roles Define collaborations using classifier roles:

Represent any object of a class. Can have a name describing the role.

Syntax: object_name /role_name : base_class

Collaboration Diagram

• Specify that any object of Account class can be substituted.• “/Debtor” describes that money is taken out from this account.

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 29

Classifier Role Syntax Guide:

The classifier role is not underlined, to distinguish from the object diagram usage.

The object_name can be used to label a classifier role instead of a role name, when the role is not clear/ not important.

The Object Diagram on Slide 25 is a collaboration instance set of the Collaboration Diagram on Slide 28: Substitute an object a1 for the /Debtor role. Substitute an object a2 for the /Creditor role.

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 30

Roles and Objects Objects can play different roles in interactions. An object can be substituted for a role if:

it is an instance of the base class of the role or one of its subclasses.

In a given interaction, an object playing a particular role will not normally make use of all the features provided by the base class of the role: E.g., an Account object in the /Debtor role will only

receive “withdraw()” message, but not “deposit()” message.

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 31

Association Role

Similar to Classifier Role, an Association Role generalizes the links in the Object Diagram.

An association role connecting two classifier roles indicates that objects playing those roles: Can establish links to each other. Can exchange messages during interactions.

Question: What are the possible ways to set up a

communication (link) between two objects?

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 32

Association Stereotypes There are five ways to establish a link between two

objects: Base Association Parameter Local Instantiation Global Variable Self-directed Link

In UML, five corresponding stereotypes are used to denote the above: <<Association>> <<Parameter>> <<Local>> <<Global>> <<Self>>

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 33

Association Role: Base Association The most common kind of association. The association is defined between the corresponding

classes (i.e., show up in the class diagram). More “permanent” compared to other kind of association.

Usually kept as an attribute in the class. Syntax:

Label the association role with stereotype <<Association>>. Example:

Class Diagram

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 34

Base Association: Example

The interaction is possible because the Bank object holds the “IsHeldAt ” to the two account objects.

As this is the most common case, the <<association>> stereotype is usually omitted.

Collaboration Diagram

<<Association>> <<Association>>

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 35

Association Role: Parameter One object is passed to another as a parameter of a

message. In programming languages, this is implemented by

passing a reference to the object. The object receiving the message knows the identity of

the parameter object, and can, in the method body, send messages to that object.

This link is temporary, being available while the operation is executing.

Syntax: Label with the stereotype <<parameter>>.

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 36

Parameter: Exampleclass A {

//No association to class B

void methodA(B objB){

objB.methodB( ); }

}

:A :B

Collaboration Diagram

methodB( )

<<parameter>>

During the execution of methodA(), an object of class A can pass a message to an object of class B, because the reference is passed as parameter.

When methodA() terminates, the link will be over.

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 37

Association Role: Local Instantiation Implementations of operations can create

local instances of any class. Sending messages to these objects during the

execution of the operation is now possible. A link corresponding to a local variable only

lasts for the duration of an operation call. Syntax:

Label with the stereotype <<local>>.

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 38

Local Instantiation: Exampleclass A { //No association to class B void methodA( ){

B objB = new B(); objB.methodB( );

}}

:A :B

Collaboration Diagram

methodB( )

<<local>>

During the execution of methodA(), an object of class A can pass a message to an object of class B, because a local object is created.

When methodA() terminates, the link will be gone.

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 39

Association Role: Global Variable If any global variables exist and are visible, an

object can send messages to an object stored in such a variable.

Example in Java: Nested class

Example in C++: Global object pointer

Syntax: Label with the stereotype <<global>>

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 40

Global Variable: Exampleclass OuterA {

B objB;

class A { //Nested class //No association to class B void methodA( ){ objB.methodB( );

}}

}

:A :B

Collaboration Diagram

methodB( )

<<global>>

During the execution of methodA(), an object of class A can pass a message to an object of class B, because an attribute of the parent class is accessible to all nested classes.

When methodA() terminates, the link remains (why?).

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 41

Association Role: Self-Directed An object can always send messages to

itself, even though no explicit ‘link to self’ is defined.

In programming languages, this capability is provided by defining a pseudo-variable called this or self.

Syntax: Label with the stereotype <<self>>.

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 42

Self-Directed: Exampleclass A { //No association to class A void methodA( ){

this.methodA( );

}}

:A

Collaboration Diagram

methodA( )

<<self>>

During the execution of methodA(), an object of class A can pass a message to itself, because a self reference (this in Java) is always available.

When methodA() terminates, the link remains.

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 43

Sequence Diagram: Review

Review sequence diagram introduced earlier in the light of classifier role.

Classifier Role is the more

formal description

Lifeline

Message

With parameter Message ( Para )

Return

Control and possibly value are returned

Activation Bar

Time Passes

Return value

Classifier Role

Classifier Role

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 44

Sequence Diagrams Show classifier roles only (no association roles). The vertical dimension is the time and the messages

are drawn from top to bottom, in the order they are sent.

Each role has a lifeline: indicating the period of time during which objects playing

that role exist. Syntax: vertical dashed line below the classifier role.

Messages are shown as arrows leading from the lifeline of the message’s sender to that of the receiver.

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 45

Sequence Diagrams The period of time during which an object is processing a

message is called activation. Syntax: narrow rectangle whose top is connected to a message.

When an object finishes processing a message, the control returns to the sender of the message. Syntax: dashed arrow from the bottom of activation rectangle back to

lifeline of the role that sent the message.

The messages with solid arrowhead denote synchronous messages, such as normal procedure calls (the object that sends the message is suspended until the called object returns the control to the caller).

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 46

Sequence Diagram: Simple Example Suppose statements are to be printed for bank

accounts: Bank passes the relevant Account to a Statement object for

printing.

Sequence Diagram

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 47

Anything Missing?

The link between classifier roles is not indicated: How can a statement object contacts the relevant account

object ? You have to read the diagram carefully to deduce that the

link may be established by the parameter. In some cases, such deductions are impossible/prone to

error when the information is not enough. A Collaboration Diagram can show the same

exchange, but also includes the association role used for communication.

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 48

Collaboration Diagram Show classifier and association roles. Compared with diagram on Slide 46, messages also have:

sequence numbers to indicate order; optional returned values with ‘:=’ notation.

Sequence Number

Return Value

Collaboration Diagram

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 49

Collaboration versus Sequence Diagrams Unlike sequence diagrams, collaboration diagrams show the association role.

Message sequencing cannot be shown graphically and messages are numbered to indicate the order in which they are sent.

Messages can be numbered sequentially, but more commonly a hierarchical numbering scheme is used (i.e., to reflect the nesting activation made explicit in sequence diagrams).

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 50

Hierarchical Numbering Within each activation, messages are numbered

sequentially starting from 1. A unique label can then be generated for each

message by adding the number of the message to the end of the number of the activation sending the message.

Syntax: use a “.” to separate the numbers and to reflect that another level of nesting of control flow

has been initiated.

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 51

Hierarchical Numbering. Example

1 : because it is the first message

1.1: because it is the first message sent during the computation of message 1

1.2: because it is the second message sent during the computation of message 1

2.1.2: because it is the second message sent during the computation of message 2.1

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 52

Interaction Diagram: Additional Notations Subsequent examples illustrate the notations for:

Object Creation Object Destruction Iterated Messages Multiobjects Conditional Messages Message to Self

Should take note of how to portrait certain interaction in both Sequence Diagram (SD) and Collaboration Diagram (CD).

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 53

Sequence Diagram: Object Creation As time is explicitly represented in a sequence

diagram, the object creation is easy to draw:

class A { void methodA( ){

B objB = new B();

objB.methodB( );}

}methodB( )

: A

B( ) : B

Sequence Diagram

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 54

Collaboration Diagram: Object Creation In a Collaboration Diagram, new objects and new

associations have to be labeled with {new}.

:A

:B{new}

Collaboration Diagram

1: B( )

<<local>>

class A { void methodA( ){

B objB = new B();

objB.methodB( );}

}

{new}

2: methodB( )

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 55

Sequence Diagram: Object Destruction

class A { void methodA( ){

B objB = new B();

... ... ... objB = null;

... ... ...}

}

Reminder: Only the circled part of code is represented.

<<destroy>>

: A : B

Sequence Diagram

In languages with automatic garbage collection (like Java), you cannot explicitly delete an object.

Instead, remove all references to the object for it to be collected.

Label the message as <<destroy>>. Mark the lifeline of the destroyed object with a cross.

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 56

Collaboration Diagram: Object

Destruction In a Collaboration Diagram: Similarly, label the message as <<destroy>>. Label the destroyed objects and links with {destroyed}.

class A { void methodA( ){

B objB = new B();

... ... ... objB = null;

... ... ...}

}

:A

:B{destroyed}

Collaboration Diagram

<<local>>

{destroyed}

1: <<destroy>>

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 57

Role Multiplicity The number of objects playing a role can vary from one

occasion to another. Example (Restaurant Case Study):

Looking for bookings for a particular date will depend on how many total bookings are there.

: Restaurant : Booking

Sequence Diagram

getDate( )

Return date

Need to show “many booking objects will be involved”.

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 58

Role Multiplicity Role multiplicity can be added to classifier role to indicate

the number of objects involved. Syntax:

Same as the multiplicity notation in class diagram (e.g., 1..8, *, 2..* , etc).

: Restaurant : Booking

Sequence Diagram

getDate( )

Return date

Role Multiplicity

Shows that zero or more Booking objects will

be involved

*

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 59

Role Multiplicity The notation is the same in both Sequence Diagram

and Collaboration Diagram. However, the fact that the message is iterated is still

not represented.

: Restaurant : Booking

Sequence Diagram

getDate( )

Return date

*

Sent Multiple times

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 60

Iterated Messages We can clarify this by:

adding a multiplicity to the affected role. specifying that the message is iterated.

Syntax: Recurrence consists in ‘*’ written after the sequence number,

possibly followed by an iteration clause. There is no formal syntax for iteration clause. Pseudo code-

like condition is usually used, e.g., [i = 1 .. N] or [i = 1 to N]. Example:

: Restaurant : Booking

1 * [i = 1.. N] getDate( )*

Denote Recurrence Denote the Recurrence Condition

Collaboration Diagram

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 61

Multiobject

A multiobject denotes a collection of objects: It is a role with a multiplicity of zero or more.

It implies an intermediate data structure, e.g.:

: Restaurant : Booking : Booking

Collaboration Diagram

Denote Multiobject

: Restaurant : Booking

Collaboration Diagram

: Vector *

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 62

Property of Multiobject Using multiobject prevents a premature

commitment to a particular data structure: E.g., What if vector is not a good data structure for

this case? Semantically, a multiobject is a single object

representing a collection of objects. A single message sent to it implies an

operation involving the collection of objects. A good example of such operation would be

looking for a particular object in the collection.

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 63

Multiobject: Example Assume that there is only one booking per date to simplify

the discussion: A single message findBooking(Date) is sent to the Booking multiobject. The multiobject inspects all its Booking object and returns the

appropriate booking B (to indicate that B is not a new object, but one from the multiobject, a composition link is used).

The Restaurant stores B as a local reference for subsequent operations.

:Restaurant : Booking : Booking

Collaboration Diagram

B := findBooking( Date )

B: Booking <<local>>

{new}

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 64

Multiobject: Message for all objects To send a message to all objects in the multiobject:

Send a single message to the multiobject. The multiobject goes through some iterative process and

sends the message to each object in the collection. By convention, such interactions can be abbreviated by

using iterative messages. Iterated messages to a multiobject are understood to be

sent to individual objects.

: Restaurant : Booking * Print( )

Collaboration Diagram

: Booking

Each booking in the multiobject will receive the Print( ) message

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 65

Sequence Diagram: Conditional Message Conditions can be added to messages to show

the situations when they are sent. Syntax:

Write the condition in [ ] preceding a message.

class A { void methodA( ){

B objB = new B();... ... ... if ( x < y )

objB.methodB( );}

}

[x < y] methodB( )

: A : B

Sequence Diagram

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 66

Collaboration Diagram: Conditional Message Same syntax can be used for a collaboration diagram.

class A { void methodA( ){

B objB = new B();... ... ... if ( x < y )

objB.methodB( );}

}

[x < y] methodB( )

: A : B

Collaboration Diagram

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 67

Alternative Flows Sequence diagrams can show alternative

message sequences in one diagram: Two or more messages start at the same point

(fork). They are distinguished by conditions (only one will

be sent). Return messages come together later (join). Objects that receive messages may need branching

lifelines to represent alternative possibilities. Should draw two separate diagrams instead.

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 68

Sequence Diagram: Alternative Flow Pay attention to:

Branching of the messages (Fork). Joining of the return messages (Join).

class A { void methodA( ){

B objB = new B();... ... ... if ( x < y )

objB.methOne( );else objB.methTwo(

);}

}

[x < y] methOne( )

: A : B

Sequence Diagram

[x >= y] methTwo( )

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 69

Sequence Diagram: Message to Self An object can send message to itself:

Invoking another operation of its own. Usually represents implementation details.

class A { void methodA( ){

B objB = new B();

objB.methOne( );}

}

class B {void methOne( ){

methTwo( ); } void methTwo( ){

... ... ... }}

methOne( )

: A : B

Sequence Diagram

methTwo( )

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 70

Collaboration Diagram: Message to Self Make use of the <<self>> stereotype for collaboration

diagram.

class A { void methodA( ){

B objB = new B();

objB.methOne( );}

}

class B {void methOne( ){

methTwo( ); } void methTwo( ){

... ... ... }}

1: methOne( ): A : B

Collaboration Diagram

1.1: methTwo( )

<<self>>

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 71

Summary Class Diagram

Association Class, Reification N-Ary Association Qualified Association Interface

Interactions diagrams Collaborations, classifier and association roles Interaction diagrams, object creation and destruction Role multiplicity and iterated messages Multi-objects Conditional messages, messages to self

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 72

Where are we now?

Requirement

Analysis

Design

Implement

Test

Topics Covered: Detailed Class Diagram Object Diagram Collaboration Diagram Sequence Diagram

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 73

Reading Suggestions

Chapter 5 of [Bimlesh, Andrei, Soo; 2007] Chapters 8 and 9 of [Priestley; 2004]

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 74

Coming up next

Chapter 6 of [Bimlesh, Andrei, Soo; 2007] Chapter 10 of [Priestley; 2004]

04/20/23CPSC-4360-01, CPSC-5360-01,

Lecture 6 75

Thank you for your attention!

Questions?