5 Behavioral Model 1 UML Class diagram Object

����� 5 Behavioral Model 1

ประเภทของไดอะแกรมใน UML Class diagram Object diagram Static diagram Sequence diagram Collaboration diagram Requirement Capturing Dynamic diagram Use case diagram Component diagram Deployment diagram Statechart diagram Activity diagram 2

Dynamic Diagrams 4 diagrams ไดแก ¡Sequence Diagram Interaction Diagrams ¡Communication Diagram ¡State-transition Diagram ¡Activity Diagram 3















ตวอยาง Activity Diagram ของ ATM 18




Order Processing - Process step where the distribution center or warehouse is responsible to fill order (receive and stock inventory, pick, pack and ship 22 orders)


ตวอยาง Activity Diagram 24





Example: Sequence diagram : Registrar course form : Course. Form the. Manager : Curriculum. Manager Set Course Info Object creation process Add Course <<create>> a. Course : Course 29

A Communication Diagram 1: set course info 2: process course form : Course. Form 3: add course : Registrar the. Manager : Curriculum. Manager a. Course : Course 4: new course 30




UML Sequence Diagrams l ในขนตอนการวเคราะหระบบใช ในการกลนกรองรายละเอยดของ use case เพอทำการหา object เพมเตม l Actor l Columns = Object/classes l Arrow = messages l Narrow rectangles = activation l Dashed lines = lifetime 34




Sequence Diagrams Object name Lifetime Stimulus Activation Return Create Delete 38



UML Message Notation l Simple message l Synchronous message l Asynchronous message l Message return 41


Conditional Behaviors If … then Else End 43



















Hotel Example – Communication Diagram 62








State changes (2) lเหตการณ (Events) deposit ¡หมายถง Message หรอ signal ทวตถไดรบ l. Events อาจจะทำใหสถานะของ วตถเปลยนแปลง หรอไมกได overdrafted withdraw deposit withdraw ok ¡Self-transition 70







ตวอยาง State Diagram การทำงานของลฟต /Turn Off /Turn On Idle Want Up/Go Up Move Up Floor=1 Floor>1/Go Want Down / Go Down Desired Floor reached Floor<>1 Move Down &Desired Floor reached Reach 77













ตวอยางท 2 การเขยน State Diagram ของ Function ตางๆ ของ Class “Computer” Computer - Power Status # Turn On # Shut Down # Read Instruction # Decode # Execute # Store Data 90


State Diagram ของ Turn On 92


State Diagram ของ Shut Down 94


State Diagram ของ Read Instruction 96


State Diagram ของ Decode 98


State Diagram ของ Execute 100


State Diagram ของ Store Data 102





Example : State transitions for an order Item received [ not all items checked ] / get next item / get first item Checking [someitems not in stock ] [ All items checked && some items not in stock] do : check item [ All items checked && all items availables ] Dispatching do : initiate delivery Waiting Item received [ all items available] Delivered 107
![Transitions to “cancelled” [ not all items checked ] / get next item / Transitions to “cancelled” [ not all items checked ] / get next item /](http://slidetodoc.com/presentation_image_h/37ba81f52b64c36659fdbabeee6a1e21/image-108.jpg)
Transitions to “cancelled” [ not all items checked ] / get next item / get first item Checking do: check item [ All items checked && all items available ] Item received [ some items not in stock ] [ All items checked && some items not in stock ] cancelled Item received [ all items available ] Waiting cancelled Dispatching do: initiate delivery cancelled Cancelled Delivered 108


Sequential Sub. State l Sequential Sub. State ¡เปนการเปลยนสถานะการทำงานอยางเปนลำดบ จากสถานะหนง ไปสอกสถานะหนง Working Awaiting User Input Registering User Input Visualizing User Input 110


Example: Payment authorization in class Order Authorizing 2 parallel processes: - authorization - order handling [ payment not ok ] do: check payment [ payment ok ] Authorized Rejected Delivered 112

Concurrent state diagram for the class Order Cancelled Waiting Checking Dispatching Delivered Authorizing Authorized Rejected 113

State diagram notation (4) Superstate Event A State-A Event B State-B Event C l Composite state: ¡ประกอบดวย Sequential substates 114
![Superstate / Substates Active [ not all items checked ] / get next item Superstate / Substates Active [ not all items checked ] / get next item](http://slidetodoc.com/presentation_image_h/37ba81f52b64c36659fdbabeee6a1e21/image-115.jpg)
Superstate / Substates Active [ not all items checked ] / get next item / get first item Checking do : check item [ All items checked && all items availables ] Item received [someitems not in stock ] [ All items checked && some items not in stock] cancelled Cancelled Waiting Item received [ all items available] Dispatching Delivered do : initiate delivery 115


- Slides: 117