+ All Categories
Home > Documents > Lecture Outline

Lecture Outline

Date post: 10-Feb-2016
Category:
Upload: nishi
View: 45 times
Download: 0 times
Share this document with a friend
Description:
วิชาวิเคราะห์และออกแบบระบบเชิงวัตถุ Lec09 :: Behavioral Modeling with UML Behavioral Diagrams Interaction Diagrams State Diagrams Activity Diagram Last Updated :: 17/04/2551 Mr. Nattapong Songneam [email protected] http://www.siam2dev.com. Lecture Outline. Behavioral Diagrams - PowerPoint PPT Presentation
31
วววววววววววววววววววววว ววววววววววววว Lec09 :: Behavioral Modeling with UML Behavioral Diagrams Interaction Diagrams State Diagrams State Diagrams Activity Diagram Activity Diagram Last Updated :: 17/04/2551 Mr. Nattapong Songneam [email protected] http://www.siam2dev.com
Transcript
Page 1: Lecture Outline

วชิาวเิคราะห์และออกแบบระบบเชงิวตัถุLec09 :: Behavioral Modeling with UML

Behavioral DiagramsInteraction Diagrams

State DiagramsState DiagramsActivity DiagramActivity Diagram

Last Updated :: 17/04/2551

Mr. Nattapong [email protected]://www.siam2dev.com

Page 2: Lecture Outline

Lecture OutlineLecture Outline•Behavioral Diagrams•State-Transition Diagram•Activity Diagram

Page 3: Lecture Outline

UML has 9 kinds of UML has 9 kinds of diagramsdiagrams Class Diagram

Object Diagram Component Diagram Deployment Diagram Use Case Diagram Sequence Diagram Collaboration Diagram StateTransition Diagram Activity Diagram

Structural Structural DiagramsDiagrams

Behavioral DiagramsBehavioral Diagrams

Page 4: Lecture Outline

Behavioral DiagramsBehavioral Diagrams•Behavioral Diagrams เป็น

โครงสรา้งแบบ dynamic • 4 diagrams ได้แก่

•Sequence Diagram•Collaboration Diagram•State-transition Diagram•Activity Diagram

Interaction Diagrams

Page 5: Lecture Outline

A State-Transition A State-Transition DiagramDiagram

Initialization Openentry: Register studentexit: Increment count

Closed

Canceled

do: Initialize course

do: Finalize coursedo: Notify registered students

Add Student / Set count = 0

Add student[ count < 10 ]

[ count = 10 ]

Cancel

Cancel

Cancel

Page 6: Lecture Outline

An Activity DiagramAn Activity DiagramShow

MessageBox“Printing” on Screen

Create postscriptfile

Send postscriptfile to printer

RemoveMessageBox

displayer samplerSwimlane Example

Ordinary Example

Page 7: Lecture Outline

State DiagramState Diagram

Page 8: Lecture Outline

State diagramState diagram• แสดงพฤติกรรมของวตัถใุดๆ วตัถหุน่ึงท่ี

สรา้งขึน้จากคลาส• แสดงสถานะ (states) ท้ังหมดท่ีเป็นไปได้

ของวตัถุ• แสดงการเปลี่ยนแปลงสถานะของวตัถุ ท่ี

เป็นผลจาก message ท่ีวตัถนัุน้ได้รบั• ชื่ออ่ืนๆ ของ State Diagram ได้แก่

•State transition diagram•Harel diagram (statecharts)

Page 9: Lecture Outline

Object statesObject states• สถานะ (State)

= ชุดของค่าท่ี บง่บอกถึง วตัถุ (รวม ท้ัง condition และ situation

ของวตัถ)ุ ท่ีเวลาใดเวลาหนึ่ง• สถานะถกูกำาหนดโดยค่าของ

attribute ในวตัถุoverdrafted

ok

Accountbalance : Float states

Page 10: Lecture Outline

State changes (1)State changes (1)• สถานะอาจเปลี่ยนแปลง เมื่อมเีหตกุารณ์

(event) เกิดขึน้กับวตัถุ•State transition

•หมายถึงความสมัพนัธท่ี์ระบุการเปล่ียนแปลงของสถานะoverdrafted

ok

deposit(sum) withdraw(sum)

Page 11: Lecture Outline

State changes (2)State changes (2)• เหตกุารณ์

(Events)• หมายถึง Message

หรอื signal ท่ีวตัถุได้รบั

•Events อาจจะทำาให้สถานะของวตัถุ

เปล่ียนแปลง หรอืไม่ก็ได้•Self-transition

overdrafted

ok

deposit

withdrawdeposit

withdraw

Page 12: Lecture Outline

State diagram State diagram notation (1)notation (1)• entry / entry-action

• เมื่อเขา้มายงั State นี้ให้ทำา entry-action

• do / activity-action• หลังจากเขา้มายงั State นี้แล้ว หาก

ไมม่เีง่ือนไขอ่ืนใดให้ทำา activity-action

• exit / exit-action• ขณะท่ีจะออกจาก State น้ี ให้ทำา

activity-action • conditon / condition-action

• ขณะท่ีอยูภ่ายใน State นี้ ให้ทำาcondition-action ตามเง่ือนไขท่ีกำาหนด

State name

entry / entry-action

condition /conditiont-action exit / exit-action

do / activity-Aevent1(a:T)[exp]: action1

