UML Sequence Diagrams for Process Views
Transcript of UML Sequence Diagrams for Process Views
![Page 1: UML Sequence Diagrams for Process Views](https://reader034.fdocuments.us/reader034/viewer/2022051318/5868219f1a28abc2638b98ad/html5/thumbnails/1.jpg)
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](https://reader034.fdocuments.us/reader034/viewer/2022051318/5868219f1a28abc2638b98ad/html5/thumbnails/2.jpg)
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](https://reader034.fdocuments.us/reader034/viewer/2022051318/5868219f1a28abc2638b98ad/html5/thumbnails/3.jpg)
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](https://reader034.fdocuments.us/reader034/viewer/2022051318/5868219f1a28abc2638b98ad/html5/thumbnails/4.jpg)
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](https://reader034.fdocuments.us/reader034/viewer/2022051318/5868219f1a28abc2638b98ad/html5/thumbnails/5.jpg)
Relationship exerciseGeneralizationAssociationpAggregation
CompositionLeap Year
Table
Calendar CalendarEntry
Executive Conference
CSE 403, Spring 2008, AlversonCalendar Room
![Page 6: UML Sequence Diagrams for Process Views](https://reader034.fdocuments.us/reader034/viewer/2022051318/5868219f1a28abc2638b98ad/html5/thumbnails/6.jpg)
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](https://reader034.fdocuments.us/reader034/viewer/2022051318/5868219f1a28abc2638b98ad/html5/thumbnails/7.jpg)
MVP Sequence diagram q g
CSE 403, Spring 2008, Alverson
![Page 8: UML Sequence Diagrams for Process Views](https://reader034.fdocuments.us/reader034/viewer/2022051318/5868219f1a28abc2638b98ad/html5/thumbnails/8.jpg)
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](https://reader034.fdocuments.us/reader034/viewer/2022051318/5868219f1a28abc2638b98ad/html5/thumbnails/9.jpg)
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](https://reader034.fdocuments.us/reader034/viewer/2022051318/5868219f1a28abc2638b98ad/html5/thumbnails/10.jpg)
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](https://reader034.fdocuments.us/reader034/viewer/2022051318/5868219f1a28abc2638b98ad/html5/thumbnails/11.jpg)
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](https://reader034.fdocuments.us/reader034/viewer/2022051318/5868219f1a28abc2638b98ad/html5/thumbnails/12.jpg)
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](https://reader034.fdocuments.us/reader034/viewer/2022051318/5868219f1a28abc2638b98ad/html5/thumbnails/13.jpg)
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](https://reader034.fdocuments.us/reader034/viewer/2022051318/5868219f1a28abc2638b98ad/html5/thumbnails/14.jpg)
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](https://reader034.fdocuments.us/reader034/viewer/2022051318/5868219f1a28abc2638b98ad/html5/thumbnails/15.jpg)
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](https://reader034.fdocuments.us/reader034/viewer/2022051318/5868219f1a28abc2638b98ad/html5/thumbnails/16.jpg)
Example sequence diagram #2p q g
object calls itself
CSE 403, Spring 2008, Alverson
itself
![Page 17: UML Sequence Diagrams for Process Views](https://reader034.fdocuments.us/reader034/viewer/2022051318/5868219f1a28abc2638b98ad/html5/thumbnails/17.jpg)
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](https://reader034.fdocuments.us/reader034/viewer/2022051318/5868219f1a28abc2638b98ad/html5/thumbnails/18.jpg)
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](https://reader034.fdocuments.us/reader034/viewer/2022051318/5868219f1a28abc2638b98ad/html5/thumbnails/19.jpg)
What control pattern?p
CSE 403, Spring 2008, Alverson
![Page 20: UML Sequence Diagrams for Process Views](https://reader034.fdocuments.us/reader034/viewer/2022051318/5868219f1a28abc2638b98ad/html5/thumbnails/20.jpg)
What control pattern?p
CSE 403, Spring 2008, Alverson
![Page 21: UML Sequence Diagrams for Process Views](https://reader034.fdocuments.us/reader034/viewer/2022051318/5868219f1a28abc2638b98ad/html5/thumbnails/21.jpg)
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](https://reader034.fdocuments.us/reader034/viewer/2022051318/5868219f1a28abc2638b98ad/html5/thumbnails/22.jpg)
What about with this one?
CSE 403, Spring 2008, Alverson
![Page 23: UML Sequence Diagrams for Process Views](https://reader034.fdocuments.us/reader034/viewer/2022051318/5868219f1a28abc2638b98ad/html5/thumbnails/23.jpg)
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](https://reader034.fdocuments.us/reader034/viewer/2022051318/5868219f1a28abc2638b98ad/html5/thumbnails/24.jpg)
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](https://reader034.fdocuments.us/reader034/viewer/2022051318/5868219f1a28abc2638b98ad/html5/thumbnails/25.jpg)
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](https://reader034.fdocuments.us/reader034/viewer/2022051318/5868219f1a28abc2638b98ad/html5/thumbnails/26.jpg)
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