UML Sequence Diagrams for Process Views

Preview:

Citation preview

UML Sequence Diagrams for Process Views

CSE 403, Spring 2008, AlversonWith some material from MartyStepp lectures, Wi07.

Outline

UML class diagrams – recapUML class diagrams recapUML sequence diagramsUML wrapupUML wrapup

More detail:More detail: http://dn.codegear.com/article/31863#sequence-diagramshttp://www-128.ibm.com/developerworks/rational/library/3101.htmlhttp://www awprofessional com/articles/article asp?p=169507&rl=1http://www.awprofessional.com/articles/article.asp?p=169507&rl=1

CSE 403, Spring 2008, Alverson

UML classes

class nameattributes - all data fields of the objectjo visibility name : type

operations – omit trivial, inherited methodso visibility name (parameters) : return_type

visibility: + public# protected- private

CSE 403, Spring 2008, Alverson

underline static values

Class relationshipsp

generalization – inheritance between classesgeneralization – inheritance between classes

association connection between classesassociation – connection between classeso dependency

Solid line, or dotted if temporary dependencySo d e, o dotted te po a y depe de cyo aggregation

class contains another class

i icomposition variationcontained class will not exist without the container class

o multiplicity navigabilityCSE 403, Spring 2008, Alverson

o multiplicity, navigability

Relationship exerciseGeneralizationAssociationpAggregation

CompositionLeap Year

Table

Calendar CalendarEntry

Executive Conference

CSE 403, Spring 2008, AlversonCalendar Room

UML Sequence Diagramsq gsequence diagram:

details how operations are carried out whatdetails how operations are carried out -- what messages are sent and when

capture the process view of an architecture – provide a dynamic view of behavior

organized according to time - time progresses as you go down the pagep g

objects are listed from left to right, based on when they take part in the message sequence

CSE 403, Spring 2008, Alverson

take part in the message sequence

MVP Sequence diagram q g

CSE 403, Spring 2008, Alverson

How do you start?y

1. Identify the process/algorithm/activity you1. Identify the process/algorithm/activity you want to capture (may be a use case)

2. Identify the major objects involved

3. Map out the flow of control/messages to achieve the result

CSE 403, Spring 2008, Alverson

Representing objectsp g jInstanceName : ClassName

object anonymous objectobject of unknown class

Alverson : Instructor : Instructor Alverson

lifeline

CSE 403, Spring 2008, Alverson

Messages between objectsmessage (method call) indicated by horizontal arrow to other object

g j

horizontal arrow to other objecto with message name and arguments above

arrowarrow

Alverson : Instructormethod name

requestClassGrades(ClassID)

method argument types

CSE 403, Spring 2008, Alverson

g yp

More on messagesgmessage indicated by horizontal arrow o dashed arrow back indicates returno dashed arrow back indicates returno different arrowheads for normal / concurrent

(asynchronous) methods

Alverson : InstructorLevy : DepartmentHead Alverson : Instructor

requestClassGrades(ClassID)

Levy : DepartmentHead

type of

return

synchronous(full arrow)

Grades

giveRaise(BigNumber)

ypreturn value

CSE 403, Spring 2008, Alverson

return(dashed line) asynchronous

(half arrow)

giveRaise(BigNumber)

Indicating method callsgactivation: thick box over object's life line; drawn

: Instructor : Student object s life line; drawn when object's method is on the stack

giveTest(Test)

on the stacko either that object is running

its code, or o it is on the stack waiting for

another object's method to finish

Results

finishactivationResults

CSE 403, Spring 2008, Alverson

Lifetime of objectsjcreation: arrow with 'new' written above it : Instructor creationwritten above ito an object created after the

start of the sequence

: Instructor

: Surveynew

creation

qappears lower than the others

deletion: an X at bottom of object's lifelineobject s lifelineo how do objects get deleted

in java? in C?

Results

CSE 403, Spring 2008, Alverson

jdeletion

Conditionals and loops (UML2)p ( )

iteration frame

loop control

iteration frame

if/then/else

condition control

frame

CSE 403, Spring 2008, Alverson

if/then frame

Example sequence diagram #1p q g

UML1 style ofUML1 style of iteration and conditionals

CSE 403, Spring 2008, Alverson

Example sequence diagram #2p q g

object calls itself

CSE 403, Spring 2008, Alverson

itself

Using visio to create a SDgCreate a sequence diagram to represent a q g pskier booking a lesson

Objects: Skier, Booking System, Calendar

CSE 403, Spring 2008, Alverson

Forms of system controlyWhat can you say about the control flow of each of the following systems?of the following systems?o Is it centralized?o Is it distributed?o Does the sequence diagram help show this?

CSE 403, Spring 2008, Alverson

What control pattern?p

CSE 403, Spring 2008, Alverson

What control pattern?p

CSE 403, Spring 2008, Alverson

What’s wrong with this SD?gLook at the UML syntax and the viability of the scenario

CSE 403, Spring 2008, Alverson

What about with this one?

CSE 403, Spring 2008, Alverson

Why not just code it?y jSequence diagrams can be somewhat close to the code level So why not just code up thatthe code level. So why not just code up that algorithm rather than drawing it as a sequence diagram?diagram?

CSE 403, Spring 2008, Alverson

Why not just code it?y jSequence diagrams can be somewhat close to the code level So why not just code up thatthe code level. So why not just code up that algorithm rather than drawing it as a sequence diagram?diagram?

a good sequence diagram is an abstractionsequence diagrams are language-agnostic sequence diagrams are language agnostic non-developers can do sequence diagramscan see many objects/classes at a time on same

( l b d d h) blpage (visual bandwidth), enablingeasier understandingeasier review for correctness

CSE 403, Spring 2008, Alverson

easier review for correctnessgood communication medium

UML closing thoughtsg gWhat’s good about UML?

A lo A common language makes it easier to share requirements, specs, designs

o Visual syntax is goodo Visual syntax is good summarizes informationgood for non developers/less technical g p

o Tool support is availableVisio, Violet, Rational, Eclipse (June 2007), …Some tools convert from UML to code

CSE 403, Spring 2008, Alverson

UML closing thoughtsg gWhat’s not so good?o Rich language (good and bad)o Rich language (good and bad)o Visual syntax does not always work or scale

Features hard to depictLarge diagrams would be required, which are hard to understand

UML is happening!o UML is widely known by users, tool vendors, y y , ,

developers, customerso Seems a step forward – a standard language for

representing software architecture and designCSE 403, Spring 2008, Alverson

representing software architecture and design

Recommended