41
1 Conceptual Design: UML Sequence Diagrams

249 Conceptual Design: UML Sequence Diagrams. 250 Object Responsibilities n Attributes - What I know about myself n Relationships - What I know about

Embed Size (px)

Citation preview

1

Conceptual Design:

UML Sequence Diagrams

2

Object Responsibilities

Attributes - “What I know about myself”

Relationships - “What I know about other

Classes and Objects”

Operations - “What I do”

3

Operations

Synonyms: methods, functions & services

Definition: Actions performed to fulfill the purpose

of the information system and meet the needs of

the user.

Respond to an event that happens: External events - business activities

Internal events - messages sent to accomplish an

operation’s intended purpose

4

Types of Operations

Basic - implied or implicit (not listed)

create a new object

search for an object

get and set attribute values

connect and disconnect object associations

delete an object

Problem domain – specific to the domain being studied

5

Template

ClassName

operations

attributes

ClassName

1) basic operations2) problem domain specific operations - inherited - local

attributes - inherited - local

you think....

Thinking…

6

Problem Domain Operations Example

Student

registerForCoursedropCourserequestTranscriptpayStudentFeesetc...

studentIDNumberstudentNameetc...

• next....Basic Services Examples...

7

NEW Operation Example

Student

attributes

operations

Student 1Student 2

Student 3

Student

attributes

operations

Student 1Student 2

Student 3Student 4

new Student

before after

•Note: All basic operation examples are for illustrationonly as each implementation language handles them differently

8

SEARCH Operation Example #1

Student

attributes

operations

Student 1

Student 2Student 3

search[Student, studentIDNumber = 123-45-6789]

Student

attributes

operations

Student 1Student 2

Student 3

StudentIDNumber:123-45-6789

9

SEARCH Operation Example #2

Student

attributes

operations

Student 1

Student 2Student 3

search[Student, studentName = “Smith”]

Student 1Student 2

Student 3

StudentName:Smith,Mary

StudentName:Smith,John

Student

attributes

operations

10

GET Operation Example

Student

attributes

operations

Student 1Student 2

Student 3

telephone:(619)588-3296

get[Student=“Student2”, telephone]

result: telephone = (619)588-3296

11

SET Operation Example

Student

attributes

operations

Student 1Student 2

Student 3

set[Student, telephone,(619)594-3736]

telephone:(619)588-3296

Student

attributes

operations

Student 1Student 2

Student 3

telephone:(619)594-3736

before after

12

CONNECT Operation Example

StudentClub

attributes

operations

ACM ClubBeta Sigma Pi Club

AITP Club

connect[StudentClub=AITP Club, ClubMember=AITP-Student N]

ClubMember

attributes

operations

ACM-Student 1ACM-Student N

BSP-Student 1BSP-Student N

AITP-Student 1

AITP-Student N

13

DISCONNECT Operation Example

StudentClub

attributes

operations

ACM ClubBeta Sigma Pi Club

AITP Club

disconnect[StudentClub=AITP Club, ClubMember=AITP-Student N]

ClubMember

attributes

operations

ACM-Student 1ACM-Student N

BSP-Student 1BSP-Student N

AITP-Student 1

AITP-Student N

14

DELETE Operation Example

Student

attributes

operations

Student 1Student 2

Student 3

Student

attributes

operations

Student 1

Student 3

delete[Student 2]

before after

15

Problem Domain Operations

“Come in all sizes and shapes”

May be unique to the problem domain

Consider encapsulation and reuse when designing

Some respond to external events...

Others respond to internal events

Details of each operation are documented via UML

diagrams and other techniques

16

Problem Domain Operation Example #1

Automobile

beginningMileageendingMileage

calculateMilesDriven

calculateMilesDriven[VIN = 12345, totalMiles]

VIN: 12345

17,489 17,924

calculateMilesDriven

totalMiles = endingMileage - beginningMileage

(sample):435 = 17,924 - 17,489

17

Problem Domain Operation Example #2

Automobile

rentalCharge

salesTaxOwed

salesTaxOwed[VIN = 12345, taxRate, totalTax]

VIN: 12345

$279.00

salesTaxOwed

totalTax = rentalCharge X taxRate

