cs212: object oriented analysis and design lecture 34: uml activity and collaboration diagram

44
CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

Upload: jeffery-strickland

Post on 17-Jan-2016

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

CS212: Object Oriented Analysis and Design

Lecture 34: UML Activity and Collaboration diagram

Page 2: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

Recap of Lecture 33

• Class diagram

• Sequence diagram

• Sequence diagram – ATM problem

Page 3: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

Outline of Lecture 34

• Sequence diagram – ATM problem

• Activity diagram

• Collaboration diagram

Page 4: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

Example: Use Case Diagram of the Vending Machine

C u s to m e r

D ep o s it M o n ey

M ak e S e lec tio n

M a in te n a n ceO pe ra to r

Up d ate D atab as e

C an c ella tio n

Page 5: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

The Initial Object-Model

V e n din g M a ch in eC o n tro lle r

Nu m e ric K e y pa d

W ire le s sK e y bo a rd

C R T D is pla y

M o n e y D e te ct io nH a rdwa re

M o n e y D is pe n s e r

Pro du ctD is pe n s e r

Pro du ct D a ta ba s e

Designate the Actor objects with the <<actor>> stereotype above the object label

<<actor>>

<<actor>>

<<actor>>

<<actor>>

<<actor>>

<<actor>>

Page 6: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

Deposit Money Use Case

C u s to m e r

M o n e y D e te c t io nH a rd w a re

CRT D is p la yVe n d in g M a c h in e

Co n t ro lle r

D e p o s it M o n e y

[Id le S ta te ]D is p la y W e lc o meM e s s a g e

D is p la y A mo u n t

S e n d A mo u n t

P ro mp t fo r S e le c t io n

S ta rt T ime r

[If T ime r > 30 s e c o n d s a n d In v a lid o r N o S e le c t io n ] Re tu rn M o n e y

M o n e yD is p e n s e r

S to pT ime r[Id le S ta te ]

D is p la y W e lc o meM e s s a g e

Page 7: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

Make Selection Use Case

C u s to m e r

N u me ric K e y p a d CRT D is p la yVe n d in g M a c h in e

Co n t ro lle rM o n e y

D is p e n s e rP ro d u c t

D is p e n s e r

P ro mp tfo rS e le c t io n

En te r S e le c t io n

D is p la y S e le c t io n

S e n d S e le c t io n

P ro d u c tD a ta b a s e

In q u ire D a ta b a s e

[if In v a lid S e le c t io n ]P ro mp t fo r A n o th e r S e le c t io n

D is p e n s e P ro d u c t

D is p e n s e Ca lc u la te dCh a n g e[Id le S ta te ]

D is p la y W e lc o meM e s s a g e

No te : I n s u f f icie n tm o n e y , s e le ct io n

n o t a v a ila ble

No te : I fR e le a s e - I n pu t

B u t to n Pre s s e d s e eC a n ce lla t io n

S e qu e n ce D ia g ra m

Re tu rn Re s p o n s e

Va lid a te

U p d a te D a ta b a s e

Page 8: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

Cancellation Use Case

C u s to m e r

N u me ric K e y p a d CRT D is p la yVe n d in g M a c h in e

Co n t ro lle rM o n e y D is p e n s e r

P ro mp tfo rS e le c t io nRe le a s e -In p u t

Bu t to n P re s s e d

S e n d Ca n c e lla t io n S ig n a l

[Id le S ta te ]D is p la y W e lc o meM e s s a g e

Re tu rn M o n e y

Page 9: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

Update Database Use Case

M a in te n a n ceO pe ra to r

A ll H a rd w a reExc e p t CRT D is p la y

CRT D is p la yVe n d in g M a c h in e

Co n t ro lle rP ro d u c t

D a ta b a s eW ire le s s K e y b o a rd

P o w e r O n

S e n d A c t iv e S ig n a l

D is p la y P ro g ra mmin gIn fo rma t io n

D is a b le

En a b le

S e n d U p d a te Co mma n d s

U p d a te D a ta b a s e

P o w e r O ff

[Id le S ta te ]D is p la y W e lc o me In fo rma t io n