state variable(s)

eventn(a:T)[exp]: actionn

Page 13: Lecture Outline

State-A State-BEvent(arguments) [condition]/action

State diagram State diagram notation (2)notation (2)

•Event

• หมายถึง เหตกุารณ์ที่เกิดขึน้ใน time และ space• ก่อให้เกิด (trigger) การเปลี่ยนสถานะ (transition)• อาจเป็น signals, calls, ชว่งเวล า หรอื การเปลี่ยน

สถานะ •Condition

•Transition อาจเกิดขึน้เมื่อ condition เป็นจรงิเท่านัน้•Action

• หมายถึง กระบวนการท่ีเกิดขึน้โดยอยา่งรวดเรว็ โดยไมถ่กูขดัจงัหวะ

Page 14: Lecture Outline

State diagram State diagram notation (3)notation (3)

•Start state• ไมม่ี event triggers • อาจมี branch conditions • อาจเปล่ียนสถานะจาก start states

•End state• สิน้สดุ state machine

Initial state State-BEvent(attribute)

Start State End State

Page 15: Lecture Outline

Example : State Example : State transitions for an transitions for an

invoiceinvoiceUnpaid PaidPaid DestroyedCreated

Page 16: Lecture Outline

Example : State Example : State transitions for an transitions for an

orderorder

Checkingdo : check item

Dispatchingdo : initiate delivery

Waiting

Delivered

/ get first item

Item received [someitems not in stock ]

Item received[ all items available]

Delivered

[ All items checked && some items notin stock]

[ All items checked && all items availables ]

[ not all items checked ] / get next item

Page 17: Lecture Outline

Transitions to Transitions to “cancelled“cancelled”

Dispatchingdo: initiate delivery

Waiting

Delivered

Item received [ some items not in stock ]

Item received [ allitems available ]

Delivered

Cancelled

Checkingdo: check

item

[ not all items checked ] / get next item

/ get first item[ All items checked &&some items not in stock ]

[ All items checked && all items available ]

cancelled

cancelled cancelled

Page 18: Lecture Outline

State diagram State diagram notation (4)notation (4)

Superstate

State-A State-BState-BEvent A

Event B Event C

• Composite state:• Sequential substates

Page 19: Lecture Outline

Superstate / Superstate / SubstatesSubstates

Delivered

Cancelled

Active

cancelledChecking

do : check item

Dispatchingdo : initiate delivery

Waiting / get first item

Item received [someitems not in stock ]

Item received[ all items available]

Delivered

[ All items checked && some items not in stock]

[ All items checked && all items

availables ]

[ not all items checked ] / get next item

Page 20: Lecture Outline

ExercisesExercises• ให้สรา้ง State diagram สำาหรบั

•an elevator•a soccer game•an ATM•a mobile phone•…

Page 21: Lecture Outline

Activity DiagramActivity Diagram

Page 22: Lecture Outline

• ใชส้ำาหรบัอธบิาย• กระแสการไหลของการทำางาน (workflow)• การประมวลผลแบบขนาน (parallel

processing)•Activities

•conceptual: task to be done•specification/implementation:

method of a class•Similar to Petri nets

Activity diagramActivity diagram

Page 23: Lecture Outline

Activity

Activity

Activity

Activity

Structure of activity Structure of activity diagramsdiagrams

[synchronization condition]

Concurrent fork

Concurrent join

Synchronization bar:• outbound triggers: activities can be carried out in parallel (any order)• default: outbound triggers occur when all incoming triggers occurred (i.e. all predecessors finished)

Activity diagram shows partial order of activities

Synchronization

Bar

Page 24: Lecture Outline

Example of activity Example of activity diagramsdiagrams

• The Coffee Pot

Page 25: Lecture Outline

Put coffeein filter

Add waterto reservoir

Put filterin machine

Turn onmachine

Activity diagramActivity diagramFind coffee

Page 26: Lecture Outline

Conditions in activity Conditions in activity diagramsdiagrams

Put coffeein filter

Check waterin reservoir

Put filterin machine

Turn onmachine

[not enough water]Put water inthe reservoir

[else]

Sequential branchunguarded transition

[filter with coffee in machine and reservoir contains water]

Find coffee

Page 27: Lecture Outline

Structure of activity diagrams

Activity

Activity

Activity

Activity

Activity

[condition 1]

[condition 2]

[synchronization condition]

Branch

Guard expression

Strictly UML:•forks joins•branch merge•No synchronization condition

Page 28: Lecture Outline

SwimlaSwimlanesnes

• Identify responsibilities

• Example:Modeling workflows for business units

Request product

Processorder

Pullmaterial

Shiporder

Customer Sales Warehouse

Page 29: Lecture Outline

Request product

Process OrderPull Material

Ship Order

Customer Sales Warehouse

Continue Work

Recieve Order Bill Customer

Pay BillClose Order

Page 30: Lecture Outline

Request product

Process OrderPull Material

Ship Order

Customer Sales Warehouse

Continue Work

Recieve Order Bill Customer

Pay Bill

Close Order

o:Order[in progress]

o:Order[filled]

b:Bill[unpaid]

b:Bill[paid]

Page 31: Lecture Outline

SummarySummary•Software Modeling•Require and Domain

Analysis Model•Design Model•Brief Overview of Unified

Modeling Language (UML)•Use Case Model


Recommended