(sample):$21.62 = 279.00 X .0775

18

Problem Domain Operation Example #3

Report

vehiclesOverdueReport

message sent to Automobile’s checkReturnDate operation

Automobile

scheduledReturnDate

checkReturnDate

checkReturnDate[listOfVehicles]

checkReturnDate

For each Automobile If scheduledReturnDate less than Today send vehicle information message to overdueVehicleReport EndifEnd For Each

(sample):VIN: 12345scheduledReturnDate: 05/05/95Today’s Date: 04/30/95overdue: No

VIN: 12654scheduledReturnDate: 04/28/95Today’s Date: 04/30/95overdue: Yes (will be on report)

etc....

19

Encapsulation and Reuse Operation Example

Student

addCourse

NOTE: The addCourse service requests the assistance of each ofthe other services (which are either part of the Student Class or some other Class within the information system) in order to carry out its intended purpose.

SomeOtherClass(es)

enterStudentIDNumbervalidateIDNumberenterClassScheduleNumbervalidateClassScheduleNumbercheckSeatAvailabilitycheckStudentRestrictionsreserveSeatInClass

addCourse responds to external event; others respond to internal event

20

Finding Operations

Identifying events and associated operations

Identify Class states - attribute values

Identify needed messages

Specifying details of known operations

21

Describing Operation Details

UML Sequence Diagram

UML Collaboration Diagram

UML State Diagram

UML Activity Diagram

Structured English or Pseudocode

Decision Tables and Decision Trees

22

UML Sequence Diagram

Is an interaction diagram that emphasizes the time ordering of messages

Also referred to as a Scenario - how a use case is realized (enacted) Graphically, it is a 2-dimensional table that shows objects arranged

along the X-axis and messages, ordered in increasing time, along the Y-axis.

Object1 Object2 ObjectN

Message1()Message2()

Message3()

Message4()

[check=“true”]new()

w: OrderEntryWindow o: Order l: OrderLineItem i: StockIteme: Employee

new()prepare()

* prepare()

check()

[check=“true”]remove()

needToReorder()

[needToReorder=“true”]new()

r: ReorderItem

d: DeliveryItem

UML Sequence Diagram (partial)(Adapted from Fowler, M., UML Distilled, Addison-Wesley, 1997, p. 104.)

new() prepare() prepare() check() if check() true remove() needToReorder() if needToReorder() true new() endif new() endif

24

Classes from the UML Sequence Diagram

OrderEntryWindow Order OrderLineItem StockItem

ReorderItem DeliveryItem

Boundary Class Problem Domain Classes

new()etc…

prepare()etc…

prepare()etc…

check()remove()needToReorder()etc…

new()etc…

new()etc…

25

UML Collaboration Diagram

Is an interaction diagram that emphasizes the structural

organization of the objects that send and receive messages

Graphically, it is a collection of vertices and arcs

First, place objects as vertices; second, render the links that

connect the objects as arcs; third, adorn the links with the

numbered messages that objects send and receive

Optionally, can contain a path (<<local>>, <<global>>, etc.)

Object1

Object2 ObjectN

1: Message()2: Message()

3: Message()

4: Message()

26

UML Collaboration Diagram

Create one of theseand the other is

Automatically created

Collaboration Diagram

27

UML State Diagram

UML State Diagram Template

State 1

State 2 State 3

State n

conditionaction

(note: each arrow should be labeled ‘condition - action’)

28

UML State Diagram Example #1

A telephone answering machine example (incomplete)

Idle

RecordingOutgoingMessage

Answeringa Call

RecordingIncomingMessage

RewindingTape

PlayingMessages

Record Button Pushed

PhoneRings Caller

Speaks

End ofmessage

Play Messages Button Pushed

29

UML State Diagram Example #2

FlightLeg Seat

20..350

1

Available Locked Soldlock

timed out

unlock

sold

30

UML Activity Diagram

Shows the flow from one activity to another.

Activities result in actions

Can be attached to classes, interfaces,

component nodes, use cases, collaborations,

and operations

Is similar to a Data Flow Diagram (DFD)

Used mainly when behavior is complex

Approximates a visual programming language

for the UML

UML Activity Diagram Examplepick show

schedule show

publicize show

sell tickets