D is p la y U p d a teCo mma n d s

T e rmin a te U p d a te M o d e

Page 10: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

What is an Activity Diagram?

• It represent the dynamic (behavioral) view of a system

• Typically used for business (transaction) process modeling and modeling the logic captured by a single use-case or usage scenario

• Used to represent the flow across use cases

• To represent flow within a particular use case

Page 11: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

What is an Activity Diagram?

• Object oriented equivalent of flow chart and data flow diagrams in function-oriented design approach

• It contains

• activities, • transitions between activities, • decision points, • synchronization bars, • swim lanes and • many more…

Page 12: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

Example: Student Enrollment

Page 13: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

Different activities during enrollment

Enrollment form by student• Verification• Data entry

Fees payment• Verification• Approval

Hostel allotment• Allotment• Fees

payment• Allot room

Medical checkup• Create

record• Enter record

Issue cards• Library card• ID card

Page 14: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

Activity Diagram and its components

R ece ived fo rm

P aym ent feesH oste l

a llo tm ent

Issue identitycard

M edica l check

Issue lib rarycard

Initial node

Final node

Action

Flow/ edge

Fork

Join

Merge

Page 15: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

Basic Components

• Initial node • The filled circle is the starting point

of the diagram

• Final node• The filled circle with a boarder is the

ending point. An activity diagram can have zero or more activity final state.

• Action• The rounded circle represents

action. Actions are considered atomic

• Flow/ edge• The arrows in the diagram. The

order of execution of the actions. • Control flow vs. object flow.

R ece ived fo rm

P aym ent feesH oste l

a llo tm ent

Issue identitycard

M edica l check

Issue lib rarycard

Page 16: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

Basic Components

• Fork• A black bar ( horizontal/vertical )

with one flow going into it and several leaving it. This denotes the beginning of parallel activities

• Join• A block bar with several flows

entering it and one leaving it. this denotes the end of parallel activities

• Merge• A diamond with several flows

entering and one leaving. The implication is that all incoming flow to reach this point until processing continues

R ece ived fo rm

P aym ent feesH oste l

a llo tm ent

Issue identitycard

M edica l check

Issue lib rarycard

Page 17: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

Join vs. Merge

• A join is different from a merge in that the • join synchronizes two inflows and produces a single

outflow.

• The outflow from a join cannot execute until all inflows have been received

• A merge passes any control flows straight through it. • If two or more inflows are received by a merge symbol, the

action pointed to by its outflow is executed two or more times

Page 18: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

Basic Components

• Decision• A diamond with one flow entering and

several leaving. The flow leaving includes conditions as yes/ no state

• Flow final• The circle with X though it. This indicates

that Process stop at this point

• Swim lane• A partition in activity diagram by means

of dashed line, called swim lane.

• This swim lane may be horizontal or vertical

R eceived form

Paym ent feesH oste l

a llo tm ent

Issue identitycard

M edica l check

Issue lib rarycard

Page 19: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

Detailed Activity Diagram

R ece ived form

Paym ent feesH oste l

a llo tm ent

Issue identitycard

M edica l check

Issue lib rarycard

1

2

Page 20: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

Detailed Activity Diagram

Fill-info rm

C h eckform

[Incorrect]

[Correct]

D isp lay s tu d en tsc reen

In p u t s tu d en tin fo rm a tion

V erify th eap p lica tion s

S ea rch fo r S tu d en tselec tion lis t

[Not Found]

R egret m essage

[Found]

R egretreg is tra tion

[No M atch]

[M atch]

C rea te record 1

Page 21: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

Detailed Activity Diagram

1 D isp layen ro llm en t fo rm

C a lcu la tereg is tra tion fees

D isp a ly feesp ayab le sc reen

P ay fee

P rocessp aym en t

P rin t receip t

2

Page 22: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

Activity Diagram with Swim Lane

Fill-info rm

C h eckfo rm

[Incorrect]

[Correct]

D isp lay s tu d en tsc reen

In p u t s tu d en tin fo rm a tion S ea rch fo r S tu d en t

selec tion lis t

V erify th eap p lica tion s

R egret m essage

