1. Trang chủ
  2. » Công Nghệ Thông Tin

Bài Giảng Phân tích thiết kế hướng đối tượng (phần 5) ppsx

32 629 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Use Case Realization Lecture 5
Trường học Hoa Sen University
Chuyên ngành Phân tích thiết kế hướng đối tượng
Thể loại Bài Giảng
Định dạng
Số trang 32
Dung lượng 2,66 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Interaction diagrams Generalization of two more specialized UML diagram types – Sequence diagrams – Communication diagrams  Illustrate how objects collaborate via messages and method

Trang 1

Use case realization

Lecture 5

Trang 3

Interaction diagrams

 Generalization of two more specialized

UML diagram types

– Sequence diagrams

– Communication diagrams

 Illustrate how objects collaborate via

messages and methods

Trang 4

Sequence vs Communication diagram

illustrate interactions in a

kind of fence format

– Easier to see the call

doThree

: A

myB : B

1: doTwo 2: doThree doOne

Trang 5

Common notation: participants –

lifeline box

sales:

ArrayList<Sale>

lifeline box representing an

instance of an ArrayList class,

parameterized (templatized) to

hold Sale objects

lifeline box representing an

unnamed instance of class Sale lifeline box representing a named instance

sales[ i ] : Sale

lifeline box representing

one instance of class Sale, selected from the sales

ArrayList <Sale> collection

x : List

«metaclass»

Font

lifeline box representing the class

Font, or more precisely, that Font is

an instance of class Class – an

instance of a metaclass

related example

Trang 6

Sequence diagram notation

doC doD

typical sychronous message

shown with a filled -arrow line

Trang 7

Sequence diagram notation

 Illustrating reply or returns

– Using the message syntax

returnVar = message(parameter).

– Using a reply message line

 Message to “self” or “this”

public class Register{

public void doX(){

doX

aDate

: Register doX

clear

Trang 8

Sequence diagram notation

– In implementation:

invoke the new

operator and call the

authorize

note that newly created objects are placed at their creation "height"

: Sale

: Payment create(cashTendered)

the «destroy» stereotyped message, with the large

X and short lifeline indicates explicit object destruction

«destroy» X

Trang 9

Sequence diagram notation

 Diagram frames in UML sequence

loop

: A

Trang 10

Sequence diagram notation

 Common frame operators

Frame

operator Meaning

conditional logic expressed in the guards

Trang 11

Sequence diagram notation

public class foo{

Bar bar = new Bar();

Trang 12

[ else ]

Trang 13

Sequence diagram notation

 Iteration over a collection

: Sale This lifeline box represents one

instance from a collection of many

SalesLineItem objects

lineItems[i] is the expression to

select one element from the collection of many

SalesLineItems; the ‘i” value refers to the same “i” in the guard

in the LOOP frame

an action box may contain arbitrary language

statements (in this case, incrementing ‘i’)

it is placed over the lifeline to which it applies

i++

Trang 14

Sequence diagram notation

public class Sale{

private List<salesLineItem> lineItems = new ArrayList<salesLineItem>();

public Money getTotal(){

Money total = new Money();

Money subtotal = null;

for (SalesLineItem lineItem: lineItems){

Trang 15

Sequence diagram notation

 Nesting frames

calculate

: Bar xx

[ color = red ]

opt

: Foo

loop(n)

Trang 16

Sequence diagram notation

a reference to an interaction within another

interaction.

– A frame around an entire sequence diagram, labelled

with the tag sd and a name,

– A frame tagged ref, called a reference, that refers to

another named sequence diagram;

Trang 17

Sequence diagram notation

interaction occurrence note it covers a set of lifelines note that the sd frame it relates to has the same lifelines: B and C

Trang 18

Sequence diagram notation

public class Foo{

public void doX(){

Locale[] locales = Calendar.getAvailableLocales();

Trang 19

Sequence diagram notation

Polymorphic messages and cases

:Register

authorizedoX

:Payment {abstract}

polymorphic message object in role of abstract superclass

:DebitPayment

doAauthorize

DebitPaymentauthorize()

Payment is an abstract

superclass, with concrete subclasses that implement the polymorphic authorize operation

separate diagrams for each polymorphic concrete case

Trang 20

Sequence diagram notation

– Call does not wait for a response

– Asynchronous calls are used in multi-thread

application

– Show as a stick arrow message

– It is common for modeler to use stick arrow to

represent synchronous message

– Do not assume the shape of the arrow is correct

Trang 21

Sequence diagram notation

Trang 22

Collaboration diagram notation

– Message between objects is

represented with a message

expression and small arrow

indicating the direction of the

message

– A sequence number is added

to show the sequential order of

messages in the current thread

of control

– Many messages may flow

along a same single link

1: makePayment(cashTendered) 2: foo

2.1: bar

link line

1: msg2 2: msg3 3: msg4 3.1: msg5

msg1

Trang 23

Collaboration diagram notation (cont)

“this”

– Use a message named

create for this purpose

Trang 24

Collaboration diagram notation (cont)

 Message number sequencing

– OK to use flat numbering style or

– Nested decimal numbers

legal numbering

Trang 25

Collaboration diagram notation (cont)

: A

: C

1.1: msg3 2.1: msg5 2: msg4

: D 2.2: msg6

fourth

sixth

fifth third

Trang 26

Collaboration diagram notation (cont)

square brackets The

message is only sent if

the clause evaluates to

exclusive conditional paths

Trang 27

Collaboration diagram notation (cont)

Trang 28

Collaboration diagram notation (cont)

1 * [i = 1 n]: st = getSubtotal : Sale

t = getTotal

This lifeline box represents one instance from a

collection of many SalesLineItem objects

lineItems[i] is the expression to select one

element from the collection of many SalesLineItems; the ‘i” value comes from the message clause.

lineItems[i]:

SalesLineItem

this iteration and recurrence clause indicates

we are looping across each element of the

lineItems collection.

1 *: st = getSubtotal : Sale

SalesLineItem

Trang 29

Collaboration diagram notation (cont)

1: locs = getAvailableLocales : Foo «metaclass» Calendar

doX

message to class, or a static method call

Trang 30

Collaboration diagram notation (cont)

Polymorphic messages and cases

Trang 31

Collaboration diagram notation (cont)

3: runFinalization :ClockStarter System : Class

startClock

:Clock

1: create 2: run

asynchronous message active object

Trang 32

Interaction and Class Diagrams

makePayment(cashTendered) makePayment(cashTendered)

Register

makePayment(…)

Sale

makePayment(…)

1 currentSale

messages in interaction

diagrams indicate operations

identified in the interaction diagrams are declared in the class diagrams

Ngày đăng: 05/07/2014, 16:20

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

🧩 Sản phẩm bạn có thể quan tâm