buy scriptsand music

hireartists

buildsets

designlighting

makecostumes

(fork)

(activity)

rehearse

dressrehearsal

perform

(completiontransition)

(join)

Adapted from: Rumbaugh, J, Jacobson, I. and Booch, G., The Unified Modeling Language Reference Guide, Addison-Wesley, 1999, p. 32

32

For each Automobile If scheduledReturnDate less than Today send vehicle information message to overdueVehicleReport EndifEnd For Each

Structured English Example

Automobile

checkReturnDate

checkReturnDate operation Structured English

scheduledReturnDate

Note: Structured English is often referred to as Pseudocode

33

Decision Tables

RulesConditions

Actions

1...2...3...4...5...etc...

1...2...3...etc...

1. 2. 3. 4. 5. 6. 7. 8. etc..

Decision Table template

34

Decision Table Example #1

Rules

Con

dit

ion

sA

cti

on

s

Percent >=90%

89% >= Percent >= 80%

79% >= Percent >= 70%

69% >= Percent >= 60%

59% >= Percent

Grade = A

Grade = B

Grade = C

Grade = D

Grade = F

1 2 3 4 5

Y

X

Y

X

Y

X

Y

X

Y

X

Do the conditions cover all possible cases?

35

Decision Table Example #2

Rules

Con

dit

ion

sA

cti

on

s

Registration Fee = 0?

Payment Type

Credit Card # Input?

C.C. Expire Date Input?

C.C. Cardholder Name Input?

Bank Check Number Input?

Remarks by User Input?

Activate POST Button

Deactivate POST Button

1 2 3 4 5……...

Y

-

-

-

-

-

Y

X

N

Cash

-

-

-

-

-

X

N

Check

-

-

-

Y

-

X

N

CrCd

Y

Y

Y

-

-

X

X……..

36

Decision Trees

Decision Tree template

condition 1

rule 1

rule 2

rule n

condition 2

condition 2

condition 2

rule 1

rule 2

rule n

rule 1

rule 2

rule n

rule 1

rule 2

rule n

condition n

condition n

condition n

condition n

condition n

condition n

condition n

condition n

condition n

rule 1rule 2rule nrule 1rule 2rule nrule 1rule 2rule nrule 1rule 2rule nrule 1rule 2rule nrule 1rule 2rule nrule 1rule 2rule nrule 1rule 2rule nrule 1rule 2rule n

action(s)action(s)action(s)action(s)action(s)action(s)

action(s)action(s)action(s)

action(s)action(s)action(s)action(s)action(s)action(s)action(s)action(s)action(s)action(s)action(s)action(s)action(s)action(s)action(s)action(s)action(s)action(s)

37

Decision Tree Example

Percent >= 90%?

Yes Grade = A

No 89% >= Percent >= 80%?

Yes Grade = B

No 79% >= Percent >= 70%?

Yes Grade = C

No Etc...

Do the conditions cover all possible cases?

38

When to use O-O Analysis, Design, & Programming?

• Graphical User Interfaces (GUI)

• Event-Driven Programming

• Heterogeneous Environments

• Distributed Environments

• More sophisticated applications

• Persistent Data requires:

• Audio

• Video

• Graphics

• Other non-row/column data

• Higher utilization of REUSE practice

• Etc...

39

Alternative O-O A, D, & P Strategies

ANALYSIS DESIGN PROGRAMMING

Structured

Structured

Object

Object

Object

Object

Structured

Object

Structured

Object

Object

Object

Object

Object

Conventional 3-4GL

Conventional 3-4GL

Mixture - Conv/Obj.

Object

•There are all kinds of variations on these or other strategies

•ODBMS, Relational, and Extended-Relational DBMS are options

40

•Simula - late 1960’s•Smalltalk since 1970’s; Xerox Star in 1981•Eiffel - Bertrand Meyer•Delphi (Borland.Com or Inprise)•Java (Sun) & Visual J Languages

•C++ (Borland, Microsoft)•Objective C•Ada•Object Pascal•Object COBOL•Visual FoxPro•Powerbuilder•Visual Basic•etc...

OO PROGRAMMING: ROCK SOLID!

Pure

Enhanced

Pure OOP versus enhanced deterministic languages

41