<<

UML Sequence for Process Views

CSE 403, Spring 2008, Alverson With some material from MartyStepp lectures, Wi07. Outline

y UML class diagrams – recap y UML sequence diagrams y UML wrapup

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

CSE 403, Spring 2008, Alverson UML classes

y class name y attributes - all data fields of the object o visibility : type y operationsname – omit trivial, inherited methods o visibility (parameters) : return_type y visibility:name + public #protected -private y underline static values CSE 403, Spring 2008, Alverson Class relationships y generalization – inheritance between classes y association – connection between classes o ‡ Solid lin e, or dotted if tem por ar y depen den cy o aggregation ƒ class contains another class ‡ composiiition variation ƒ contained class will not exist without the container class o multiplicity, navigability

CSE 403, Spring 2008, Alverson Generalization Relationship exercise Association Aggregation Composition Leap Year Table

Calendar Calendar Entry

Executive Conference Calendar Room CSE 403, Spring 2008, Alverson UML Seqqguence Diagrams sequence : details how operations are carried out -- what messages are sent and when y capture the process view of an architecture – provide a dynamic view of behavior y organized according to time - time progresses as you go down the ppgage y objects are listed from left to right, based on when they take part in the message sequence

CSE 403, Spring 2008, Alverson MVP Seqqguence diagram

CSE 403, Spring 2008, Alverson How do you start?

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

2. Identify the major objects involved

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

CSE 403, Spring 2008, Alverson Reppgjresenting objects InstanceName : ClassName

object of object anonymous object unknown class

Alverson : Instructor : Instructor Alverson

lifeline

CSE 403, Spring 2008, Alverson Messaggjes between objects y message (method call) indicated by horizontal arrow to other object o with message name and arguments above arrow

method name Alverson : Instructor

requestClassGrades(ClassID)

method arggypument types

CSE 403, Spring 2008, Alverson More on messages y message indicated by horizontal arrow o dashed arrow back indicates return o different arrowheads for normal / concurrent (asynchronous) methods

Levy : DepartmentHead Alverson : Instructor

requestClassGrades(ClassID) type of return value Grades synchronous (full arrow) return giveRaise(BigNumber) (dashed line) CSE 403, Spring 2008, Alverson asynchronous (half arrow) Indicating method calls y activation: thick box over : Instructor : Student object' s life line; drawn giveTest(Test) when object's method is on the stack o either that object is running its code, or

o it is on the stack waiting for Results another object's method to finish Results activation

CSE 403, Spring 2008, Alverson Lifetime of objects y creation: arrow with 'new' written above it : Instructor creation o an object created after the start of the sequence new : Survey appears lower than the others y deletion: an X at bottom of object' s lifeline Results o how do objects get deleted in java? in C? deletion CSE 403, Spring 2008, Alverson Conditionals and loopp(s (UML2 )

iteration frame loop control

condition control if/then/else frame

if/then

frameCSE 403, Spring 2008, Alverson Examppqle sequence dia gram #1

UML1 style of iteration and conditionals

CSE 403, Spring 2008, Alverson Examppqle sequence dia gram #2

object calls itself

CSE 403, Spring 2008, Alverson Using visio to create a SD y Create a seqqgpuence diagram to represent a skier booking a lesson y Objects: Skier, Booking System, Calendar

CSE 403, Spring 2008, Alverson Forms of system control y What can you say about the control flow of each 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?

CSE 403, Spring 2008, Alverson What control pattern?

CSE 403, Spring 2008, Alverson What’s wrong with this SD? y Look 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 Whyyj not just code it? y Sequence diagrams can be somewhat close to the code level. So why not just code up that algorithm rather than drawing it as a sequence diagram?

CSE 403, Spring 2008, Alverson Whyyj not just code it? y Sequence diagrams can be somewhat close to the code level. So why not just code up that algorithm rather than drawing it as a sequence diagram?

„ a good sequence diagram is an abstraction

„ sequence diagrams are language-agnostic

„ non-developers can do sequence diagrams

„ can see many objects/classes at a time on same page (lbddh)bl(visual bandwidth), enabling

„ easier understanding

„ easier review for correctness

„ CSE good403, Spring 2008,communication Alverson medium UML closinggg thoughts y What’s good about UML? o AlA common language ‡ makes it easier to share requirements, specs, designs o Visual syntax is good ‡ summarizes information ‡ ggpood for non developers/less technical o Tool support is available ‡ Visio, Violet, Rational, Eclipse (June 2007), … ‡ Some tools convert from UML to code

CSE 403, Spring 2008, Alverson UML closinggg thoughts y What’s not so good? o Rich language (good and bad) o Visual syntax does not always work or scale ‡ Features hard to depict ‡ Large diagrams would be required, which are hard to understand y UML is happening! o UML is widelyyy, known by users, tool vendors, developers, customers o Seems a step forward – a standard language for representing software architecture and design

CSE 403, Spring 2008, Alverson