C rea te reco rd

R egretreg is tra tion

[No M atch]

[M atch]

[Not Found]

[Found]

1

Stu

dent

Reg

istr

arS

yste

m

Page 23: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

Partition

Page 24: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

Sending arguments

Page 25: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

Object and Object Flow

• An object flow is a path along which objects can pass. An object is shown as a rectangle

• An object flow is shown as a connector with an arrowhead denoting the direction the object is being passed.

Page 26: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

Input and Output Pin

• An object flow must have an object on at least one of its ends.

• A shorthand notation would be to use input and output pins

Page 27: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

Data Store

• A data store is shown as an object with the «datastore» keyword

Page 28: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

Expansion Region

• It is a structured activity region that executes multiple times.

• Input and output expansion nodes

• They are drawn as a group of three boxes

• Each box represents a multiple selection of items.

• The keyword iterative, parallel or stream is shown in the top left corner of the region

Page 29: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

Exception Handling

The action safeguarded by the exception handler points to the exception handler with a lightning bolt arrow

Page 30: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

Event-Based Actions

• Enable objects and signals to be transmitted to receiver objects

Accept event action to model an action that waits for the occurrence of a specific event

Accept time event action to model a time-based event

Send signal actions to send signals to another action

Page 31: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

Event based Action: Example

Page 32: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

Interruptible Activity Region• It surrounds a group of actions that can be interrupted.

• E.g. the Process Order action will execute until completion, when it will pass control to the Close Order action,

• Unless a Cancel Request interrupt is received which will pass control to the Cancel Order action

Page 33: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

An Example

• Identify the business logic in the activity diagram shown below

Page 34: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

Importance of Activity Diagram

• It can depict a model in several ways

• It can also depicts “Basic course of action” as well as “detailed courses”

• It can also be drawn that cross several use cases, or that address just a small portion of use case

• Normally employed in business process modeling. This is carried out during the initial stages of requirement analysis and specification

• Very useful to understand the complex processing activities involving many components

Page 35: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

Collaboration Diagram

• It is the second form of the interaction diagram

• Shows both the structural and behavioral aspects, explicitly.

• The structural aspect consists of object and the links existing between them

• The behavioral aspect is described by a set of messages exchanged among the different collaborations

• An object is also called collaborator

Page 36: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

Components of Collaboration Diagram

• It contains the following things:

• Objects drawn as rectangles

• Links between the objects shown as lines connecting as lines connecting the linked objects

• Messages shown as text and an arrow that points from a client object to a respondent object

Page 37: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

Example: Collaboration Diagram

ord erE n try :C u stom er

an O rd er:O rd er

o rd erS et:Item L ist

:O rd erIn fo:C on firm O rd er

:In ven to ryM an ager

1: create()

2: * [fo r a ll item in O rder]

setO rder()

3: sta tus = inventoryC heck()4: ava ilab le = checkSupply()

[sta tus]new [availab le]

new

Page 38: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

Example

Page 39: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

Example

Page 40: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

Note: Collaboration Diagram

• The sequence indicated by numbering the messages

• Here, we have used the simple numbering scheme.

• The UML also allows decimal scheme [as in DFD] to document the hierarchical messaging

Page 41: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

Sequence vs. Collaboration

• There are two basic features by which Sequence diagram differs from the Collaboration diagram

• Object life time• In sequence diagram, there is a object line represent the

existence of an object over a period of time. • There is no object life time in collaboration diagram

• Focus of control• In sequence diagram, there is the focus of control to show

the period of time during which object is performing an action.

• There is no focus of control in collaboration diagram

Page 42: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

Sequence vs. Collaboration

• Sequence diagram provides a way to look at scenario in a time based order – what happen after what etc.

• Customer easily can read and understand this type of diagram.

• Hence, they are very useful in the early analysis phases as well as in coding phase

• Collaboration diagram tend to provide the big picture for a scenario

• since the collaborations are organized around the object links to one another.

• These diagrams seem to be used more in the design phase of development

Page 43: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

A Roadmap from Modelling to Coding

Page 44: CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram

Thank youNext Lecture: Modeling using UML