26
UML Sequence Diagrams for Process Views CSE 403, Spring 2008, Alverson With some material from MartyStepp lectures, Wi07.

UML Sequence Diagrams for Process Views

Embed Size (px)

Citation preview

Page 1: UML Sequence Diagrams for Process Views

UML Sequence Diagrams for Process Views

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

Page 2: UML Sequence Diagrams for Process Views

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

Page 3: UML Sequence Diagrams for Process Views

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

Page 4: UML Sequence Diagrams for Process Views

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

Page 5: UML Sequence Diagrams for Process Views

Relationship exerciseGeneralizationAssociationpAggregation

CompositionLeap Year

Table

Calendar CalendarEntry

Executive Conference

CSE 403, Spring 2008, AlversonCalendar Room

Page 6: UML Sequence Diagrams for Process Views

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

Page 7: UML Sequence Diagrams for Process Views

MVP Sequence diagram q g

CSE 403, Spring 2008, Alverson

Page 8: UML Sequence Diagrams for Process Views

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

Page 9: UML Sequence Diagrams for Process Views

Representing objectsp g jInstanceName : ClassName

object anonymous objectobject of unknown class

Alverson : Instructor : Instructor Alverson

lifeline

CSE 403, Spring 2008, Alverson

Page 10: UML Sequence Diagrams for Process Views

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

Page 11: UML Sequence Diagrams for Process Views

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)

Page 12: UML Sequence Diagrams for Process Views

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

Page 13: UML Sequence Diagrams for Process Views

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

Page 14: UML Sequence Diagrams for Process Views

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

Page 15: UML Sequence Diagrams for Process Views

Example sequence diagram #1p q g

UML1 style ofUML1 style of iteration and conditionals

CSE 403, Spring 2008, Alverson

Page 16: UML Sequence Diagrams for Process Views

Example sequence diagram #2p q g

object calls itself

CSE 403, Spring 2008, Alverson

itself

Page 17: UML Sequence Diagrams for Process Views

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

Page 18: UML Sequence Diagrams for Process Views

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

Page 19: UML Sequence Diagrams for Process Views

What control pattern?p

CSE 403, Spring 2008, Alverson

Page 20: UML Sequence Diagrams for Process Views

What control pattern?p

CSE 403, Spring 2008, Alverson

Page 21: UML Sequence Diagrams for Process Views

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

CSE 403, Spring 2008, Alverson

Page 22: UML Sequence Diagrams for Process Views

What about with this one?

CSE 403, Spring 2008, Alverson

Page 23: UML Sequence Diagrams for Process Views

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

Page 24: UML Sequence Diagrams for Process Views

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

Page 25: UML Sequence Diagrams for Process Views

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

Page 26: UML Sequence Diagrams for Process Views

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